Skip to content
Snippets Groups Projects
Verified Commit 20b89555 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

core: move Python call to the dynamic lib

parent 41d2650e
No related branches found
No related tags found
No related merge requests found
......@@ -44,12 +44,21 @@ namespace eigenpy
EIGENPY_DLLEXPORT int call_PyArray_ObjectType(PyObject *, int);
EIGENPY_DLLEXPORT PyTypeObject * getPyArrayType();
EIGENPY_DLLEXPORT int call_PyArray_DescrFromType(int typenum);
EIGENPY_DLLEXPORT void call_PyArray_InitArrFuncs(PyArray_ArrFuncs * funcs);
EIGENPY_DLLEXPORT int call_PyArray_RegisterDataType(PyArray_Descr * dtype);
}
#else
#define call_PyArray_SimpleNew PyArray_SimpleNew
#define call_PyArray_New(py_type_ptr,nd,shape,np_type,data_ptr,options) \
PyArray_New(py_type_ptr,nd,shape,np_type,NULL,data_ptr,0,options,NULL)
#define getPyArrayType() &PyArray_Type
#define call_PyArray_DescrFromType(typenum) PyArray_DescrFromType(typenum)
#define call_PyArray_InitArrFuncs(funcs) PyArray_InitArrFuncs(funcs)
#define call_PyArray_RegisterDataType(dtype) PyArray_RegisterDataType(dtype)
#endif
#endif // ifndef __eigenpy_numpy_hpp__
......@@ -70,7 +70,7 @@ namespace eigenpy
}
else
{
PyArray_Descr * new_descr = PyArray_DescrFromType(NumpyEquivalentType<Scalar>::type_code);
PyArray_Descr * new_descr = call_PyArray_DescrFromType(NumpyEquivalentType<Scalar>::type_code);
return new_descr->typeobj;
}
}
......@@ -107,7 +107,7 @@ namespace eigenpy
{
namespace bp = boost::python;
PyArray_Descr * descr_ptr = new PyArray_Descr(*PyArray_DescrFromType(NPY_OBJECT));
PyArray_Descr * descr_ptr = new PyArray_Descr(*call_PyArray_DescrFromType(NPY_OBJECT));
PyArray_Descr & descr = *descr_ptr;
descr.typeobj = py_type_ptr;
descr.kind = 'V';
......@@ -120,7 +120,7 @@ namespace eigenpy
PyArray_ArrFuncs * funcs_ptr = new PyArray_ArrFuncs;
PyArray_ArrFuncs & funcs = *funcs_ptr;
descr.f = funcs_ptr;
PyArray_InitArrFuncs(funcs_ptr);
call_PyArray_InitArrFuncs(funcs_ptr);
funcs.getitem = getitem;
funcs.setitem = setitem;
funcs.nonzero = nonzero;
......@@ -129,9 +129,9 @@ namespace eigenpy
funcs.dotfunc = dotfunc;
// f->cast = cast;
const int code = PyArray_RegisterDataType(descr_ptr);
const int code = call_PyArray_RegisterDataType(descr_ptr);
assert(code >= 0 && "The return code should be positive");
PyArray_Descr * new_descr = PyArray_DescrFromType(code);
PyArray_Descr * new_descr = call_PyArray_DescrFromType(code);
type_to_py_type_bindings.insert(std::make_pair(type_info_ptr,py_type_ptr));
py_array_descr_bindings[py_type_ptr] = new_descr;
......
......@@ -38,6 +38,21 @@ namespace eigenpy
}
PyTypeObject * getPyArrayType() { return &PyArray_Type; }
int call_PyArray_DescrFromType(int typenum)
{
return PyArray_DescrFromType(typenum);
}
void call_PyArray_InitArrFuncs(PyArray_ArrFuncs * funcs)
{
PyArray_InitArrFuncs(funcs);
}
int call_PyArray_RegisterDataType(PyArray_Descr * dtype)
{
return PyArray_RegisterDataType(dtype);
}
#endif
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment