mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 13:15:12 +00:00
do a fallback search over types to handle incompatible std::type_info* across module boundaries (fixes issue #4)
This commit is contained in:
parent
3419ee909f
commit
fa1bfb2ec7
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user