Debian Codegraph @

.cargo/vendor/cbindgen/tests/expectations/enum.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 a1 = 0,
22 a2 = 2,
23 a3,
24 a4 = 5,
25 };
26 typedef uint64_t A;
27
28 enum B {
29 b1 = 0,
30 b2 = 2,
31 b3,
32 b4 = 5,
33 };
34 typedef uint32_t B;
35
36 enum C {
37 c1 = 0,
38 c2 = 2,
39 c3,
40 c4 = 5,
41 };
42 typedef uint16_t C;
43
44 enum D {
45 d1 = 0,
46 d2 = 2,
47 d3,
48 d4 = 5,
49 };
50 typedef uint8_t D;
51
52 enum E {
53 e1 = 0,
54 e2 = 2,
55 e3,
56 e4 = 5,
57 };
58 typedef uintptr_t E;
59
60 enum F {
61 f1 = 0,
62 f2 = 2,
63 f3,
64 f4 = 5,
65 };
66 typedef intptr_t F;
67
68 typedef enum {
69 l1,
70 l2,
71 l3,
72 l4,
73 } L;
74
75 enum M {
76 m1 = -1,
77 m2 = 0,
78 m3 = 1,
79 };
80 typedef int8_t M;
81
82 typedef enum {
83 n1,
84 n2,
85 n3,
86 n4,
87 } N;
88
89 enum O {
90 o1,
91 o2,
92 o3,
93 o4,
94 };
95 typedef int8_t O;
96
97 typedef struct J J;
98
99 typedef struct K K;
100
101 typedef struct Opaque Opaque;
102
103 enum G_Tag {
104 Foo,
105 Bar,
106 Baz,
107 };
108 typedef uint8_t G_Tag;
109
110 typedef struct {
111 G_Tag tag;
112 uint8_t x;
113 int16_t y;
114 } Bar_Body;
115
116 typedef union {
117 G_Tag tag;
118 struct {
119 G_Tag foo_tag;
120 int16_t foo;
121 };
122 Bar_Body bar;
123 } G;
124
125 typedef enum {
126 H_Foo,
127 H_Bar,
128 H_Baz,
129 } H_Tag;
130
131 typedef struct {
132 uint8_t x;
133 int16_t y;
134 } H_Bar_Body;
135
136 typedef struct {
137 H_Tag tag;
138 union {
139 struct {
140 int16_t foo;
141 };
142 H_Bar_Body bar;
143 };
144 } H;
145
146 enum ExI_Tag {
147 ExI_Foo,
148 ExI_Bar,
149 ExI_Baz,
150 };
151 typedef uint8_t ExI_Tag;
152
153 typedef struct {
154 uint8_t x;
155 int16_t y;
156 } ExI_Bar_Body;
157
158 typedef struct {
159 ExI_Tag tag;
160 union {
161 struct {
162 int16_t foo;
163 };
164 ExI_Bar_Body bar;
165 };
166 } ExI;
167
168 enum P_Tag {
169 P0,
170 P1,
171 };
172 typedef uint8_t P_Tag;
173
174 typedef struct {
175 uint8_t _0;
176 uint8_t _1;
177 uint8_t _2;
178 } P1_Body;
179
180 typedef struct {
181 P_Tag tag;
182 union {
183 struct {
184 uint8_t p0;
185 };
186 P1_Body p1;
187 };
188 } P;
189
190 typedef enum {
191 Ok,
192 Err,
193 } Q_Tag;
194
195 typedef struct {
196 Q_Tag tag;
197 union {
198 struct {
199 uint32_t *ok;
200 };
201 struct {
202 uint32_t err;
203 };
204 };
205 } Q;
206
207 typedef enum {
208 IRFoo,
209 IRBar,
210 IRBaz,
211 } R_Tag;
212
213 typedef struct {
214 uint8_t x;
215 int16_t y;
216 } IRBar_Body;
217
218 typedef struct {
219 R_Tag tag;
220 union {
221 struct {
222 int16_t IRFoo;
223 };
224 IRBar_Body IRBar;
225 };
226 } R;
227
228 void root(Opaque *opaque,
229 A a,
230 B b,
231 C c,
232 D d,
233 E e,
234 F f,
235 G g,
236 H h,
237 ExI i,
238 J j,
239 K k,
240 L l,
241 M m,
242 N n,
243 O o,
244 P p,
245 Q q,
246 R r);
247
248 #if 0
249 ''' '
250 #endif
251
252 #include <stddef.h>
253 #include "testing-helpers.h"
254 static_assert(offsetof(CBINDGEN_STRUCT(P), tag) == 0, "unexpected offset for tag");
255 static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p0");
256 static_assert(offsetof(CBINDGEN_STRUCT(P), p0) == 1, "unexpected offset for p1");
257 static_assert(sizeof(CBINDGEN_STRUCT(P)) == 4, "unexpected size for P");
258
259 #if 0
260 ' '''
261 #endif