Skip to content

Commit 584dbe3

Browse files
authored
Merge pull request #137 from jcarpent/devel
Fix important bug in 1.6.10
2 parents 7233fad + 7631a42 commit 584dbe3

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

include/eigenpy/details.hpp

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,41 @@
1616
#include "eigenpy/registration.hpp"
1717
#include "eigenpy/map.hpp"
1818

19+
namespace boost { namespace python { namespace converter {
20+
21+
template<class MatType>
22+
struct implicit<Eigen::MatrixBase<MatType>,MatType>
23+
{
24+
typedef Eigen::MatrixBase<MatType> Source;
25+
typedef MatType Target;
26+
27+
static void* convertible(PyObject* obj)
28+
{
29+
// Find a converter which can produce a Source instance from
30+
// obj. The user has told us that Source can be converted to
31+
// Target, and instantiating construct() below, ensures that
32+
// at compile-time.
33+
return implicit_rvalue_convertible_from_python(obj, registered<Source>::converters)
34+
? obj : 0;
35+
}
36+
37+
static void construct(PyObject* obj, rvalue_from_python_stage1_data* data)
38+
{
39+
void* storage = ((rvalue_from_python_storage<Target>*)data)->storage.bytes;
40+
41+
arg_from_python<Source> get_source(obj);
42+
bool convertible = get_source.convertible();
43+
BOOST_VERIFY(convertible);
44+
45+
new (storage) Target(get_source().derived());
46+
47+
// record successful construction
48+
data->convertible = storage;
49+
}
50+
};
51+
52+
}}} // namespace boost::python::converter
53+
1954
#define GET_PY_ARRAY_TYPE(array) PyArray_ObjectType(reinterpret_cast<PyObject *>(array), 0)
2055

2156
namespace eigenpy
@@ -531,13 +566,13 @@ namespace eigenpy
531566

532567
// Add also conversion to Eigen::MatrixBase<MatType>
533568
typedef Eigen::MatrixBase<MatType> MatTypeBase;
569+
// bp::implicitly_convertible<MatTypeBase,MatType>();
534570
bp::implicitly_convertible<MatType,MatTypeBase>();
535-
bp::implicitly_convertible<MatTypeBase,MatType>();
536571
}
537572
};
538573

539574
#if EIGEN_VERSION_AT_LEAST(3,2,0)
540-
/// Template specialization for Eigen::Ref
575+
// Template specialization for Eigen::Ref
541576
template<typename MatType>
542577
struct EigenFromPyConverter< eigenpy::Ref<MatType> >
543578
{

python/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ SET(PYTHON_FILES
5555
)
5656

5757
FOREACH(python ${PYTHON_FILES})
58-
PYTHON_BUILD(${PROJECT_NAME} ${python})
58+
IF(NOT WIN32)
59+
PYTHON_BUILD(${PROJECT_NAME} ${python})
60+
ENDIF()
5961
INSTALL(FILES
6062
"${CMAKE_CURRENT_SOURCE_DIR}/eigenpy/${python}"
6163
DESTINATION ${${PYWRAP}_INSTALL_DIR})

0 commit comments

Comments
 (0)