Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake
4 changes: 2 additions & 2 deletions include/eigenpy/angle-axis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions include/eigenpy/quaternion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
25 changes: 25 additions & 0 deletions include/eigenpy/registration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define __eigenpy_registration_hpp__

#include <boost/python.hpp>
#include <boost/python/scope.hpp>

namespace eigenpy
{
Expand All @@ -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__