Commit fa1bfb2e by Wenzel Jakob

do a fallback search over types to handle incompatible std::type_info* across…

do a fallback search over types to handle incompatible std::type_info* across module boundaries (fixes issue #4)
parent 3419ee90
......@@ -101,10 +101,21 @@ public:
class type_caster_custom {
public:
PYBIND11_NOINLINE type_caster_custom(const std::type_info *type_info) {
auto const& registered_types = get_internals().registered_types;
auto & registered_types = get_internals().registered_types;
auto it = registered_types.find(type_info);
if (it != registered_types.end())
if (it != registered_types.end()) {
typeinfo = &it->second;
} else {
/* Unknown type?! Since std::type_info* often varies across
module boundaries, the following does an explicit check */
for (auto const &type : registered_types) {
if (strcmp(type.first->name(), type_info->name()) == 0) {
registered_types[type_info] = type.second;
typeinfo = &type.second;
break;
}
}
}
}
PYBIND11_NOINLINE bool load(PyObject *src, bool convert) {
......
......@@ -135,7 +135,7 @@ template <typename type, typename holder_type = std::unique_ptr<type>> struct in
holder_type holder;
};
/// Additional type information which does not fit into the PyTypeObjet
/// Additional type information which does not fit into the PyTypeObject
struct type_info {
PyTypeObject *type;
size_t type_size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment