μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
attr.h
Go to the documentation of this file.
1/*
2 pybind11/attr.h: Infrastructure for processing custom
3 type and function attributes
4
5 Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>
6
7 All rights reserved. Use of this source code is governed by a
8 BSD-style license that can be found in the LICENSE file.
9*/
10
11#pragma once
12
13#include "cast.h"
14
15#include <functional>
16
18
19
21
23struct is_method {
25 explicit is_method(const handle &c) : class_(c) {}
26};
27
29struct is_operator {};
30
32struct is_final {};
33
35struct scope {
37 explicit scope(const handle &s) : value(s) {}
38};
39
41struct doc {
42 const char *value;
43 explicit doc(const char *value) : value(value) {}
44};
45
47struct name {
48 const char *value;
49 explicit name(const char *value) : value(value) {}
50};
51
53struct sibling {
55 explicit sibling(const handle &value) : value(value.ptr()) {}
56};
57
59template <typename T>
60struct base {
61
63 "base<T>() was deprecated in favor of specifying 'T' as a template argument to class_")
64 base() {} // NOLINT(modernize-use-equals-default): breaks MSVC 2015 when adding an attribute
65};
66
68template <size_t Nurse, size_t Patient>
69struct keep_alive {};
70
73
75struct dynamic_attr {};
76
79
81struct metaclass {
83
84 PYBIND11_DEPRECATED("py::metaclass() is no longer required. It's turned on by default now.")
85 // NOLINTNEXTLINE(modernize-use-equals-default): breaks MSVC 2015 when adding an attribute
87
90};
91
102 using callback = std::function<void(PyHeapTypeObject *heap_type)>;
103
105
107};
108
111 const bool value;
112 constexpr explicit module_local(bool v = true) : value(v) {}
113};
114
116struct arithmetic {};
117
119struct prepend {};
120
139template <typename... Ts>
141
142template <>
143struct call_guard<> {
144 using type = detail::void_type;
145};
146
147template <typename T>
148struct call_guard<T> {
149 static_assert(std::is_default_constructible<T>::value,
150 "The guard type must be default constructible");
151
152 using type = T;
153};
154
155template <typename T, typename... Ts>
156struct call_guard<T, Ts...> {
157 struct type {
158 T guard{}; // Compose multiple guard types with left-to-right default-constructor order
159 typename call_guard<Ts...>::type next{};
160 };
161};
162
164
166/* Forward declarations */
167enum op_id : int;
168enum op_type : int;
169struct undefined_t;
170template <op_id id, op_type ot, typename L = undefined_t, typename R = undefined_t>
171struct op_;
172void keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret);
173
176 const char *name;
177 const char *descr;
179 bool convert : 1;
180 bool none : 1;
181
182 argument_record(const char *name, const char *descr, handle value, bool convert, bool none)
184};
185
191 is_operator(false), is_method(false), has_args(false), has_kwargs(false),
192 prepend(false) {}
193
195 char *name = nullptr; /* why no C++ strings? They generate heavier code.. */
196
197 // User-specified documentation string
198 char *doc = nullptr;
199
201 char *signature = nullptr;
202
204 std::vector<argument_record> args;
205
207 handle (*impl)(function_call &) = nullptr;
208
210 void *data[3] = {};
211
213 void (*free_data)(function_record *ptr) = nullptr;
214
216 return_value_policy policy = return_value_policy::automatic;
217
220
223
225 bool is_stateless : 1;
226
228 bool is_operator : 1;
229
231 bool is_method : 1;
232
234 bool has_args : 1;
235
237 bool has_kwargs : 1;
238
240 bool prepend : 1;
241
243 std::uint16_t nargs;
244
247 std::uint16_t nargs_pos = 0;
248
250 std::uint16_t nargs_pos_only = 0;
251
253 PyMethodDef *def = nullptr;
254
257
260
263};
264
268 : multiple_inheritance(false), dynamic_attr(false), buffer_protocol(false),
269 default_holder(true), module_local(false), is_final(false) {}
270
273
275 const char *name = nullptr;
276
277 // Pointer to RTTI type_info data structure
278 const std::type_info *type = nullptr;
279
281 size_t type_size = 0;
282
284 size_t type_align = 0;
285
287 size_t holder_size = 0;
288
290 void *(*operator_new)(size_t) = nullptr;
291
293 void (*init_instance)(instance *, const void *) = nullptr;
294
296 void (*dealloc)(detail::value_and_holder &) = nullptr;
297
300
302 const char *doc = nullptr;
303
306
309
312
314 bool dynamic_attr : 1;
315
318
321
323 bool module_local : 1;
324
326 bool is_final : 1;
327
328 PYBIND11_NOINLINE void add_base(const std::type_info &base, void *(*caster)(void *) ) {
329 auto *base_info = detail::get_type_info(base, false);
330 if (!base_info) {
331 std::string tname(base.name());
332 detail::clean_type_id(tname);
333 pybind11_fail("generic_type: type \"" + std::string(name)
334 + "\" referenced unknown base type \"" + tname + "\"");
335 }
336
337 if (default_holder != base_info->default_holder) {
338 std::string tname(base.name());
339 detail::clean_type_id(tname);
340 pybind11_fail("generic_type: type \"" + std::string(name) + "\" "
341 + (default_holder ? "does not have" : "has")
342 + " a non-default holder type while its base \"" + tname + "\" "
343 + (base_info->default_holder ? "does not" : "does"));
344 }
345
346 bases.append((PyObject *) base_info->type);
347
348 if (base_info->type->tp_dictoffset != 0) {
349 dynamic_attr = true;
350 }
351
352 if (caster) {
353 base_info->implicit_casts.emplace_back(type, caster);
354 }
355 }
356};
357
358inline function_call::function_call(const function_record &f, handle p) : func(f), parent(p) {
359 args.reserve(f.nargs);
360 args_convert.reserve(f.nargs);
361}
362
365
372template <typename T, typename SFINAE = void>
374
375template <typename T>
378 static void init(const T &, function_record *) {}
379 static void init(const T &, type_record *) {}
380 static void precall(function_call &) {}
381 static void postcall(function_call &, handle) {}
382};
383
385template <>
387 static void init(const name &n, function_record *r) { r->name = const_cast<char *>(n.value); }
388};
389
391template <>
393 static void init(const doc &n, function_record *r) { r->doc = const_cast<char *>(n.value); }
394};
395
397template <>
399 static void init(const char *d, function_record *r) { r->doc = const_cast<char *>(d); }
400 static void init(const char *d, type_record *r) { r->doc = const_cast<char *>(d); }
401};
402template <>
404
406template <>
408 static void init(const return_value_policy &p, function_record *r) { r->policy = p; }
409};
410
413template <>
415 static void init(const sibling &s, function_record *r) { r->sibling = s.value; }
416};
417
419template <>
421 static void init(const is_method &s, function_record *r) {
422 r->is_method = true;
423 r->scope = s.class_;
424 }
425};
426
428template <>
430 static void init(const scope &s, function_record *r) { r->scope = s.value; }
431};
432
434template <>
436 static void init(const is_operator &, function_record *r) { r->is_operator = true; }
437};
438
439template <>
441 : process_attribute_default<is_new_style_constructor> {
443 r->is_new_style_constructor = true;
444 }
445};
446
447inline void check_kw_only_arg(const arg &a, function_record *r) {
448 if (r->args.size() > r->nargs_pos && (!a.name || a.name[0] == '\0')) {
449 pybind11_fail("arg(): cannot specify an unnamed argument after a kw_only() annotation or "
450 "args() argument");
451 }
452}
453
455 if (r->is_method && r->args.empty()) {
456 r->args.emplace_back("self", nullptr, handle(), /*convert=*/true, /*none=*/false);
457 }
458}
459
461template <>
463 static void init(const arg &a, function_record *r) {
465 r->args.emplace_back(a.name, nullptr, handle(), !a.flag_noconvert, a.flag_none);
466
467 check_kw_only_arg(a, r);
468 }
469};
470
472template <>
474 static void init(const arg_v &a, function_record *r) {
475 if (r->is_method && r->args.empty()) {
476 r->args.emplace_back(
477 "self", /*descr=*/nullptr, /*parent=*/handle(), /*convert=*/true, /*none=*/false);
478 }
479
480 if (!a.value) {
481#if !defined(NDEBUG)
482 std::string descr("'");
483 if (a.name) {
484 descr += std::string(a.name) + ": ";
485 }
486 descr += a.type + "'";
487 if (r->is_method) {
488 if (r->name) {
489 descr += " in method '" + (std::string) str(r->scope) + "."
490 + (std::string) r->name + "'";
491 } else {
492 descr += " in method of '" + (std::string) str(r->scope) + "'";
493 }
494 } else if (r->name) {
495 descr += " in function '" + (std::string) r->name + "'";
496 }
497 pybind11_fail("arg(): could not convert default argument " + descr
498 + " into a Python object (type not registered yet?)");
499#else
500 pybind11_fail("arg(): could not convert default argument "
501 "into a Python object (type not registered yet?). "
502 "Compile in debug mode for more information.");
503#endif
504 }
505 r->args.emplace_back(a.name, a.descr, a.value.inc_ref(), !a.flag_noconvert, a.flag_none);
506
507 check_kw_only_arg(a, r);
508 }
509};
510
512template <>
514 static void init(const kw_only &, function_record *r) {
516 if (r->has_args && r->nargs_pos != static_cast<std::uint16_t>(r->args.size())) {
517 pybind11_fail("Mismatched args() and kw_only(): they must occur at the same relative "
518 "argument location (or omit kw_only() entirely)");
519 }
520 r->nargs_pos = static_cast<std::uint16_t>(r->args.size());
521 }
522};
523
525template <>
527 static void init(const pos_only &, function_record *r) {
529 r->nargs_pos_only = static_cast<std::uint16_t>(r->args.size());
530 if (r->nargs_pos_only > r->nargs_pos) {
531 pybind11_fail("pos_only(): cannot follow a py::args() argument");
532 }
533 // It also can't follow a kw_only, but a static_assert in pybind11.h checks that
534 }
535};
536
539template <typename T>
541 : process_attribute_default<handle> {
542 static void init(const handle &h, type_record *r) { r->bases.append(h); }
543};
544
546template <typename T>
548 static void init(const base<T> &, type_record *r) { r->add_base(typeid(T), nullptr); }
549};
550
552template <>
554 static void init(const multiple_inheritance &, type_record *r) {
555 r->multiple_inheritance = true;
556 }
557};
558
559template <>
561 static void init(const dynamic_attr &, type_record *r) { r->dynamic_attr = true; }
562};
563
564template <>
566 static void init(const custom_type_setup &value, type_record *r) {
567 r->custom_type_setup_callback = value.value;
568 }
569};
570
571template <>
573 static void init(const is_final &, type_record *r) { r->is_final = true; }
574};
575
576template <>
578 static void init(const buffer_protocol &, type_record *r) { r->buffer_protocol = true; }
579};
580
581template <>
583 static void init(const metaclass &m, type_record *r) { r->metaclass = m.value; }
584};
585
586template <>
588 static void init(const module_local &l, type_record *r) { r->module_local = l.value; }
589};
590
592template <>
594 static void init(const prepend &, function_record *r) { r->prepend = true; }
595};
596
598template <>
600
601template <typename... Ts>
602struct process_attribute<call_guard<Ts...>> : process_attribute_default<call_guard<Ts...>> {};
603
609template <size_t Nurse, size_t Patient>
610struct process_attribute<keep_alive<Nurse, Patient>>
611 : public process_attribute_default<keep_alive<Nurse, Patient>> {
612 template <size_t N = Nurse, size_t P = Patient, enable_if_t<N != 0 && P != 0, int> = 0>
613 static void precall(function_call &call) {
614 keep_alive_impl(Nurse, Patient, call, handle());
615 }
616 template <size_t N = Nurse, size_t P = Patient, enable_if_t<N != 0 && P != 0, int> = 0>
617 static void postcall(function_call &, handle) {}
618 template <size_t N = Nurse, size_t P = Patient, enable_if_t<N == 0 || P == 0, int> = 0>
619 static void precall(function_call &) {}
620 template <size_t N = Nurse, size_t P = Patient, enable_if_t<N == 0 || P == 0, int> = 0>
621 static void postcall(function_call &call, handle ret) {
622 keep_alive_impl(Nurse, Patient, call, ret);
623 }
624};
625
627template <typename... Args>
629 static void init(const Args &...args, function_record *r) {
632 using expander = int[];
633 (void) expander{
634 0, ((void) process_attribute<typename std::decay<Args>::type>::init(args, r), 0)...};
635 }
636 static void init(const Args &...args, type_record *r) {
639 using expander = int[];
640 (void) expander{0,
642 }
643 static void precall(function_call &call) {
645 using expander = int[];
646 (void) expander{0,
648 }
649 static void postcall(function_call &call, handle fn_ret) {
652 using expander = int[];
653 (void) expander{
655 }
656};
657
658template <typename T>
660
662template <typename... Extra>
664
666template <typename... Extra,
667 size_t named = constexpr_sum(std::is_base_of<arg, Extra>::value...),
668 size_t self = constexpr_sum(std::is_same<is_method, Extra>::value...)>
669constexpr bool expected_num_args(size_t nargs, bool has_args, bool has_kwargs) {
670 PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(nargs, has_args, has_kwargs);
671 return named == 0 || (self + named + size_t(has_args) + size_t(has_kwargs)) == nargs;
672}
673
Definition: pytypes.h:1776
\rst Holds a reference to a Python object (no reference counting)
Definition: pytypes.h:194
const handle & inc_ref() const &
\rst Manually increase the reference count of the Python object.
Definition: pytypes.h:211
Definition: pytypes.h:1746
void append(T &&val)
Definition: pytypes.h:1764
Definition: pytypes.h:1422
Definition: pytypes.h:1200
Definition: pytypes.h:1167
void append_self_arg_if_needed(function_record *r)
Definition: attr.h:454
void check_kw_only_arg(const arg &a, function_record *r)
Definition: attr.h:447
void keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret)
Definition: pybind11.h:2239
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)
Definition: attr.h:663
constexpr bool expected_num_args(size_t nargs, bool has_args, bool has_kwargs)
Check the number of named arguments at compile time.
Definition: attr.h:669
typename std::enable_if< B, T >::type enable_if_t
from cpp_future import (convenient aliases from C++14/17)
Definition: common.h:625
PYBIND11_NOINLINE void pybind11_fail(const char *reason)
Thrown when pybind11::cast or.
Definition: common.h:992
#define PYBIND11_NOINLINE
Definition: common.h:129
std::size_t size_t
Definition: common.h:461
constexpr size_t constexpr_sum()
Compile-time integer sum.
Definition: common.h:786
#define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...)
Definition: common.h:1187
#define PYBIND11_NAMESPACE_END(name)
Definition: common.h:21
typename exactly_one< Predicate, Default, Ts... >::type exactly_one_t
Definition: common.h:847
#define PYBIND11_NAMESPACE_BEGIN(name)
Definition: common.h:20
#define PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(...)
Definition: common.h:1195
return_value_policy
Approach used to cast a previously unknown C++ instance into a Python object.
Definition: common.h:470
@ move
Use std::move to move the return value contents into a new instance that will be owned by Python.
#define PYBIND11_DEPRECATED(reason)
Definition: common.h:139
op_type
Definition: operators.h:65
static const self_t self
Definition: operators.h:72
op_id
Enumeration with all supported operator types.
Definition: operators.h:18
detail::initimpl::constructor< Args... > init()
Binds an existing constructor taking arguments Args...
Definition: pybind11.h:1900
std::is_base_of< pyobject_tag, remove_reference_t< T > > is_pyobject
Definition: pytypes.h:62
Annotation for arguments with values.
Definition: cast.h:1265
object value
The default value.
Definition: cast.h:1309
std::string type
The C++ type name of the default value (only available when compiled in debug mode)
Definition: cast.h:1314
const char * descr
The (optional) description of the default value.
Definition: cast.h:1311
Annotation for arguments.
Definition: cast.h:1238
const char * name
If non-null, this is a named kwargs argument.
Definition: cast.h:1257
bool flag_none
If set (the default), allow None to be passed to this argument.
Definition: cast.h:1260
bool flag_noconvert
If set, do not allow conversion (requires a supporting type caster!)
Definition: cast.h:1258
Internal data structure which holds metadata about a keyword argument.
Definition: attr.h:175
argument_record(const char *name, const char *descr, handle value, bool convert, bool none)
Definition: attr.h:182
handle value
Associated Python object.
Definition: attr.h:178
const char * name
Argument name.
Definition: attr.h:176
bool none
True if None is allowed when loading.
Definition: attr.h:180
bool convert
True if the argument is allowed to convert when loading.
Definition: attr.h:179
const char * descr
Human-readable version of the argument value.
Definition: attr.h:177
Annotation to mark enums as an arithmetic type.
Definition: attr.h:116
Annotation indicating that a class derives from another given type.
Definition: attr.h:60
PYBIND11_DEPRECATED("base<T>() was deprecated in favor of specifying 'T' as a template argument to class_") base()
Definition: attr.h:62
Annotation which enables the buffer protocol for a type.
Definition: attr.h:78
\rst A call policy which places one or more guard variables (Ts...) around the function call.
Definition: attr.h:140
Specifies a custom callback with signature void (PyHeapTypeObject*) that may be used to customize the...
Definition: attr.h:101
std::function< void(PyHeapTypeObject *heap_type)> callback
Definition: attr.h:102
callback value
Definition: attr.h:106
custom_type_setup(callback value)
Definition: attr.h:104
Definition: descr.h:25
Annotation for documentation.
Definition: attr.h:41
doc(const char *value)
Definition: attr.h:43
const char * value
Definition: attr.h:42
Annotation which enables dynamic attributes, i.e. adds __dict__ to a class.
Definition: attr.h:75
Internal data associated with a single function call.
Definition: cast.h:1355
function_call(const function_record &f, handle p)
Definition: attr.h:358
std::vector< bool > args_convert
The convert value the arguments should be loaded with.
Definition: cast.h:1365
Internal data structure which holds metadata about a bound function (signature, overloads,...
Definition: attr.h:188
bool prepend
True if this function is to be inserted at the beginning of the overload resolution chain.
Definition: attr.h:240
void(* free_data)(function_record *ptr)
Pointer to custom destructor for 'data' (if needed)
Definition: attr.h:213
char * doc
Definition: attr.h:198
return_value_policy policy
Return value policy associated with this function.
Definition: attr.h:216
function_record()
Definition: attr.h:189
bool is_new_style_constructor
True if this is a new-style __init__ defined in detail/init.h
Definition: attr.h:222
std::uint16_t nargs_pos_only
Number of leading arguments (counted in nargs) that are positional-only.
Definition: attr.h:250
function_record * next
Pointer to next overload.
Definition: attr.h:262
handle(* impl)(function_call &)
Pointer to lambda function which converts arguments and performs the actual call.
Definition: attr.h:207
handle sibling
Python handle to the sibling function representing an overload chain.
Definition: attr.h:259
std::uint16_t nargs
Number of arguments (including py::args and/or py::kwargs, if present)
Definition: attr.h:243
std::uint16_t nargs_pos
Number of leading positional arguments, which are terminated by a py::args or py::kwargs argument or ...
Definition: attr.h:247
char * signature
Human-readable version of the function signature.
Definition: attr.h:201
bool is_constructor
True if name == 'init'.
Definition: attr.h:219
bool is_method
True if this is a method.
Definition: attr.h:231
bool is_operator
True if this is an operator (add), etc.
Definition: attr.h:228
bool is_stateless
True if this is a stateless function pointer.
Definition: attr.h:225
std::vector< argument_record > args
List of registered keyword arguments.
Definition: attr.h:204
char * name
Function name.
Definition: attr.h:195
handle scope
Python handle to the parent scope (a class or a module)
Definition: attr.h:256
PyMethodDef * def
Python method object.
Definition: attr.h:253
void * data[3]
Storage for the wrapped function pointer and captured data, if any.
Definition: attr.h:210
bool has_args
True if the function has a '*args' argument.
Definition: attr.h:234
bool has_kwargs
True if the function has a '**kwargs' argument.
Definition: attr.h:237
The 'instance' type which needs to be standard layout (need to be able to use 'offsetof')
Definition: common.h:554
Annotation for classes that cannot be subclassed.
Definition: attr.h:32
Check if T is an instantiation of the template Class.
Definition: common.h:893
Annotation for methods.
Definition: attr.h:23
is_method(const handle &c)
Definition: attr.h:25
handle class_
Definition: attr.h:24
Tag for a new-style __init__ defined in detail/init.h
Definition: attr.h:364
Annotation for operators.
Definition: attr.h:29
Keep patient alive while nurse lives.
Definition: attr.h:69
Annotation indicating that all following arguments are keyword-only; the is the equivalent of an unna...
Definition: cast.h:1321
Annotation which requests that a special metaclass is created for a type.
Definition: attr.h:81
handle value
Definition: attr.h:82
metaclass(handle value)
Override pybind11's default metaclass.
Definition: attr.h:89
Annotation that marks a class as local to the module:
Definition: attr.h:110
constexpr module_local(bool v=true)
Definition: attr.h:112
const bool value
Definition: attr.h:111
Annotation indicating that a class is involved in a multiple inheritance relationship.
Definition: attr.h:72
Annotation for function names.
Definition: attr.h:47
const char * value
Definition: attr.h:48
name(const char *value)
Definition: attr.h:49
Operator implementation generator.
Definition: operators.h:86
Annotation indicating that all previous arguments are positional-only; the is the equivalent of an un...
Definition: cast.h:1326
Mark a function for addition at the beginning of the existing overload chain instead of the end.
Definition: attr.h:119
static void init(const handle &h, type_record *r)
Definition: attr.h:542
static void init(const arg &a, function_record *r)
Definition: attr.h:463
static void init(const arg_v &a, function_record *r)
Definition: attr.h:474
static void init(const base< T > &, type_record *r)
Definition: attr.h:548
static void init(const buffer_protocol &, type_record *r)
Definition: attr.h:578
static void init(const char *d, type_record *r)
Definition: attr.h:400
static void init(const char *d, function_record *r)
Definition: attr.h:399
static void init(const custom_type_setup &value, type_record *r)
Definition: attr.h:566
static void init(const doc &n, function_record *r)
Definition: attr.h:393
static void init(const dynamic_attr &, type_record *r)
Definition: attr.h:561
static void init(const is_final &, type_record *r)
Definition: attr.h:573
static void init(const is_method &s, function_record *r)
Definition: attr.h:421
static void init(const is_new_style_constructor &, function_record *r)
Definition: attr.h:442
static void init(const is_operator &, function_record *r)
Definition: attr.h:436
static void precall(function_call &call)
Definition: attr.h:613
static void postcall(function_call &call, handle ret)
Definition: attr.h:621
static void postcall(function_call &, handle)
Definition: attr.h:617
static void precall(function_call &)
Definition: attr.h:619
static void init(const kw_only &, function_record *r)
Definition: attr.h:514
static void init(const metaclass &m, type_record *r)
Definition: attr.h:583
static void init(const module_local &l, type_record *r)
Definition: attr.h:588
static void init(const multiple_inheritance &, type_record *r)
Definition: attr.h:554
static void init(const name &n, function_record *r)
Definition: attr.h:387
static void init(const pos_only &, function_record *r)
Definition: attr.h:527
static void init(const prepend &, function_record *r)
Definition: attr.h:594
static void init(const return_value_policy &p, function_record *r)
Definition: attr.h:408
static void init(const scope &s, function_record *r)
Definition: attr.h:430
static void init(const sibling &s, function_record *r)
Definition: attr.h:415
static void init(const T &, function_record *)
Default implementation: do nothing.
Definition: attr.h:378
static void postcall(function_call &, handle)
Definition: attr.h:381
static void precall(function_call &)
Definition: attr.h:380
static void init(const T &, type_record *)
Definition: attr.h:379
Partial template specializations to process custom attributes provided to cpp_function_ and class_.
Definition: attr.h:373
Recursively iterate over variadic template arguments.
Definition: attr.h:628
static void precall(function_call &call)
Definition: attr.h:643
static void init(const Args &...args, function_record *r)
Definition: attr.h:629
static void init(const Args &...args, type_record *r)
Definition: attr.h:636
static void postcall(function_call &call, handle fn_ret)
Definition: attr.h:649
Annotation for parent scope.
Definition: attr.h:35
handle value
Definition: attr.h:36
scope(const handle &s)
Definition: attr.h:37
Annotation indicating that a function is an overload associated with a given "sibling".
Definition: attr.h:53
handle value
Definition: attr.h:54
sibling(const handle &value)
Definition: attr.h:55
Special data structure which (temporarily) holds metadata about a bound class.
Definition: attr.h:266
handle metaclass
Custom metaclass (optional)
Definition: attr.h:305
bool multiple_inheritance
Multiple inheritance marker.
Definition: attr.h:311
bool default_holder
Is the default (unique_ptr) holder type used?
Definition: attr.h:320
PYBIND11_NOINLINE type_record()
Definition: attr.h:267
size_t holder_size
How large is the type's holder?
Definition: attr.h:287
bool module_local
Is the class definition local to the module shared object?
Definition: attr.h:323
void(* init_instance)(instance *, const void *)
Function pointer to class_<..>::init_instance.
Definition: attr.h:293
bool is_final
Is the class inheritable from python classes?
Definition: attr.h:326
size_t type_size
How large is the underlying C++ type?
Definition: attr.h:281
handle scope
Handle to the parent scope.
Definition: attr.h:272
bool buffer_protocol
Does the class implement the buffer protocol?
Definition: attr.h:317
const char * doc
Optional docstring.
Definition: attr.h:302
size_t type_align
What is the alignment of the underlying C++ type?
Definition: attr.h:284
PYBIND11_NOINLINE void add_base(const std::type_info &base, void *(*caster)(void *))
Definition: attr.h:328
list bases
List of base classes of the newly created type.
Definition: attr.h:299
custom_type_setup::callback custom_type_setup_callback
Custom type setup.
Definition: attr.h:308
bool dynamic_attr
Does the class manage a dict?
Definition: attr.h:314
void(* dealloc)(detail::value_and_holder &)
Function pointer to class_<..>::dealloc.
Definition: attr.h:296
Type for an unused type slot.
Definition: operators.h:75