Classes | Macros | Typedefs | Functions | Variables
internals.h File Reference
#include "common.h"
#include "../pytypes.h"
#include <exception>
#include <mutex>
#include <thread>
Include dependency graph for internals.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  instance_map_shard
 
struct  internals
 
struct  local_internals
 
struct  override_hash
 
struct  local_internals::shared_loader_life_support_data
 
struct  type_equal_to
 
struct  type_hash
 
struct  type_info
 

Macros

#define PYBIND11_BUILD_ABI   ""
 
#define PYBIND11_BUILD_TYPE   ""
 On MSVC, debug and release builds are not ABI-compatible! More...
 
#define PYBIND11_COMPILER_TYPE   "_unknown"
 
#define PYBIND11_INTERNALS_ID
 
#define PYBIND11_INTERNALS_KIND   ""
 
#define PYBIND11_INTERNALS_VERSION   4
 
#define PYBIND11_LOCK_INTERNALS(internals)
 
#define PYBIND11_MODULE_LOCAL_ID
 
#define PYBIND11_STDLIB   ""
 Also standard libs. More...
 
#define PYBIND11_TLS_DELETE_VALUE(key)   PyThread_tss_set((key), nullptr)
 
#define PYBIND11_TLS_FREE(key)   PyThread_tss_free(key)
 
#define PYBIND11_TLS_GET_VALUE(key)   PyThread_tss_get((key))
 
#define PYBIND11_TLS_KEY_CREATE(var)   (((var) = PyThread_tss_alloc()) != nullptr && (PyThread_tss_create((var)) == 0))
 
#define PYBIND11_TLS_KEY_INIT(var)   Py_tss_t *var = nullptr;
 
#define PYBIND11_TLS_KEY_REF   Py_tss_t *
 
#define PYBIND11_TLS_REPLACE_VALUE(key, value)   PyThread_tss_set((key), (value))
 

Typedefs

using ExceptionTranslator = void(*)(std::exception_ptr)
 
using instance_map = std::unordered_multimap< const void *, instance * >
 
template<typename value_type >
using type_map = std::unordered_map< std::type_index, value_type, type_hash, type_equal_to >
 

Functions

template<typename... Args>
const char * c_str (Args &&...args)
 
const char * get_function_record_capsule_name ()
 
PYBIND11_NOINLINE internalsget_internals ()
 Return a reference to the current internals data. More...
 
object get_internals_obj_from_state_dict (handle state_dict)
 
internals **& get_internals_pp ()
 
internals ** get_internals_pp_from_capsule (handle obj)
 
local_internalsget_local_internals ()
 Works like get_internals, but for things which are locally registered. More...
 
template<typename T >
Tget_or_create_shared_data (const std::string &name)
 
object get_python_state_dict ()
 
PYBIND11_NOINLINE void * get_shared_data (const std::string &name)
 
template<class T , enable_if_t< std::is_same< std::nested_exception, remove_cvref_t< T >>::value, int > = 0>
bool handle_nested_exception (const T &exc, const std::exception_ptr &p)
 
bool is_function_record_capsule (const capsule &cap)
 
PyTypeObject * make_default_metaclass ()
 
PyObject * make_object_base_type (PyTypeObject *metaclass)
 
PyTypeObject * make_static_property_type ()
 
std::uint64_t mix64 (std::uint64_t z)
 
size_t num_registered_instances ()
 
bool raise_err (PyObject *exc_type, const char *msg)
 
uint64_t round_up_to_next_pow2 (uint64_t x)
 
bool same_type (const std::type_info &lhs, const std::type_info &rhs)
 
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...
 
void translate_exception (std::exception_ptr)
 
void translate_local_exception (std::exception_ptr p)
 
template<typename F >
auto with_instance_map (const void *ptr, const F &cb) -> decltype(cb(std::declval< instance_map & >()))
 
template<typename F >
auto with_internals (const F &cb) -> decltype(cb(get_internals()))
 

Variables

constexpr const char * internals_function_record_capsule_name = "pybind11_function_record_capsule"
 

