Debian Codegraph @

testdata/structtest/structreturn_test.c

raw
1 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: 2024 The Ebitengine Authors
3
4 #include <stdint.h>
5
6 struct Empty{};
7
8 struct Empty ReturnEmpty() {
9 struct Empty e = {};
10 return e;
11 }
12
13 struct StructInStruct{
14 struct{ int16_t a; } a;
15 struct{ int16_t b; } b;
16 struct{ int16_t c; } c;
17 };
18
19 struct StructInStruct ReturnStructInStruct(int16_t a, int16_t b, int16_t c) {
20 struct StructInStruct e = {{a}, {b}, {c}};
21 return e;
22 }
23
24 struct ThreeShorts{
25 int16_t a, b, c;
26 };
27
28 struct ThreeShorts ReturnThreeShorts(int16_t a, int16_t b, int16_t c) {
29 struct ThreeShorts e = {a, b, c};
30 return e;
31 }
32
33 struct FourShorts{
34 int16_t a, b, c, d;
35 };
36
37 struct FourShorts ReturnFourShorts(int16_t a, int16_t b, int16_t c, int16_t d) {
38 struct FourShorts e = {a, b, c, d};
39 return e;
40 }
41
42 struct OneLong{
43 int64_t a;
44 };
45
46 struct OneLong ReturnOneLong(int64_t a) {
47 struct OneLong e = {a};
48 return e;
49 }
50
51 struct TwoLongs{
52 int64_t a, b;
53 };
54
55 struct TwoLongs ReturnTwoLongs(int64_t a, int64_t b) {
56 struct TwoLongs e = {a, b};
57 return e;
58 }
59
60 struct ThreeLongs{
61 int64_t a, b, c;
62 };
63
64 struct ThreeLongs ReturnThreeLongs(int64_t a, int64_t b, int64_t c) {
65 struct ThreeLongs e = {a, b, c};
66 return e;
67 }
68
69 struct OneFloat{
70 float a;
71 };
72
73 struct TwoFloats{
74 float a, b;
75 };
76
77 struct TwoFloats ReturnTwoFloats(float a, float b) {
78 struct TwoFloats e = {a, b};
79 return e;
80 }
81
82 struct ThreeFloats{
83 float a, b, c;
84 };
85
86 struct ThreeFloats ReturnThreeFloats(float a, float b, float c) {
87 struct ThreeFloats e = {a, b, c};
88 return e;
89 }
90
91 struct FourFloats{
92 float a, b, c, d;
93 };
94
95 struct FourFloats ReturnFourFloats(float a, float b, float c, float d) {
96 struct FourFloats e = {a, b, c, d};
97 return e;
98 }
99
100 struct OneFloat ReturnOneFloat(float a) {
101 struct OneFloat e = {a};
102 return e;
103 }
104
105 struct OneDouble{
106 double a;
107 };
108
109 struct OneDouble ReturnOneDouble(double a) {
110 struct OneDouble e = {a};
111 return e;
112 }
113
114 struct TwoDoubles{
115 double a, b;
116 };
117
118 struct TwoDoubles ReturnTwoDoubles(double a, double b) {
119 struct TwoDoubles e = {a, b};
120 return e;
121 }
122
123 struct ThreeDoubles{
124 double a, b, c;
125 };
126
127 struct ThreeDoubles ReturnThreeDoubles(double a, double b, double c) {
128 struct ThreeDoubles e = {a, b, c};
129 return e;
130 }
131
132 struct FourDoubles{
133 double a, b, c, d;
134 };
135
136 struct FourDoubles ReturnFourDoubles(double a, double b, double c, double d) {
137 struct FourDoubles e = {a, b, c, d};
138 return e;
139 }
140
141 struct FourDoublesInternal{
142 struct {
143 double a, b;
144 } f;
145 struct {
146 double c, d;
147 } g;
148 };
149
150 struct FourDoublesInternal ReturnFourDoublesInternal(double a, double b, double c, double d) {
151 struct FourDoublesInternal e = { {a, b}, {c, d} };
152 return e;
153 }
154
155 struct FiveDoubles{
156 double a, b, c, d, e;
157 };
158
159 struct FiveDoubles ReturnFiveDoubles(double a, double b, double c, double d, double e) {
160 struct FiveDoubles s = {a, b, c, d, e};
161 return s;
162 }
163
164 struct OneFloatOneDouble{
165 float a;
166 double b;
167 };
168
169 struct OneFloatOneDouble ReturnOneFloatOneDouble(float a, double b) {
170 struct OneFloatOneDouble e = {a, b};
171 return e;
172 }
173
174 struct OneDoubleOneFloat{
175 double a;
176 float b;
177 };
178
179 struct OneDoubleOneFloat ReturnOneDoubleOneFloat(double a, float b) {
180 struct OneDoubleOneFloat e = {a, b};
181 return e;
182 }
183
184 struct Unaligned1{
185 int8_t a;
186 int16_t b;
187 int64_t c;
188 };
189
190 struct Unaligned1 ReturnUnaligned1(int8_t a, int16_t b, int64_t c) {
191 struct Unaligned1 e = {a, b, c};
192 return e;
193 }
194
195 struct Mixed1{
196 float a;
197 int32_t b;
198 };
199
200 struct Mixed1 ReturnMixed1(float a, int32_t b) {
201 struct Mixed1 e = {a, b};
202 return e;
203 }
204
205 struct Mixed2{
206 float a;
207 int32_t b;
208 float c;
209 int32_t d;
210 };
211
212 struct Mixed2 ReturnMixed2(float a, int32_t b, float c, int32_t d) {
213 struct Mixed2 e = {a, b, c, d};
214 return e;
215 }
216
217 struct Mixed3{
218 float a;
219 uint32_t b;
220 double c;
221 };
222
223 struct Mixed3 ReturnMixed3(float a, uint32_t b, double c) {
224 struct Mixed3 s = {a, b, c};
225 return s;
226 }
227
228 struct Mixed4{
229 double a;
230 uint32_t b;
231 float c;
232 };
233
234 struct Mixed4 ReturnMixed4(double a, uint32_t b, float c) {
235 struct Mixed4 s = {a, b, c};
236 return s;
237 }
238
239 struct Mixed5{
240 int64_t *a;
241 int32_t b;
242 float c;
243 int32_t d;
244 };
245
246 struct Mixed5 ReturnMixed5(int64_t *a, int32_t b, float c, int32_t d) {
247 struct Mixed5 s = {a, b, c, d};
248 return s;
249 }
250
251 struct Mixed5 IdentityMixed5(struct Mixed5 m) {
252 return m;
253 }
254
255 struct SmallBool{
256 _Bool a;
257 int32_t b;
258 int64_t c;
259 };
260
261 struct SmallBool ReturnSmallBool(_Bool a, int32_t b, int64_t c) {
262 struct SmallBool s = {a, b, c};
263 return s;
264 }
265
266 struct LargeBool{
267 _Bool a;
268 int32_t b;
269 int64_t c;
270 int64_t d;
271 };
272
273 struct LargeBool ReturnLargeBool(_Bool a, int32_t b, int64_t c, int64_t d) {
274 struct LargeBool s = {a, b, c, d};
275 return s;
276 }
277
278 struct Ptr1{
279 int64_t *a;
280 void *b;
281 };
282
283 struct Ptr1 ReturnPtr1(int64_t *a, void *b) {
284 struct Ptr1 s = {a, b};
285 return s;
286 }