Skip to content

Commit 500401b

Browse files
committed
core: add PlainObjectBase support
1 parent abcc7c3 commit 500401b

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

include/eigenpy/details.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ namespace boost { namespace python { namespace detail {
4949
std::size_t, value = sizeof(MatType));
5050
};
5151

52+
template<class MatType>
53+
struct referent_size<Eigen::PlainObjectBase<MatType>&>
54+
{
55+
BOOST_STATIC_CONSTANT(
56+
std::size_t, value = sizeof(MatType));
57+
};
58+
59+
template<class MatType>
60+
struct referent_size<Eigen::PlainObjectBase<MatType> >
61+
{
62+
BOOST_STATIC_CONSTANT(
63+
std::size_t, value = sizeof(MatType));
64+
};
65+
5266
}}}
5367

5468
namespace eigenpy

include/eigenpy/eigen-from-python.hpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,14 @@ namespace boost { namespace python { namespace converter {
173173
EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &)
174174
};
175175

176+
/// \brief Template specialization of rvalue_from_python_data
177+
template<typename Derived>
178+
struct rvalue_from_python_data<Eigen::PlainObjectBase<Derived> const &>
179+
: rvalue_from_python_data_eigen<Derived const &>
180+
{
181+
EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &)
182+
};
183+
176184
template<typename MatType, int Options, typename Stride>
177185
struct rvalue_from_python_data<Eigen::Ref<MatType,Options,Stride> &>
178186
: rvalue_from_python_storage<Eigen::Ref<MatType,Options,Stride> &>
@@ -425,6 +433,10 @@ namespace eigenpy
425433
typedef Eigen::EigenBase<MatType> EigenBase;
426434
EigenFromPy<EigenBase>::registration();
427435

436+
// Add conversion to Eigen::PlainObjectBase<MatType>
437+
typedef Eigen::PlainObjectBase<MatType> PlainObjectBase;
438+
EigenFromPy<PlainObjectBase>::registration();
439+
428440
#if EIGEN_VERSION_AT_LEAST(3,2,0)
429441
// Add conversion to Eigen::Ref<MatType>
430442
typedef Eigen::Ref<MatType> RefType;
@@ -464,6 +476,20 @@ namespace eigenpy
464476
&EigenFromPy::construct,bp::type_id<Base>());
465477
}
466478
};
479+
480+
template<typename MatType>
481+
struct EigenFromPy< Eigen::PlainObjectBase<MatType> > : EigenFromPy<MatType>
482+
{
483+
typedef EigenFromPy<MatType> EigenFromPyDerived;
484+
typedef Eigen::PlainObjectBase<MatType> Base;
485+
486+
static void registration()
487+
{
488+
bp::converter::registry::push_back
489+
(reinterpret_cast<void *(*)(_object *)>(&EigenFromPy::convertible),
490+
&EigenFromPy::construct,bp::type_id<Base>());
491+
}
492+
};
467493

468494
#if EIGEN_VERSION_AT_LEAST(3,2,0)
469495

0 commit comments

Comments
 (0)