μ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 "detail/common.h"
14#include "cast.h"
15
16#include <functional>
17
19
20
22
24struct is_method {
26 explicit is_method(const handle &c) : class_(c) {}
27};
28
30struct is_operator {};
31
33struct is_final {};
34
36struct scope {
38 explicit scope(const handle &s) : value(s) {}
39};
40
42struct doc {
43 const char *value;
44 explicit doc(const char *value) : value(value) {}
45};
46
48struct name {
49 const char *value;
50 explicit name(const char *value) : value(value) {}
51};
52
54struct sibling {
56 explicit sibling(const handle &value) : value(value.ptr()) {}
57};
58
60template <typename T>
61struct base {
62
64 "base<T>() was deprecated in favor of specifying 'T' as a template argument to class_")
65 base() = default;
66};
67
69template <size_t Nurse, size_t Patient>
70struct keep_alive {};
71
73struct multiple_inheritance {};
74
76struct dynamic_attr {};
77
79struct buffer_protocol {};
80
82struct metaclass {
84
85 PYBIND11_DEPRECATED("py::metaclass() is no longer required. It's turned on by default now.")
86 metaclass() = default;
87
89 explicit metaclass(handle value) : value(value) {}
90};
91
101struct custom_type_setup {
102 using callback = std::function<void(PyHeapTypeObject *heap_type)>;
103
104 explicit custom_type_setup(callback value) : value(std::move(value)) {}
105
106 callback value;
107};
108
110struct module_local {
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>
140struct call_guard;
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
175struct argument_record {
176 const char *name;
177 const char *descr;
178 handle value;
179 bool convert : 1;
180 bool none : 1;
181
182 argument_record(const char *name, const char *descr, handle value, bool convert, bool none)
183 : name(name), descr(descr), value(value), convert(convert), none(none) {}
184};
185
188struct function_record {
190 : is_constructor(false), is_new_style_constructor(false), is_stateless(false),
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
219 bool is_constructor : 1;
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
262 function_record *next = nullptr;
263};
264
266struct type_record {
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
299 list bases;
300
302 const char *doc = nullptr;
303
306
308 custom_type_setup::callback custom_type_setup_callback;
309
311 bool multiple_inheritance : 1;
312
314 bool dynamic_attr : 1;
315
317 bool buffer_protocol : 1;
318
320 bool default_holder : 1;
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 PY_VERSION_HEX < 0x030B0000
349 dynamic_attr |= base_info->type->tp_dictoffset != 0;
350#else
351 dynamic_attr |= (base_info->type->tp_flags & Py_TPFLAGS_MANAGED_DICT) != 0;
352#endif
353
354 if (caster) {
355 base_info->implicit_casts.emplace_back(type, caster);
356 }
357 }
358};
359
360inline function_call::function_call(const function_record &f, handle p) : func(f), parent(p) {
361 args.reserve(f.nargs);
362 args_convert.reserve(f.nargs);
363}
364
367
374template <typename T, typename SFINAE = void>
375struct process_attribute;
376
377template <typename T>
380 static void init(const T &, function_record *) {}
381 static void init(const T &, type_record *) {}
382 static void precall(function_call &) {}
383 static void postcall(function_call &, handle) {}
384};
385
387template <>
389 static void init(const name &n, function_record *r) { r->name = const_cast<char *>(n.value); }
390};
391
393template <>
395 static void init(const doc &n, function_record *r) { r->doc = const_cast<char *>(n.value); }
396};
397
399template <>
401 static void init(const char *d, function_record *r) { r->doc = const_cast<char *>(d); }
402 static void init(const char *d, type_record *r) { r->doc = d; }
403};
404template <>
406
408template <>
410 static void init(const return_value_policy &p, function_record *r) { r->policy = p; }
411};
412
415template <>
417 static void init(const sibling &s, function_record *r) { r->sibling = s.value; }
418};
419
421template <>
423 static void init(const is_method &s, function_record *r) {
424 r->is_method = true;
425 r->scope = s.class_;
426 }
427};
428
430template <>
432 static void init(const scope &s, function_record *r) { r->scope = s.value; }
433};
434
436template <>
438 static void init(const is_operator &, function_record *r) { r->is_operator = true; }
439};
440
441template <>
443 : process_attribute_default<is_new_style_constructor> {
445 r->is_new_style_constructor = true;
446 }
447};
448
449inline void check_kw_only_arg(const arg &a, function_record *r) {
450 if (r->args.size() > r->nargs_pos && (!a.name || a.name[0] == '\0')) {
451 pybind11_fail("arg(): cannot specify an unnamed argument after a kw_only() annotation or "
452 "args() argument");
453 }
454}
455
457 if (r->is_method && r->args.empty()) {
458 r->args.emplace_back("self", nullptr, handle(), /*convert=*/true, /*none=*/false);
459 }
460}
461
463template <>
465 static void init(const arg &a, function_record *r) {
467 r->args.emplace_back(a.name, nullptr, handle(), !a.flag_noconvert, a.flag_none);
468
469 check_kw_only_arg(a, r);
470 }
471};
472
474template <>
476 static void init(const arg_v &a, function_record *r) {
477 if (r->is_method && r->args.empty()) {
478 r->args.emplace_back(
479 "self", /*descr=*/nullptr, /*parent=*/handle(), /*convert=*/true, /*none=*/false);
480 }
481
482 if (!a.value) {
483#if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
484 std::string descr("'");
485 if (a.name) {
486 descr += std::string(a.name) + ": ";
487 }
488 descr += a.type + "'";
489 if (r->is_method) {
490 if (r->name) {
491 descr += " in method '" + (std::string) str(r->scope) + "."
492 + (std::string) r->name + "'";
493 } else {
494 descr += " in method of '" + (std::string) str(r->scope) + "'";
495 }
496 } else if (r->name) {
497 descr += " in function '" + (std::string) r->name + "'";
498 }
499 pybind11_fail("arg(): could not convert default argument " + descr
500 + " into a Python object (type not registered yet?)");
501#else
502 pybind11_fail("arg(): could not convert default argument "
503 "into a Python object (type not registered yet?). "
504 "#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for "
505 "more information.");
506#endif
507 }
508 r->args.emplace_back(a.name, a.descr, a.value.inc_ref(), !a.flag_noconvert, a.flag_none);
509
510 check_kw_only_arg(a, r);
511 }
512};
513
515template <>
517 static void init(const kw_only &, function_record *r) {
519 if (r->has_args && r->nargs_pos != static_cast<std::uint16_t>(r->args.size())) {
520 pybind11_fail("Mismatched args() and kw_only(): they must occur at the same relative "
521 "argument location (or omit kw_only() entirely)");
522 }
523 r->nargs_pos = static_cast<std::uint16_t>(r->args.size());
524 }
525};
526
528template <>
530 static void init(const pos_only &, function_record *r) {
532 r->nargs_pos_only = static_cast<std::uint16_t>(r->args.size());
533 if (r->nargs_pos_only > r->nargs_pos) {
534 pybind11_fail("pos_only(): cannot follow a py::args() argument");
535 }
536 // It also can't follow a kw_only, but a static_assert in pybind11.h checks that
537 }
538};
539
542template <typename T>
544 : process_attribute_default<handle> {
545 static void init(const handle &h, type_record *r) { r->bases.append(h); }
546};
547
549template <typename T>
551 static void init(const base<T> &, type_record *r) { r->add_base(typeid(T), nullptr); }
552};
553
555template <>
557 static void init(const multiple_inheritance &, type_record *r) {
558 r->multiple_inheritance = true;
559 }
560};
561
562template <>
564 static void init(const dynamic_attr &, type_record *r) { r->dynamic_attr = true; }
565};
566
567template <>
569 static void init(const custom_type_setup &value, type_record *r) {
570 r->custom_type_setup_callback = value.value;
571 }
572};
573
574template <>
576 static void init(const is_final &, type_record *r) { r->is_final = true; }
577};
578
579template <>
581 static void init(const buffer_protocol &, type_record *r) { r->buffer_protocol = true; }
582};
583
584template <>
586 static void init(const metaclass &m, type_record *r) { r->metaclass = m.value; }
587};
588
589template <>
591 static void init(const module_local &l, type_record *r) { r->module_local = l.value; }
592};
593
595template <>
597 static void init(const prepend &, function_record *r) { r->prepend = true; }
598};
599
601template <>
603
604template <typename... Ts>
605struct process_attribute<call_guard<Ts...>> : process_attribute_default<call_guard<Ts...>> {};
606
612template <size_t Nurse, size_t Patient>
613struct process_attribute<keep_alive<Nurse, Patient>>
614 : public process_attribute_default<keep_alive<Nurse, Patient>> {
615 template <size_t N = Nurse, size_t P = Patient, enable_if_t<N != 0 && P != 0, int> = 0>
616 static void precall(function_call &call) {
617 keep_alive_impl(Nurse, Patient, call, handle());
618 }
619 template <size_t N = Nurse, size_t P = Patient, enable_if_t<N != 0 && P != 0, int> = 0>
620 static void postcall(function_call &, handle) {}
621 template <size_t N = Nurse, size_t P = Patient, enable_if_t<N == 0 || P == 0, int> = 0>
622 static void precall(function_call &) {}
623 template <size_t N = Nurse, size_t P = Patient, enable_if_t<N == 0 || P == 0, int> = 0>
624 static void postcall(function_call &call, handle ret) {
625 keep_alive_impl(Nurse, Patient, call, ret);
626 }
627};
628
630template <typename... Args>
631struct process_attributes {
632 static void init(const Args &...args, function_record *r) {
635 using expander = int[];
636 (void) expander{
637 0, ((void) process_attribute<typename std::decay<Args>::type>::init(args, r), 0)...};
638 }
639 static void init(const Args &...args, type_record *r) {
642 using expander = int[];
643 (void) expander{0,
645 }
646 static void precall(function_call &call) {
648 using expander = int[];
649 (void) expander{0,
651 }
652 static void postcall(function_call &call, handle fn_ret) {
655 using expander = int[];
656 (void) expander{
658 }
659};
660
661template <typename T>
663
665template <typename... Extra>
667
669template <typename... Extra,
670 size_t named = constexpr_sum(std::is_base_of<arg, Extra>::value...),
671 size_t self = constexpr_sum(std::is_same<is_method, Extra>::value...)>
672constexpr bool expected_num_args(size_t nargs, bool has_args, bool has_kwargs) {
673 PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(nargs, has_args, has_kwargs);
674 return named == 0 || (self + named + size_t(has_args) + size_t(has_kwargs)) == nargs;
675}
676
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
int nargs
Definition: benchmark.py:7
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
arr data(const arr &a, Ix... index)
void keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret)
Definition: pybind11.h:2239
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
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()=default
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
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:44
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
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
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
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
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
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
bool has_args
True if the function has a '*args' argument.
Definition: attr.h:234
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:26
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
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:50
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:545
static void init(const arg &a, function_record *r)
Definition: attr.h:465
static void init(const arg_v &a, function_record *r)
Definition: attr.h:476
static void init(const base< T > &, type_record *r)
Definition: attr.h:551
static void init(const buffer_protocol &, type_record *r)
Definition: attr.h:581
static void init(const char *d, type_record *r)
Definition: attr.h:402
static void init(const char *d, function_record *r)
Definition: attr.h:401
static void init(const custom_type_setup &value, type_record *r)
Definition: attr.h:569
static void init(const doc &n, function_record *r)
Definition: attr.h:395
static void init(const dynamic_attr &, type_record *r)
Definition: attr.h:564
static void init(const is_final &, type_record *r)
Definition: attr.h:576
static void init(const is_method &s, function_record *r)
Definition: attr.h:423
static void init(const is_new_style_constructor &, function_record *r)
Definition: attr.h:444
static void init(const is_operator &, function_record *r)
Definition: attr.h:438
static void precall(function_call &call)
Definition: attr.h:616
static void postcall(function_call &call, handle ret)
Definition: attr.h:624
static void postcall(function_call &, handle)
Definition: attr.h:620
static void precall(function_call &)
Definition: attr.h:622
static void init(const kw_only &, function_record *r)
Definition: attr.h:517
static void init(const metaclass &m, type_record *r)
Definition: attr.h:586
static void init(const module_local &l, type_record *r)
Definition: attr.h:591
static void init(const multiple_inheritance &, type_record *r)
Definition: attr.h:557
static void init(const name &n, function_record *r)
Definition: attr.h:389
static void init(const pos_only &, function_record *r)
Definition: attr.h:530
static void init(const prepend &, function_record *r)
Definition: attr.h:597
static void init(const return_value_policy &p, function_record *r)
Definition: attr.h:410
static void init(const scope &s, function_record *r)
Definition: attr.h:432
static void init(const sibling &s, function_record *r)
Definition: attr.h:417
static void init(const T &, function_record *)
Default implementation: do nothing.
Definition: attr.h:380
static void postcall(function_call &, handle)
Definition: attr.h:383
static void precall(function_call &)
Definition: attr.h:382
static void init(const T &, type_record *)
Definition: attr.h:381
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:646
static void init(const Args &...args, function_record *r)
Definition: attr.h:632
static void init(const Args &...args, type_record *r)
Definition: attr.h:639
static void postcall(function_call &call, handle fn_ret)
Definition: attr.h:652
Annotation for parent scope.
Definition: attr.h:35
handle value
Definition: attr.h:36
scope(const handle &s)
Definition: attr.h:38
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:56
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
PYBIND11_NOINLINE type_record()
Definition: attr.h:267
bool module_local
Is the class definition local to the module shared object?
Definition: attr.h:323
bool is_final
Is the class inheritable from python classes?
Definition: attr.h:326
bool buffer_protocol
Does the class implement the buffer protocol?
Definition: attr.h:317
const char * doc
Optional docstring.
Definition: attr.h:302
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
Type for an unused type slot.
Definition: operators.h:75