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

Merge pull request #251 from proyan/devel

[user-type] get class object for type exposed through boost python
parents 4492a1aa 13c6dea8
No related branches found
No related tags found
No related merge requests found
...@@ -289,6 +289,28 @@ namespace eigenpy ...@@ -289,6 +289,28 @@ namespace eigenpy
return true; return true;
} }
/// \brief Get the class object for a wrapped type that has been exposed
/// through Boost.Python.
template <typename T>
boost::python::object getInstanceClass()
{
// Query into the registry for type T.
namespace bp = boost::python;
bp::type_info type = bp::type_id<T>();
const bp::converter::registration* registration =
bp::converter::registry::query(type);
// If the class is not registered, return None.
if (!registration) {
//std::cerr<<"Class Not Registered. Returning Empty."<<std::endl;
return bp::object();
}
bp::handle<PyTypeObject> handle(bp::borrowed(registration->get_class_object()));
return bp::object(handle);
}
template<typename Scalar> template<typename Scalar>
int registerNewType(PyTypeObject * py_type_ptr = NULL) int registerNewType(PyTypeObject * py_type_ptr = NULL)
{ {
......
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