From 821711e20352bc9c63a298182e012cf81e6230e0 Mon Sep 17 00:00:00 2001 From: Justin Carpentier <justin.carpentier@inria.fr> Date: Fri, 21 Feb 2020 18:37:07 +0100 Subject: [PATCH] core: add dedicated EigenToPyConverter --- CMakeLists.txt | 1 + include/eigenpy/details.hpp | 3 ++- include/eigenpy/eigen-to-python.hpp | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bac27375..328be5b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,6 +108,7 @@ SET(${PROJECT_NAME}_HEADERS include/eigenpy/fwd.hpp include/eigenpy/eigen-allocator.hpp include/eigenpy/eigen-to-python.hpp + include/eigenpy/eigen-from-python.hpp include/eigenpy/map.hpp include/eigenpy/geometry.hpp include/eigenpy/geometry-conversion.hpp diff --git a/include/eigenpy/details.hpp b/include/eigenpy/details.hpp index b29878b4..699afb41 100644 --- a/include/eigenpy/details.hpp +++ b/include/eigenpy/details.hpp @@ -304,6 +304,7 @@ namespace eigenpy } }; +#endif template<typename MatType,typename EigenEquivalentType> EIGENPY_DEPRECATED @@ -317,7 +318,7 @@ namespace eigenpy { if(check_registration<MatType>()) return; - bp::to_python_converter<MatType,EigenToPy<MatType> >(); + EigenToPyConverter<MatType>::registration(); EigenFromPyConverter<MatType>::registration(); } diff --git a/include/eigenpy/eigen-to-python.hpp b/include/eigenpy/eigen-to-python.hpp index 6c343f2d..0696eea1 100644 --- a/include/eigenpy/eigen-to-python.hpp +++ b/include/eigenpy/eigen-to-python.hpp @@ -47,6 +47,24 @@ namespace eigenpy } }; + template<typename MatType> + struct EigenToPyConverter + { + static void registration() + { + bp::to_python_converter<MatType,EigenToPy<MatType> >(); + } + }; + +#if EIGEN_VERSION_AT_LEAST(3,2,0) + template<typename MatType> + struct EigenToPyConverter< eigenpy::Ref<MatType> > + { + static void registration() + { + } + }; +#endif } #endif // __eigenpy_eigen_to_python_hpp__ -- GitLab