Macro Definition Documentation

◆ PYBIND11_BUILD_ABI

#define PYBIND11_BUILD_ABI   ""

On Linux/OSX, changes in GXX_ABI_VERSION indicate ABI incompatibility. On MSVC, changes in _MSC_VER may indicate ABI incompatibility (#2898).

Definition at line 301 of file internals.h.

◆ PYBIND11_BUILD_TYPE

#define PYBIND11_BUILD_TYPE   ""

On MSVC, debug and release builds are not ABI-compatible!

Definition at line 256 of file internals.h.

◆ PYBIND11_COMPILER_TYPE

#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 278 of file internals.h.

◆ PYBIND11_INTERNALS_ID

#define PYBIND11_INTERNALS_ID
Value:
"__pybind11_internals_v" PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION) \
PYBIND11_INTERNALS_KIND PYBIND11_COMPILER_TYPE PYBIND11_STDLIB \
PYBIND11_BUILD_ABI PYBIND11_BUILD_TYPE "__"

Definition at line 309 of file internals.h.

◆ PYBIND11_INTERNALS_KIND

#define PYBIND11_INTERNALS_KIND   ""

Definition at line 306 of file internals.h.

◆ PYBIND11_INTERNALS_VERSION

#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 44 of file internals.h.

◆ PYBIND11_LOCK_INTERNALS

#define PYBIND11_LOCK_INTERNALS (   internals)

Definition at line 619 of file internals.h.

◆ PYBIND11_MODULE_LOCAL_ID

#define PYBIND11_MODULE_LOCAL_ID
Value:
"__pybind11_module_local_v" PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION) \
PYBIND11_INTERNALS_KIND PYBIND11_COMPILER_TYPE PYBIND11_STDLIB \
PYBIND11_BUILD_ABI PYBIND11_BUILD_TYPE "__"

Definition at line 314 of file internals.h.

◆ PYBIND11_STDLIB

#define PYBIND11_STDLIB   ""

Also standard libs.

Definition at line 289 of file internals.h.

◆ PYBIND11_TLS_DELETE_VALUE

#define PYBIND11_TLS_DELETE_VALUE (   key)    PyThread_tss_set((key), nullptr)

Definition at line 100 of file internals.h.

◆ PYBIND11_TLS_FREE

#define PYBIND11_TLS_FREE (   key)    PyThread_tss_free(key)

Definition at line 101 of file internals.h.

◆ PYBIND11_TLS_GET_VALUE

#define PYBIND11_TLS_GET_VALUE (   key)    PyThread_tss_get((key))

Definition at line 98 of file internals.h.

◆ PYBIND11_TLS_KEY_CREATE

#define PYBIND11_TLS_KEY_CREATE (   var)    (((var) = PyThread_tss_alloc()) != nullptr && (PyThread_tss_create((var)) == 0))

Definition at line 96 of file internals.h.

◆ PYBIND11_TLS_KEY_INIT

#define PYBIND11_TLS_KEY_INIT (   var)    Py_tss_t *var = nullptr;

Definition at line 95 of file internals.h.

◆ PYBIND11_TLS_KEY_REF

#define PYBIND11_TLS_KEY_REF   Py_tss_t *

Definition at line 94 of file internals.h.

◆ PYBIND11_TLS_REPLACE_VALUE

#define PYBIND11_TLS_REPLACE_VALUE (   key,
  value 
)    PyThread_tss_set((key), (value))

Definition at line 99 of file internals.h.

Typedef Documentation

◆ ExceptionTranslator

using ExceptionTranslator = void (*)(std::exception_ptr)

Definition at line 54 of file internals.h.

◆ instance_map

using instance_map = std::unordered_multimap<const void *, instance *>

Definition at line 149 of file internals.h.

◆ type_map

template<typename value_type >
using type_map = std::unordered_map<std::type_index, value_type, type_hash, type_equal_to>

Definition at line 139 of file internals.h.

Function Documentation

◆ c_str()

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(). 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 684 of file internals.h.

◆ get_function_record_capsule_name()

