#include "../pytypes.h"
#include "common.h"
#include "descr.h"
#include "internals.h"
#include "typeid.h"
#include <cstdint>
#include <iterator>
#include <new>
#include <string>
#include <type_traits>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <utility>
#include <vector>
Go to the source code of this file.
Typedefs | |
template<typename T > | |
using | cast_op_type = conditional_t< std::is_pointer< remove_reference_t< T > >::value, typename std::add_pointer< intrinsic_t< T > >::type, typename std::add_lvalue_reference< intrinsic_t< T > >::type > |
template<typename T > | |
using | movable_cast_op_type = conditional_t< std::is_pointer< typename std::remove_reference< T >::type >::value, typename std::add_pointer< intrinsic_t< T > >::type, conditional_t< std::is_rvalue_reference< T >::value, typename std::add_rvalue_reference< intrinsic_t< T > >::type, typename std::add_lvalue_reference< intrinsic_t< T > >::type > > |
Functions | |
const std::vector< detail::type_info * > & | all_type_info (PyTypeObject *type) |
void | all_type_info_add_base_most_derived_first (std::vector< type_info * > &bases, type_info *addl_base) |
std::pair< decltype(internals::registered_types_py)::iterator, bool > | all_type_info_get_cache (PyTypeObject *type) |
PYBIND11_NOINLINE void | all_type_info_populate (PyTypeObject *t, std::vector< type_info * > &bases) |
PYBIND11_NOINLINE handle | find_registered_python_instance (void *src, const detail::type_info *tinfo) |
detail::type_info * | get_global_type_info (const std::type_index &tp) |
detail::type_info * | get_local_type_info (const std::type_index &tp) |
PYBIND11_NOINLINE handle | get_object_handle (const void *ptr, const detail::type_info *type) |
PyThreadState * | get_thread_state_unchecked () |
PYBIND11_NOINLINE handle | get_type_handle (const std::type_info &tp, bool throw_if_missing) |
PYBIND11_NOINLINE detail::type_info * | get_type_info (const std::type_index &tp, bool throw_if_missing=false) |
PYBIND11_NOINLINE detail::type_info * | get_type_info (PyTypeObject *type) |
PYBIND11_NOINLINE bool | isinstance_generic (handle obj, const std::type_info &tp) |
void | keep_alive_impl (handle nurse, handle patient) |
PyObject * | make_new_instance (PyTypeObject *type) |
std::string | quote_cpp_type_name (const std::string &cpp_type_name) |
PYBIND11_NOINLINE std::string | type_info_description (const std::type_info &ti) |
using cast_op_type = conditional_t<std::is_pointer<remove_reference_t<T> >::value, typename std::add_pointer<intrinsic_t<T> >::type, typename std::add_lvalue_reference<intrinsic_t<T> >::type> |
Determine suitable casting operator for pointer-or-lvalue-casting type casters. The type caster needs to provide operator T*()
and operator T&()
operators.
If the type supports moving the value away via an operator T&&() &&
method, it should use movable_cast_op_type
instead.
Definition at line 841 of file type_caster_base.h.
using movable_cast_op_type = conditional_t<std::is_pointer<typename std::remove_reference<T>::type>::value, typename std::add_pointer<intrinsic_t<T> >::type, conditional_t<std::is_rvalue_reference<T>::value, typename std::add_rvalue_reference<intrinsic_t<T> >::type, typename std::add_lvalue_reference<intrinsic_t<T> >::type> > |
Determine suitable casting operator for a type caster with a movable value. Such a type caster needs to provide operator T*()
, operator T&()
, and operator T&&() &&
. The latter will be called in appropriate contexts where the value can be moved rather than copied.
These operator are automatically provided when using the PYBIND11_TYPE_CASTER macro.
Definition at line 856 of file type_caster_base.h.
|
inline |
Extracts vector of type_info pointers of pybind-registered roots of the given Python type. Will be just 1 pybind type for the Python type of a pybind-registered class, or for any Python-side derived class that uses single inheritance. Will contain as many types as required for a Python class that uses multiple inheritance to inherit (directly or indirectly) from multiple pybind-registered classes. Will be empty if neither the type nor any base classes are pybind-registered.
The value is cached for the lifetime of the Python type.
Definition at line 173 of file type_caster_base.h.
|
inline |
Definition at line 96 of file type_caster_base.h.
|
inline |
Definition at line 2367 of file pybind11.h.
PYBIND11_NOINLINE void all_type_info_populate | ( | PyTypeObject * | t, |
std::vector< type_info * > & | bases | ||
) |
Definition at line 109 of file type_caster_base.h.
PYBIND11_NOINLINE handle find_registered_python_instance | ( | void * | src, |
const detail::type_info * | tinfo | ||
) |
Definition at line 247 of file type_caster_base.h.
|
inline |
Definition at line 209 of file type_caster_base.h.
|
inline |
Definition at line 200 of file type_caster_base.h.
PYBIND11_NOINLINE handle get_object_handle | ( | const void * | ptr, |
const detail::type_info * | type | ||
) |
Definition at line 503 of file type_caster_base.h.
|
inline |
Definition at line 517 of file type_caster_base.h.
PYBIND11_NOINLINE handle get_type_handle | ( | const std::type_info & | tp, |
bool | throw_if_missing | ||
) |
Definition at line 241 of file type_caster_base.h.
PYBIND11_NOINLINE detail::type_info* get_type_info | ( | const std::type_index & | tp, |
bool | throw_if_missing = false |
||
) |
Return the type info for a given C++ type; on lookup failure can either throw or return nullptr.
Definition at line 223 of file type_caster_base.h.
PYBIND11_NOINLINE detail::type_info* get_type_info | ( | PyTypeObject * | type | ) |
Gets a single pybind11 type info for a python type. Returns nullptr if neither the type nor any ancestors are pybind11-registered. Throws an exception if there are multiple bases–use all_type_info
instead if you want to support multiple bases.
Definition at line 188 of file type_caster_base.h.
PYBIND11_NOINLINE bool isinstance_generic | ( | handle | obj, |
const std::type_info & | tp | ||
) |
Definition at line 495 of file type_caster_base.h.
Definition at line 2318 of file pybind11.h.
|
inline |
Instance creation function for all pybind11 types. It allocates the internal instance layout for holding C++ objects and holders. Allocation is done lazily (the first time the instance is cast to a reference or pointer), and initialization is done by an __init__
function.
|
inline |
Definition at line 1200 of file type_caster_base.h.
PYBIND11_NOINLINE std::string type_info_description | ( | const std::type_info & | ti | ) |
Definition at line 1204 of file type_caster_base.h.