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 
24 struct is_method {
26  explicit is_method(const handle &c) : class_(c) {}
27 };
28 
30 struct is_setter {};
31 
33 struct is_operator {};
34 
36 struct is_final {};
37 
39 struct scope {
41  explicit scope(const handle &s) : value(s) {}
42 };
43 
45 struct doc {
46  const char *value;
47  explicit doc(const char *value) : value(value) {}
48 };
49 
51 struct name {
52  const char *value;
53  explicit name(const char *value) : value(value) {}
54 };
55 
57 struct sibling {
59  explicit sibling(const handle &value) : value(value.ptr()) {}
60 };
61 
63 template <typename T>
64 struct base {
65 
67  "base<T>() was deprecated in favor of specifying 'T' as a template argument to class_")
68  base() = default;
69 };
70 
72 template <size_t Nurse, size_t Patient>
73 struct keep_alive {};
74 
77 
79 struct dynamic_attr {};
80 
82 struct buffer_protocol {};
83 
85 struct metaclass {
87 
88  PYBIND11_DEPRECATED("py::metaclass() is no longer required. It's turned on by default now.")
89  metaclass() = default;
90 
92  explicit metaclass(handle value) : value(value) {}
93 };
94 
105  using callback = std::function<void(PyHeapTypeObject *heap_type)>;
106 
108 
110 };
111 
113 struct module_local {
114  const bool value;
115  constexpr explicit module_local(bool v = true) : value(v) {}
116 };
117 
119 struct arithmetic {};
120 
122 struct prepend {};
123 
142 template <typename... Ts>
143 struct call_guard;
144 
145 template <>
146 struct call_guard<> {
147  using type = detail::void_type;
148 };
149 
150 template <typename T>
151 struct call_guard<T> {
153  "The guard type must be default constructible");
154 
155  using type = T;
156 };
157 
158 template <typename T, typename... Ts>
159 struct call_guard<T, Ts...> {
160  struct type {
161  T guard{}; // Compose multiple guard types with left-to-right default-constructor order
162  typename call_guard<Ts...>::type next{};
163  };
164 };
165 
167 
169 /* Forward declarations */
170 enum op_id : int;
171 enum op_type : int;
172 struct undefined_t;
173 template <op_id id, op_type ot, typename L = undefined_t, typename R = undefined_t>
174 struct op_;
175 void keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret);
176 
179  const char *name;
180  const char *descr;
182  bool convert : 1;
183  bool none : 1;
184 
185  argument_record(const char *name, const char *descr, handle value, bool convert, bool none)
187 };
188 
193  : is_constructor(false), is_new_style_constructor(false), is_stateless(false),
194  is_operator(false), is_method(false), is_setter(false), has_args(false),
195  has_kwargs(false), prepend(false) {}
196 
198  char *name = nullptr; /* why no C++ strings? They generate heavier code.. */
199 
200  // User-specified documentation string
201  char *doc = nullptr;
202 
204  char *signature = nullptr;
205 
207  std::vector<argument_record> args;
208 
210  handle (*impl)(function_call &) = nullptr;
211 
213  void *data[3] = {};
214 
216  void (*free_data)(function_record *ptr) = nullptr;
217 
220 
222  bool is_constructor : 1;
223 
226 
228  bool is_stateless : 1;
229 
231  bool is_operator : 1;
232 
234  bool is_method : 1;
235 
237  bool is_setter : 1;
238 
240  bool has_args : 1;
241 
243  bool has_kwargs : 1;
244 
246  bool prepend : 1;
247 
250 
254 
257 
259  PyMethodDef *def = nullptr;
260 
263 
266 
268  function_record *next = nullptr;
269 };
270 
272 struct type_record {
274  : multiple_inheritance(false), dynamic_attr(false), buffer_protocol(false),
275  default_holder(true), module_local(false), is_final(false) {}
276 
279 
281  const char *name = nullptr;
282 
283  // Pointer to RTTI type_info data structure
284  const std::type_info *type = nullptr;
285 
287  size_t type_size = 0;
288 
290  size_t type_align = 0;
291 
293  size_t holder_size = 0;
294 
296  void *(*operator_new)(size_t) = nullptr;
297 
299  void (*init_instance)(instance *, const void *) = nullptr;
300 
302  void (*dealloc)(detail::value_and_holder &) = nullptr;
303 
306 
308  const char *doc = nullptr;
309 
312 
315 
318 
320  bool dynamic_attr : 1;
321 
323  bool buffer_protocol : 1;
324 
326  bool default_holder : 1;
327 
329  bool module_local : 1;
330 
332  bool is_final : 1;
333 
334  PYBIND11_NOINLINE void add_base(const std::type_info &base, void *(*caster)(void *) ) {
335  auto *base_info = detail::get_type_info(base, false);
336  if (!base_info) {
337  std::string tname(base.name());
338  detail::clean_type_id(tname);
339  pybind11_fail("generic_type: type \"" + std::string(name)
340  + "\" referenced unknown base type \"" + tname + "\"");
341  }
342 
343  if (default_holder != base_info->default_holder) {
344  std::string tname(base.name());
345  detail::clean_type_id(tname);
346  pybind11_fail("generic_type: type \"" + std::string(name) + "\" "
347  + (default_holder ? "does not have" : "has")
348  + " a non-default holder type while its base \"" + tname + "\" "
349  + (base_info->default_holder ? "does not" : "does"));
350  }
351 
352  bases.append((PyObject *) base_info->type);
353 
354 #if PY_VERSION_HEX < 0x030B0000
355  dynamic_attr |= base_info->type->tp_dictoffset != 0;
356 #else
357  dynamic_attr |= (base_info->type->tp_flags & Py_TPFLAGS_MANAGED_DICT) != 0;
358 #endif
359 
360  if (caster) {
361  base_info->implicit_casts.emplace_back(type, caster);
362  }
363  }
364 };
365 
367  args.reserve(f.nargs);
368  args_convert.reserve(f.nargs);
369 }
370 
373 
380 template <typename T, typename SFINAE = void>
382 
383 template <typename T>
386  static void init(const T &, function_record *) {}
387  static void init(const T &, type_record *) {}
388  static void precall(function_call &) {}
389  static void postcall(function_call &, handle) {}
390 };
391 
393 template <>
395  static void init(const name &n, function_record *r) { r->name = const_cast<char *>(n.value); }
396 };
397 
399 template <>
401  static void init(const doc &n, function_record *r) { r->doc = const_cast<char *>(n.value); }
402 };
403 
405 template <>
407  static void init(const char *d, function_record *r) { r->doc = const_cast<char *>(d); }
408  static void init(const char *d, type_record *r) { r->doc = d; }
409 };
410 template <>
412 
414 template <>
416  static void init(const return_value_policy &p, function_record *r) { r->policy = p; }
417 };
418 
421 template <>
423  static void init(const sibling &s, function_record *r) { r->sibling = s.value; }
424 };
425 
427 template <>
429  static void init(const is_method &s, function_record *r) {
430  r->is_method = true;
431  r->scope = s.class_;
432  }
433 };
434 
436 template <>
438  static void init(const is_setter &, function_record *r) { r->is_setter = true; }
439 };
440 
442 template <>
444  static void init(const scope &s, function_record *r) { r->scope = s.value; }
445 };
446 
448 template <>
450  static void init(const is_operator &, function_record *r) { r->is_operator = true; }
451 };
452 
453 template <>
455  : process_attribute_default<is_new_style_constructor> {
456  static void init(const is_new_style_constructor &, function_record *r) {
457  r->is_new_style_constructor = true;
458  }
459 };
460 
461 inline void check_kw_only_arg(const arg &a, function_record *r) {
462  if (r->args.size() > r->nargs_pos && (!a.name || a.name[0] == '\0')) {
463  pybind11_fail("arg(): cannot specify an unnamed argument after a kw_only() annotation or "
464  "args() argument");
465  }
466 }
467 
469  if (r->is_method && r->args.empty()) {
470  r->args.emplace_back("self", nullptr, handle(), /*convert=*/true, /*none=*/false);
471  }
472 }
473 
475 template <>
477  static void init(const arg &a, function_record *r) {
479  r->args.emplace_back(a.name, nullptr, handle(), !a.flag_noconvert, a.flag_none);
480 
481  check_kw_only_arg(a, r);
482  }
483 };
484 
486 template <>
488  static void init(const arg_v &a, function_record *r) {
489  if (r->is_method && r->args.empty()) {
490  r->args.emplace_back(
491  "self", /*descr=*/nullptr, /*parent=*/handle(), /*convert=*/true, /*none=*/false);
492  }
493 
494  if (!a.value) {
495 #if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
496  std::string descr("'");
497  if (a.name) {
498  descr += std::string(a.name) + ": ";
499  }
500  descr += a.type + "'";
501  if (r->is_method) {
502  if (r->name) {
503  descr += " in method '" + (std::string) str(r->scope) + "."
504  + (std::string) r->name + "'";
505  } else {
506  descr += " in method of '" + (std::string) str(r->scope) + "'";
507  }
508  } else if (r->name) {
509  descr += " in function '" + (std::string) r->name + "'";
510  }
511  pybind11_fail("arg(): could not convert default argument " + descr
512  + " into a Python object (type not registered yet?)");
513 #else
514  pybind11_fail("arg(): could not convert default argument "
515  "into a Python object (type not registered yet?). "
516  "#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for "
517  "more information.");
518 #endif
519  }
520  r->args.emplace_back(a.name, a.descr, a.value.inc_ref(), !a.flag_noconvert, a.flag_none);
521 
522  check_kw_only_arg(a, r);
523  }
524 };
525 
527 template <>
529  static void init(const kw_only &, function_record *r) {
531  if (r->has_args && r->nargs_pos != static_cast<std::uint16_t>(r->args.size())) {
532  pybind11_fail("Mismatched args() and kw_only(): they must occur at the same relative "
533  "argument location (or omit kw_only() entirely)");
534  }
535  r->nargs_pos = static_cast<std::uint16_t>(r->args.size());
536  }
537 };
538 
540 template <>
542  static void init(const pos_only &, function_record *r) {
544  r->nargs_pos_only = static_cast<std::uint16_t>(r->args.size());
545  if (r->nargs_pos_only > r->nargs_pos) {
546  pybind11_fail("pos_only(): cannot follow a py::args() argument");
547  }
548  // It also can't follow a kw_only, but a static_assert in pybind11.h checks that
549  }
550 };
551 
554 template <typename T>
556  : process_attribute_default<handle> {
557  static void init(const handle &h, type_record *r) { r->bases.append(h); }
558 };
559 
561 template <typename T>
563  static void init(const base<T> &, type_record *r) { r->add_base(typeid(T), nullptr); }
564 };
565 
567 template <>
569  static void init(const multiple_inheritance &, type_record *r) {
570  r->multiple_inheritance = true;
571  }
572 };
573 
574 template <>
576  static void init(const dynamic_attr &, type_record *r) { r->dynamic_attr = true; }
577 };
578 
579 template <>
581  static void init(const custom_type_setup &value, type_record *r) {
583  }
584 };
585 
586 template <>
588  static void init(const is_final &, type_record *r) { r->is_final = true; }
589 };
590 
591 template <>
593  static void init(const buffer_protocol &, type_record *r) { r->buffer_protocol = true; }
594 };
595 
596 template <>
598  static void init(const metaclass &m, type_record *r) { r->metaclass = m.value; }
599 };
600 
601 template <>
603  static void init(const module_local &l, type_record *r) { r->module_local = l.value; }
604 };
605 
607 template <>
609  static void init(const prepend &, function_record *r) { r->prepend = true; }
610 };
611 
613 template <>
615 
616 template <typename... Ts>
617 struct process_attribute<call_guard<Ts...>> : process_attribute_default<call_guard<Ts...>> {};
618 
624 template <size_t Nurse, size_t Patient>
625 struct process_attribute<keep_alive<Nurse, Patient>>
626  : public process_attribute_default<keep_alive<Nurse, Patient>> {
627  template <size_t N = Nurse, size_t P = Patient, enable_if_t<N != 0 && P != 0, int> = 0>
628  static void precall(function_call &call) {
629  keep_alive_impl(Nurse, Patient, call, handle());
630  }
631  template <size_t N = Nurse, size_t P = Patient, enable_if_t<N != 0 && P != 0, int> = 0>
632  static void postcall(function_call &, handle) {}
633  template <size_t N = Nurse, size_t P = Patient, enable_if_t<N == 0 || P == 0, int> = 0>
634  static void precall(function_call &) {}
635  template <size_t N = Nurse, size_t P = Patient, enable_if_t<N == 0 || P == 0, int> = 0>
636  static void postcall(function_call &call, handle ret) {
637  keep_alive_impl(Nurse, Patient, call, ret);
638  }
639 };
640 
642 template <typename... Args>
644  static void init(const Args &...args, function_record *r) {
647  using expander = int[];
648  (void) expander{
649  0, ((void) process_attribute<typename std::decay<Args>::type>::init(args, r), 0)...};
650  }
651  static void init(const Args &...args, type_record *r) {
654  using expander = int[];
655  (void) expander{0,
657  }
658  static void precall(function_call &call) {
660  using expander = int[];
661  (void) expander{0,
663  }
664  static void postcall(function_call &call, handle fn_ret) {
667  using expander = int[];
668  (void) expander{
670  }
671 };
672 
673 template <typename T>
675 
677 template <typename... Extra>
679 
681 template <typename... Extra,
684 constexpr bool expected_num_args(size_t nargs, bool has_args, bool has_kwargs) {
685  PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(nargs, has_args, has_kwargs);
686  return named == 0 || (self + named + size_t(has_args) + size_t(has_kwargs)) == nargs;
687 }
688 
buffer_protocol
Annotation which enables the buffer protocol for a type.
Definition: attr.h:82
gtsam.examples.DogLegOptimizerExample.int
int
Definition: DogLegOptimizerExample.py:111
type_record::doc
const char * doc
Optional docstring.
Definition: attr.h:308
function_record::is_new_style_constructor
bool is_new_style_constructor
True if this is a new-style __init__ defined in detail/init.h
Definition: attr.h:225
return_value_policy::move
@ move
process_attribute< arg >::init
static void init(const arg &a, function_record *r)
Definition: attr.h:477
process_attribute< doc >::init
static void init(const doc &n, function_record *r)
Definition: attr.h:401
process_attribute_default
Definition: attr.h:384
is_instantiation
Definition: wrap/pybind11/include/pybind11/detail/common.h:936
is_setter
Annotation for setters.
Definition: attr.h:30
name
Annotation for function names.
Definition: attr.h:51
function_record
Definition: attr.h:191
base
Annotation indicating that a class derives from another given type.
Definition: attr.h:64
process_attribute< dynamic_attr >::init
static void init(const dynamic_attr &, type_record *r)
Definition: attr.h:576
function_record::scope
handle scope
Python handle to the parent scope (a class or a module)
Definition: attr.h:262
cast.h
append_self_arg_if_needed
void append_self_arg_if_needed(function_record *r)
Definition: attr.h:468
process_attribute< name >::init
static void init(const name &n, function_record *r)
Definition: attr.h:395
function_record::sibling
handle sibling
Python handle to the sibling function representing an overload chain.
Definition: attr.h:265
gtsam.examples.DogLegOptimizerExample.type
type
Definition: DogLegOptimizerExample.py:111
custom_type_setup::callback
std::function< void(PyHeapTypeObject *heap_type)> callback
Definition: attr.h:105
sibling::value
handle value
Definition: attr.h:58
scope
Annotation for parent scope.
Definition: attr.h:39
base::PYBIND11_DEPRECATED
PYBIND11_DEPRECATED("base<T>() was deprecated in favor of specifying 'T' as a template argument to class_") base()=default
s
RealScalar s
Definition: level1_cplx_impl.h:126
d
static const double d[K][N]
Definition: igam.h:11
function_record::nargs
std::uint16_t nargs
Number of arguments (including py::args and/or py::kwargs, if present)
Definition: attr.h:249
return_value_policy
return_value_policy
Approach used to cast a previously unknown C++ instance into a Python object.
Definition: wrap/pybind11/include/pybind11/detail/common.h:499
list
Definition: pytypes.h:2166
type_record::dynamic_attr
bool dynamic_attr
Does the class manage a dict?
Definition: attr.h:320
custom_type_setup::custom_type_setup
custom_type_setup(callback value)
Definition: attr.h:107
process_attribute< return_value_policy >::init
static void init(const return_value_policy &p, function_record *r)
Definition: attr.h:416
multiple_inheritance
Annotation indicating that a class is involved in a multiple inheritance relationship.
Definition: attr.h:76
is_final
Annotation for classes that cannot be subclassed.
Definition: attr.h:36
is_operator
Annotation for operators.
Definition: attr.h:33
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
clean_type_id
PYBIND11_NOINLINE void clean_type_id(std::string &name)
Definition: typeid.h:35
constexpr_sum
constexpr size_t constexpr_sum()
Compile-time integer sum.
Definition: wrap/pybind11/include/pybind11/detail/common.h:828
process_attribute< arg_v >::init
static void init(const arg_v &a, function_record *r)
Definition: attr.h:488
argument_record::argument_record
argument_record(const char *name, const char *descr, handle value, bool convert, bool none)
Definition: attr.h:185
process_attribute< const char * >::init
static void init(const char *d, function_record *r)
Definition: attr.h:407
process_attribute< metaclass >::init
static void init(const metaclass &m, type_record *r)
Definition: attr.h:598
check_kw_only_arg
void check_kw_only_arg(const arg &a, function_record *r)
Definition: attr.h:461
process_attributes::init
static void init(const Args &...args, type_record *r)
Definition: attr.h:651
ret
DenseIndex ret
Definition: level1_cplx_impl.h:44
is_method::class_
handle class_
Definition: attr.h:25
PYBIND11_NAMESPACE_END
#define PYBIND11_NAMESPACE_END(name)
Definition: wrap/pybind11/include/pybind11/detail/common.h:80
module_local::module_local
constexpr module_local(bool v=true)
Definition: attr.h:115
PYBIND11_NOINLINE
#define PYBIND11_NOINLINE
Definition: wrap/pybind11/include/pybind11/detail/common.h:194
module_local::value
const bool value
Definition: attr.h:114
type
Definition: pytypes.h:1525
T
Eigen::Triplet< double > T
Definition: Tutorial_sparse_example.cpp:6
metaclass::value
handle value
Definition: attr.h:86
function_record::has_kwargs
bool has_kwargs
True if the function has a '**kwargs' argument.
Definition: attr.h:243
detail
Definition: testSerializationNonlinear.cpp:70
function_call::function_call
function_call(const function_record &f, handle p)
Definition: attr.h:366
type_record::init_instance
void(* init_instance)(instance *, const void *)
Function pointer to class_<..>::init_instance.
Definition: attr.h:299
PYBIND11_NAMESPACE_BEGIN
#define PYBIND11_NAMESPACE_BEGIN(name)
Definition: wrap/pybind11/include/pybind11/detail/common.h:76
argument_record::value
handle value
Associated Python object.
Definition: attr.h:181
doc::doc
doc(const char *value)
Definition: attr.h:47
op_
Operator implementation generator.
Definition: attr.h:174
h
const double h
Definition: testSimpleHelicopter.cpp:19
function_record::policy
return_value_policy policy
Return value policy associated with this function.
Definition: attr.h:219
process_attribute< keep_alive< Nurse, Patient > >::precall
static void precall(function_call &)
Definition: attr.h:634
type_record::holder_size
size_t holder_size
How large is the type's holder?
Definition: attr.h:293
process_attribute< base< T > >::init
static void init(const base< T > &, type_record *r)
Definition: attr.h:563
op_id
op_id
Enumeration with all supported operator types.
Definition: operators.h:18
is_method
Annotation for methods.
Definition: attr.h:24
arithmetic
Annotation to mark enums as an arithmetic type.
Definition: attr.h:119
function_record::data
void * data[3]
Storage for the wrapped function pointer and captured data, if any.
Definition: attr.h:213
descr
Definition: descr.h:25
function_record::def
PyMethodDef * def
Python method object.
Definition: attr.h:259
type_record::module_local
bool module_local
Is the class definition local to the module shared object?
Definition: attr.h:329
process_attribute< T, enable_if_t< is_pyobject< T >::value > >::init
static void init(const handle &h, type_record *r)
Definition: attr.h:557
process_attribute
Definition: attr.h:381
argument_record
Internal data structure which holds metadata about a keyword argument.
Definition: attr.h:178
type_record::default_holder
bool default_holder
Is the default (unique_ptr) holder type used?
Definition: attr.h:326
instance
The 'instance' type which needs to be standard layout (need to be able to use 'offsetof')
Definition: wrap/pybind11/include/pybind11/detail/common.h:583
function_call
Internal data associated with a single function call.
Definition: cast.h:1537
argument_record::name
const char * name
Argument name.
Definition: attr.h:179
n
int n
Definition: BiCGSTAB_simple.cpp:1
prepend
Mark a function for addition at the beginning of the existing overload chain instead of the end.
Definition: attr.h:122
sibling
Annotation indicating that a function is an overload associated with a given "sibling".
Definition: attr.h:57
type_record::metaclass
handle metaclass
Custom metaclass (optional)
Definition: attr.h:311
process_attribute_default::init
static void init(const T &, type_record *)
Definition: attr.h:387
argument_record::convert
bool convert
True if the argument is allowed to convert when loading.
Definition: attr.h:182
doc
Annotation for documentation.
Definition: attr.h:45
type_record::multiple_inheritance
bool multiple_inheritance
Multiple inheritance marker.
Definition: attr.h:317
dynamic_attr
Annotation which enables dynamic attributes, i.e. adds __dict__ to a class.
Definition: attr.h:79
class_
Definition: pybind11.h:1588
exactly_one_t
typename exactly_one< Predicate, Default, Ts... >::type exactly_one_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:889
function_record::is_method
bool is_method
True if this is a method.
Definition: attr.h:234
return_value_policy::automatic
@ automatic
undefined_t
Type for an unused type slot.
Definition: operators.h:75
handle
Definition: pytypes.h:226
process_attribute< pos_only >::init
static void init(const pos_only &, function_record *r)
Definition: attr.h:542
function_record::impl
handle(* impl)(function_call &)
Pointer to lambda function which converts arguments and performs the actual call.
Definition: attr.h:210
process_attribute< keep_alive< Nurse, Patient > >::postcall
static void postcall(function_call &, handle)
Definition: attr.h:632
arg_v
Definition: cast.h:1439
process_attribute< kw_only >::init
static void init(const kw_only &, function_record *r)
Definition: attr.h:529
function_record::nargs_pos
std::uint16_t nargs_pos
Definition: attr.h:253
name::value
const char * value
Definition: attr.h:52
type_record::bases
list bases
List of base classes of the newly created type.
Definition: attr.h:305
extract_guard_t
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:678
is_new_style_constructor
Tag for a new-style __init__ defined in detail/init.h
Definition: attr.h:372
metaclass
Annotation which requests that a special metaclass is created for a type.
Definition: attr.h:85
process_attribute< const char * >
Process an attribute specifying the function's docstring (provided as a C-style string)
Definition: attr.h:406
function_record::signature
char * signature
Human-readable version of the function signature.
Definition: attr.h:204
function_record::prepend
bool prepend
True if this function is to be inserted at the beginning of the overload resolution chain.
Definition: attr.h:246
type_record
Special data structure which (temporarily) holds metadata about a bound class.
Definition: attr.h:272
l
static const Line3 l(Rot3(), 1, 1)
arg
Definition: cast.h:1412
module_local
Annotation that marks a class as local to the module:
Definition: attr.h:113
process_attribute< prepend >::init
static void init(const prepend &, function_record *r)
Definition: attr.h:609
process_attribute< is_method >::init
static void init(const is_method &s, function_record *r)
Definition: attr.h:429
process_attributes::postcall
static void postcall(function_call &call, handle fn_ret)
Definition: attr.h:664
process_attribute< is_new_style_constructor >::init
static void init(const is_new_style_constructor &, function_record *r)
Definition: attr.h:456
keep_alive
Keep patient alive while nurse lives.
Definition: attr.h:73
function_record::nargs_pos_only
std::uint16_t nargs_pos_only
Number of leading arguments (counted in nargs) that are positional-only.
Definition: attr.h:256
function_record::is_constructor
bool is_constructor
True if name == 'init'.
Definition: attr.h:222
process_attribute< is_operator >::init
static void init(const is_operator &, function_record *r)
Definition: attr.h:450
type_record::add_base
PYBIND11_NOINLINE void add_base(const std::type_info &base, void *(*caster)(void *))
Definition: attr.h:334
function_record::next
function_record * next
Pointer to next overload.
Definition: attr.h:268
get_type_info
PYBIND11_NOINLINE detail::type_info * get_type_info(PyTypeObject *type)
Definition: type_caster_base.h:188
argument_record::descr
const char * descr
Human-readable version of the argument value.
Definition: attr.h:180
process_attribute_default::precall
static void precall(function_call &)
Definition: attr.h:388
scope::scope
scope(const handle &s)
Definition: attr.h:41
process_attribute< keep_alive< Nurse, Patient > >::postcall
static void postcall(function_call &call, handle ret)
Definition: attr.h:636
PYBIND11_NAMESPACE
Definition: test_custom_type_casters.cpp:24
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
Eigen::Triplet< double >
common.h
function_record::doc
char * doc
Definition: attr.h:201
process_attribute< keep_alive< Nurse, Patient > >::precall
static void precall(function_call &call)
Definition: attr.h:628
pybind11_fail
PyExc_RuntimeError PYBIND11_NOINLINE void pybind11_fail(const char *reason)
Used internally.
Definition: wrap/pybind11/include/pybind11/detail/common.h:1026
kw_only
Definition: cast.h:1495
argument_record::none
bool none
True if None is allowed when loading.
Definition: attr.h:183
size_t
std::size_t size_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:490
function_record::has_args
bool has_args
True if the function has a '*args' argument.
Definition: attr.h:240
function_record::is_stateless
bool is_stateless
True if this is a stateless function pointer.
Definition: attr.h:228
tree::f
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Definition: testExpression.cpp:218
custom_type_setup
Definition: attr.h:104
type_record::is_final
bool is_final
Is the class inheritable from python classes?
Definition: attr.h:332
function_record::is_operator
bool is_operator
True if this is an operator (add), etc.
Definition: attr.h:231
process_attributes
Recursively iterate over variadic template arguments.
Definition: attr.h:643
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100
#define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...)
Definition: wrap/pybind11/include/pybind11/detail/common.h:1230
call_guard
Definition: attr.h:143
benchmark.nargs
nargs
Definition: benchmark.py:8
function_record::args
std::vector< argument_record > args
List of registered keyword arguments.
Definition: attr.h:207
type_record::dealloc
void(* dealloc)(detail::value_and_holder &)
Function pointer to class_<..>::dealloc.
Definition: attr.h:302
std
Definition: BFloat16.h:88
args
Definition: pytypes.h:2210
p
float * p
Definition: Tutorial_Map_using.cpp:9
doc::value
const char * value
Definition: attr.h:46
uint16_t
unsigned short uint16_t
Definition: ms_stdint.h:84
process_attribute< scope >::init
static void init(const scope &s, function_record *r)
Definition: attr.h:444
process_attribute_default::init
static void init(const T &, function_record *)
Default implementation: do nothing.
Definition: attr.h:386
is_pyobject
std::is_base_of< pyobject_tag, remove_reference_t< T > > is_pyobject
Definition: pytypes.h:73
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
list::append
void append(T &&val)
Definition: pytypes.h:2187
function_record::free_data
void(* free_data)(function_record *ptr)
Pointer to custom destructor for 'data' (if needed)
Definition: attr.h:216
process_attribute< buffer_protocol >::init
static void init(const buffer_protocol &, type_record *r)
Definition: attr.h:593
name::name
name(const char *value)
Definition: attr.h:53
function_record::function_record
function_record()
Definition: attr.h:192
type_record::type_align
size_t type_align
What is the alignment of the underlying C++ type?
Definition: attr.h:290
keep_alive_impl
void keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret)
Definition: pybind11.h:2349
pos_only
Definition: cast.h:1500
type_record::scope
handle scope
Handle to the parent scope.
Definition: attr.h:278
process_attribute< is_setter >::init
static void init(const is_setter &, function_record *r)
Definition: attr.h:438
type_record::buffer_protocol
bool buffer_protocol
Does the class implement the buffer protocol?
Definition: attr.h:323
process_attribute< const char * >::init
static void init(const char *d, type_record *r)
Definition: attr.h:408
process_attribute< module_local >::init
static void init(const module_local &l, type_record *r)
Definition: attr.h:603
type_record::type_size
size_t type_size
How large is the underlying C++ type?
Definition: attr.h:287
function_record::name
char * name
Function name.
Definition: attr.h:198
sibling::sibling
sibling(const handle &value)
Definition: attr.h:59
PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER
#define PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(...)
Definition: wrap/pybind11/include/pybind11/detail/common.h:1238
process_attribute< sibling >::init
static void init(const sibling &s, function_record *r)
Definition: attr.h:423
type_record::type_record
PYBIND11_NOINLINE type_record()
Definition: attr.h:273
PYBIND11_DEPRECATED
PYBIND11_DEPRECATED("make_simple_namespace should be replaced with " "py::module_::import(\"types\").attr(\"SimpleNamespace\") ") object make_simple_namespace(Args &&...args_)
Definition: pybind11.h:1384
process_attributes::precall
static void precall(function_call &call)
Definition: attr.h:658
scope::value
handle value
Definition: attr.h:40
function_record::is_setter
bool is_setter
True if this is a setter.
Definition: attr.h:237
process_attribute< is_final >::init
static void init(const is_final &, type_record *r)
Definition: attr.h:588
none
Definition: pytypes.h:1786
func
Definition: benchGeometry.cpp:23
gtsam.examples.DogLegOptimizerExample.default
default
Definition: DogLegOptimizerExample.py:111
expected_num_args
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:684
is_method::is_method
is_method(const handle &c)
Definition: attr.h:26
process_attributes::init
static void init(const Args &...args, function_record *r)
Definition: attr.h:644
process_attribute_default::postcall
static void postcall(function_call &, handle)
Definition: attr.h:389
gtsam.examples.ShonanAveragingCLI.str
str
Definition: ShonanAveragingCLI.py:115
enable_if_t
typename std::enable_if< B, T >::type enable_if_t
from cpp_future import (convenient aliases from C++14/17)
Definition: wrap/pybind11/include/pybind11/detail/common.h:654
test_callbacks.value
value
Definition: test_callbacks.py:160
op_type
op_type
Definition: operators.h:65
process_attribute< multiple_inheritance >::init
static void init(const multiple_inheritance &, type_record *r)
Definition: attr.h:569
function_call::args_convert
std::vector< bool > args_convert
The convert value the arguments should be loaded with.
Definition: cast.h:1547
custom_type_setup::value
callback value
Definition: attr.h:109
process_attribute< custom_type_setup >::init
static void init(const custom_type_setup &value, type_record *r)
Definition: attr.h:581
type_record::custom_type_setup_callback
custom_type_setup::callback custom_type_setup_callback
Custom type setup.
Definition: attr.h:314


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:01:52