μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | List of all members
cpp_function Class Reference

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>

Inheritance diagram for cpp_function:
[legend]
Collaboration diagram for cpp_function:
[legend]

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...
 
- Public Member Functions inherited from function
handle cpp_function () const
 
bool is_cpp_function () const
 
handle cpp_function () const
 
bool is_cpp_function () const
 
- Public Member Functions inherited from object
 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...
 
objectoperator= (const object &other)
 
objectoperator= (object &&other) noexcept
 
template<typename T >
cast () const &
 
template<typename 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...
 
objectoperator= (const object &other)
 
objectoperator= (object &&other) noexcept
 
template<typename T >
cast () const &
 
template<typename T >
cast () &&
 
 object (handle h, borrowed_t)
 
 object (handle h, stolen_t)
 
template<typename T >
cast () const &
 
template<typename T >
cast () &&
 
template<>
void cast () const &
 
template<>
void cast () &&
 
- Public Member Functions inherited from handle
 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 handleinc_ref () const &
 \rst Manually increase the reference count of the Python object. More...
 
const handledec_ref () const &
 \rst Manually decrease the reference count of the Python object. More...
 
template<typename 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 handleinc_ref () const &
 \rst Manually increase the reference count of the Python object. More...
 
const handledec_ref () const &
 \rst Manually decrease the reference count of the Python object. More...
 
template<typename 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 Public Member Functions inherited from handle
static std::size_t inc_ref_counter ()
 
