diff --git a/include/eigenpy/details.hpp b/include/eigenpy/details.hpp index 09a589cb8dad97a97cdf597208c4e739ec02bb73..a7fbb8553a7a47bbe37ef49cd4553aa8540826ed 100644 --- a/include/eigenpy/details.hpp +++ b/include/eigenpy/details.hpp @@ -16,6 +16,41 @@ #include "eigenpy/registration.hpp" #include "eigenpy/map.hpp" +namespace boost { namespace python { namespace converter { + +template<class MatType> +struct implicit<Eigen::MatrixBase<MatType>,MatType> +{ + typedef Eigen::MatrixBase<MatType> Source; + typedef MatType Target; + + static void* convertible(PyObject* obj) + { + // Find a converter which can produce a Source instance from + // obj. The user has told us that Source can be converted to + // Target, and instantiating construct() below, ensures that + // at compile-time. + return implicit_rvalue_convertible_from_python(obj, registered<Source>::converters) + ? obj : 0; + } + + static void construct(PyObject* obj, rvalue_from_python_stage1_data* data) + { + void* storage = ((rvalue_from_python_storage<Target>*)data)->storage.bytes; + + arg_from_python<Source> get_source(obj); + bool convertible = get_source.convertible(); + BOOST_VERIFY(convertible); + + new (storage) Target(get_source().derived()); + + // record successful construction + data->convertible = storage; + } +}; + +}}} // namespace boost::python::converter + #define GET_PY_ARRAY_TYPE(array) PyArray_ObjectType(reinterpret_cast<PyObject *>(array), 0) namespace eigenpy @@ -531,13 +566,13 @@ namespace eigenpy // Add also conversion to Eigen::MatrixBase<MatType> typedef Eigen::MatrixBase<MatType> MatTypeBase; +// bp::implicitly_convertible<MatTypeBase,MatType>(); bp::implicitly_convertible<MatType,MatTypeBase>(); - bp::implicitly_convertible<MatTypeBase,MatType>(); } }; #if EIGEN_VERSION_AT_LEAST(3,2,0) - /// Template specialization for Eigen::Ref + // Template specialization for Eigen::Ref template<typename MatType> struct EigenFromPyConverter< eigenpy::Ref<MatType> > { diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 56d3f6898355da49ae9ef5eb7354813d45af7d08..df5a117f5db3e73b195f40c4db4ea6dfb077da2f 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -55,7 +55,9 @@ SET(PYTHON_FILES ) FOREACH(python ${PYTHON_FILES}) - PYTHON_BUILD(${PROJECT_NAME} ${python}) + IF(NOT WIN32) + PYTHON_BUILD(${PROJECT_NAME} ${python}) + ENDIF() INSTALL(FILES "${CMAKE_CURRENT_SOURCE_DIR}/eigenpy/${python}" DESTINATION ${${PYWRAP}_INSTALL_DIR})