diff --git a/cmake b/cmake index 61e5574a0615706aab06986f6aecf665ddc31141..40207e1a74854fa99a42304837f826f1692d4440 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 61e5574a0615706aab06986f6aecf665ddc31141 +Subproject commit 40207e1a74854fa99a42304837f826f1692d4440 diff --git a/include/eigenpy/angle-axis.hpp b/include/eigenpy/angle-axis.hpp index f97ea8d3fa852481abfdb16de77a74f93120bfce..b1371237bd9407e63480f4ebbb9e81481c64a6ae 100644 --- a/include/eigenpy/angle-axis.hpp +++ b/include/eigenpy/angle-axis.hpp @@ -103,8 +103,8 @@ namespace eigenpy static void expose() { - if(check_registration<AngleAxis>()) return; - + if(register_symbolic_link_to_registered_type<AngleAxis>()) return; + bp::class_<AngleAxis>("AngleAxis", "AngleAxis representation of rotations.\n\n", bp::no_init) diff --git a/include/eigenpy/quaternion.hpp b/include/eigenpy/quaternion.hpp index 96055338e2123e56860d056f7c43a6dc475b0989..ed289d0e43882c9795a09a5c9606a17b64afdc0d 100644 --- a/include/eigenpy/quaternion.hpp +++ b/include/eigenpy/quaternion.hpp @@ -203,8 +203,8 @@ namespace eigenpy static void expose() { - if(check_registration<Quaternion>()) return; - + if(register_symbolic_link_to_registered_type<Quaternion>()) return; + bp::class_<Quaternion>("Quaternion", "Quaternion representing rotation.\n\n" "Supported operations " diff --git a/include/eigenpy/registration.hpp b/include/eigenpy/registration.hpp index 945742aa68820f3e51065a0191daeffd6226b681..b9e339ed51eb6fd750f2d88fefa1cae9a5c6facc 100644 --- a/include/eigenpy/registration.hpp +++ b/include/eigenpy/registration.hpp @@ -7,6 +7,7 @@ #define __eigenpy_registration_hpp__ #include <boost/python.hpp> +#include <boost/python/scope.hpp> namespace eigenpy { @@ -29,6 +30,30 @@ namespace eigenpy return true; } + + /// + /// \brief Symlink to the current scope the already registered class T. + /// + ///Â \returns true if the type T is effectively symlinked. + /// + /// \tparam T The type to symlink. + /// + template<typename T> + inline bool register_symbolic_link_to_registered_type() + { + namespace bp = boost::python; + + if(eigenpy::check_registration<T>()) + { + const bp::type_info info = bp::type_id<T>(); + const bp::converter::registration* reg = bp::converter::registry::query(info); + bp::handle<> class_obj(reg->get_class_object()); + bp::scope().attr(reg->get_class_object()->tp_name) = bp::object(class_obj); + return true; + } + + return false; + } } #endif // ifndef __eigenpy_registration_hpp__