Skip to content

Commit c4d2239

Browse files
committed
core: add fix for bug in boost::rvalue_from_python_data
1 parent 1e0eb6e commit c4d2239

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ SET(${PROJECT_NAME}_HEADERS
103103
include/eigenpy/quaternion.hpp
104104
include/eigenpy/stride.hpp
105105
include/eigenpy/ref.hpp
106+
include/eigenpy/details/rvalue_from_python_data.hpp
106107
)
107108

108109
INCLUDE_DIRECTORIES(${${PROJECT_NAME}_BINARY_DIR}/include)

include/eigenpy/details.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#ifndef __eigenpy_details_hpp__
77
#define __eigenpy_details_hpp__
88

9+
#include "eigenpy/details/rvalue_from_python_data.hpp"
910
#include "eigenpy/fwd.hpp"
1011

1112
#include <patchlevel.h> // For PY_MAJOR_VERSION
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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

Comments
 (0)