Commit 690dfafb authored by Jeremy Cohen's avatar Jeremy Cohen
Browse files

Python 3-related fixes for python bindings. Part of fix for #107.

parent 1b284d83
......@@ -75,8 +75,8 @@ struct NekMatrixToPython
#else
py::object capsule(
py::handle<>(PyCapsule_New(
(void *)new std::shared_ptr<NekMatrix<T, StandardMatrixTag>>(mat),
(PyCapsule_Destructor)&CapsuleDestructor<T, StandardMatrixTag>)));
(void *)new std::shared_ptr<NekMatrix<T, StandardMatrixTag>>(mat), NULL,
(PyCapsule_Destructor)&NekMatrixCapsuleDestructor<T, StandardMatrixTag>)));
#endif
int nRows = mat->GetRows(), nCols = mat->GetColumns();
......
......@@ -70,6 +70,7 @@ namespace np = boost::numpy;
} \
tmp.export_values(); \
}
#if PY_MAJOR_VERSION == 2
#define NEKPY_WRAP_ENUM_STRING_DOCS(ENUMNAME,MAPNAME,DOCSTRING) \
{ \
py::enum_<ENUMNAME> tmp(#ENUMNAME); \
......@@ -83,4 +84,18 @@ namespace np = boost::numpy;
PyDict_SetItemString(pto->tp_dict, "__doc__", \
PyString_FromString(DOCSTRING)); \
}
#else
#define NEKPY_WRAP_ENUM_STRING_DOCS(ENUMNAME,MAPNAME,DOCSTRING) \
{ \
py::enum_<ENUMNAME> tmp(#ENUMNAME); \
for (int a = 0; a < (int)SIZENAME(ENUMNAME); ++a) \
{ \
tmp.value(MAPNAME[a].c_str(), (ENUMNAME)a); \
} \
tmp.export_values(); \
PyTypeObject * pto = \
reinterpret_cast<PyTypeObject*>(tmp.ptr()); \
PyDict_SetItemString(pto->tp_dict, "__doc__", \
PyUnicode_FromString(DOCSTRING)); \
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment