mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 13:15:12 +00:00
One way to deal with the order dependency issue. This is not the best way, more like a proof of concept.
This commit is contained in:
parent
7f8b2081ff
commit
eb09c6c1b9
@ -713,15 +713,30 @@ public:
|
|||||||
// if we can find an exact match (or, for a simple C++ type, an inherited match); if
|
// if we can find an exact match (or, for a simple C++ type, an inherited match); if
|
||||||
// so, we can safely reinterpret_cast to the relevant pointer.
|
// so, we can safely reinterpret_cast to the relevant pointer.
|
||||||
if (bases.size() > 1) {
|
if (bases.size() > 1) {
|
||||||
|
type_info *best_base = nullptr;
|
||||||
|
if (no_cpp_mi) {
|
||||||
for (auto *base : bases) {
|
for (auto *base : bases) {
|
||||||
if (no_cpp_mi ? PyType_IsSubtype(base->type, typeinfo->type)
|
if (PyType_IsSubtype(base->type, typeinfo->type)) {
|
||||||
: base->type == typeinfo->type) {
|
if (best_base == nullptr
|
||||||
this_.load_value(
|
|| PyType_IsSubtype(base->type, best_base->type)) {
|
||||||
reinterpret_cast<instance *>(src.ptr())->get_value_and_holder(base));
|
best_base = base;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for (auto *base : bases) {
|
||||||
|
if (base->type == typeinfo->type) {
|
||||||
|
best_base = base;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (best_base != nullptr) {
|
||||||
|
this_.load_value(
|
||||||
|
reinterpret_cast<instance *>(src.ptr())->get_value_and_holder(best_base));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Case 2c: C++ multiple inheritance is involved and we couldn't find an exact type
|
// Case 2c: C++ multiple inheritance is involved and we couldn't find an exact type
|
||||||
// match in the registered bases, above, so try implicit casting (needed for proper C++
|
// match in the registered bases, above, so try implicit casting (needed for proper C++
|
||||||
|
Loading…
Reference in New Issue
Block a user