Debian Codegraph @

.cargo/vendor/cbindgen/tests/expectations/enum.compat.c

raw
1 #if 0
2 ''' '
3 #endif
4
5 #ifdef __cplusplus
6 template <typename T>
7 using Box = T*;
8 #endif
9
10 #if 0
11 ' '''
12 #endif
13
14
15 #include <stdarg.h>
16 #include <stdbool.h>
17 #include <stdint.h>
18 #include <stdlib.h>
19
20 enum A
21 #ifdef __cplusplus
22 : uint64_t
23 #endif // __cplusplus
24 {
25 a1 = 0,
26 a2 = 2,
27 a3,
28 a4 = 5,
29 };
30 #ifndef __cplusplus
31 typedef uint64_t A;
32 #endif // __cplusplus
33
34 enum B
35 #ifdef __cplusplus
36 : uint32_t
37 #endif // __cplusplus
38 {
39 b1 = 0,
40 b2 = 2,
41 b3,
42 b4 = 5,
43 };
44 #ifndef __cplusplus
45 typedef uint32_t B;
46 #endif // __cplusplus
47
48 enum C
49 #ifdef __cplusplus
50 : uint16_t
51 #endif // __cplusplus
52 {
53 c1 = 0,
54 c2 = 2,
55 c3,
56 c4 = 5,
57 };
58 #ifndef __cplusplus
59 typedef uint16_t C;
60 #endif // __cplusplus
61
62 enum D
63 #ifdef __cplusplus
64 : uint8_t
65 #endif // __cplusplus
66 {
67 d1 = 0,
68 d2 = 2,
69 d3,
70 d4 = 5,
71 };
72 #ifndef __cplusplus
73 typedef uint8_t D;
74 #endif // __cplusplus
75
76 enum E
77 #ifdef __cplusplus
78 : uintptr_t
79 #endif // __cplusplus
80 {
81 e1 = 0,
82 e2 = 2,
83 e3,
84 e4 = 5,
85 };
86 #ifndef __cplusplus
87 typedef uintptr_t E;
88 #endif // __cplusplus
89
90 enum F
91 #ifdef __cplusplus
92 : intptr_t
93 #endif // __cplusplus
94 {
95 f1 = 0,
96 f2 = 2,
97 f3,
98 f4 = 5,
99 };
100 #ifndef __cplusplus
101 typedef intptr_t F;
102 #endif // __cplusplus
103
104 typedef enum {
105 l1,
106 l2,
107 l3,
108 l4,
109 } L;
110
111 enum M
112 #ifdef __cplusplus
113 : int8_t
114 #endif // __cplusplus
115 {
116 m1 = -1,
117 m2 = 0,
118 m3 = 1,
119 };
120 #ifndef __cplusplus
121 typedef int8_t M;
122 #endif // __cplusplus
123
124 typedef enum {
125 n1,
126 n2,
127 n3,
128 n4,
129 } N;
130
131 enum O
132 #ifdef __cplusplus
133 : int8_t
134 #endif // __cplusplus
135 {
136 o1,
137 o2,
138 o3,
139 o4,
140 };
141 #ifndef __cplusplus
142 typedef int8_t O;
143 #endif // __cplusplus
144
145 typedef struct J J;
146
147 typedef struct K K;
148
149 typedef struct Opaque Opaque;
150
151 enum G_Tag
152 #ifdef __cplusplus
153 : uint8_t
154 #endif // __cplusplus
155 {
156 Foo,
157 Bar,
158 Baz,
159 };
160 #ifndef __cplusplus
161 typedef uint8_t G_Tag;
162 #endif // __cplusplus
163
164 typedef struct {
165 G_Tag tag;
166 uint8_t x;
167 int16_t y;
168 } Bar_Body;
169
170 typedef union {
171 G_Tag tag;
172 struct {
173 G_Tag foo_tag;
174 int16_t foo;
175 };
176 Bar_Body bar;
177 } G;
178
179 typedef enum {
180 H_Foo,
181 H_Bar,
182 H_Baz,
183 } H_Tag;
184
185 typedef struct {
186 uint8_t x;
187 int16_t y;
188 } H_Bar_Body;
189
190 typedef struct {
191 H_Tag tag;
192 union {
193 struct {
194 int16_t foo;
195 };
196 H_Bar_Body bar;
197 };
198 } H;
199
200 enum ExI_Tag
201 #ifdef __cplusplus
202 : uint8_t
203 #endif // __cplusplus
204 {
205 ExI_Foo,
206 ExI_Bar,
207 ExI_Baz,
208 };
209 #ifndef __cplusplus
210 typedef uint8_t ExI_Tag;
211 #endif // __cplusplus
212
213 typedef struct {
214 uint8_t x;
215 int16_t y;
216 } ExI_Bar_Body;
217
218 typedef struct {
219 ExI_Tag tag;
220 union {
221 struct {
222 int16_t foo;
223 };
224 ExI_Bar_Body bar;
225 };
226 } ExI;
227
228 enum P_Tag
229 #ifdef __cplusplus
230 : uint8_t
231 #endif // __cplusplus
232 {
233 P0,
234 P1,
235 };
236 #ifndef __cplusplus
237 typedef uint8_t P_Tag;
238 #endif // __cplusplus
239
240 typedef struct {
241 uint8_t _0;
242 uint8_t _1;
243 uint8_t _2;
244 } P1_Body;
245
246 typedef struct {
247 P_Tag tag;
248 union {
249 struct {
250 uint8_t p0;
251 };
252 P1_Body p1;
253 };
254 } P;
255
256 typedef enum {
257 Ok,
258 Err,
259 } Q_Tag;
260
261 typedef struct {
262 Q_Tag tag;
263 union {
264 struct {
265 uint32_t *ok;
266 };
267 struct {
268 uint32_t err;
269 };
270 };
271 } Q;
272
273 typedef enum {
274 IRFoo,
275 IRBar,
276 IRBaz,
277 } R_Tag;
278
279 typedef struct {
280 uint8_t x;
281 int16_t y;
282 } IRBar_Body;
283
284 typedef struct {
285 R_Tag tag;
286 union {
287 struct {
288 int16_t IRFoo;
289 };
290 IRBar_Body IRBar;
291 };
292 } R;
293
294 #ifdef __cplusplus
295 extern "C" {
296 #endif // __cplusplus
297
298 void root(Opaque *opaque,
299 A a,
300 B b,
301 C c,
302 D d,
303 E e,
304 F f,
305 G g,
306 H h,
307 ExI i,
308 J j,
309 K k,
310 L l,
311 M m,
312 N n,
313 O o,
314 P p,
315 Q q,
316 R r);
317
318 #ifdef __cplusplus
319 } // extern "C"
320 #endif // __cplusplus
321
322 #if 0
323 ''' '
324 #endif
325
326 #include <stddef.h>
327 #include "testing-helpers.h"
328 static_assert(offsetof(CBINDGEN_STRUCT(P), tag) == 0, "unexpected offset for tag");
329 static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p0");
330 static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p1");
331 static_assert(sizeof(CBINDGEN_STRUCT(P)) == 4, "unexpected size for P");
332
333 #if 0
334 ' '''
335 #endif