MCPcopy Create free account
hub / github.com/pybind/pybind11 / traverse_offset_bases

Function traverse_offset_bases

include/pybind11/detail/class.h:304–322  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

302/// correctly recognize an offset base class pointer. This calls a function with any offset base
303/// ptrs.
304inline 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
325inline void enable_try_inc_ref(PyObject *obj) {

Callers 2

register_instanceFunction · 0.85
deregister_instanceFunction · 0.85

Calls 2

fFunction · 0.85
ptrMethod · 0.80

Tested by

no test coverage detected