cppyabm
1.0.17
An agent-based library to integrate C++ and Python
|
|
Go to the documentation of this file.
42 template <
typename T>
struct base {
44 PYBIND11_DEPRECATED(
"base<T>() was deprecated in favor of specifying 'T' as a template argument to class_")
49 template <
size_t Nurse,
size_t Patient>
struct keep_alive { };
64 PYBIND11_DEPRECATED(
"py::metaclass() is no longer required. It's turned on by default now.")
102 template <
typename T>
105 "The guard type must be default constructible");
110 template <
typename T,
typename... Ts>
125 template <op_
id id, op_type ot,
typename L = undefined_t,
typename R = undefined_t>
struct op_;
157 std::vector<argument_record>
args;
208 PyMethodDef *
def =
nullptr;
233 const std::type_info *
type =
nullptr;
251 void (*
dealloc)(detail::value_and_holder &) =
nullptr;
257 const char *
doc =
nullptr;
283 std::string tname(
base.name());
286 "\" referenced unknown base type \"" + tname +
"\"");
290 std::string tname(
base.name());
294 " a non-default holder type while its base \"" + tname +
"\" " +
295 (base_info->default_holder ?
"does not" :
"does"));
300 if (base_info->type->tp_dictoffset != 0)
304 base_info->implicit_casts.emplace_back(
type, caster);
381 pybind11_fail(
"arg(): cannot specify an unnamed argument after an kw_only() annotation");
389 r->
args.emplace_back(
"self",
nullptr,
handle(),
true ,
false );
400 r->
args.emplace_back(
"self",
nullptr ,
handle() ,
true ,
false );
404 std::string
descr(
"'");
409 descr +=
" in method '" + (std::string)
str(r->
scope) +
"." + (std::string) r->
name +
"'";
411 descr +=
" in method of '" + (std::string)
str(r->
scope) +
"'";
412 }
else if (r->
name) {
413 descr +=
" in function '" + (std::string) r->
name +
"'";
416 +
descr +
" into a Python object (type not registered yet?)");
419 "into a Python object (type not registered yet?). "
420 "Compile in debug mode for more information.");
444 template <
typename T>
450 template <
typename T>
496 template <
typename... Ts>
505 template <
size_t N = Nurse,
size_t P = Patient, enable_if_t<N != 0 && P != 0,
int> = 0>
507 template <
size_t N = Nurse,
size_t P = Patient, enable_if_t<N != 0 && P != 0,
int> = 0>
509 template <
size_t N = Nurse,
size_t P = Patient, enable_if_t<N == 0 || P == 0,
int> = 0>
511 template <
size_t N = Nurse,
size_t P = Patient, enable_if_t<N == 0 || P == 0,
int> = 0>
535 template <
typename T>
539 template <
typename... Extra>
543 template <
typename... Extra,
547 return named == 0 || (
self + named +
size_t(has_args) +
size_t(has_kwargs)) ==
nargs;
Annotation which enables the buffer protocol for a type.
const char * doc
Optional docstring.
bool is_new_style_constructor
True if this is a new-style __init__ defined in detail/init.h
typename std::enable_if< B, T >::type enable_if_t
from cpp_future import (convenient aliases from C++14/17)
static void init(const arg &a, function_record *r)
static void init(const doc &n, function_record *r)
bool has_kw_only_args
True once a 'py::kw_only' is encountered (any following args are keyword-only)
Annotation for function names.
Internal data structure which holds metadata about a bound function (signature, overloads,...
#define PYBIND11_NAMESPACE_BEGIN(name)
Annotation indicating that a class derives from another given type.
static void init(const dynamic_attr &, type_record *r)
handle scope
Python handle to the parent scope (a class or a module)
static void init(const Args &... args, type_record *r)
#define PYBIND11_NAMESPACE_END(name)
void ignore_unused(const int *)
Ignore that a variable is unused in compiler warnings.
static void init(const name &n, function_record *r)
handle sibling
Python handle to the sibling function representing an overload chain.
Annotation for parent scope.
#define PYBIND11_NAMESPACE
static void init(const Args &... args, function_record *r)
std::uint16_t nargs
Number of arguments (including py::args and/or py::kwargs, if present)
bool dynamic_attr
Does the class manage a dict?
static void init(const return_value_policy &p, function_record *r)
Annotation indicating that a class is involved in a multiple inheritance relationship.
Annotation for classes that cannot be subclassed.
Annotation for operators.
#define PYBIND11_DEPRECATED(reason)
PYBIND11_NOINLINE void clean_type_id(std::string &name)
static void init(const arg_v &a, function_record *r)
argument_record(const char *name, const char *descr, handle value, bool convert, bool none)
static void init(const char *d, function_record *r)
const handle & inc_ref() const &
static void postcall(function_call &, handle)
#define PYBIND11_NOINLINE
constexpr module_local(bool v=true)
bool has_kwargs
True if the function has a '**kwargs' argument.
function_call(const function_record &f, handle p)
void(* init_instance)(instance *, const void *)
Function pointer to class_<..>::init_instance.
constexpr size_t constexpr_sum()
Compile-time integer sum.
handle value
Associated Python object.
Operator implementation generator.
return_value_policy policy
Return value policy associated with this function.
size_t holder_size
How large is the type's holder?
op_id
Enumeration with all supported operator types.
Annotation to mark enums as an arithmetic type.
void * data[3]
Storage for the wrapped function pointer and captured data, if any.
static void init(const handle &h, type_record *r)
PyMethodDef * def
Python method object.
bool module_local
Is the class definition local to the module shared object?
void process_kw_only_arg(const arg &a, function_record *r)
Internal data structure which holds metadata about a keyword argument.
bool default_holder
Is the default (unique_ptr) holder type used?
The 'instance' type which needs to be standard layout (need to be able to use 'offsetof')
Internal data associated with a single function call.
const char * name
Argument name.
Mark a function for addition at the beginning of the existing overload chain instead of the end.
Annotation indicating that a function is an overload associated with a given "sibling".
handle metaclass
Custom metaclass (optional)
static void init(const T &, type_record *)
std::string type
The C++ type name of the default value (only available when compiled in debug mode)
bool convert
True if the argument is allowed to convert when loading.
Annotation for documentation.
bool multiple_inheritance
Multiple inheritance marker.
const char * name
If non-null, this is a named kwargs argument.
Annotation which enables dynamic attributes, i.e. adds __dict__ to a class.
static void precall(function_call &)
bool is_method
True if this is a method.
Type for an unused type slot.
static void init(const pos_only &, function_record *r)
object value
The default value.
handle(* impl)(function_call &)
Pointer to lambda function which converts arguments and performs the actual call.
static void init(const kw_only &, function_record *r)
list bases
List of base classes of the newly created type.
typename exactly_one_t< is_call_guard, call_guard<>, Extra... >::type extract_guard_t
Extract the type from the first call_guard in Extras... (or void_type if none found)
Tag for a new-style __init__ defined in detail/init.h
Process an attribute specifying the function's docstring (provided as a C-style string)
std::uint16_t nargs_kw_only
Number of trailing arguments (counted in nargs) that are keyword-only.
bool flag_noconvert
If set, do not allow conversion (requires a supporting type caster!)
char * signature
Human-readable version of the function signature.
bool prepend
True if this function is to be inserted at the beginning of the overload resolution chain.
Special data structure which (temporarily) holds metadata about a bound class.
Annotation that marks a class as local to the module:
static void init(const prepend &, function_record *r)
static void init(const is_method &s, function_record *r)
static void postcall(function_call &call, handle fn_ret)
static void init(const is_new_style_constructor &, function_record *r)
Keep patient alive while nurse lives.
std::uint16_t nargs_pos_only
Number of leading arguments (counted in nargs) that are positional-only.
bool is_constructor
True if name == 'init'.
static void init(const is_operator &, function_record *r)
PYBIND11_NOINLINE void add_base(const std::type_info &base, void *(*caster)(void *))
bool flag_none
If set (the default), allow None to be passed to this argument.
function_record * next
Pointer to next overload.
const char * descr
Human-readable version of the argument value.
static void precall(function_call &)
bool none
True if None is allowed when loading.
bool has_args
True if the function has a '*args' argument.
PyExc_RuntimeError PYBIND11_NOINLINE void pybind11_fail(const char *reason)
Used internally.
bool is_stateless
True if this is a stateless function pointer.
typename exactly_one< Predicate, Default, Ts... >::type exactly_one_t
bool is_final
Is the class inheritable from python classes?
bool is_operator
True if this is an operator (add), etc.
const char * descr
The (optional) description of the default value.
Recursively iterate over variadic template arguments.
void append(T &&val) const
std::vector< argument_record > args
List of registered keyword arguments.
PyObject * ptr() const
Return the underlying PyObject * pointer.
void(* dealloc)(detail::value_and_holder &)
Function pointer to class_<..>::dealloc.
return_value_policy
Approach used to cast a previously unknown C++ instance into a Python object.
static void init(const scope &s, function_record *r)
static void init(const T &, function_record *)
Default implementation: do nothing.
std::is_base_of< pyobject_tag, remove_reference_t< T > > is_pyobject
static void init(const base< T > &, type_record *r)
void(* free_data)(function_record *ptr)
Pointer to custom destructor for 'data' (if needed)
static void init(const buffer_protocol &, type_record *r)
size_t type_align
What is the alignment of the underlying C++ type?
void keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret)
handle scope
Handle to the parent scope.
static void precall(function_call &call)
bool buffer_protocol
Does the class implement the buffer protocol?
static void init(const char *d, type_record *r)
static void init(const module_local &l, type_record *r)
size_t type_size
How large is the underlying C++ type?
char * name
Function name.
sibling(const handle &value)
static void init(const sibling &s, function_record *r)
PYBIND11_NOINLINE type_record()
static void precall(function_call &call)
static void init(const is_final &, type_record *r)
constexpr bool expected_num_args(size_t nargs, bool has_args, bool has_kwargs)
Check the number of named arguments at compile time.
is_method(const handle &c)
static void postcall(function_call &, handle)
static void postcall(function_call &call, handle ret)
static void init(const multiple_inheritance &, type_record *r)
std::vector< bool > args_convert
The convert value the arguments should be loaded with.
PYBIND11_NOINLINE detail::type_info * get_type_info(PyTypeObject *type)