Verified Commit afcf90e6 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

core: extend current API to hanle allocation of arrays of PyTypeObject

parent d8ee7100
......@@ -42,7 +42,10 @@ namespace eigenpy
if(NumpyType::sharedMemory())
{
PyArrayObject * pyArray = (PyArrayObject*) call_PyArray_New(static_cast<int>(nd), shape,
PyTypeObject * py_type_ptr = &PyArray_Type;
PyArrayObject * pyArray = (PyArrayObject*) call_PyArray_New(py_type_ptr,
static_cast<int>(nd),
shape,
NumpyEquivalentType<Scalar>::type_code,
mat.data(),
NPY_ARRAY_MEMORY_CONTIGUOUS | NPY_ARRAY_ALIGNED);
......@@ -77,7 +80,10 @@ namespace eigenpy
if(NumpyType::sharedMemory())
{
PyArrayObject * pyArray = (PyArrayObject*) call_PyArray_New(static_cast<int>(nd), shape,
PyTypeObject * py_type_ptr = &PyArray_Type;
PyArrayObject * pyArray = (PyArrayObject*) call_PyArray_New(py_type_ptr,
static_cast<int>(nd),
shape,
NumpyEquivalentType<Scalar>::type_code,
const_cast<SimilarMatrixType &>(mat.derived()).data(),
NPY_ARRAY_MEMORY_CONTIGUOUS_RO | NPY_ARRAY_ALIGNED);
......
......@@ -35,16 +35,16 @@ namespace eigenpy
#if defined _WIN32 || defined __CYGWIN__
namespace eigenpy
{
EIGENPY_DLLEXPORT PyObject* call_PyArray_SimpleNew(int nd, npy_intp * shape, int np_type);
EIGENPY_DLLEXPORT PyObject* call_PyArray_SimpleNew(int nd, npy_intp * shape, int np_type);
EIGENPY_DLLEXPORT PyObject* call_PyArray_New(int nd, npy_intp * shape, int np_type, void * data_ptr, int options);
EIGENPY_DLLEXPORT PyObject* call_PyArray_New(PyTypeObject * py_type_ptr, int nd, npy_intp * shape, int np_type, void * data_ptr, int 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)
#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)
#endif
#endif // ifndef __eigenpy_numpy_hpp__
......@@ -22,9 +22,9 @@ namespace eigenpy
return PyArray_SimpleNew(nd,shape,np_type);
}
PyObject* call_PyArray_New(int nd, npy_intp * shape, int np_type, void * data_ptr, int options)
PyObject* call_PyArray_New(PyTypeObject * py_type_ptr, int nd, npy_intp * shape, int np_type, void * data_ptr, int options)
{
return PyArray_New(&PyArray_Type,nd,shape,np_type,NULL,data_ptr,0,options,NULL);
return PyArray_New(py_type_ptr,nd,shape,np_type,NULL,data_ptr,0,options,NULL);
}
int call_PyArray_ObjectType(PyObject * obj, int val)
......
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