|
| 1 | +#ifndef __eigenpy_details_rvalue_from_python_data_hpp__ |
| 2 | +#define __eigenpy_details_rvalue_from_python_data_hpp__ |
| 3 | + |
| 4 | +#include <boost/python/converter/rvalue_from_python_data.hpp> |
| 5 | +#include <Eigen/Core> |
| 6 | + |
| 7 | +namespace boost |
| 8 | +{ |
| 9 | + namespace python |
| 10 | + { |
| 11 | + namespace converter |
| 12 | + { |
| 13 | + |
| 14 | + /// \brief Template specialization of rvalue_from_python_data |
| 15 | + template<typename Derived> |
| 16 | + struct rvalue_from_python_data<Eigen::MatrixBase<Derived> const & > |
| 17 | + : rvalue_from_python_storage<Eigen::MatrixBase<Derived> const & > |
| 18 | + { |
| 19 | + typedef Eigen::MatrixBase<Derived> const & T; |
| 20 | + |
| 21 | +# if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) \ |
| 22 | +&& (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 245) \ |
| 23 | +&& (!defined(__DECCXX_VER) || __DECCXX_VER > 60590014) \ |
| 24 | +&& !defined(BOOST_PYTHON_SYNOPSIS) /* Synopsis' OpenCXX has trouble parsing this */ |
| 25 | + // This must always be a POD struct with m_data its first member. |
| 26 | + BOOST_STATIC_ASSERT(BOOST_PYTHON_OFFSETOF(rvalue_from_python_storage<T>,stage1) == 0); |
| 27 | +# endif |
| 28 | + |
| 29 | + // The usual constructor |
| 30 | + rvalue_from_python_data(rvalue_from_python_stage1_data const & _stage1) |
| 31 | + { |
| 32 | + this->stage1 = _stage1; |
| 33 | + } |
| 34 | + |
| 35 | + // This constructor just sets m_convertible -- used by |
| 36 | + // implicitly_convertible<> to perform the final step of the |
| 37 | + // conversion, where the construct() function is already known. |
| 38 | + rvalue_from_python_data(void* convertible) |
| 39 | + { |
| 40 | + this->stage1.convertible = convertible; |
| 41 | + } |
| 42 | + |
| 43 | + // Destroys any object constructed in the storage. |
| 44 | + ~rvalue_from_python_data() |
| 45 | + { |
| 46 | + if (this->stage1.convertible == this->storage.bytes) |
| 47 | + static_cast<Derived *>((void *)this->storage.bytes)->~Derived(); |
| 48 | + } |
| 49 | + }; |
| 50 | + |
| 51 | + } |
| 52 | + } |
| 53 | +} // namespace boost::python::converter |
| 54 | + |
| 55 | +#endif // ifndef __eigenpy_details_rvalue_from_python_data_hpp__ |
0 commit comments