v0.6.0 32fe07e

struct_test.c RawHistoryFolder

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: 2024 The Ebitengine Authors
3
4// Empty is empty
5struct Empty {};
6
7// NoStruct tests that an empty struct doesn't cause issues
8unsigned long NoStruct(struct Empty e) {
9    return 0xdeadbeef;
10}
11
12struct EmptyEmpty {
13    struct Empty x;
14};
15
16unsigned long EmptyEmpty(struct EmptyEmpty e) {
17    return 0xdeadbeef;
18}
19
20unsigned long EmptyEmptyWithReg(unsigned int x, struct EmptyEmpty e, unsigned int y) {
21    return (x << 16) | y;
22}
23
24// GreaterThan16Bytes is 24 bytes on 64 bit systems
25struct GreaterThan16Bytes {
26   long  *x, *y, *z;
27};
28
29// GreaterThan16Bytes is a basic test for structs bigger than 16 bytes
30unsigned long GreaterThan16Bytes(struct GreaterThan16Bytes g) {
31    return *g.x + *g.y + *g.z;
32}
33
34// AfterRegisters tests to make sure that structs placed on the stack work properly
35unsigned long AfterRegisters(long a, long b, long c, long d, long e, long f, long g, long h, struct GreaterThan16Bytes bytes) {
36    long registers = a + b + c + d + e + f + g + h;
37    long stack =  *bytes.x + *bytes.y + *bytes.z;
38    if (registers != stack) {
39        return 0xbadbad;
40    }
41    if (stack != 0xdeadbeef) {
42        return 0xcafebad;
43    }
44    return stack;
45}
46
47unsigned long BeforeRegisters(struct GreaterThan16Bytes bytes, long a, long b) {
48    return *bytes.x + *bytes.y + *bytes.z + a + b;
49}
50
51struct GreaterThan16BytesStruct {
52    struct {
53        long  *x, *y, *z;
54    } a ;
55};
56
57unsigned long GreaterThan16BytesStruct(struct GreaterThan16BytesStruct g) {
58    return *(g.a.x) + *(g.a.y) + *(g.a.z);
59}
60
61struct IntLessThan16Bytes {
62    long x, y;
63};
64
65unsigned long IntLessThan16Bytes(struct IntLessThan16Bytes l) {
66    return l.x + l.y;
67}
68
69struct FloatLessThan16Bytes {
70    float x, y;
71};
72
73float FloatLessThan16Bytes(struct FloatLessThan16Bytes f) {
74    return f.x + f.y;
75}
76
77struct FloatAndInt {
78    float x;
79    int   y;
80};
81
82float FloatAndInt(struct FloatAndInt f) {
83    return f.x + f.y;
84}
85
86struct DoubleStruct {
87    double x;
88};
89
90double DoubleStruct(struct DoubleStruct d) {
91    return d.x;
92}
93
94struct TwoDoubleStruct {
95    double x, y;
96};
97
98double TwoDoubleStruct(struct TwoDoubleStruct d) {
99    return d.x + d.y;
100}
101
102struct TwoDoubleTwoStruct {
103    struct {
104        double x, y;
105    } s;
106};
107
108double TwoDoubleTwoStruct(struct TwoDoubleTwoStruct d) {
109    return d.s.x + d.s.y;
110}
111
112struct ThreeDoubleStruct {
113    double x, y, z;
114};
115
116double ThreeDoubleStruct(struct ThreeDoubleStruct d) {
117    return d.x + d.y + d.z;
118}
119
120struct LargeFloatStruct {
121    double a, b, c, d, e, f;
122};
123
124double LargeFloatStruct(struct LargeFloatStruct s) {
125    return s.a + s.b + s.c + s.d + s.e + s.f;
126}
127
128double LargeFloatStructWithRegs(double a, double b, double c, struct LargeFloatStruct s) {
129    return a + b + c + s.a + s.b + s.c + s.d + s.e + s.f;
130}
131
132struct Rect {
133    double x, y, w, h;
134};
135
136double Rectangle(struct Rect rect) {
137    return rect.x + rect.y + rect.w + rect.h;
138}
139
140double RectangleSubtract(struct Rect rect) {
141    return (rect.x + rect.y) - (rect.w + rect.h);
142}
143
144double RectangleWithRegs(double a, double b, double c, double d, double e, struct Rect rect) {
145    return a + b + c + d + e + rect.x + rect.y + rect.w + rect.h;
146}
147
148struct FloatArray {
149    double a[2];
150};
151
152double FloatArray(struct FloatArray f) {
153    return f.a[0] + f.a[1];
154}
155
156struct UnsignedChar4Bytes {
157    unsigned char a, b, c, d;
158};
159
160unsigned int UnsignedChar4Bytes(struct UnsignedChar4Bytes b) {
161    return (((int)b.a)<<24) | (((int)b.b)<<16) | (((int)b.c)<<8) | (((int)b.d)<<0);
162}
163
164struct UnsignedChar4BytesStruct {
165    struct {
166        unsigned char a;
167    } x;
168    struct {
169        unsigned char b;
170    } y;
171    struct {
172        unsigned char c;
173    } z;
174    struct {
175        unsigned char d;
176    } w;
177};
178
179unsigned int UnsignedChar4BytesStruct(struct UnsignedChar4BytesStruct b) {
180    return (((int)b.x.a)<<24) | (((int)b.y.b)<<16) | (((int)b.z.c)<<8) | (((int)b.w.d)<<0);
181}
182
183struct Short {
184    unsigned short a, b, c, d;
185};
186
187unsigned long Short(struct Short s) {
188    return (long)s.a << 48 | (long)s.b << 32 | (long)s.c << 16 | (long)s.d << 0;
189}
190
191struct Int {
192    unsigned int a, b;
193};
194
195unsigned long Int(struct Int i) {
196    return (long)i.a << 32 | (long)i.b << 0;
197}
198
199struct Long {
200    unsigned long a;
201};
202
203unsigned long Long(struct Long l) {
204    return l.a;
205}
206
207struct Char8Bytes {
208    signed char a, b, c, d, e, f, g, h;
209};
210
211int Char8Bytes(struct Char8Bytes b) {
212    return (int)b.a + (int)b.b + (int)b.c + (int)b.d + (int)b.e + (int)b.f + (int)b.g + (int)b.h;
213}
214
215struct Odd {
216    unsigned char a, b, c;
217};
218
219int Odd(struct Odd o) {
220    return (int)o.a + (int)o.b + (int)o.c;
221}
222
223struct Char2Short1 {
224    unsigned char a, b;
225    unsigned short c;
226};
227
228int Char2Short1s(struct Char2Short1 s) {
229    return (int)s.a + (int)s.b + (int)s.c;
230}
231
232struct SignedChar2Short1 {
233    signed char a, b;
234    signed short c;
235};
236
237int SignedChar2Short1(struct SignedChar2Short1 s) {
238    return s.a + s.b + s.c;
239}
240
241struct Array4UnsignedChars {
242    unsigned char a[4];
243};
244
245unsigned int Array4UnsignedChars(struct Array4UnsignedChars a) {
246    return (((int)a.a[0])<<24) | (((int)a.a[1])<<16) | (((int)a.a[2])<<8) | (((int)a.a[3])<<0);
247}
248
249struct Array3UnsignedChar {
250    unsigned char a[3];
251};
252
253unsigned int Array3UnsignedChars(struct Array3UnsignedChar a) {
254    return (((int)a.a[0])<<24) | (((int)a.a[1])<<16) | (((int)a.a[2])<<8) | 0xef;
255}
256
257struct Array2UnsignedShort {
258    unsigned short a[2];
259};
260
261unsigned int Array2UnsignedShorts(struct Array2UnsignedShort a) {
262    return (((int)a.a[0])<<16) | (((int)a.a[1])<<0);
263}
264
265struct Array4Chars {
266    char a[4];
267};
268
269int Array4Chars(struct Array4Chars a) {
270    return (int)a.a[0] + (int)a.a[1] + (int)a.a[2] + (int)a.a[3];
271}
272
273struct Array2Short {
274    short a[2];
275};
276
277int Array2Shorts(struct Array2Short a) {
278    return (int)a.a[0] + (int)a.a[1];
279}
280
281struct Array3Short {
282    short a[3];
283};
284
285int Array3Shorts(struct Array3Short a) {
286    return (int)a.a[0] + (int)a.a[1] + (int)a.a[2];
287}
288
289struct BoolStruct {
290    _Bool b;
291};
292
293_Bool BoolStruct(struct BoolStruct b) {
294    return b.b;
295}
296
297struct BoolFloat {
298    _Bool b;
299    float f;
300};
301
302float BoolFloat(struct BoolFloat s) {
303    if (s.b)
304        return s.f;
305    return -s.f;
306}
307
308struct Content {
309      struct { double x, y; } point;
310      struct { double width, height; } size;
311};
312
313unsigned long InitWithContentRect(int *win, struct Content c, int style, int backing, _Bool flag) {
314  if (win == 0)
315      return 0xBAD;
316  if (!flag)
317      return 0xF1A6; // FLAG
318  return (unsigned long)(c.point.x + c.point.y + c.size.width + c.size.height) / (style - backing);
319}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close