convenience function to create a pybind::handle<> to the python version of a C++ type

This commit is contained in:
Wenzel Jakob 2015-10-02 00:42:33 +02:00
parent 6918922332
commit 6a32620db3

View File

@ -404,5 +404,13 @@ inline handle get_object_handle(const void *ptr) {
return it->second; return it->second;
} }
inline handle get_type_handle(const std::type_info &tp) {
auto instances = get_internals().registered_types;
auto it = instances.find(&tp);
if (it == instances.end())
return handle();
return handle((PyObject *) it->second.type);
}
NAMESPACE_END(detail) NAMESPACE_END(detail)
NAMESPACE_END(pybind) NAMESPACE_END(pybind)