Go to the source code of this file.
Classes | |
struct | type_hash |
struct | type_equal_to |
struct | override_hash |
struct | internals |
Internal data structure used to track registered instances and types. More... | |
struct | type_info |
Additional type information which does not fit into the PyTypeObject. More... | |
struct | local_internals |
Macros | |
#define | PYBIND11_INTERNALS_VERSION 4 |
Tracks the internals and type_info ABI version independent of the main library version. More... | |
#define | PYBIND11_TLS_KEY_REF decltype(PyThread_create_key()) |
#define | PYBIND11_TLS_KEY_INIT(var) PYBIND11_TLS_KEY_REF var = 0; |
#define | PYBIND11_TLS_KEY_CREATE(var) (((var) = PyThread_create_key()) != -1) |
#define | PYBIND11_TLS_GET_VALUE(key) PyThread_get_key_value((key)) |
#define | PYBIND11_TLS_DELETE_VALUE(key) PyThread_delete_key_value(key) |
#define | PYBIND11_TLS_REPLACE_VALUE(key, value) ::pybind11::detail::tls_replace_value((key), (value)) |
#define | PYBIND11_TLS_FREE(key) (void) key |
#define | PYBIND11_BUILD_TYPE "" |
On MSVC, debug and release builds are not ABI-compatible! More... | |
#define | PYBIND11_COMPILER_TYPE "_unknown" |
Let's assume that different compilers are ABI-incompatible. More... | |
#define | PYBIND11_STDLIB "" |
Also standard libs. More... | |
#define | PYBIND11_BUILD_ABI "" |
On Linux/OSX, changes in GXX_ABI_VERSION indicate ABI incompatibility. More... | |
#define | PYBIND11_INTERNALS_KIND "_without_thread" |
#define | PYBIND11_INTERNALS_ID |
#define | PYBIND11_MODULE_LOCAL_ID |
Typedefs | |
using | ExceptionTranslator = void(*)(std::exception_ptr) |
template<typename value_type > | |
using | type_map = std::unordered_map< std::type_index, value_type, type_hash, type_equal_to > |
Functions | |
PyTypeObject * | make_static_property_type () |
A static_property is the same as a property but the __get__() and __set__() methods are modified to always use the object type instead of a concrete instance. More... | |
PyTypeObject * | make_default_metaclass () |
This metaclass is assigned by default to all pybind11 types and is required in order for static properties to function correctly. More... | |
PyObject * | make_object_base_type (PyTypeObject *metaclass) |
Create the type which can be used as a common base for all classes. More... | |
void | tls_replace_value (PYBIND11_TLS_KEY_REF key, void *value) |
bool | same_type (const std::type_info &lhs, const std::type_info &rhs) |
internals **& | get_internals_pp () |
Each module locally stores a pointer to the internals data. More... | |
template<class T > | |
bool | handle_nested_exception (const T &, std::exception_ptr &) |
bool | raise_err (PyObject *exc_type, const char *msg) |
void | translate_exception (std::exception_ptr p) |
void | translate_local_exception (std::exception_ptr p) |
PYBIND11_NOINLINE internals & | get_internals () |
Return a reference to the current internals data. More... | |
local_internals & | get_local_internals () |
Works like get_internals , but for things which are locally registered. More... | |
template<typename... Args> | |
const char * | c_str (Args &&...args) |
Constructs a std::string with the given arguments, stores it in internals , and returns its c_str() . More... | |
PYBIND11_NOINLINE void * | get_shared_data (const std::string &name) |
Returns a named pointer that is shared among all extension modules (using the same pybind11 version) running in the current interpreter. More... | |
PYBIND11_NOINLINE void * | set_shared_data (const std::string &name, void *data) |
Set the shared data that can be later recovered by get_shared_data() . More... | |
template<typename T > | |
T & | get_or_create_shared_data (const std::string &name) |
Returns a typed reference to a shared data entry (by using get_shared_data() ) if such entry exists. More... | |
#define PYBIND11_BUILD_ABI "" |
On Linux/OSX, changes in GXX_ABI_VERSION indicate ABI incompatibility.
Definition at line 268 of file internals.h.
#define PYBIND11_BUILD_TYPE "" |
On MSVC, debug and release builds are not ABI-compatible!
Definition at line 226 of file internals.h.
#define PYBIND11_COMPILER_TYPE "_unknown" |
Let's assume that different compilers are ABI-incompatible.
A user can manually set this string if they know their compiler is compatible.
Definition at line 248 of file internals.h.
#define PYBIND11_INTERNALS_ID |
Definition at line 280 of file internals.h.
#define PYBIND11_INTERNALS_KIND "_without_thread" |
Definition at line 276 of file internals.h.
#define PYBIND11_INTERNALS_VERSION 4 |
Tracks the internals
and type_info
ABI version independent of the main library version.
Some portions of the code use an ABI that is conditional depending on this version number. That allows ABI-breaking changes to be "pre-implemented". Once the default version number is incremented, the conditional logic that no longer applies can be removed. Additionally, users that need not maintain ABI compatibility can increase the version number in order to take advantage of any functionality/efficiency improvements that depend on the newer ABI.
WARNING: If you choose to manually increase the ABI version, note that pybind11 may not be tested as thoroughly with a non-default ABI version, and further ABI-incompatible changes may be made before the ABI is officially changed to the new version.
Definition at line 31 of file internals.h.
#define PYBIND11_MODULE_LOCAL_ID |
Definition at line 285 of file internals.h.
#define PYBIND11_STDLIB "" |
Also standard libs.
Definition at line 259 of file internals.h.
#define PYBIND11_TLS_DELETE_VALUE | ( | key | ) | PyThread_delete_key_value(key) |
Definition at line 93 of file internals.h.
#define PYBIND11_TLS_FREE | ( | key | ) | (void) key |
Definition at line 100 of file internals.h.
#define PYBIND11_TLS_GET_VALUE | ( | key | ) | PyThread_get_key_value((key)) |
Definition at line 84 of file internals.h.
#define PYBIND11_TLS_KEY_CREATE | ( | var | ) | (((var) = PyThread_create_key()) != -1) |
Definition at line 83 of file internals.h.
#define PYBIND11_TLS_KEY_INIT | ( | var | ) | PYBIND11_TLS_KEY_REF var = 0; |
Definition at line 82 of file internals.h.
#define PYBIND11_TLS_KEY_REF decltype(PyThread_create_key()) |
Definition at line 81 of file internals.h.
#define PYBIND11_TLS_REPLACE_VALUE | ( | key, | |
value | |||
) | ::pybind11::detail::tls_replace_value((key), (value)) |
Definition at line 94 of file internals.h.
using ExceptionTranslator = void (*)(std::exception_ptr) |
Definition at line 36 of file internals.h.
using type_map = std::unordered_map<std::type_index, value_type, type_hash, type_equal_to> |
Definition at line 137 of file internals.h.
const char * c_str | ( | Args &&... | args | ) |
Constructs a std::string with the given arguments, stores it in internals
, and returns its c_str()
.
Such strings objects have a long storage duration – the internal strings are only cleared when the program exits or after interpreter shutdown (when embedding), and so are suitable for c-style strings needed by Python internals (such as PyTypeObject's tp_name).
Definition at line 534 of file internals.h.
References get_internals(), and internals::static_strings.
Referenced by bind_map(), xpath_ast_node::eval_number(), xpath_ast_node::eval_string_concat(), cpp_function::initialize_generic(), make_new_python_type(), type_caster< CharT, enable_if_t< is_std_char_type< CharT >::value > >::operator CharT *(), pybind11_set_dict(), and TEST_SUBMODULE().
PYBIND11_NOINLINE internals & get_internals | ( | ) |
Return a reference to the current internals
data.
Definition at line 416 of file internals.h.
References get_internals_pp(), make_default_metaclass(), make_object_base_type(), make_static_property_type(), pybind11_fail(), PYBIND11_INTERNALS_ID, PYBIND11_STR_TYPE, PYBIND11_TLS_KEY_CREATE, PYBIND11_TLS_REPLACE_VALUE, internals::registered_exception_translators, translate_exception(), and translate_local_exception().
Referenced by add_patient(), all_type_info_get_cache(), all_type_info_populate(), c_str(), class_< type_, options >::class_(), clear_patients(), generic_type::def_property_static_impl(), deregister_instance_impl(), cpp_function::dispatcher(), find_registered_python_instance(), get_function_record_capsule_name(), get_global_type_info(), get_object_handle(), get_type_override(), enum_base::init(), generic_type::initialize(), make_new_python_type(), pybind11_meta_dealloc(), pybind11_meta_setattro(), pybind11_object_dealloc(), register_instance_impl(), and register_structured_dtype().
|
inline |
Each module locally stores a pointer to the internals
data.
The data itself is shared among modules with the same PYBIND11_INTERNALS_ID
.
Definition at line 292 of file internals.h.
Referenced by get_internals().
|
inline |
Works like get_internals
, but for things which are locally registered.
Definition at line 524 of file internals.h.
Referenced by class_< type_, options >::class_(), cpp_function::dispatcher(), get_local_type_info(), generic_type::initialize(), and pybind11_meta_dealloc().
T & get_or_create_shared_data | ( | const std::string & | name | ) |
Returns a typed reference to a shared data entry (by using get_shared_data()
) if such entry exists.
Otherwise, a new object of default-constructible type T
is added to the shared data under the given name and a reference to it is returned.
Definition at line 561 of file internals.h.
References internals::shared_data.
PYBIND11_NOINLINE void * get_shared_data | ( | const std::string & | name | ) |
Returns a named pointer that is shared among all extension modules (using the same pybind11 version) running in the current interpreter.
Names starting with underscores are reserved for internal usage. Returns nullptr
if no matching entry was found.
Definition at line 545 of file internals.h.
References internals::shared_data.
bool handle_nested_exception | ( | const T & | , |
std::exception_ptr & | |||
) |
Definition at line 324 of file internals.h.
Referenced by translate_exception().
|
inline |
This metaclass is assigned by default to all pybind11 types and is required in order for static properties to function correctly.
Users may override this using py::metaclass
. Return value: New reference.
Definition at line 243 of file class.h.
Referenced by get_internals().
|
inline |
Create the type which can be used as a common base for all classes.
This is needed in order to satisfy Python's requirements for multiple inheritance. Return value: New reference.
Definition at line 465 of file class.h.
Referenced by get_internals().
|
inline |
A static_property
is the same as a property
but the __get__()
and __set__()
methods are modified to always use the object type instead of a concrete instance.
Return value: New reference.
Definition at line 61 of file class.h.
Referenced by get_internals().
|
inline |
Definition at line 329 of file internals.h.
References raise_from().
Referenced by translate_exception().
|
inline |
Definition at line 114 of file internals.h.
Referenced by find_registered_python_instance(), type_caster< std::function< Return(Args...)> >::load(), type_caster_base< type >::src_and_type(), and type_caster_generic::try_load_foreign_module_local().
PYBIND11_NOINLINE void * set_shared_data | ( | const std::string & | name, |
void * | data | ||
) |
Set the shared data that can be later recovered by get_shared_data()
.
Definition at line 552 of file internals.h.
References data().
|
inline |
Definition at line 89 of file internals.h.
|
inline |
Definition at line 340 of file internals.h.
References handle_nested_exception(), raise_err(), error_already_set::restore(), and error_already_set::what().
Referenced by get_internals(), and handle_nested_exception().
|
inline |
Definition at line 400 of file internals.h.
References error_already_set::restore().
Referenced by get_internals().