File tree Expand file tree Collapse file tree 19 files changed +281
-1
lines changed Expand file tree Collapse file tree 19 files changed +281
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+
3+ classes :
4+ Buffers :
5+ methods :
6+ set_buffer :
7+ buffers :
8+ - { type: in, src: data, len: len }
9+ get_buffer2 :
10+ buffers :
11+ - { type: out, src: data, len: len }
12+ get_buffer1 :
13+ buffers :
14+ - { type: out, src: data, len: len }
15+
16+ v_set_buffer :
17+ buffers :
18+ - { type: in, src: data, len: len }
19+ v_get_buffer2 :
20+ buffers :
21+ - { type: out, src: data, len: len }
22+ v_get_buffer1 :
23+ buffers :
24+ - { type: out, src: data, len: len }
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ functions:
2222classes :
2323 IgnoredClass :
2424 ignore : true
25+ IgnoredTemplatedClass :
26+ ignore : true
2527 IgnoredClassWithEnum :
2628 ignore : true
2729 ClassWithIgnored :
@@ -36,6 +38,15 @@ classes:
3638 Param1 :
3739 ignore : true
3840 methods :
41+ ClassWithIgnored :
42+ cpp_code : |
43+ [](py::args) {
44+ return std::make_shared<ClassWithIgnored>(1);
45+ }
46+ keepalive : []
47+ param_override :
48+ y :
49+ ignore : true
3950 fnIgnore :
4051 ignore : true
4152 fnIgnoredParam :
@@ -46,4 +57,12 @@ classes:
4657 cpp_code : |
4758 [](ClassWithIgnored * self, int y) {
4859 return self->fnIgnoredParam(42, y);
49- }
60+ }
61+ ClassWithIgnoredBase :
62+ ignored_bases :
63+ - IgnoredClass
64+ force_no_trampoline : true
65+ ClassWithIgnoredTemplateBase :
66+ ignored_bases :
67+ - IgnoredTemplatedClass<std::vector<int>>
68+ force_no_trampoline : true
Original file line number Diff line number Diff line change 22
33classes :
44 InlineCode :
5+ constants :
6+ - NS::inner::KONSTANT
57 enums :
68 MyE :
79 inline_code : |
810 .value("Value2", (InlineCode::MyE)2)
911 methods :
1012 get2 :
13+ cpp_code_with_constant :
14+ cpp_code : |
15+ [](InlineCode *self) {
16+ return KONSTANT;
17+ }
1118 inline_code : |
1219 // you can even start with a comment
1320 .def("get4", [](InlineCode *self) {
Original file line number Diff line number Diff line change @@ -5,6 +5,11 @@ functions:
55classes :
66 VBase :
77 methods :
8+ different_cpp_and_py :
9+ cpp_code : |
10+ [](VBase * self, int x) {
11+ return x + 2;
12+ }
813 pure_io :
914 param_override :
1015 ss :
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ generate = [
4444 { abstract = "abstract.h" },
4545 { base_qualname = "base_qualname.h" },
4646 { base_qualname_hidden = "base_qualname_hidden.h" },
47+ { buffers = "buffers.h" },
4748 { custom_type_caster = "custom_type_caster.h" },
4849 { defaults = "defaults.h" },
4950 { docstrings = "docstrings.h" },
@@ -56,6 +57,7 @@ generate = [
5657 { inline_code = "inline_code.h" },
5758 { lifetime = "lifetime.h" },
5859 { nested = "nested.h" },
60+ { operators = "operators.h" },
5961 { overloads = "overloads.h" },
6062 { parameters = "parameters.h" },
6163 { refqual = "refqual.h" },
Original file line number Diff line number Diff line change 33# autogenerated by 'robotpy-build create-imports rpytest.ft rpytest.ft._rpytest_ft'
44from ._rpytest_ft import (
55 Abstract ,
6+ Buffers ,
67 ClassWithFields ,
78 ClassWithIgnored ,
89 ClassWithTrampoline ,
1920 GEnum ,
2021 GEnumMath ,
2122 HasFactory ,
23+ HasOperator ,
2224 IBase ,
2325 IChild ,
2426 IFinal ,
8082 VChild ,
8183 VirtualComma ,
8284 checkConvertRpyintToInt ,
85+ check_different_cpp_and_py ,
8386 check_impure_io ,
8487 check_pure_io ,
8588 convertRpyintToInt ,
107110
108111__all__ = [
109112 "Abstract" ,
113+ "Buffers" ,
110114 "ClassWithFields" ,
111115 "ClassWithIgnored" ,
112116 "ClassWithTrampoline" ,
123127 "GEnum" ,
124128 "GEnumMath" ,
125129 "HasFactory" ,
130+ "HasOperator" ,
126131 "IBase" ,
127132 "IChild" ,
128133 "IFinal" ,
184189 "VChild" ,
185190 "VirtualComma" ,
186191 "checkConvertRpyintToInt" ,
192+ "check_different_cpp_and_py" ,
187193 "check_impure_io" ,
188194 "check_pure_io" ,
189195 "convertRpyintToInt" ,
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include < cstring>
4+ #include < vector>
5+
6+ class Buffers {
7+ public:
8+
9+ // in
10+ void set_buffer (const uint8_t *data, size_t len) {
11+ m_buf.resize (len);
12+ memcpy (m_buf.data (), data, len);
13+ }
14+
15+ // out
16+ // - data is bytes
17+ // - len is input_size and output size
18+ void get_buffer2 (uint8_t *data, size_t *len) {
19+ *len = get_buffer1 (data, *len);
20+ }
21+
22+ // out
23+ // - data is bytes
24+ // - len is input size
25+ // - return value is output size
26+ size_t get_buffer1 (uint8_t *data, size_t len) {
27+ size_t rlen = len < m_buf.size () ? len : m_buf.size ();
28+ if (rlen) {
29+ memcpy (data, m_buf.data (), rlen);
30+ }
31+ return rlen;
32+ }
33+
34+ //
35+ // virtual functions -- trampolines are disabled but normal function
36+ // calls work
37+ //
38+
39+ virtual void v_set_buffer (const uint8_t *data, size_t len) {
40+ set_buffer (data, len);
41+ }
42+
43+ virtual void v_get_buffer2 (uint8_t *data, size_t *len) {
44+ get_buffer2 (data, len);
45+ }
46+
47+ virtual size_t v_get_buffer1 (uint8_t *data, size_t len) {
48+ return get_buffer1 (data, len);
49+ }
50+
51+ private:
52+
53+ std::vector<uint8_t > m_buf;
54+ };
Original file line number Diff line number Diff line change 11#pragma once
22
3+ #include < vector>
4+
35//
46// Test anything that can be ignored
57//
@@ -13,12 +15,18 @@ int fnIgnoredParam(int x) { return x; }
1315// class
1416struct IgnoredClass {};
1517
18+ template <typename T>
19+ struct IgnoredTemplatedClass {};
20+
1621struct IgnoredClassWithEnum {
1722 enum AlsoIgnored { Value = 1 };
1823};
1924
2025struct ClassWithIgnored {
2126
27+ // constructor with ignored param
28+ ClassWithIgnored (int y) {}
29+
2230 // class function
2331 int fnIgnore () { return 0x2 ; }
2432
@@ -39,6 +47,12 @@ struct ClassWithIgnored {
3947 };
4048};
4149
50+ struct ClassWithIgnoredBase : IgnoredClass {
51+ };
52+
53+ struct ClassWithIgnoredTemplateBase : IgnoredTemplatedClass<std::vector<int >> {
54+ };
55+
4256// enums
4357enum IgnoredEnum {
4458 Original1 = 1
Original file line number Diff line number Diff line change @@ -11,26 +11,31 @@ struct IBase
1111 IBase () {}
1212 virtual ~IBase () {}
1313
14+ /* * doc: base::baseOnly */
1415 virtual std::string baseOnly ()
1516 {
1617 return " base::baseOnly" ;
1718 }
1819
20+ /* * doc: base::baseAndGrandchild */
1921 virtual std::string baseAndGrandchild ()
2022 {
2123 return " base::baseAndGrandchild" ;
2224 }
2325
26+ /* * doc: base::baseAndChild */
2427 virtual std::string baseAndChild ()
2528 {
2629 return " base::baseAndChild" ;
2730 }
2831
32+ /* * doc: base::baseAndPyChild */
2933 virtual std::string baseAndPyChild ()
3034 {
3135 return " base::baseAndPyChild" ;
3236 }
3337
38+ /* * doc: base::baseAndChildFinal */
3439 virtual std::string baseAndChildFinal ()
3540 {
3641 return " base::baseAndChildFinal" ;
Original file line number Diff line number Diff line change @@ -10,11 +10,13 @@ struct IChild : IBase
1010{
1111 IChild () : IBase(), i(42 ) {}
1212
13+ /* * doc: child::baseAndChild */
1314 std::string baseAndChild () override
1415 {
1516 return " child::baseAndChild" ;
1617 }
1718
19+ /* * doc: child::baseAndChildFinal */
1820 std::string baseAndChildFinal () final
1921 {
2022 return " child::baseAndChildFinal" ;
You can’t perform that action at this time.
0 commit comments