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

core: add helper eigen_from_py_construct

parent ab986afe
No related branches found
No related tags found
No related merge requests found
...@@ -83,6 +83,22 @@ namespace boost { namespace python { namespace converter { ...@@ -83,6 +83,22 @@ namespace boost { namespace python { namespace converter {
namespace eigenpy namespace eigenpy
{ {
template<typename MatOrRefType>
void eigen_from_py_construct(PyObject* pyObj,
bp::converter::rvalue_from_python_stage1_data* memory)
{
PyArrayObject * pyArray = reinterpret_cast<PyArrayObject*>(pyObj);
assert((PyArray_DIMS(pyArray)[0]<INT_MAX) && (PyArray_DIMS(pyArray)[1]<INT_MAX));
bp::converter::rvalue_from_python_storage<MatOrRefType>* storage = reinterpret_cast<bp::converter::rvalue_from_python_storage<MatOrRefType>*>
(reinterpret_cast<void*>(memory));
EigenAllocator<MatOrRefType>::allocate(pyArray,storage);
memory->convertible = storage->storage.bytes;
}
template<typename MatType> template<typename MatType>
struct EigenFromPy struct EigenFromPy
{ {
...@@ -215,15 +231,7 @@ namespace eigenpy ...@@ -215,15 +231,7 @@ namespace eigenpy
void EigenFromPy<MatType>::construct(PyObject* pyObj, void EigenFromPy<MatType>::construct(PyObject* pyObj,
bp::converter::rvalue_from_python_stage1_data* memory) bp::converter::rvalue_from_python_stage1_data* memory)
{ {
PyArrayObject * pyArray = reinterpret_cast<PyArrayObject*>(pyObj); eigen_from_py_construct<MatType>(pyObj,memory);
assert((PyArray_DIMS(pyArray)[0]<INT_MAX) && (PyArray_DIMS(pyArray)[1]<INT_MAX));
void* storage = reinterpret_cast<bp::converter::rvalue_from_python_storage<MatType>*>
(reinterpret_cast<void*>(memory))->storage.bytes;
EigenAllocator<MatType>::allocate(pyArray,storage);
memory->convertible = storage;
} }
template<typename MatType> template<typename MatType>
......
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