cppyabm
1.0.17
An agent-based library to integrate C++ and Python
|
|
Go to the documentation of this file.
18 template <
typename Return,
typename... Args>
20 using type = std::function<Return(Args...)>;
28 if (!convert)
return false;
32 if (!isinstance<function>(src))
35 auto func = reinterpret_borrow<function>(src);
45 if (
auto cfunc = func.cpp_function()) {
46 auto c = reinterpret_borrow<capsule>(PyCFunction_GET_SELF(cfunc.ptr()));
49 if (rec && rec->is_stateless &&
60 func_handle(
function&& f_) : f(
std::move(f_)) {}
61 func_handle(
const func_handle& f_) {
74 func_wrapper(func_handle&& hf): hfunc(
std::move(hf)) {}
75 Return operator()(Args...
args)
const {
77 object retval(hfunc.f(std::forward<Args>(
args)...));
79 return (retval.template cast<Return>());
87 template <
typename Func>
92 auto result = f_.template target<function_type>();
Internal data structure which holds metadata about a bound function (signature, overloads,...
#define PYBIND11_NAMESPACE_BEGIN(name)
#define PYBIND11_NAMESPACE_END(name)
#define PYBIND11_NAMESPACE
bool load(handle src, bool convert)
const handle & inc_ref() const &
constexpr descr< N - 1 > _(char const(&text)[N])
Return(*)(Args...) function_type
PYBIND11_TYPE_CASTER(type, _("Callable[[")+concat(make_caster< Args >::name...)+_("], ")+make_caster< retval_type >::name+_("]"))
typename std::conditional< B, T, F >::type conditional_t
bool same_type(const std::type_info &lhs, const std::type_info &rhs)
constexpr descr< 0 > concat()
Wraps an arbitrary C++ function/method/lambda function/.. into a callable Python object.
detail::enable_if_t<!detail::move_never< T >::value, T > move(object &&obj)
static handle cast(Func &&f_, return_value_policy policy, handle)
Helper type to replace 'void' in some expressions.
return_value_policy
Approach used to cast a previously unknown C++ instance into a Python object.
conditional_t< std::is_same< Return, void >::value, void_type, Return > retval_type