Verified Commit 78efea55 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

core: patch Win32

which is not able to retrieve EIGENPY_ARRAY_API when compiling other module because the symbol is not exported
parent dbde4c15
...@@ -20,8 +20,8 @@ namespace eigenpy ...@@ -20,8 +20,8 @@ namespace eigenpy
{ {
typedef typename SimilarMatrixType::Scalar Scalar; typedef typename SimilarMatrixType::Scalar Scalar;
PyArrayObject * pyArray = (PyArrayObject*) PyArray_SimpleNew(nd, shape, PyArrayObject * pyArray = (PyArrayObject*) call_PyArray_SimpleNew(nd, shape,
NumpyEquivalentType<Scalar>::type_code); NumpyEquivalentType<Scalar>::type_code);
// Copy data // Copy data
EigenAllocator<SimilarMatrixType>::copy(mat,pyArray); EigenAllocator<SimilarMatrixType>::copy(mat,pyArray);
...@@ -40,11 +40,10 @@ namespace eigenpy ...@@ -40,11 +40,10 @@ namespace eigenpy
typedef typename SimilarMatrixType::Scalar Scalar; typedef typename SimilarMatrixType::Scalar Scalar;
enum { NPY_ARRAY_MEMORY_CONTIGUOUS = SimilarMatrixType::IsRowMajor ? NPY_ARRAY_CARRAY : NPY_ARRAY_FARRAY }; enum { NPY_ARRAY_MEMORY_CONTIGUOUS = SimilarMatrixType::IsRowMajor ? NPY_ARRAY_CARRAY : NPY_ARRAY_FARRAY };
PyArrayObject * pyArray = (PyArrayObject*) PyArray_New(&PyArray_Type, nd, shape, PyArrayObject * pyArray = (PyArrayObject*) call_PyArray_New(nd, shape,
NumpyEquivalentType<Scalar>::type_code, NULL, NumpyEquivalentType<Scalar>::type_code,
mat.data(), 0, mat.data(),
NPY_ARRAY_MEMORY_CONTIGUOUS | NPY_ARRAY_ALIGNED, NPY_ARRAY_MEMORY_CONTIGUOUS | NPY_ARRAY_ALIGNED);
NULL);
return pyArray; return pyArray;
} }
...@@ -69,11 +68,10 @@ namespace eigenpy ...@@ -69,11 +68,10 @@ namespace eigenpy
typedef typename SimilarMatrixType::Scalar Scalar; typedef typename SimilarMatrixType::Scalar Scalar;
enum { NPY_ARRAY_MEMORY_CONTIGUOUS_RO = SimilarMatrixType::IsRowMajor ? NPY_ARRAY_CARRAY_RO : NPY_ARRAY_FARRAY_RO }; enum { NPY_ARRAY_MEMORY_CONTIGUOUS_RO = SimilarMatrixType::IsRowMajor ? NPY_ARRAY_CARRAY_RO : NPY_ARRAY_FARRAY_RO };
PyArrayObject * pyArray = (PyArrayObject*) PyArray_New(&PyArray_Type, nd, shape, PyArrayObject * pyArray = (PyArrayObject*) call_PyArray_New(nd, shape,
NumpyEquivalentType<Scalar>::type_code, NULL, NumpyEquivalentType<Scalar>::type_code,
const_cast<SimilarMatrixType &>(mat.derived()).data(), 0, const_cast<SimilarMatrixType &>(mat.derived()).data(),
NPY_ARRAY_MEMORY_CONTIGUOUS_RO | NPY_ARRAY_ALIGNED, NPY_ARRAY_MEMORY_CONTIGUOUS_RO | NPY_ARRAY_ALIGNED);
NULL);
return pyArray; return pyArray;
} }
......
...@@ -19,11 +19,32 @@ ...@@ -19,11 +19,32 @@
#include <numpy/noprefix.h> #include <numpy/noprefix.h>
#define EIGENPY_GET_PY_ARRAY_TYPE(array) PyArray_ObjectType(reinterpret_cast<PyObject *>(array), 0) #if defined _WIN32 || defined __CYGWIN__
#define EIGENPY_GET_PY_ARRAY_TYPE(array) \
call_PyArray_ObjectType(reinterpret_cast<PyObject *>(array), 0)
#else
#define EIGENPY_GET_PY_ARRAY_TYPE(array) \
PyArray_ObjectType(reinterpret_cast<PyObject *>(array), 0)
#endif
namespace eigenpy namespace eigenpy
{ {
void EIGENPY_DLLEXPORT import_numpy(); void EIGENPY_DLLEXPORT import_numpy();
} }
#if defined _WIN32 || defined __CYGWIN__
namespace eigenpy
{
EIGENPY_DLLEXPORT PyArrayObject* call_PyArray_SimpleNew(npy_intp nd, npy_intp * shape, NPY_TYPES np_type);
EIGENPY_DLLEXPORT PyArrayObject* call_PyArray_New(npy_intp nd, npy_intp * shape, NPY_TYPES np_type, void * data_ptr, npy_intp options);
EIGENPY_DLLEXPORT int call_PyArray_ObjectType(PyObject *, int);
}
#else
#define call_PyArray_SimpleNew PyArray_SimpleNew
#define call_PyArray_New(nd,shape,np_type,data_ptr,options) \
PyArray_New(&PyArray_Type,nd,shape,np_type,NULL,data_ptr,0,options,NULL)
#endif
#endif // ifndef __eigenpy_numpy_hpp__ #endif // ifndef __eigenpy_numpy_hpp__
...@@ -14,4 +14,23 @@ namespace eigenpy ...@@ -14,4 +14,23 @@ namespace eigenpy
PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import");
} }
} }
#if defined _WIN32 || defined __CYGWIN__
PyArrayObject* call_PyArray_SimpleNew(npy_intp nd, npy_intp * shape, NPY_TYPES np_type)
{
return PyArray_SimpleNew(nd,shape,np_type);
}
PyArrayObject* call_PyArray_New(npy_intp nd, npy_intp * shape, NPY_TYPES np_type, void * data_ptr, npy_intp options)
{
return PyArray_New(&PyArray_Type,nd,shape,np_type,NULL,data_ptr,0,options,NULL);
}
int call_PyArray_ObjectType(PyObject * obj, int val)
{
return PyArray_ObjectType(obj,val);
}
#endif
} }
Supports Markdown
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