Debian Codegraph @

.cargo/vendor/cbindgen/tests/expectations/annotation.cpp

raw
1 #include <cstdarg>
2 #include <cstdint>
3 #include <cstdlib>
4 #include <ostream>
5 #include <new>
6
7 enum class C : uint32_t {
8 X = 2,
9 Y,
10 };
11
12 struct A {
13 int32_t m0;
14
15 A(int32_t const& m0)
16 : m0(m0)
17 {}
18
19 bool operator<(const A& other) const {
20 return m0 < other.m0;
21 }
22 bool operator<=(const A& other) const {
23 return m0 <= other.m0;
24 }
25 };
26
27 struct B {
28 int32_t x;
29 float y;
30 };
31
32 union F {
33 enum class Tag : uint8_t {
34 Foo,
35 Bar,
36 Baz,
37 };
38
39 struct Foo_Body {
40 Tag tag;
41 int16_t _0;
42 };
43
44 struct Bar_Body {
45 Tag tag;
46 uint8_t x;
47 int16_t y;
48 };
49
50 struct {
51 Tag tag;
52 };
53 Foo_Body foo;
54 Bar_Body bar;
55
56 static F Foo(const int16_t &_0) {
57 F result;
58 ::new (&result.foo._0) (int16_t)(_0);
59 result.tag = Tag::Foo;
60 return result;
61 }
62
63 bool IsFoo() const {
64 return tag == Tag::Foo;
65 }
66
67 static F Bar(const uint8_t &x,
68 const int16_t &y) {
69 F result;
70 ::new (&result.bar.x) (uint8_t)(x);
71 ::new (&result.bar.y) (int16_t)(y);
72 result.tag = Tag::Bar;
73 return result;
74 }
75
76 bool IsBar() const {
77 return tag == Tag::Bar;
78 }
79
80 static F Baz() {
81 F result;
82 result.tag = Tag::Baz;
83 return result;
84 }
85
86 bool IsBaz() const {
87 return tag == Tag::Baz;
88 }
89 };
90
91 struct H {
92 enum class Tag : uint8_t {
93 Hello,
94 There,
95 Everyone,
96 };
97
98 struct Hello_Body {
99 int16_t _0;
100 };
101
102 struct There_Body {
103 uint8_t x;
104 int16_t y;
105 };
106
107 Tag tag;
108 union {
109 Hello_Body hello;
110 There_Body there;
111 };
112
113 static H Hello(const int16_t &_0) {
114 H result;
115 ::new (&result.hello._0) (int16_t)(_0);
116 result.tag = Tag::Hello;
117 return result;
118 }
119
120 bool IsHello() const {
121 return tag == Tag::Hello;
122 }
123
124 static H There(const uint8_t &x,
125 const int16_t &y) {
126 H result;
127 ::new (&result.there.x) (uint8_t)(x);
128 ::new (&result.there.y) (int16_t)(y);
129 result.tag = Tag::There;
130 return result;
131 }
132
133 bool IsThere() const {
134 return tag == Tag::There;
135 }
136
137 static H Everyone() {
138 H result;
139 result.tag = Tag::Everyone;
140 return result;
141 }
142
143 bool IsEveryone() const {
144 return tag == Tag::Everyone;
145 }
146 };
147
148 extern "C" {
149
150 void root(A x, B y, C z, F f, H h);
151
152 } // extern "C"