The 'instance' type which needs to be standard layout (need to be able to use 'offsetof')
More...
#include <common.h>
The 'instance' type which needs to be standard layout (need to be able to use 'offsetof')
Definition at line 437 of file common.h.
◆ allocate_layout()
Initializes all of the above type/values/holders data (but not the instance values themselves)
Definition at line 363 of file cast.h.
◆ deallocate_layout()
Destroys/deallocates all of the above.
Definition at line 411 of file cast.h.
◆ get_value_and_holder()
Returns the value_and_holder wrapper for the given type (or the first, if find_type
omitted). Returns a default-constructed (with .inst = nullptr
) object on failure if throw_if_missing
is false.
Extracts C++ value and holder pointer references from an instance (which may contain multiple values/holders for python-side multiple inheritance) that match the given type. Throws an error if the given type (or ValueType, if omitted) is not a pybind11 base of the given instance. If find_type
is omitted (or explicitly specified as nullptr) the first value/holder are returned, regardless of type (and the resulting .type will be nullptr).
The returned object should be short-lived: in particular, it must not outlive the called-upon instance.
Definition at line 339 of file cast.h.
◆ @1
Storage for pointers and holder; see simple_layout, below, for a description.
◆ has_patients
bool instance::has_patients |
◆ nonsimple
◆ owned
If true, the pointer is owned which means we're free to manage it with a holder.
Definition at line 447 of file common.h.
◆ simple_holder_constructed
bool instance::simple_holder_constructed |
For simple layout, tracks whether the holder has been constructed.
Definition at line 473 of file common.h.
◆ simple_instance_registered
bool instance::simple_instance_registered |
For simple layout, tracks whether the instance is registered in registered_instances
Definition at line 475 of file common.h.
◆ simple_layout
bool instance::simple_layout |
An instance has two possible value/holder layouts.
Simple layout (when this flag is true), means the simple_value_holder
is set with a pointer and the holder object governing that pointer, i.e. [val1*][holder]. This layout is applied whenever there is no python-side multiple inheritance of bound C++ types and the type's holder will fit in the default space (which is large enough to hold either a std::unique_ptr or std::shared_ptr).
Non-simple layout applies when using custom holders that require more space than shared_ptr
(which is typically the size of two pointers), or when multiple inheritance is used on the python side. Non-simple layout allocates the required amount of memory to have multiple bound C++ classes as parents. Under this layout, nonsimple.values_and_holders
is set to a pointer to allocated space of the required space to hold a sequence of value pointers and holders followed status
, a set of bit flags (1 byte each), i.e. [val1*][holder1][val2*][holder2]...[bb...] where each [block] is rounded up to a multiple of sizeof(void *)
. nonsimple.status
is, for convenience, a pointer to the beginning of the [bb...] block (but not independently allocated).
Status bits indicate whether the associated holder is constructed (& status_holder_constructed) and whether the value pointer is registered (& status_instance_registered) in registered_instances
.
Definition at line 471 of file common.h.
◆ simple_value_holder
◆ status_holder_constructed
constexpr uint8_t instance::status_holder_constructed = 1 |
|
staticconstexpr |
Bit values for the non-simple status flags.
Definition at line 491 of file common.h.
◆ status_instance_registered
constexpr uint8_t instance::status_instance_registered = 2 |
|
staticconstexpr |
◆ weakrefs
PyObject* instance::weakrefs |
Weak references.
Definition at line 445 of file common.h.
The documentation for this struct was generated from the following files:
- /Users/matin/Downloads/testProjs/CppyABM/examples/Cppy/build/_deps/pybind11-src/include/pybind11/detail/common.h
- /Users/matin/Downloads/testProjs/CppyABM/examples/Cppy/build/_deps/pybind11-src/include/pybind11/cast.h