diff --git a/include/eigenpy/eigen-from-python.hpp b/include/eigenpy/eigen-from-python.hpp index f74bdab603e09a929a195a70f129609a7efa0745..dabb7b9d33f5e45da9981b1fd9d38055ee5a129c 100644 --- a/include/eigenpy/eigen-from-python.hpp +++ b/include/eigenpy/eigen-from-python.hpp @@ -285,7 +285,7 @@ namespace eigenpy template<typename MatType> void* EigenFromPy<MatType>::convertible(PyArrayObject* pyArray) { - if(!PyArray_Check(pyArray)) + if(!call_PyArray_Check(pyArray)) return 0; if(!np_type_is_convertible_into_scalar<Scalar>(EIGENPY_GET_PY_ARRAY_TYPE(pyArray))) @@ -476,7 +476,7 @@ namespace eigenpy /// \brief Determine if pyObj can be converted into a MatType object static void* convertible(PyArrayObject * pyArray) { - if(!PyArray_Check(pyArray)) + if(!call_PyArray_Check(pyArray)) return 0; if(!PyArray_ISWRITEABLE(pyArray)) return 0; diff --git a/include/eigenpy/numpy.hpp b/include/eigenpy/numpy.hpp index 184006f93292c14aebb6d5333ac75597bda1cde3..b0de2648bdfc2953afe3e14be3eaeb68e36148b4 100644 --- a/include/eigenpy/numpy.hpp +++ b/include/eigenpy/numpy.hpp @@ -37,6 +37,8 @@ namespace eigenpy #if defined _WIN32 || defined __CYGWIN__ namespace eigenpy { + EIGENPY_DLLEXPORT bool call_PyArray_Check(PyObject *); + EIGENPY_DLLEXPORT PyObject* call_PyArray_SimpleNew(int nd, npy_intp * shape, int np_type); EIGENPY_DLLEXPORT PyObject* call_PyArray_New(PyTypeObject * py_type_ptr, int nd, npy_intp * shape, int np_type, void * data_ptr, int options); @@ -52,6 +54,7 @@ namespace eigenpy EIGENPY_DLLEXPORT int call_PyArray_RegisterDataType(PyArray_Descr * dtype); } #else + #define call_PyArray_Check(py_obj) PyArray_Check(py_obj) #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) diff --git a/src/numpy.cpp b/src/numpy.cpp index 8833a560f3a050fa8b201e9fcdf3e5750bff792e..10c3d7ea0557a69616b4cbf6af0869d80f645605 100644 --- a/src/numpy.cpp +++ b/src/numpy.cpp @@ -22,6 +22,11 @@ namespace eigenpy #if defined _WIN32 || defined __CYGWIN__ + bool call_PyArray_Check(PyObject * py_obj) + { + return PyArray_Check(py_obj); + } + PyObject* call_PyArray_SimpleNew(int nd, npy_intp * shape, int np_type) { return PyArray_SimpleNew(nd,shape,np_type);