Debian Codegraph @

testdata/structtest/structreturn_test.c

raw symbols SCIP
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, 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 OneFloat ReturnOneFloat(float a) {
92 struct OneFloat e = {a};
93 return e;
94 }
95
96 struct OneDouble{
97 double a;
98 };
99
100 struct OneDouble ReturnOneDouble(double a) {
101 struct OneDouble e = {a};
102 return e;
103 }
104
105 struct TwoDoubles{
106 double a, b;
107 };
108
109 struct TwoDoubles ReturnTwoDoubles(double a, double b) {
110 struct TwoDoubles e = {a, b};
111 return e;
112 }
113
114 struct ThreeDoubles{
115 double a, b, c;
116 };
117
118 struct ThreeDoubles ReturnThreeDoubles(double a, double b, double c) {
119 struct ThreeDoubles e = {a, b, c};
120 return e;
121 }
122
123 struct FourDoubles{
124 double a, b, c, d;
125 };
126
127 struct FourDoubles ReturnFourDoubles(double a, double b, double c, double d) {
128 struct FourDoubles e = {a, b, c, d};
129 return e;
130 }
131
132 struct FourDoublesInternal{
133 struct {
134 double a, b;
135 } f;
136 struct {
137 double c, d;
138 } g;
139 };
140
141 struct FourDoublesInternal ReturnFourDoublesInternal(double a, double b, double c, double d) {
142 struct FourDoublesInternal e = { {a, b}, {c, d} };
143 return e;
144 }
145
146 struct FiveDoubles{
147 double a, b, c, d, e;
148 };
149
150 struct FiveDoubles ReturnFiveDoubles(double a, double b, double c, double d, double e) {
151 struct FiveDoubles s = {a, b, c, d, e};
152 return s;
153 }
154
155 struct OneFloatOneDouble{
156 float a;
157 double b;
158 };
159
160 struct OneFloatOneDouble ReturnOneFloatOneDouble(float a, double b) {
161 struct OneFloatOneDouble e = {a, b};
162 return e;
163 }
164
165 struct OneDoubleOneFloat{
166 double a;
167 float b;
168 };
169
170 struct OneDoubleOneFloat ReturnOneDoubleOneFloat(double a, float b) {
171 struct OneDoubleOneFloat e = {a, b};
172 return e;
173 }
174
175 struct Unaligned1{
176 int8_t a;
177 int16_t b;
178 int64_t c;
179 };
180
181 struct Unaligned1 ReturnUnaligned1(int8_t a, int16_t b, int64_t c) {
182 struct Unaligned1 e = {a, b, c};
183 return e;
184 }
185
186 struct Mixed1{
187 float a;
188 int32_t b;
189 };
190
191 struct Mixed1 ReturnMixed1(float a, int32_t b) {
192 struct Mixed1 e = {a, b};
193 return e;
194 }
195
196 struct Mixed2{
197 float a;
198 int32_t b;
199 float c;
200 int32_t d;
201 };
202
203 struct Mixed2 ReturnMixed2(float a, int32_t b, float c, int32_t d) {
204 struct Mixed2 e = {a, b, c, d};
205 return e;
206 }
207
208 struct Mixed3{
209 float a;
210 uint32_t b;
211 double c;
212 };
213
214 struct Mixed3 ReturnMixed3(float a, uint32_t b, double c) {
215 struct Mixed3 s = {a, b, c};
216 return s;
217 }
218
219 struct Mixed4{
220 double a;
221 uint32_t b;
222 float c;
223 };
224
225 struct Mixed4 ReturnMixed4(double a, uint32_t b, float c) {
226 struct Mixed4 s = {a, b, c};
227 return s;
228 }
229
230 struct Mixed5{
231 int64_t *a;
232 int32_t b;
233 float c;
234 int32_t d;
235 };
236
237 struct Mixed5 ReturnMixed5(int64_t *a, int32_t b, float c, int32_t d) {
238 struct Mixed5 s = {a, b, c, d};
239 return s;
240 }
241
242 struct Mixed5 IdentityMixed5(struct Mixed5 m) {
243 return m;
244 }
245
246 struct SmallBool{
247 _Bool a;
248 int32_t b;
249 int64_t c;
250 };
251
252 struct SmallBool ReturnSmallBool(_Bool a, int32_t b, int64_t c) {
253 struct SmallBool s = {a, b, c};
254 return s;
255 }
256
257 struct LargeBool{
258 _Bool a;
259 int32_t b;
260 int64_t c;
261 int64_t d;
262 };
263
264 struct LargeBool ReturnLargeBool(_Bool a, int32_t b, int64_t c, int64_t d) {
265 struct LargeBool s = {a, b, c, d};
266 return s;
267 }
268
269 struct Ptr1{
270 int64_t *a;
271 void *b;
272 };
273
274 struct Ptr1 ReturnPtr1(int64_t *a, void *b) {
275 struct Ptr1 s = {a, b};
276 return s;
277 }