Verified Commit a9981b17 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

core/geometry: specialize converter for Quaternion

parent c68020de
......@@ -12,6 +12,49 @@
#include "eigenpy/exception.hpp"
namespace boost { namespace python { namespace converter {
/// \brief Template specialization of rvalue_from_python_data
template<typename Quaternion>
struct rvalue_from_python_data<Eigen::QuaternionBase<Quaternion> const &>
: rvalue_from_python_data_eigen<Quaternion const &>
{
RVALUE_FROM_PYTHON_DATA_INIT(Quaternion const &)
};
template <class Quaternion>
struct implicit<Quaternion, Eigen::QuaternionBase<Quaternion> >
{
typedef Quaternion Source;
typedef Eigen::QuaternionBase<Quaternion> Target;
static void* convertible(PyObject* obj)
{
// Find a converter which can produce a Source instance from
// obj. The user has told us that Source can be converted to
// Target, and instantiating construct() below, ensures that
// at compile-time.
return implicit_rvalue_convertible_from_python(obj, registered<Source>::converters)
? obj : 0;
}
static void construct(PyObject* obj, rvalue_from_python_stage1_data* data)
{
void* storage = ((rvalue_from_python_storage<Target>*)data)->storage.bytes;
arg_from_python<Source> get_source(obj);
bool convertible = get_source.convertible();
BOOST_VERIFY(convertible);
new (storage) Source(get_source());
// record successful construction
data->convertible = storage;
}
};
}}} // namespace boost::python::converter
namespace eigenpy
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment