For multiple inheritance types we need to recursively register/deregister base pointers for any base classes with pointers that are difference from the instance value pointer so that we can correctly recognize an offset base class pointer. This calls a function with any offset base ptrs.
| 302 | /// correctly recognize an offset base class pointer. This calls a function with any offset base |
| 303 | /// ptrs. |
| 304 | inline void traverse_offset_bases(void *valueptr, |
| 305 | const detail::type_info *tinfo, |
| 306 | instance *self, |
| 307 | bool (*f)(void * /*parentptr*/, instance * /*self*/)) { |
| 308 | for (handle h : reinterpret_borrow<tuple>(tinfo->type->tp_bases)) { |
| 309 | if (auto *parent_tinfo = get_type_info(reinterpret_cast<PyTypeObject *>(h.ptr()))) { |
| 310 | for (auto &c : parent_tinfo->implicit_casts) { |
| 311 | if (c.first == tinfo->cpptype) { |
| 312 | auto *parentptr = c.second(valueptr); |
| 313 | if (parentptr != valueptr) { |
| 314 | f(parentptr, self); |
| 315 | } |
| 316 | traverse_offset_bases(parentptr, parent_tinfo, self, f); |
| 317 | break; |
| 318 | } |
| 319 | } |
| 320 | } |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | #ifdef Py_GIL_DISABLED |
| 325 | inline void enable_try_inc_ref(PyObject *obj) { |
no test coverage detected