- Public Attributes inherited from object
bool is_borrowed: handle(h) { if (is_borrowed) { inc_ref()
 
- Protected Attributes inherited from handle
PyObject * m_ptr = nullptr
 

Detailed Description

Wraps an arbitrary C++ function/method/lambda function/.. into a callable Python object.

Definition at line 81 of file pybind11.h.

Member Typedef Documentation

◆ unique_function_record [1/2]

using cpp_function::unique_function_record = std::unique_ptr<detail::function_record, InitializingFunctionRecordDeleter>
protected

Definition at line 157 of file pybind11.h.

◆ unique_function_record [2/2]

using cpp_function::unique_function_record = std::unique_ptr<detail::function_record, InitializingFunctionRecordDeleter>
protected

Definition at line 158 of file pybind11.h.

Constructor & Destructor Documentation

◆ cpp_function() [1/16]

cpp_function::cpp_function ( )
default

◆ cpp_function() [2/16]

cpp_function::cpp_function ( std::nullptr_t  )
inline

Definition at line 85 of file pybind11.h.

◆ cpp_function() [3/16]

template<typename Return , typename... Args, typename... Extra>
cpp_function::cpp_function ( Return(*)(Args...)  f,
const Extra &...  extra 
)
inline

Construct a cpp_function from a vanilla function pointer.

Definition at line 90 of file pybind11.h.

◆ cpp_function() [4/16]

template<typename Func , typename... Extra, typename = detail::enable_if_t<detail::is_lambda<Func>::value>>
cpp_function::cpp_function ( Func &&  f,
const Extra &...  extra 
)
inline

Construct a cpp_function from a lambda function (possibly with internal state)

Definition at line 99 of file pybind11.h.

◆ cpp_function() [5/16]

template<typename Return , typename Class , typename... Arg, typename... Extra>
cpp_function::cpp_function ( Return(Class::*)(Arg...)  f,
const Extra &...  extra 
)
inline

Construct a cpp_function from a class method (non-const, no ref-qualifier)

Definition at line 107 of file pybind11.h.

◆ cpp_function() [6/16]

template<typename Return , typename Class , typename... Arg, typename... Extra>
cpp_function::cpp_function ( Return(Class::*)(Arg...) f &  ,
const Extra &...  extra 
)
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.

◆ cpp_function() [7/16]

template<typename Return , typename Class , typename... Arg, typename... Extra>
cpp_function::cpp_function ( Return(Class::*)(Arg...) const  f,
const Extra &...  extra 
)
inline

Construct a cpp_function from a class method (const, no ref-qualifier)

Definition at line 129 of file pybind11.h.

◆ cpp_function() [8/16]

template<typename Return , typename Class , typename... Arg, typename... Extra>
cpp_function::cpp_function ( Return(Class::*)(Arg...) const f &  ,
const Extra &...  extra 
)
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.

◆ cpp_function() [9/16]

cpp_function::cpp_function ( )
default

◆ cpp_function() [10/16]

cpp_function::cpp_function ( std::nullptr_t  )
inline

Definition at line 86 of file pybind11.h.

◆ cpp_function() [11/16]

template<typename Return , typename... Args, typename... Extra>
cpp_function::cpp_function ( Return(*)(Args...)  f,
const Extra &...  extra 
)
inline

Construct a cpp_function from a vanilla function pointer.

Definition at line 91 of file pybind11.h.

References initialize().

◆ cpp_function() [12/16]

template<typename Func , typename... Extra, typename = detail::enable_if_t<detail::is_lambda<Func>::value>>
cpp_function::cpp_function ( Func &&  f,
const Extra &...  extra 
)
inline

Construct a cpp_function from a lambda function (possibly with internal state)

Definition at line 100 of file pybind11.h.

References initialize().

◆ cpp_function() [13/16]

template<typename Return , typename Class , typename... Arg, typename... Extra>
cpp_function::cpp_function ( Return(Class::*)(Arg...)  f,
const Extra &...  extra 
)
inline

Construct a cpp_function from a class method (non-const, no ref-qualifier)

Definition at line 108 of file pybind11.h.

References initialize().

◆ cpp_function() [14/16]

template<typename Return , typename Class , typename... Arg, typename... Extra>
cpp_function::cpp_function ( Return(Class::*)(Arg...) f &  ,
const Extra &...  extra 
)
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().

◆ cpp_function() [15/16]

template<typename Return , typename Class , typename... Arg, typename... Extra>
cpp_function::cpp_function ( Return(Class::*)(Arg...) const  f,
const Extra &...  extra 
)
inline

Construct a cpp_function from a class method (const, no ref-qualifier)

Definition at line 130 of file pybind11.h.

References initialize().

◆ cpp_function() [16/16]

template<typename Return , typename Class , typename... Arg, typename... Extra>
cpp_function::cpp_function ( Return(Class::*)(Arg...) const f &  ,
const Extra &...  extra 
)
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().

Member Function Documentation

◆ destruct() [1/2]

static void cpp_function::destruct ( detail::function_record *  rec,
bool  free_strings = true 
)
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()().

◆ destruct() [2/2]

static void cpp_function::destruct ( detail::function_record *  rec,
bool  free_strings = true 
)
inlinestaticprotected

When a cpp_function is GCed, release any memory allocated by pybind11.

Definition at line 623 of file pybind11.h.

References arg::name.

◆ dispatcher() [1/2]

static PyObject * cpp_function::dispatcher ( PyObject *  self,
PyObject *  args_in,
PyObject *  kwargs_in 
)
inlinestaticprotected

◆ dispatcher() [2/2]

static PyObject * cpp_function::dispatcher ( PyObject *  self,
PyObject *  args_in,
PyObject *  kwargs_in 
)
inlinestaticprotected

◆ initialize() [1/2]

template<typename Func , typename Return , typename... Args, typename... Extra>
void cpp_function::initialize ( Func &&  f,
Return(*)(Args...)  ,
const Extra &...  extra 
)
inlineprotected

◆ initialize() [2/2]

template<typename Func , typename Return , typename... Args, typename... Extra>
void cpp_function::initialize ( Func &&  f,
Return(*)(Args...)  ,
const Extra &...  extra 
)
inlineprotected

◆ initialize_generic() [1/2]

void cpp_function::initialize_generic ( unique_function_record &&  unique_rec,
const char *  text,
const std::type_info *const *  types,
size_t  args 
)
inlineprotected

◆ initialize_generic() [2/2]

void cpp_function::initialize_generic ( unique_function_record &&  unique_rec,
const char *  text,
const std::type_info *const *  types,
size_t  args 
)
inlineprotected

◆ make_function_record() [1/2]

PYBIND11_NOINLINE unique_function_record cpp_function::make_function_record ( )
inlineprotected

Space optimization: don't inline this frequently instantiated fragment.

Definition at line 161 of file pybind11.h.

Referenced by initialize().

◆ make_function_record() [2/2]

PYBIND11_NOINLINE unique_function_record cpp_function::make_function_record ( )
inlineprotected

Space optimization: don't inline this frequently instantiated fragment.

Definition at line 162 of file pybind11.h.

◆ name() [1/2]

object cpp_function::name ( ) const
inline

Return the function name.

Definition at line 149 of file pybind11.h.

Referenced by add_class_method(), and class_< type_, options >::def_static().

◆ name() [2/2]

object cpp_function::name ( ) const
inline

Return the function name.

Definition at line 150 of file pybind11.h.


The documentation for this class was generated from the following files: