-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path0003-v4.1.0.5-python-update-to-pybind11-for-Python-3.11.patch
20155 lines (17820 loc) · 758 KB
/
0003-v4.1.0.5-python-update-to-pybind11-for-Python-3.11.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From a0cf4634ab2d8df4ca68f621cec4c216306a5caf Mon Sep 17 00:00:00 2001
From: Steven Koo <[email protected]>
Date: Mon, 8 Aug 2022 17:11:06 -0500
Subject: [PATCH] python: update to pybind11 for Python 3.11
Python 3.11 did not build correctly with previous versions of pybind11.
This updates the headers to pybind 2.10.0, which does.
Signed-off-by: Steven Koo <[email protected]>
---
host/lib/deps/pybind11/LICENSE | 2 +-
host/lib/deps/pybind11/README.md | 2 +-
.../lib/deps/pybind11/include/pybind11/attr.h | 347 ++-
.../pybind11/include/pybind11/buffer_info.h | 127 +-
.../lib/deps/pybind11/include/pybind11/cast.h | 2119 ++++++----------
.../deps/pybind11/include/pybind11/chrono.h | 160 +-
.../deps/pybind11/include/pybind11/complex.h | 31 +-
.../pybind11/include/pybind11/detail/class.h | 288 ++-
.../pybind11/include/pybind11/detail/common.h | 945 ++++---
.../pybind11/include/pybind11/detail/descr.h | 108 +-
.../pybind11/include/pybind11/detail/init.h | 282 ++-
.../include/pybind11/detail/internals.h | 419 +++-
.../pybind11/detail/type_caster_base.h | 973 ++++++++
.../pybind11/include/pybind11/detail/typeid.h | 30 +-
.../deps/pybind11/include/pybind11/eigen.h | 467 ++--
.../deps/pybind11/include/pybind11/embed.h | 166 +-
.../lib/deps/pybind11/include/pybind11/eval.h | 102 +-
.../pybind11/include/pybind11/functional.h | 70 +-
host/lib/deps/pybind11/include/pybind11/gil.h | 177 ++
.../deps/pybind11/include/pybind11/iostream.h | 116 +-
.../deps/pybind11/include/pybind11/numpy.h | 1353 ++++++----
.../pybind11/include/pybind11/operators.h | 252 +-
.../deps/pybind11/include/pybind11/options.h | 37 +-
.../deps/pybind11/include/pybind11/pybind11.h | 2185 ++++++++++-------
.../deps/pybind11/include/pybind11/pytypes.h | 1627 ++++++++----
host/lib/deps/pybind11/include/pybind11/stl.h | 269 +-
.../include/pybind11/stl/filesystem.h | 122 +
.../deps/pybind11/include/pybind11/stl_bind.h | 657 +++--
28 files changed, 8517 insertions(+), 4916 deletions(-)
create mode 100644 host/lib/deps/pybind11/include/pybind11/detail/type_caster_base.h
create mode 100644 host/lib/deps/pybind11/include/pybind11/gil.h
create mode 100644 host/lib/deps/pybind11/include/pybind11/stl/filesystem.h
diff --git a/host/lib/deps/pybind11/LICENSE b/host/lib/deps/pybind11/LICENSE
index 6f15578cc..e466b0dfd 100644
--- a/host/lib/deps/pybind11/LICENSE
+++ b/host/lib/deps/pybind11/LICENSE
@@ -25,5 +25,5 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-Please also refer to the file CONTRIBUTING.md, which clarifies licensing of
+Please also refer to the file .github/CONTRIBUTING.md, which clarifies licensing of
external contributions to this project including patches, pull requests, etc.
diff --git a/host/lib/deps/pybind11/README.md b/host/lib/deps/pybind11/README.md
index 6622895b2..8a18dcf36 100644
--- a/host/lib/deps/pybind11/README.md
+++ b/host/lib/deps/pybind11/README.md
@@ -1,6 +1,6 @@
# PyBind11: Third-Party Dependency for UHD
-Version: 2.6.1 (git hash: f1abf5d)
+Version: 2.10.0 (git hash: aa304c9)
PyBind11 is a replacement for Boost.Python. Unlike Boost.Python, however, we
ship it with the UHD repository instead of relying on it to be there external to
diff --git a/host/lib/deps/pybind11/include/pybind11/attr.h b/host/lib/deps/pybind11/include/pybind11/attr.h
index ac75a4531..9ea6eea00 100644
--- a/host/lib/deps/pybind11/include/pybind11/attr.h
+++ b/host/lib/deps/pybind11/include/pybind11/attr.h
@@ -8,77 +8,122 @@
#pragma once
+#include "detail/common.h"
#include "cast.h"
+#include <functional>
+
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
-struct is_method { handle class_; is_method(const handle &c) : class_(c) { } };
+struct is_method {
+ handle class_;
+ explicit is_method(const handle &c) : class_(c) {}
+};
-struct is_operator { };
+struct is_operator {};
-struct is_final { };
+struct is_final {};
-struct scope { handle value; scope(const handle &s) : value(s) { } };
+struct scope {
+ handle value;
+ explicit scope(const handle &s) : value(s) {}
+};
-struct doc { const char *value; doc(const char *value) : value(value) { } };
+struct doc {
+ const char *value;
+ explicit doc(const char *value) : value(value) {}
+};
-struct name { const char *value; name(const char *value) : value(value) { } };
+struct name {
+ const char *value;
+ explicit name(const char *value) : value(value) {}
+};
-struct sibling { handle value; sibling(const handle &value) : value(value.ptr()) { } };
+struct sibling {
+ handle value;
+ explicit sibling(const handle &value) : value(value.ptr()) {}
+};
-template <typename T> struct base {
+template <typename T>
+struct base {
- PYBIND11_DEPRECATED("base<T>() was deprecated in favor of specifying 'T' as a template argument to class_")
- base() { }
+ PYBIND11_DEPRECATED(
+ "base<T>() was deprecated in favor of specifying 'T' as a template argument to class_")
+ base() = default;
};
-template <size_t Nurse, size_t Patient> struct keep_alive { };
+template <size_t Nurse, size_t Patient>
+struct keep_alive {};
-struct multiple_inheritance { };
+struct multiple_inheritance {};
-struct dynamic_attr { };
+struct dynamic_attr {};
-struct buffer_protocol { };
+struct buffer_protocol {};
struct metaclass {
handle value;
PYBIND11_DEPRECATED("py::metaclass() is no longer required. It's turned on by default now.")
- metaclass() { }
+ metaclass() = default;
+
+
+ explicit metaclass(handle value) : value(value) {}
+};
+
+
+
+
+
+
- explicit metaclass(handle value) : value(value) { }
+
+
+struct custom_type_setup {
+ using callback = std::function<void(PyHeapTypeObject *heap_type)>;
+
+ explicit custom_type_setup(callback value) : value(std::move(value)) {}
+
+ callback value;
};
-struct module_local { const bool value; constexpr module_local(bool v = true) : value(v) { } };
+struct module_local {
+ const bool value;
+ constexpr explicit module_local(bool v = true) : value(v) {}
+};
-struct arithmetic { };
+struct arithmetic {};
-struct prepend { };
+struct prepend {};
-template <typename... Ts> struct call_guard;
+template <typename... Ts>
+struct call_guard;
-template <> struct call_guard<> { using type = detail::void_type; };
+template <>
+struct call_guard<> {
+ using type = detail::void_type;
+};
template <typename T>
struct call_guard<T> {
@@ -103,8 +148,9 @@ PYBIND11_NAMESPACE_BEGIN(detail)
enum op_id : int;
enum op_type : int;
struct undefined_t;
-template <op_id id, op_type ot, typename L = undefined_t, typename R = undefined_t> struct op_;
-inline void keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret);
+template <op_id id, op_type ot, typename L = undefined_t, typename R = undefined_t>
+struct op_;
+void keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret);
struct argument_record {
@@ -115,15 +161,16 @@ struct argument_record {
bool none : 1;
argument_record(const char *name, const char *descr, handle value, bool convert, bool none)
- : name(name), descr(descr), value(value), convert(convert), none(none) { }
+ : name(name), descr(descr), value(value), convert(convert), none(none) {}
};
+
struct function_record {
function_record()
: is_constructor(false), is_new_style_constructor(false), is_stateless(false),
- is_operator(false), is_method(false), has_args(false),
- has_kwargs(false), has_kw_only_args(false), prepend(false) { }
+ is_operator(false), is_method(false), has_args(false), has_kwargs(false),
+ prepend(false) {}
char *name = nullptr;
@@ -138,13 +185,13 @@ struct function_record {
std::vector<argument_record> args;
- handle (*impl) (function_call &) = nullptr;
+ handle (*impl)(function_call &) = nullptr;
- void *data[3] = { };
+ void *data[3] = {};
- void (*free_data) (function_record *ptr) = nullptr;
+ void (*free_data)(function_record *ptr) = nullptr;
return_value_policy policy = return_value_policy::automatic;
@@ -171,16 +218,14 @@ struct function_record {
bool has_kwargs : 1;
- bool has_kw_only_args : 1;
-
-
bool prepend : 1;
std::uint16_t nargs;
- std::uint16_t nargs_kw_only = 0;
+
+ std::uint16_t nargs_pos = 0;
std::uint16_t nargs_pos_only = 0;
@@ -202,7 +247,7 @@ struct function_record {
struct type_record {
PYBIND11_NOINLINE type_record()
: multiple_inheritance(false), dynamic_attr(false), buffer_protocol(false),
- default_holder(true), module_local(false), is_final(false) { }
+ default_holder(true), module_local(false), is_final(false) {}
handle scope;
@@ -241,6 +286,9 @@ struct type_record {
handle metaclass;
+ custom_type_setup::callback custom_type_setup_callback;
+
+
bool multiple_inheritance : 1;
@@ -258,167 +306,218 @@ struct type_record {
bool is_final : 1;
- PYBIND11_NOINLINE void add_base(const std::type_info &base, void *(*caster)(void *)) {
- auto base_info = detail::get_type_info(base, false);
+ PYBIND11_NOINLINE void add_base(const std::type_info &base, void *(*caster)(void *) ) {
+ auto *base_info = detail::get_type_info(base, false);
if (!base_info) {
std::string tname(base.name());
detail::clean_type_id(tname);
- pybind11_fail("generic_type: type \"" + std::string(name) +
- "\" referenced unknown base type \"" + tname + "\"");
+ pybind11_fail("generic_type: type \"" + std::string(name)
+ + "\" referenced unknown base type \"" + tname + "\"");
}
if (default_holder != base_info->default_holder) {
std::string tname(base.name());
detail::clean_type_id(tname);
- pybind11_fail("generic_type: type \"" + std::string(name) + "\" " +
- (default_holder ? "does not have" : "has") +
- " a non-default holder type while its base \"" + tname + "\" " +
- (base_info->default_holder ? "does not" : "does"));
+ pybind11_fail("generic_type: type \"" + std::string(name) + "\" "
+ + (default_holder ? "does not have" : "has")
+ + " a non-default holder type while its base \"" + tname + "\" "
+ + (base_info->default_holder ? "does not" : "does"));
}
bases.append((PyObject *) base_info->type);
- if (base_info->type->tp_dictoffset != 0)
- dynamic_attr = true;
+#if PY_VERSION_HEX < 0x030B0000
+ dynamic_attr |= base_info->type->tp_dictoffset != 0;
+#else
+ dynamic_attr |= (base_info->type->tp_flags & Py_TPFLAGS_MANAGED_DICT) != 0;
+#endif
- if (caster)
+ if (caster) {
base_info->implicit_casts.emplace_back(type, caster);
+ }
}
};
-inline function_call::function_call(const function_record &f, handle p) :
- func(f), parent(p) {
+inline function_call::function_call(const function_record &f, handle p) : func(f), parent(p) {
args.reserve(f.nargs);
args_convert.reserve(f.nargs);
}
-struct is_new_style_constructor { };
+struct is_new_style_constructor {};
-template <typename T, typename SFINAE = void> struct process_attribute;
+template <typename T, typename SFINAE = void>
+struct process_attribute;
-template <typename T> struct process_attribute_default {
+template <typename T>
+struct process_attribute_default {
- static void init(const T &, function_record *) { }
- static void init(const T &, type_record *) { }
- static void precall(function_call &) { }
- static void postcall(function_call &, handle) { }
+ static void init(const T &, function_record *) {}
+ static void init(const T &, type_record *) {}
+ static void precall(function_call &) {}
+ static void postcall(function_call &, handle) {}
};
-template <> struct process_attribute<name> : process_attribute_default<name> {
+template <>
+struct process_attribute<name> : process_attribute_default<name> {
static void init(const name &n, function_record *r) { r->name = const_cast<char *>(n.value); }
};
-template <> struct process_attribute<doc> : process_attribute_default<doc> {
+template <>
+struct process_attribute<doc> : process_attribute_default<doc> {
static void init(const doc &n, function_record *r) { r->doc = const_cast<char *>(n.value); }
};
-template <> struct process_attribute<const char *> : process_attribute_default<const char *> {
+template <>
+struct process_attribute<const char *> : process_attribute_default<const char *> {
static void init(const char *d, function_record *r) { r->doc = const_cast<char *>(d); }
static void init(const char *d, type_record *r) { r->doc = const_cast<char *>(d); }
};
-template <> struct process_attribute<char *> : process_attribute<const char *> { };
+template <>
+struct process_attribute<char *> : process_attribute<const char *> {};
-template <> struct process_attribute<return_value_policy> : process_attribute_default<return_value_policy> {
+template <>
+struct process_attribute<return_value_policy> : process_attribute_default<return_value_policy> {
static void init(const return_value_policy &p, function_record *r) { r->policy = p; }
};
-template <> struct process_attribute<sibling> : process_attribute_default<sibling> {
+
+template <>
+struct process_attribute<sibling> : process_attribute_default<sibling> {
static void init(const sibling &s, function_record *r) { r->sibling = s.value; }
};
-template <> struct process_attribute<is_method> : process_attribute_default<is_method> {
- static void init(const is_method &s, function_record *r) { r->is_method = true; r->scope = s.class_; }
+template <>
+struct process_attribute<is_method> : process_attribute_default<is_method> {
+ static void init(const is_method &s, function_record *r) {
+ r->is_method = true;
+ r->scope = s.class_;
+ }
};
-template <> struct process_attribute<scope> : process_attribute_default<scope> {
+template <>
+struct process_attribute<scope> : process_attribute_default<scope> {
static void init(const scope &s, function_record *r) { r->scope = s.value; }
};
-template <> struct process_attribute<is_operator> : process_attribute_default<is_operator> {
+template <>
+struct process_attribute<is_operator> : process_attribute_default<is_operator> {
static void init(const is_operator &, function_record *r) { r->is_operator = true; }
};
-template <> struct process_attribute<is_new_style_constructor> : process_attribute_default<is_new_style_constructor> {
- static void init(const is_new_style_constructor &, function_record *r) { r->is_new_style_constructor = true; }
+template <>
+struct process_attribute<is_new_style_constructor>
+ : process_attribute_default<is_new_style_constructor> {
+ static void init(const is_new_style_constructor &, function_record *r) {
+ r->is_new_style_constructor = true;
+ }
};
-inline void process_kw_only_arg(const arg &a, function_record *r) {
- if (!a.name || strlen(a.name) == 0)
- pybind11_fail("arg(): cannot specify an unnamed argument after an kw_only() annotation");
- ++r->nargs_kw_only;
+inline void check_kw_only_arg(const arg &a, function_record *r) {
+ if (r->args.size() > r->nargs_pos && (!a.name || a.name[0] == '\0')) {
+ pybind11_fail("arg(): cannot specify an unnamed argument after a kw_only() annotation or "
+ "args() argument");
+ }
}
+inline void append_self_arg_if_needed(function_record *r) {
+ if (r->is_method && r->args.empty()) {
+ r->args.emplace_back("self", nullptr, handle(), true, false);
+ }
+}
-template <> struct process_attribute<arg> : process_attribute_default<arg> {
+
+template <>
+struct process_attribute<arg> : process_attribute_default<arg> {
static void init(const arg &a, function_record *r) {
- if (r->is_method && r->args.empty())
- r->args.emplace_back("self", nullptr, handle(), true , false );
+ append_self_arg_if_needed(r);
r->args.emplace_back(a.name, nullptr, handle(), !a.flag_noconvert, a.flag_none);
- if (r->has_kw_only_args) process_kw_only_arg(a, r);
+ check_kw_only_arg(a, r);
}
};
-template <> struct process_attribute<arg_v> : process_attribute_default<arg_v> {
+template <>
+struct process_attribute<arg_v> : process_attribute_default<arg_v> {
static void init(const arg_v &a, function_record *r) {
- if (r->is_method && r->args.empty())
- r->args.emplace_back("self", nullptr , handle() , true , false );
+ if (r->is_method && r->args.empty()) {
+ r->args.emplace_back(
+ "self", nullptr, handle(), true, false);
+ }
if (!a.value) {
-#if !defined(NDEBUG)
+#if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
std::string descr("'");
- if (a.name) descr += std::string(a.name) + ": ";
+ if (a.name) {
+ descr += std::string(a.name) + ": ";
+ }
descr += a.type + "'";
if (r->is_method) {
- if (r->name)
- descr += " in method '" + (std::string) str(r->scope) + "." + (std::string) r->name + "'";
- else
+ if (r->name) {
+ descr += " in method '" + (std::string) str(r->scope) + "."
+ + (std::string) r->name + "'";
+ } else {
descr += " in method of '" + (std::string) str(r->scope) + "'";
+ }
} else if (r->name) {
descr += " in function '" + (std::string) r->name + "'";
}
- pybind11_fail("arg(): could not convert default argument "
- + descr + " into a Python object (type not registered yet?)");
+ pybind11_fail("arg(): could not convert default argument " + descr
+ + " into a Python object (type not registered yet?)");
#else
pybind11_fail("arg(): could not convert default argument "
"into a Python object (type not registered yet?). "
- "Compile in debug mode for more information.");
+ "#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for "
+ "more information.");
#endif
}
r->args.emplace_back(a.name, a.descr, a.value.inc_ref(), !a.flag_noconvert, a.flag_none);
- if (r->has_kw_only_args) process_kw_only_arg(a, r);
+ check_kw_only_arg(a, r);
}
};
-template <> struct process_attribute<kw_only> : process_attribute_default<kw_only> {
+template <>
+struct process_attribute<kw_only> : process_attribute_default<kw_only> {
static void init(const kw_only &, function_record *r) {
- r->has_kw_only_args = true;
+ append_self_arg_if_needed(r);
+ if (r->has_args && r->nargs_pos != static_cast<std::uint16_t>(r->args.size())) {
+ pybind11_fail("Mismatched args() and kw_only(): they must occur at the same relative "
+ "argument location (or omit kw_only() entirely)");
+ }
+ r->nargs_pos = static_cast<std::uint16_t>(r->args.size());
}
};
-template <> struct process_attribute<pos_only> : process_attribute_default<pos_only> {
+template <>
+struct process_attribute<pos_only> : process_attribute_default<pos_only> {
static void init(const pos_only &, function_record *r) {
+ append_self_arg_if_needed(r);
r->nargs_pos_only = static_cast<std::uint16_t>(r->args.size());
+ if (r->nargs_pos_only > r->nargs_pos) {
+ pybind11_fail("pos_only(): cannot follow a py::args() argument");
+ }
+
}
};
+
template <typename T>
-struct process_attribute<T, enable_if_t<is_pyobject<T>::value>> : process_attribute_default<handle> {
+struct process_attribute<T, enable_if_t<is_pyobject<T>::value>>
+ : process_attribute_default<handle> {
static void init(const handle &h, type_record *r) { r->bases.append(h); }
};
@@ -431,7 +530,9 @@ struct process_attribute<base<T>> : process_attribute_default<base<T>> {
template <>
struct process_attribute<multiple_inheritance> : process_attribute_default<multiple_inheritance> {
- static void init(const multiple_inheritance &, type_record *r) { r->multiple_inheritance = true; }
+ static void init(const multiple_inheritance &, type_record *r) {
+ r->multiple_inheritance = true;
+ }
};
template <>
@@ -439,6 +540,13 @@ struct process_attribute<dynamic_attr> : process_attribute_default<dynamic_attr>
static void init(const dynamic_attr &, type_record *r) { r->dynamic_attr = true; }
};
+template <>
+struct process_attribute<custom_type_setup> {
+ static void init(const custom_type_setup &value, type_record *r) {
+ r->custom_type_setup_callback = value.value;
+ }
+};
+
template <>
struct process_attribute<is_final> : process_attribute_default<is_final> {
static void init(const is_final &, type_record *r) { r->is_final = true; }
@@ -470,37 +578,55 @@ template <>
struct process_attribute<arithmetic> : process_attribute_default<arithmetic> {};
template <typename... Ts>
-struct process_attribute<call_guard<Ts...>> : process_attribute_default<call_guard<Ts...>> { };
+struct process_attribute<call_guard<Ts...>> : process_attribute_default<call_guard<Ts...>> {};
-template <size_t Nurse, size_t Patient> struct process_attribute<keep_alive<Nurse, Patient>> : public process_attribute_default<keep_alive<Nurse, Patient>> {
+template <size_t Nurse, size_t Patient>
+struct process_attribute<keep_alive<Nurse, Patient>>
+ : public process_attribute_default<keep_alive<Nurse, Patient>> {
template <size_t N = Nurse, size_t P = Patient, enable_if_t<N != 0 && P != 0, int> = 0>
- static void precall(function_call &call) { keep_alive_impl(Nurse, Patient, call, handle()); }
+ static void precall(function_call &call) {
+ keep_alive_impl(Nurse, Patient, call, handle());
+ }
template <size_t N = Nurse, size_t P = Patient, enable_if_t<N != 0 && P != 0, int> = 0>
- static void postcall(function_call &, handle) { }
+ static void postcall(function_call &, handle) {}
template <size_t N = Nurse, size_t P = Patient, enable_if_t<N == 0 || P == 0, int> = 0>
- static void precall(function_call &) { }
+ static void precall(function_call &) {}
template <size_t N = Nurse, size_t P = Patient, enable_if_t<N == 0 || P == 0, int> = 0>
- static void postcall(function_call &call, handle ret) { keep_alive_impl(Nurse, Patient, call, ret); }
+ static void postcall(function_call &call, handle ret) {
+ keep_alive_impl(Nurse, Patient, call, ret);
+ }
};
-template <typename... Args> struct process_attributes {
- static void init(const Args&... args, function_record *r) {
- int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::init(args, r), 0) ... };
- ignore_unused(unused);
+template <typename... Args>
+struct process_attributes {
+ static void init(const Args &...args, function_record *r) {
+ PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(r);
+ PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(r);
+ using expander = int[];
+ (void) expander{
+ 0, ((void) process_attribute<typename std::decay<Args>::type>::init(args, r), 0)...};
}
- static void init(const Args&... args, type_record *r) {
- int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::init(args, r), 0) ... };
- ignore_unused(unused);
+ static void init(const Args &...args, type_record *r) {
+ PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(r);
+ PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(r);
+ using expander = int[];
+ (void) expander{0,
+ (process_attribute<typename std::decay<Args>::type>::init(args, r), 0)...};
}
static void precall(function_call &call) {
- int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::precall(call), 0) ... };
- ignore_unused(unused);
+ PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(call);
+ using expander = int[];
+ (void) expander{0,
+ (process_attribute<typename std::decay<Args>::type>::precall(call), 0)...};
}
static void postcall(function_call &call, handle fn_ret) {
- int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::postcall(call, fn_ret), 0) ... };
- ignore_unused(unused);
+ PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(call, fn_ret);
+ PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(fn_ret);
+ using expander = int[];
+ (void) expander{
+ 0, (process_attribute<typename std::decay<Args>::type>::postcall(call, fn_ret), 0)...};
}
};
@@ -514,9 +640,10 @@ using extract_guard_t = typename exactly_one_t<is_call_guard, call_guard<>, Extr
template <typename... Extra,
size_t named = constexpr_sum(std::is_base_of<arg, Extra>::value...),
- size_t self = constexpr_sum(std::is_same<is_method, Extra>::value...)>
+ size_t self = constexpr_sum(std::is_same<is_method, Extra>::value...)>
constexpr bool expected_num_args(size_t nargs, bool has_args, bool has_kwargs) {
- return named == 0 || (self + named + has_args + has_kwargs) == nargs;
+ PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(nargs, has_args, has_kwargs);
+ return named == 0 || (self + named + size_t(has_args) + size_t(has_kwargs)) == nargs;
}
PYBIND11_NAMESPACE_END(detail)
diff --git a/host/lib/deps/pybind11/include/pybind11/buffer_info.h b/host/lib/deps/pybind11/include/pybind11/buffer_info.h
index 1f24e16ad..30e99b4cd 100644
--- a/host/lib/deps/pybind11/include/pybind11/buffer_info.h
+++ b/host/lib/deps/pybind11/include/pybind11/buffer_info.h
@@ -18,9 +18,11 @@ PYBIND11_NAMESPACE_BEGIN(detail)
inline std::vector<ssize_t> c_strides(const std::vector<ssize_t> &shape, ssize_t itemsize) {
auto ndim = shape.size();
std::vector<ssize_t> strides(ndim, itemsize);
- if (ndim > 0)
- for (size_t i = ndim - 1; i > 0; --i)
+ if (ndim > 0) {
+ for (size_t i = ndim - 1; i > 0; --i) {
strides[i - 1] = strides[i] * shape[i];
+ }
+ }
return strides;
}
@@ -28,8 +30,9 @@ inline std::vector<ssize_t> c_strides(const std::vector<ssize_t> &shape, ssize_t
inline std::vector<ssize_t> f_strides(const std::vector<ssize_t> &shape, ssize_t itemsize) {
auto ndim = shape.size();
std::vector<ssize_t> strides(ndim, itemsize);
- for (size_t i = 1; i < ndim; ++i)
+ for (size_t i = 1; i < ndim; ++i) {
strides[i] = strides[i - 1] * shape[i - 1];
+ }
return strides;
}
@@ -41,58 +44,86 @@ struct buffer_info {
ssize_t itemsize = 0;
ssize_t size = 0;
std::string format;
+
ssize_t ndim = 0;
std::vector<ssize_t> shape;
std::vector<ssize_t> strides;
+
bool readonly = false;
buffer_info() = default;
- buffer_info(void *ptr, ssize_t itemsize, const std::string &format, ssize_t ndim,
- detail::any_container<ssize_t> shape_in, detail::any_container<ssize_t> strides_in, bool readonly=false)
- : ptr(ptr), itemsize(itemsize), size(1), format(format), ndim(ndim),
- shape(std::move(shape_in)), strides(std::move(strides_in)), readonly(readonly) {
- if (ndim != (ssize_t) shape.size() || ndim != (ssize_t) strides.size())
+ buffer_info(void *ptr,
+ ssize_t itemsize,
+ const std::string &format,
+ ssize_t ndim,
+ detail::any_container<ssize_t> shape_in,
+ detail::any_container<ssize_t> strides_in,
+ bool readonly = false)
+ : ptr(ptr), itemsize(itemsize), size(1), format(format), ndim(ndim),
+ shape(std::move(shape_in)), strides(std::move(strides_in)), readonly(readonly) {
+ if (ndim != (ssize_t) shape.size() || ndim != (ssize_t) strides.size()) {
pybind11_fail("buffer_info: ndim doesn't match shape and/or strides length");
- for (size_t i = 0; i < (size_t) ndim; ++i)
+ }
+ for (size_t i = 0; i < (size_t) ndim; ++i) {
size *= shape[i];
+ }
}
template <typename T>
- buffer_info(T *ptr, detail::any_container<ssize_t> shape_in, detail::any_container<ssize_t> strides_in, bool readonly=false)
- : buffer_info(private_ctr_tag(), ptr, sizeof(T), format_descriptor<T>::format(), static_cast<ssize_t>(shape_in->size()), std::move(shape_in), std::move(strides_in), readonly) { }
-
- buffer_info(void *ptr, ssize_t itemsize, const std::string &format, ssize_t size, bool readonly=false)
- : buffer_info(ptr, itemsize, format, 1, {size}, {itemsize}, readonly) { }
+ buffer_info(T *ptr,
+ detail::any_container<ssize_t> shape_in,
+ detail::any_container<ssize_t> strides_in,
+ bool readonly = false)
+ : buffer_info(private_ctr_tag(),
+ ptr,
+ sizeof(T),
+ format_descriptor<T>::format(),
+ static_cast<ssize_t>(shape_in->size()),
+ std::move(shape_in),
+ std::move(strides_in),
+ readonly) {}
+
+ buffer_info(void *ptr,
+ ssize_t itemsize,
+ const std::string &format,
+ ssize_t size,
+ bool readonly = false)
+ : buffer_info(ptr, itemsize, format, 1, {size}, {itemsize}, readonly) {}
template <typename T>
- buffer_info(T *ptr, ssize_t size, bool readonly=false)
- : buffer_info(ptr, sizeof(T), format_descriptor<T>::format(), size, readonly) { }
+ buffer_info(T *ptr, ssize_t size, bool readonly = false)
+ : buffer_info(ptr, sizeof(T), format_descriptor<T>::format(), size, readonly) {}
template <typename T>
- buffer_info(const T *ptr, ssize_t size, bool readonly=true)
- : buffer_info(const_cast<T*>(ptr), sizeof(T), format_descriptor<T>::format(), size, readonly) { }
+ buffer_info(const T *ptr, ssize_t size, bool readonly = true)
+ : buffer_info(
+ const_cast<T *>(ptr), sizeof(T), format_descriptor<T>::format(), size, readonly) {}
explicit buffer_info(Py_buffer *view, bool ownview = true)
- : buffer_info(view->buf, view->itemsize, view->format, view->ndim,
+ : buffer_info(
+ view->buf,
+ view->itemsize,
+ view->format,
+ view->ndim,
{view->shape, view->shape + view->ndim},
view->strides
- ? std::vector<ssize_t>(view->strides, view->strides + view->ndim)
- : detail::c_strides({view->shape, view->shape + view->ndim}, view->itemsize),
- view->readonly) {
+ ? std::vector<ssize_t>(view->strides, view->strides + view->ndim)
+ : detail::c_strides({view->shape, view->shape + view->ndim}, view->itemsize),
+ (view->readonly != 0)) {
+
this->m_view = view;
+
this->ownview = ownview;
}
buffer_info(const buffer_info &) = delete;
- buffer_info& operator=(const buffer_info &) = delete;
+ buffer_info &operator=(const buffer_info &) = delete;
- buffer_info(buffer_info &&other) {
- (*this) = std::move(other);
- }
+ buffer_info(buffer_info &&other) noexcept { (*this) = std::move(other); }
- buffer_info& operator=(buffer_info &&rhs) {
+ buffer_info &operator=(buffer_info &&rhs) noexcept {
ptr = rhs.ptr;
itemsize = rhs.itemsize;
size = rhs.size;
@@ -107,17 +138,28 @@ struct buffer_info {
}
~buffer_info() {
- if (m_view && ownview) { PyBuffer_Release(m_view); delete m_view; }
+ if (m_view && ownview) {
+ PyBuffer_Release(m_view);
+ delete m_view;
+ }
}
Py_buffer *view() const { return m_view; }
Py_buffer *&view() { return m_view; }
-private:
- struct private_ctr_tag { };
- buffer_info(private_ctr_tag, void *ptr, ssize_t itemsize, const std::string &format, ssize_t ndim,
- detail::any_container<ssize_t> &&shape_in, detail::any_container<ssize_t> &&strides_in, bool readonly)
- : buffer_info(ptr, itemsize, format, ndim, std::move(shape_in), std::move(strides_in), readonly) { }
+private:
+ struct private_ctr_tag {};
+
+ buffer_info(private_ctr_tag,
+ void *ptr,
+ ssize_t itemsize,
+ const std::string &format,
+ ssize_t ndim,
+ detail::any_container<ssize_t> &&shape_in,
+ detail::any_container<ssize_t> &&strides_in,
+ bool readonly)
+ : buffer_info(
+ ptr, itemsize, format, ndim, std::move(shape_in), std::move(strides_in), readonly) {}
Py_buffer *m_view = nullptr;
bool ownview = false;
@@ -125,17 +167,22 @@ private:
PYBIND11_NAMESPACE_BEGIN(detail)
-template <typename T, typename SFINAE = void> struct compare_buffer_info {
- static bool compare(const buffer_info& b) {
+template <typename T, typename SFINAE = void>
+struct compare_buffer_info {
+ static bool compare(const buffer_info &b) {
return b.format == format_descriptor<T>::format() && b.itemsize == (ssize_t) sizeof(T);
}
};
-template <typename T> struct compare_buffer_info<T, detail::enable_if_t<std::is_integral<T>::value>> {
- static bool compare(const buffer_info& b) {
- return (size_t) b.itemsize == sizeof(T) && (b.format == format_descriptor<T>::value ||
- ((sizeof(T) == sizeof(long)) && b.format == (std::is_unsigned<T>::value ? "L" : "l")) ||
- ((sizeof(T) == sizeof(size_t)) && b.format == (std::is_unsigned<T>::value ? "N" : "n")));
+template <typename T>
+struct compare_buffer_info<T, detail::enable_if_t<std::is_integral<T>::value>> {
+ static bool compare(const buffer_info &b) {
+ return (size_t) b.itemsize == sizeof(T)
+ && (b.format == format_descriptor<T>::value
+ || ((sizeof(T) == sizeof(long))
+ && b.format == (std::is_unsigned<T>::value ? "L" : "l"))
+ || ((sizeof(T) == sizeof(size_t))
+ && b.format == (std::is_unsigned<T>::value ? "N" : "n")));
}
};
diff --git a/host/lib/deps/pybind11/include/pybind11/cast.h b/host/lib/deps/pybind11/include/pybind11/cast.h
index 2682a8c3d..ee7eb4480 100644
--- a/host/lib/deps/pybind11/include/pybind11/cast.h
+++ b/host/lib/deps/pybind11/include/pybind11/cast.h
@@ -8,994 +8,168 @@
#pragma once
-#include "pytypes.h"
-#include "detail/typeid.h"
-#include "detail/descr.h"
-#include "detail/internals.h"
-#include <array>
-#include <limits>
-#include <tuple>
-#include <type_traits>
-
-#if defined(PYBIND11_CPP17)
-# if defined(__has_include)
-# if __has_include(<string_view>)
-# define PYBIND11_HAS_STRING_VIEW
-# endif
-# elif defined(_MSC_VER)
-# define PYBIND11_HAS_STRING_VIEW
-# endif
-#endif
-#ifdef PYBIND11_HAS_STRING_VIEW
-#include <string_view>
-#endif
-
-#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
-# define PYBIND11_HAS_U8STRING
-#endif
-
-PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
-PYBIND11_NAMESPACE_BEGIN(detail)
-
-
-
-class loader_life_support {
-public:
-
- loader_life_support() {
- get_internals().loader_patient_stack.push_back(nullptr);
- }
-
-
- ~loader_life_support() {
- auto &stack = get_internals().loader_patient_stack;
- if (stack.empty())
- pybind11_fail("loader_life_support: internal error");
-
- auto ptr = stack.back();
- stack.pop_back();
- Py_CLEAR(ptr);
-
-
- if (stack.capacity() > 16 && !stack.empty() && stack.capacity() / stack.size() > 2)
- stack.shrink_to_fit();
- }
-
-
-
- PYBIND11_NOINLINE static void add_patient(handle h) {
- auto &stack = get_internals().loader_patient_stack;
- if (stack.empty())
- throw cast_error("When called outside a bound function, py::cast() cannot "
- "do Python -> C++ conversions which require the creation "
- "of temporary values");
-
- auto &list_ptr = stack.back();
- if (list_ptr == nullptr) {
- list_ptr = PyList_New(1);
- if (!list_ptr)
- pybind11_fail("loader_life_support: error allocating list");
- PyList_SET_ITEM(list_ptr, 0, h.inc_ref().ptr());
- } else {
- auto result = PyList_Append(list_ptr, h.ptr());
- if (result == -1)
- pybind11_fail("loader_life_support: error adding patient");
- }
- }
-};
-
-
-
-
-inline std::pair<decltype(internals::registered_types_py)::iterator, bool> all_type_info_get_cache(PyTypeObject *type);
-
-
-PYBIND11_NOINLINE inline void all_type_info_populate(PyTypeObject *t, std::vector<type_info *> &bases) {
- std::vector<PyTypeObject *> check;
- for (handle parent : reinterpret_borrow<tuple>(t->tp_bases))
- check.push_back((PyTypeObject *) parent.ptr());
-
- auto const &type_dict = get_internals().registered_types_py;
- for (size_t i = 0; i < check.size(); i++) {
- auto type = check[i];
-
- if (!PyType_Check((PyObject *) type)) continue;
-
-
- auto it = type_dict.find(type);
- if (it != type_dict.end()) {
-
-
-
-