Skip to content
Snippets Groups Projects
Unverified Commit 3917a9cf authored by Justin Carpentier's avatar Justin Carpentier Committed by GitHub
Browse files

Merge pull request #61 from jcarpent/devel

Registration
parents 4f729893 2bdf6b82
No related branches found
No related tags found
No related merge requests found
Subproject commit 61e5574a0615706aab06986f6aecf665ddc31141 Subproject commit 40207e1a74854fa99a42304837f826f1692d4440
...@@ -103,8 +103,8 @@ namespace eigenpy ...@@ -103,8 +103,8 @@ namespace eigenpy
static void expose() static void expose()
{ {
if(check_registration<AngleAxis>()) return; if(register_symbolic_link_to_registered_type<AngleAxis>()) return;
bp::class_<AngleAxis>("AngleAxis", bp::class_<AngleAxis>("AngleAxis",
"AngleAxis representation of rotations.\n\n", "AngleAxis representation of rotations.\n\n",
bp::no_init) bp::no_init)
......
...@@ -203,8 +203,8 @@ namespace eigenpy ...@@ -203,8 +203,8 @@ namespace eigenpy
static void expose() static void expose()
{ {
if(check_registration<Quaternion>()) return; if(register_symbolic_link_to_registered_type<Quaternion>()) return;
bp::class_<Quaternion>("Quaternion", bp::class_<Quaternion>("Quaternion",
"Quaternion representing rotation.\n\n" "Quaternion representing rotation.\n\n"
"Supported operations " "Supported operations "
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#define __eigenpy_registration_hpp__ #define __eigenpy_registration_hpp__
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/python/scope.hpp>
namespace eigenpy namespace eigenpy
{ {
...@@ -29,6 +30,30 @@ namespace eigenpy ...@@ -29,6 +30,30 @@ namespace eigenpy
return true; 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__ #endif // ifndef __eigenpy_registration_hpp__
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment