1+ /*
2+ * Copyright 2018-2020, INRIA
3+ */
4+
15#ifndef __eigenpy_details_rvalue_from_python_data_hpp__
26#define __eigenpy_details_rvalue_from_python_data_hpp__
37
@@ -10,44 +14,81 @@ namespace boost
1014 {
1115 namespace converter
1216 {
13-
17+
1418 // / \brief Template specialization of rvalue_from_python_data
1519 template <typename Derived>
1620 struct rvalue_from_python_data <Eigen::MatrixBase<Derived> const & >
17- : rvalue_from_python_storage<Eigen::MatrixBase<Derived> const & >
21+ : rvalue_from_python_storage<Derived const & >
22+ {
23+ typedef Eigen::MatrixBase<Derived> const & T;
24+
25+ # if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) \
26+ && (!defined (__EDG_VERSION__) || __EDG_VERSION__ >= 245 ) \
27+ && (!defined (__DECCXX_VER) || __DECCXX_VER > 60590014 ) \
28+ && !defined (BOOST_PYTHON_SYNOPSIS) /* Synopsis' OpenCXX has trouble parsing this */
29+ // This must always be a POD struct with m_data its first member.
30+ BOOST_STATIC_ASSERT (BOOST_PYTHON_OFFSETOF(rvalue_from_python_storage<T>,stage1) == 0);
31+ # endif
32+
33+ // The usual constructor
34+ rvalue_from_python_data (rvalue_from_python_stage1_data const & _stage1)
35+ {
36+ this ->stage1 = _stage1;
37+ }
38+
39+ // This constructor just sets m_convertible -- used by
40+ // implicitly_convertible<> to perform the final step of the
41+ // conversion, where the construct() function is already known.
42+ rvalue_from_python_data (void * convertible)
43+ {
44+ this ->stage1 .convertible = convertible;
45+ }
46+
47+ // Destroys any object constructed in the storage.
48+ ~rvalue_from_python_data ()
49+ {
50+ if (this ->stage1 .convertible == this ->storage .bytes )
51+ static_cast <Derived *>((void *)this ->storage .bytes )->~Derived ();
52+ }
53+ };
54+
55+ // / \brief Template specialization of rvalue_from_python_data
56+ template <typename Derived>
57+ struct rvalue_from_python_data <Eigen::EigenBase<Derived> const & >
58+ : rvalue_from_python_storage<Derived const & >
1859 {
1960 typedef Eigen::MatrixBase<Derived> const & T;
20-
61+
2162# if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) \
2263&& (!defined (__EDG_VERSION__) || __EDG_VERSION__ >= 245 ) \
2364&& (!defined (__DECCXX_VER) || __DECCXX_VER > 60590014 ) \
2465&& !defined (BOOST_PYTHON_SYNOPSIS) /* Synopsis' OpenCXX has trouble parsing this */
2566 // This must always be a POD struct with m_data its first member.
2667 BOOST_STATIC_ASSERT (BOOST_PYTHON_OFFSETOF(rvalue_from_python_storage<T>,stage1) == 0);
2768# endif
28-
69+
2970 // The usual constructor
3071 rvalue_from_python_data (rvalue_from_python_stage1_data const & _stage1)
3172 {
3273 this ->stage1 = _stage1;
3374 }
34-
75+
3576 // This constructor just sets m_convertible -- used by
3677 // implicitly_convertible<> to perform the final step of the
3778 // conversion, where the construct() function is already known.
3879 rvalue_from_python_data (void * convertible)
3980 {
4081 this ->stage1 .convertible = convertible;
4182 }
42-
83+
4384 // Destroys any object constructed in the storage.
4485 ~rvalue_from_python_data ()
4586 {
4687 if (this ->stage1 .convertible == this ->storage .bytes )
4788 static_cast <Derived *>((void *)this ->storage .bytes )->~Derived ();
4889 }
4990 };
50-
91+
5192 }
5293 }
5394} // namespace boost::python::converter
0 commit comments