From 1fb4cf409f0348715905bca7fea86bde78ce2d17 Mon Sep 17 00:00:00 2001 From: Justin Carpentier <justin.carpentier@inria.fr> Date: Fri, 21 Feb 2020 18:46:25 +0100 Subject: [PATCH] core: move template specilization to the right place --- CMakeLists.txt | 1 - include/eigenpy/details.hpp | 1 - .../details/rvalue_from_python_data.hpp | 96 ------------------- include/eigenpy/eigen-from-python.hpp | 80 ++++++++++++++++ 4 files changed, 80 insertions(+), 98 deletions(-) delete mode 100644 include/eigenpy/details/rvalue_from_python_data.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 328be5b..8497bbb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,7 +120,6 @@ SET(${PROJECT_NAME}_HEADERS include/eigenpy/quaternion.hpp include/eigenpy/stride.hpp include/eigenpy/ref.hpp - include/eigenpy/details/rvalue_from_python_data.hpp include/eigenpy/version.hpp ) diff --git a/include/eigenpy/details.hpp b/include/eigenpy/details.hpp index 2d391ed..6b15de6 100644 --- a/include/eigenpy/details.hpp +++ b/include/eigenpy/details.hpp @@ -6,7 +6,6 @@ #ifndef __eigenpy_details_hpp__ #define __eigenpy_details_hpp__ -#include "eigenpy/details/rvalue_from_python_data.hpp" #include "eigenpy/fwd.hpp" #include "eigenpy/eigenpy.hpp" diff --git a/include/eigenpy/details/rvalue_from_python_data.hpp b/include/eigenpy/details/rvalue_from_python_data.hpp deleted file mode 100644 index ee28904..0000000 --- a/include/eigenpy/details/rvalue_from_python_data.hpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2018-2020, INRIA - */ - -#ifndef __eigenpy_details_rvalue_from_python_data_hpp__ -#define __eigenpy_details_rvalue_from_python_data_hpp__ - -#include <boost/python/converter/rvalue_from_python_data.hpp> -#include <Eigen/Core> - -namespace boost -{ - namespace python - { - namespace converter - { - - /// \brief Template specialization of rvalue_from_python_data - template<typename Derived> - struct rvalue_from_python_data<Eigen::MatrixBase<Derived> const & > - : rvalue_from_python_storage<Derived const & > - { - typedef Eigen::MatrixBase<Derived> const & T; - -# if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) \ -&& (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 245) \ -&& (!defined(__DECCXX_VER) || __DECCXX_VER > 60590014) \ -&& !defined(BOOST_PYTHON_SYNOPSIS) /* Synopsis' OpenCXX has trouble parsing this */ - // This must always be a POD struct with m_data its first member. - BOOST_STATIC_ASSERT(BOOST_PYTHON_OFFSETOF(rvalue_from_python_storage<T>,stage1) == 0); -# endif - - // The usual constructor - rvalue_from_python_data(rvalue_from_python_stage1_data const & _stage1) - { - this->stage1 = _stage1; - } - - // This constructor just sets m_convertible -- used by - // implicitly_convertible<> to perform the final step of the - // conversion, where the construct() function is already known. - rvalue_from_python_data(void* convertible) - { - this->stage1.convertible = convertible; - } - - // Destroys any object constructed in the storage. - ~rvalue_from_python_data() - { - if (this->stage1.convertible == this->storage.bytes) - static_cast<Derived *>((void *)this->storage.bytes)->~Derived(); - } - }; - - /// \brief Template specialization of rvalue_from_python_data - template<typename Derived> - struct rvalue_from_python_data<Eigen::EigenBase<Derived> const & > - : rvalue_from_python_storage<Derived const & > - { - typedef Eigen::EigenBase<Derived> const & T; - -# if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) \ -&& (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 245) \ -&& (!defined(__DECCXX_VER) || __DECCXX_VER > 60590014) \ -&& !defined(BOOST_PYTHON_SYNOPSIS) /* Synopsis' OpenCXX has trouble parsing this */ - // This must always be a POD struct with m_data its first member. - BOOST_STATIC_ASSERT(BOOST_PYTHON_OFFSETOF(rvalue_from_python_storage<T>,stage1) == 0); -# endif - - // The usual constructor - rvalue_from_python_data(rvalue_from_python_stage1_data const & _stage1) - { - this->stage1 = _stage1; - } - - // This constructor just sets m_convertible -- used by - // implicitly_convertible<> to perform the final step of the - // conversion, where the construct() function is already known. - rvalue_from_python_data(void* convertible) - { - this->stage1.convertible = convertible; - } - - // Destroys any object constructed in the storage. - ~rvalue_from_python_data() - { - if (this->stage1.convertible == this->storage.bytes) - static_cast<Derived *>((void *)this->storage.bytes)->~Derived(); - } - }; - - } - } -} // namespace boost::python::converter - -#endif // ifndef __eigenpy_details_rvalue_from_python_data_hpp__ diff --git a/include/eigenpy/eigen-from-python.hpp b/include/eigenpy/eigen-from-python.hpp index 0748269..899ed3b 100644 --- a/include/eigenpy/eigen-from-python.hpp +++ b/include/eigenpy/eigen-from-python.hpp @@ -10,6 +10,86 @@ #include "eigenpy/eigen-allocator.hpp" #include "eigenpy/scalar-conversion.hpp" +#include <boost/python/converter/rvalue_from_python_data.hpp> + +namespace boost { namespace python { namespace converter { + + /// \brief Template specialization of rvalue_from_python_data + template<typename Derived> + struct rvalue_from_python_data<Eigen::MatrixBase<Derived> const & > + : rvalue_from_python_storage<Derived const & > + { + typedef Eigen::MatrixBase<Derived> const & T; + +# if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) \ +&& (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 245) \ +&& (!defined(__DECCXX_VER) || __DECCXX_VER > 60590014) \ +&& !defined(BOOST_PYTHON_SYNOPSIS) /* Synopsis' OpenCXX has trouble parsing this */ + // This must always be a POD struct with m_data its first member. + BOOST_STATIC_ASSERT(BOOST_PYTHON_OFFSETOF(rvalue_from_python_storage<T>,stage1) == 0); +# endif + + // The usual constructor + rvalue_from_python_data(rvalue_from_python_stage1_data const & _stage1) + { + this->stage1 = _stage1; + } + + // This constructor just sets m_convertible -- used by + // implicitly_convertible<> to perform the final step of the + // conversion, where the construct() function is already known. + rvalue_from_python_data(void* convertible) + { + this->stage1.convertible = convertible; + } + + // Destroys any object constructed in the storage. + ~rvalue_from_python_data() + { + if (this->stage1.convertible == this->storage.bytes) + static_cast<Derived *>((void *)this->storage.bytes)->~Derived(); + } + }; + + /// \brief Template specialization of rvalue_from_python_data + template<typename Derived> + struct rvalue_from_python_data<Eigen::EigenBase<Derived> const & > + : rvalue_from_python_storage<Derived const & > + { + typedef Eigen::EigenBase<Derived> const & T; + +# if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) \ +&& (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 245) \ +&& (!defined(__DECCXX_VER) || __DECCXX_VER > 60590014) \ +&& !defined(BOOST_PYTHON_SYNOPSIS) /* Synopsis' OpenCXX has trouble parsing this */ + // This must always be a POD struct with m_data its first member. + BOOST_STATIC_ASSERT(BOOST_PYTHON_OFFSETOF(rvalue_from_python_storage<T>,stage1) == 0); +# endif + + // The usual constructor + rvalue_from_python_data(rvalue_from_python_stage1_data const & _stage1) + { + this->stage1 = _stage1; + } + + // This constructor just sets m_convertible -- used by + // implicitly_convertible<> to perform the final step of the + // conversion, where the construct() function is already known. + rvalue_from_python_data(void* convertible) + { + this->stage1.convertible = convertible; + } + + // Destroys any object constructed in the storage. + ~rvalue_from_python_data() + { + if (this->stage1.convertible == this->storage.bytes) + static_cast<Derived *>((void *)this->storage.bytes)->~Derived(); + } + }; + +} } } + namespace eigenpy { template<typename MatType> -- GitLab