Wraps an arbitrary C++ function/method/lambda function/.. into a callable Python object. More...
#include <pybind11.h>
Classes | |
struct | InitializingFunctionRecordDeleter |
class | strdup_guard |
Public Member Functions | |
cpp_function ()=default | |
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... Args, typename... Extra> | |
cpp_function (Return(*f)(Args...), const Extra &...extra) | |
Construct a cpp_function from a vanilla function pointer. More... | |
template<typename Return , typename Class , typename... Arg, typename... Extra> | |
cpp_function (Return(Class::*f)(Arg...) &, const Extra &...extra) | |
template<typename Return , typename Class , typename... Arg, typename... Extra> | |
cpp_function (Return(Class::*f)(Arg...) const &, const Extra &...extra) | |
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 Extra &...extra) | |
Construct a cpp_function from a class method (non-const, no ref-qualifier) More... | |
cpp_function (std::nullptr_t) | |
cpp_function (std::nullptr_t, const is_setter &) | |
object | name () const |
Return the function name. More... | |
![]() | |
handle | cpp_function () const |
bool | is_cpp_function () const |
![]() | |
template<typename T > | |
T | cast () && |
template<typename T > | |
T | cast () const & |
template<> | |
void | cast () const & |
object ()=default | |
object (const object &o) | |
Copy constructor; always increases the reference count. More... | |
object (handle h, borrowed_t) | |
object (handle h, stolen_t) | |
object (object &&other) noexcept | |
Move constructor; steals the object from other and preserves its reference count. More... | |
object & | operator= (const object &other) |
object & | operator= (object &&other) noexcept |
PYBIND11_DEPRECATED ("Use reinterpret_borrow<object>() or reinterpret_steal<object>()") object(handle h | |
handle | release () |
~object () | |
Destructor; automatically calls handle::dec_ref() More... | |
![]() | |
template<typename T > | |
T | cast () const |
template<> | |
void | cast () const |
bool | check () const |
const handle & | dec_ref () const & |
handle ()=default | |
The default constructor creates a handle with a nullptr -valued pointer. 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... | |
template<typename T , detail::enable_if_t< detail::is_pyobj_ptr_or_nullptr_t< T >::value, int > = 0> | |
handle (T ptr) | |
const handle & | inc_ref () const & |
operator bool () const | |
Return true when the handle wraps a valid Python object. More... | |
bool | operator!= (const handle &h) const |
bool | operator== (const handle &h) const |
PyObject *& | ptr () |
PyObject * | ptr () const |
Return the underlying PyObject * pointer. More... | |
Protected Types | |
using | unique_function_record = std::unique_ptr< detail::function_record, InitializingFunctionRecordDeleter > |
Protected Member Functions | |
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... | |
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... | |
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 107 of file pybind11.h.
|
protected |
Definition at line 185 of file pybind11.h.
|
default |
|
inline |
Definition at line 111 of file pybind11.h.
|
inline |
Definition at line 112 of file pybind11.h.
|
inline |
Construct a cpp_function from a vanilla function pointer.
Definition at line 117 of file pybind11.h.
|
inline |
Construct a cpp_function from a lambda function (possibly with internal state)
Definition at line 126 of file pybind11.h.
|
inline |
Construct a cpp_function from a class method (non-const, no ref-qualifier)
Definition at line 134 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 146 of file pybind11.h.
|
inline |
Construct a cpp_function from a class method (const, no ref-qualifier)
Definition at line 156 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 168 of file pybind11.h.
|
inlinestaticprotected |
When a cpp_function is GCed, release any memory allocated by pybind11.
Definition at line 655 of file pybind11.h.
|
inlinestaticprotected |
Main dispatch logic for calls to functions bound using pybind11.
Definition at line 701 of file pybind11.h.
|
inlineprotected |
Special internal constructor for functors, lambda functions, etc.
Definition at line 194 of file pybind11.h.
|
inlineprotected |
Register a function call with Python (generic non-templated code goes here)
Definition at line 367 of file pybind11.h.
|
inlineprotected |
Space optimization: don't inline this frequently instantiated fragment.
Definition at line 188 of file pybind11.h.
|
inline |
Return the function name.
Definition at line 176 of file pybind11.h.