Wraps an arbitrary C++ function/method/lambda function/.. into a callable Python object. More...
#include </builds/ipbus/ipbus-software/uhal/python/pybind11-python2/include/pybind11/pybind11.h>
Classes | |
struct | InitializingFunctionRecordDeleter |
class | strdup_guard |
Public Member Functions | |
cpp_function ()=default | |
cpp_function (std::nullptr_t) | |
template<typename Return , typename... Args, typename... Extra> | |
cpp_function (Return(*f)(Args...), const Extra &...extra) | |
Construct a cpp_function from a vanilla function pointer. More... | |
template<typename Func , typename... Extra, typename = detail::enable_if_t<detail::is_lambda<Func>::value>> | |
cpp_function (Func &&f, const Extra &...extra) | |
Construct a cpp_function from a lambda function (possibly with internal state) More... | |
template<typename Return , typename Class , typename... Arg, typename... Extra> | |
cpp_function (Return(Class::*f)(Arg...), const Extra &...extra) | |
Construct a cpp_function from a class method (non-const, no ref-qualifier) More... | |
template<typename Return , typename Class , typename... Arg, typename... Extra> | |
cpp_function (Return(Class::*f)(Arg...) &, const Extra &...extra) | |
Construct a cpp_function from a class method (non-const, lvalue ref-qualifier) A copy of the overload for non-const functions without explicit ref-qualifier but with an added & . More... | |
template<typename Return , typename Class , typename... Arg, typename... Extra> | |
cpp_function (Return(Class::*f)(Arg...) const, const Extra &...extra) | |
Construct a cpp_function from a class method (const, no ref-qualifier) More... | |
template<typename Return , typename Class , typename... Arg, typename... Extra> | |
cpp_function (Return(Class::*f)(Arg...) const &, const Extra &...extra) | |
Construct a cpp_function from a class method (const, lvalue ref-qualifier) A copy of the overload for const functions without explicit ref-qualifier but with an added & . More... | |
object | name () const |
Return the function name. More... | |
cpp_function ()=default | |
cpp_function (std::nullptr_t) | |
template<typename Return , typename... Args, typename... Extra> | |
cpp_function (Return(*f)(Args...), const Extra &...extra) | |
Construct a cpp_function from a vanilla function pointer. More... | |
template<typename Func , typename... Extra, typename = detail::enable_if_t<detail::is_lambda<Func>::value>> | |
cpp_function (Func &&f, const Extra &...extra) | |
Construct a cpp_function from a lambda function (possibly with internal state) More... | |
template<typename Return , typename Class , typename... Arg, typename... Extra> | |
cpp_function (Return(Class::*f)(Arg...), const Extra &...extra) | |
Construct a cpp_function from a class method (non-const, no ref-qualifier) More... | |
template<typename Return , typename Class , typename... Arg, typename... Extra> | |
cpp_function (Return(Class::*f)(Arg...) &, const Extra &...extra) | |
Construct a cpp_function from a class method (non-const, lvalue ref-qualifier) A copy of the overload for non-const functions without explicit ref-qualifier but with an added & . More... | |
template<typename Return , typename Class , typename... Arg, typename... Extra> | |
cpp_function (Return(Class::*f)(Arg...) const, const Extra &...extra) | |
Construct a cpp_function from a class method (const, no ref-qualifier) More... | |
template<typename Return , typename Class , typename... Arg, typename... Extra> | |
cpp_function (Return(Class::*f)(Arg...) const &, const Extra &...extra) | |
Construct a cpp_function from a class method (const, lvalue ref-qualifier) A copy of the overload for const functions without explicit ref-qualifier but with an added & . More... | |
object | name () const |
Return the function name. More... | |
![]() | |
handle | cpp_function () const |
bool | is_cpp_function () const |
handle | cpp_function () const |
bool | is_cpp_function () const |
![]() | |
object ()=default | |
PYBIND11_DEPRECATED ("Use reinterpret_borrow<object>() or reinterpret_steal<object>()") object(handle h | |
object (const object &o) | |
Copy constructor; always increases the reference count. More... | |
object (object &&other) noexcept | |
Move constructor; steals the object from other and preserves its reference count. More... | |
~object () | |
Destructor; automatically calls handle::dec_ref() More... | |
handle | release () |
\rst Resets the internal pointer to nullptr without decreasing the object's reference count. More... | |
object & | operator= (const object &other) |
object & | operator= (object &&other) noexcept |
template<typename T > | |
T | cast () const & |
template<typename T > | |
T | cast () && |
object (handle h, borrowed_t) | |
object (handle h, stolen_t) | |
object ()=default | |
PYBIND11_DEPRECATED ("Use reinterpret_borrow<object>() or reinterpret_steal<object>()") object(handle h | |
object (const object &o) | |
Copy constructor; always increases the reference count. More... | |
object (object &&other) noexcept | |
Move constructor; steals the object from other and preserves its reference count. More... | |
~object () | |
Destructor; automatically calls handle::dec_ref() More... | |
handle | release () |
\rst Resets the internal pointer to nullptr without decreasing the object's reference count. More... | |
object & | operator= (const object &other) |
object & | operator= (object &&other) noexcept |
template<typename T > | |
T | cast () const & |
template<typename T > | |
T | cast () && |
object (handle h, borrowed_t) | |
object (handle h, stolen_t) | |
template<typename T > | |
T | cast () const & |
template<typename T > | |
T | cast () && |
template<> | |
void | cast () const & |
template<> | |
void | cast () && |
![]() | |
handle ()=default | |
The default constructor creates a handle with a nullptr -valued pointer. More... | |
handle (PyObject *ptr) | |
Creates a handle from the given raw Python object pointer. More... | |
PyObject * | ptr () const |
Return the underlying PyObject * pointer. More... | |
PyObject *& | ptr () |
const handle & | inc_ref () const & |
\rst Manually increase the reference count of the Python object. More... | |
const handle & | dec_ref () const & |
\rst Manually decrease the reference count of the Python object. More... | |
template<typename T > | |
T | cast () const |
\rst Attempt to cast the Python object into the given C++ type. More... | |
operator bool () const | |
Return true when the handle wraps a valid Python object. More... | |
bool | operator== (const handle &h) const |
\rst Deprecated: Check that the underlying pointers are the same. More... | |
bool | operator!= (const handle &h) const |
bool | check () const |
handle ()=default | |
The default constructor creates a handle with a nullptr -valued pointer. More... | |
template<typename T , detail::enable_if_t< detail::is_pyobj_ptr_or_nullptr_t< T >::value, int > = 0> | |
handle (T ptr) | |
Enable implicit conversion from PyObject * and nullptr . More... | |
template<typename T , detail::enable_if_t< detail::all_of< detail::none_of< std::is_base_of< handle, T >, detail::is_pyobj_ptr_or_nullptr_t< T > >, std::is_convertible< T, PyObject * > >::value, int > = 0> | |
handle (T &obj) | |
Enable implicit conversion through T::operator PyObject *() . More... | |
PyObject * | ptr () const |
Return the underlying PyObject * pointer. More... | |
PyObject *& | ptr () |
const handle & | inc_ref () const & |
\rst Manually increase the reference count of the Python object. More... | |
const handle & | dec_ref () const & |
\rst Manually decrease the reference count of the Python object. More... | |
template<typename T > | |
T | cast () const |
\rst Attempt to cast the Python object into the given C++ type. More... | |
operator bool () const | |
Return true when the handle wraps a valid Python object. More... | |
bool | operator== (const handle &h) const |
\rst Deprecated: Check that the underlying pointers are the same. More... | |
bool | operator!= (const handle &h) const |
bool | check () const |
template<> | |
void | cast () const |
Protected Types | |
using | unique_function_record = std::unique_ptr< detail::function_record, InitializingFunctionRecordDeleter > |
using | unique_function_record = std::unique_ptr< detail::function_record, InitializingFunctionRecordDeleter > |
Protected Member Functions | |
PYBIND11_NOINLINE unique_function_record | make_function_record () |
Space optimization: don't inline this frequently instantiated fragment. More... | |
template<typename Func , typename Return , typename... Args, typename... Extra> | |
void | initialize (Func &&f, Return(*)(Args...), const Extra &...extra) |
Special internal constructor for functors, lambda functions, etc. More... | |
void | initialize_generic (unique_function_record &&unique_rec, const char *text, const std::type_info *const *types, size_t args) |
Register a function call with Python (generic non-templated code goes here) More... | |
PYBIND11_NOINLINE unique_function_record | make_function_record () |
Space optimization: don't inline this frequently instantiated fragment. More... | |
template<typename Func , typename Return , typename... Args, typename... Extra> | |
void | initialize (Func &&f, Return(*)(Args...), const Extra &...extra) |
Special internal constructor for functors, lambda functions, etc. More... | |
void | initialize_generic (unique_function_record &&unique_rec, const char *text, const std::type_info *const *types, size_t args) |
Register a function call with Python (generic non-templated code goes here) More... | |
Static Protected Member Functions | |
static void | destruct (detail::function_record *rec, bool free_strings=true) |
When a cpp_function is GCed, release any memory allocated by pybind11. More... | |
static PyObject * | dispatcher (PyObject *self, PyObject *args_in, PyObject *kwargs_in) |
Main dispatch logic for calls to functions bound using pybind11. More... | |
static void | destruct (detail::function_record *rec, bool free_strings=true) |
When a cpp_function is GCed, release any memory allocated by pybind11. More... | |
static PyObject * | dispatcher (PyObject *self, PyObject *args_in, PyObject *kwargs_in) |
Main dispatch logic for calls to functions bound using pybind11. More... | |
Additional Inherited Members | |
![]() | |
static std::size_t | inc_ref_counter () |
![]() | |
bool | is_borrowed: handle(h) { if (is_borrowed) { inc_ref() |
![]() | |
PyObject * | m_ptr = nullptr |
Wraps an arbitrary C++ function/method/lambda function/.. into a callable Python object.
Definition at line 81 of file pybind11.h.
|
protected |
Definition at line 157 of file pybind11.h.
|
protected |
Definition at line 158 of file pybind11.h.
|
default |
|
inline |
Definition at line 85 of file pybind11.h.
|
inline |
Construct a cpp_function from a vanilla function pointer.
Definition at line 90 of file pybind11.h.
|
inline |
Construct a cpp_function from a lambda function (possibly with internal state)
Definition at line 99 of file pybind11.h.
|
inline |
Construct a cpp_function from a class method (non-const, no ref-qualifier)
Definition at line 107 of file pybind11.h.
|
inline |
Construct a cpp_function from a class method (non-const, lvalue ref-qualifier) A copy of the overload for non-const functions without explicit ref-qualifier but with an added &
.
Definition at line 119 of file pybind11.h.
|
inline |
Construct a cpp_function from a class method (const, no ref-qualifier)
Definition at line 129 of file pybind11.h.
|
inline |
Construct a cpp_function from a class method (const, lvalue ref-qualifier) A copy of the overload for const functions without explicit ref-qualifier but with an added &
.
Definition at line 141 of file pybind11.h.
|
default |
|
inline |
Definition at line 86 of file pybind11.h.
|
inline |
Construct a cpp_function from a vanilla function pointer.
Definition at line 91 of file pybind11.h.
References initialize().
|
inline |
Construct a cpp_function from a lambda function (possibly with internal state)
Definition at line 100 of file pybind11.h.
References initialize().
|
inline |
Construct a cpp_function from a class method (non-const, no ref-qualifier)
Definition at line 108 of file pybind11.h.
References initialize().
|
inline |
Construct a cpp_function from a class method (non-const, lvalue ref-qualifier) A copy of the overload for non-const functions without explicit ref-qualifier but with an added &
.
Definition at line 120 of file pybind11.h.
References initialize().
|
inline |
Construct a cpp_function from a class method (const, no ref-qualifier)
Definition at line 130 of file pybind11.h.
References initialize().
|
inline |
Construct a cpp_function from a class method (const, lvalue ref-qualifier) A copy of the overload for const functions without explicit ref-qualifier but with an added &
.
Definition at line 142 of file pybind11.h.
References initialize().
|
inlinestaticprotected |
When a cpp_function is GCed, release any memory allocated by pybind11.
Definition at line 621 of file pybind11.h.
References arg::name.
Referenced by cpp_function::InitializingFunctionRecordDeleter::operator()().
|
inlinestaticprotected |
When a cpp_function is GCed, release any memory allocated by pybind11.
Definition at line 623 of file pybind11.h.
References arg::name.
|
inlinestaticprotected |
Main dispatch logic for calls to functions bound using pybind11.
Definition at line 667 of file pybind11.h.
References function_call::args, function_call::args_convert, function_call::args_ref, argument_record::convert, dict_getitemstring(), dict::empty(), first(), get_internals(), get_local_internals(), get_type_info(), instance::get_value_and_holder(), handle::inc_ref(), function_call::init_self, function_record::is_constructor, function_record::is_operator, function_call::kwargs_ref, argument_record::name, function_record::name, function_record::next, argument_record::none, handle::ptr(), pybind11_fail(), PYBIND11_TRY_NEXT_OVERLOAD, raise_from(), internals::registered_exception_translators, local_internals::registered_exception_translators, object::release(), error_already_set::restore(), function_record::scope, and self.
Referenced by initialize_generic().
|
inlinestaticprotected |
Main dispatch logic for calls to functions bound using pybind11.
Definition at line 669 of file pybind11.h.
References function_call::args, function_call::args_convert, function_call::args_ref, argument_record::convert, dict_getitemstring(), dict::empty(), first(), get_function_record_capsule_name(), get_internals(), get_local_internals(), get_type_info(), instance::get_value_and_holder(), handle::handle(), function_call::init_self, function_record::is_constructor, function_record::is_operator, function_call::kwargs_ref, argument_record::name, function_record::name, function_record::next, argument_record::none, handle::ptr(), pybind11_fail(), PYBIND11_TRY_NEXT_OVERLOAD, raise_from(), internals::registered_exception_translators, local_internals::registered_exception_translators, object::release(), error_already_set::restore(), function_record::scope, and self.
|
inlineprotected |
Special internal constructor for functors, lambda functions, etc.
Definition at line 167 of file pybind11.h.
References const_name(), constexpr_first(), constexpr_sum(), data(), expected_num_args(), process_attributes< Args >::init(), return_value_policy_override< Return, SFINAE >::policy(), process_attributes< Args >::postcall(), process_attributes< Args >::precall(), PYBIND11_DESCR_CONSTEXPR, PYBIND11_SILENCE_MSVC_C4127, PYBIND11_STD_LAUNDER, and PYBIND11_TRY_NEXT_OVERLOAD.
Referenced by cpp_function().
|
inlineprotected |
Special internal constructor for functors, lambda functions, etc.
Definition at line 168 of file pybind11.h.
References const_name(), constexpr_first(), constexpr_sum(), data(), expected_num_args(), process_attributes< Args >::init(), initialize_generic(), make_function_record(), return_value_policy_override< Return, SFINAE >::policy(), process_attributes< Args >::postcall(), process_attributes< Args >::precall(), PYBIND11_DESCR_CONSTEXPR, PYBIND11_STD_LAUNDER, PYBIND11_TRY_NEXT_OVERLOAD, PYBIND11_WARNING_DISABLE_GCC, and PYBIND11_WARNING_POP.
|
inlineprotected |
Register a function call with Python (generic non-templated code goes here)
Definition at line 332 of file pybind11.h.
References c_str(), handle::cast(), object::cast(), hasattr(), handle::ptr(), PYBIND11_COMPAT_STRDUP, pybind11_fail(), PYBIND11_INSTANCE_METHOD_CHECK, PYBIND11_INSTANCE_METHOD_GET_FUNCTION, PYBIND11_INSTANCE_METHOD_NEW, cpp_function::strdup_guard::release(), repr(), self, options::show_function_signatures(), options::show_user_defined_docstrings(), and tuple::size().
Referenced by initialize().
|
inlineprotected |
Register a function call with Python (generic non-templated code goes here)
Definition at line 335 of file pybind11.h.
References c_str(), handle::cast(), object::cast(), dispatcher(), hasattr(), handle::inc_ref(), handle::m_ptr, handle::ptr(), PYBIND11_COMPAT_STRDUP, PYBIND11_DETAILED_ERROR_MESSAGES, pybind11_fail(), PYBIND11_INSTANCE_METHOD_CHECK, PYBIND11_INSTANCE_METHOD_GET_FUNCTION, PYBIND11_INSTANCE_METHOD_NEW, repr(), self, options::show_function_signatures(), options::show_user_defined_docstrings(), and tuple::size().
|
inlineprotected |
Space optimization: don't inline this frequently instantiated fragment.
Definition at line 161 of file pybind11.h.
Referenced by initialize().
|
inlineprotected |
Space optimization: don't inline this frequently instantiated fragment.
Definition at line 162 of file pybind11.h.
|
inline |
Return the function name.
Definition at line 149 of file pybind11.h.
Referenced by add_class_method(), and class_< type_, options >::def_static().
|
inline |
Return the function name.
Definition at line 150 of file pybind11.h.