const char* get_function_record_capsule_name ( )
inline

Definition at line 694 of file internals.h.

◆ get_internals()

PYBIND11_NOINLINE internals& get_internals ( )

Return a reference to the current internals data.

Definition at line 483 of file internals.h.

◆ get_internals_obj_from_state_dict()

object get_internals_obj_from_state_dict ( handle  state_dict)
inline

Definition at line 454 of file internals.h.

◆ get_internals_pp()

internals**& get_internals_pp ( )
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 321 of file internals.h.

◆ get_internals_pp_from_capsule()

internals** get_internals_pp_from_capsule ( handle  obj)
inline

Definition at line 459 of file internals.h.

◆ get_local_internals()

local_internals& get_local_internals ( )
inline

Works like get_internals, but for things which are locally registered.

Definition at line 606 of file internals.h.

◆ get_or_create_shared_data()

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. 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 737 of file internals.h.

◆ get_python_state_dict()

object get_python_state_dict ( )
inline

Definition at line 433 of file internals.h.

◆ get_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 718 of file internals.h.

◆ handle_nested_exception()

template<class T , enable_if_t< std::is_same< std::nested_exception, remove_cvref_t< T >>::value, int > = 0>
bool handle_nested_exception ( const T exc,
const std::exception_ptr &  p 
)

Definition at line 331 of file internals.h.

◆ is_function_record_capsule()

bool is_function_record_capsule ( const capsule cap)
inline

Definition at line 708 of file internals.h.

◆ make_default_metaclass()

PyTypeObject* make_default_metaclass ( )
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 249 of file class.h.

◆ make_object_base_type()

PyObject* make_object_base_type ( PyTypeObject *  metaclass)
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 489 of file class.h.

◆ make_static_property_type()

PyTypeObject* make_static_property_type ( )
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 64 of file class.h.

◆ mix64()

std::uint64_t mix64 ( std::uint64_t  z)
inline

Definition at line 629 of file internals.h.

◆ num_registered_instances()

size_t num_registered_instances ( )
inline

Definition at line 664 of file internals.h.

◆ raise_err()

bool raise_err ( PyObject *  exc_type,
const char *  msg 
)
inline

Definition at line 349 of file internals.h.

◆ round_up_to_next_pow2()

uint64_t round_up_to_next_pow2 ( uint64_t  x)
inline

Definition at line 468 of file internals.h.

◆ same_type()

bool same_type ( const std::type_info &  lhs,
const std::type_info &  rhs 
)
inline

Definition at line 116 of file internals.h.

◆ set_shared_data()

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 726 of file internals.h.

◆ translate_exception()

void translate_exception ( std::exception_ptr  p)
inline

Definition at line 358 of file internals.h.

◆ translate_local_exception()

void translate_local_exception ( std::exception_ptr  p)
inline

Definition at line 418 of file internals.h.

◆ with_instance_map()

template<typename F >
auto with_instance_map ( const void *  ptr,
const F &  cb 
) -> decltype(cb(std::declval<instance_map &>()))
inline

Definition at line 639 of file internals.h.

◆ with_internals()

template<typename F >
auto with_internals ( const F &  cb) -> decltype(cb(get_internals()))
inline

Definition at line 623 of file internals.h.

Variable Documentation

◆ internals_function_record_capsule_name

constexpr const char* internals_function_record_capsule_name = "pybind11_function_record_capsule"
constexpr

Definition at line 58 of file internals.h.

PYBIND11_BUILD_TYPE
#define PYBIND11_BUILD_TYPE
On MSVC, debug and release builds are not ABI-compatible!
Definition: internals.h:256
PYBIND11_COMPILER_TYPE
#define PYBIND11_COMPILER_TYPE
Definition: internals.h:278
PYBIND11_TOSTRING
#define PYBIND11_TOSTRING(x)
Definition: wrap/pybind11/include/pybind11/detail/common.h:386
PYBIND11_INTERNALS_VERSION
#define PYBIND11_INTERNALS_VERSION
Definition: internals.h:44


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:09:47