Skip to content
Snippets Groups Projects
Verified Commit 500401b3 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

core: add PlainObjectBase support

parent abcc7c33
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,20 @@ namespace boost { namespace python { namespace detail {
std::size_t, value = sizeof(MatType));
};
template<class MatType>
struct referent_size<Eigen::PlainObjectBase<MatType>&>
{
BOOST_STATIC_CONSTANT(
std::size_t, value = sizeof(MatType));
};
template<class MatType>
struct referent_size<Eigen::PlainObjectBase<MatType> >
{
BOOST_STATIC_CONSTANT(
std::size_t, value = sizeof(MatType));
};
}}}
namespace eigenpy
......
......@@ -173,6 +173,14 @@ namespace boost { namespace python { namespace converter {
EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &)
};
/// \brief Template specialization of rvalue_from_python_data
template<typename Derived>
struct rvalue_from_python_data<Eigen::PlainObjectBase<Derived> const &>
: rvalue_from_python_data_eigen<Derived const &>
{
EIGENPY_RVALUE_FROM_PYTHON_DATA_INIT(Derived const &)
};
template<typename MatType, int Options, typename Stride>
struct rvalue_from_python_data<Eigen::Ref<MatType,Options,Stride> &>
: rvalue_from_python_storage<Eigen::Ref<MatType,Options,Stride> &>
......@@ -425,6 +433,10 @@ namespace eigenpy
typedef Eigen::EigenBase<MatType> EigenBase;
EigenFromPy<EigenBase>::registration();
// Add conversion to Eigen::PlainObjectBase<MatType>
typedef Eigen::PlainObjectBase<MatType> PlainObjectBase;
EigenFromPy<PlainObjectBase>::registration();
#if EIGEN_VERSION_AT_LEAST(3,2,0)
// Add conversion to Eigen::Ref<MatType>
typedef Eigen::Ref<MatType> RefType;
......@@ -464,6 +476,20 @@ namespace eigenpy
&EigenFromPy::construct,bp::type_id<Base>());
}
};
template<typename MatType>
struct EigenFromPy< Eigen::PlainObjectBase<MatType> > : EigenFromPy<MatType>
{
typedef EigenFromPy<MatType> EigenFromPyDerived;
typedef Eigen::PlainObjectBase<MatType> Base;
static void registration()
{
bp::converter::registry::push_back
(reinterpret_cast<void *(*)(_object *)>(&EigenFromPy::convertible),
&EigenFromPy::construct,bp::type_id<Base>());
}
};
#if EIGEN_VERSION_AT_LEAST(3,2,0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment