Skip to content

Commit 3a7db0f

Browse files
committed
Update compact_c_ffi.sed to maintain some spacing
1 parent 58b01b8 commit 3a7db0f

3 files changed

Lines changed: 15 additions & 19 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ else
124124
STRIP_CMD =
125125
LDOC_ARGS = --all
126126
endif
127-
INIT_SCRIPT_SED = src/tools/remove_lua_comments.sed src/tools/squeeze_blank_lines.sed src/tools/compact_c_ffi.sed
127+
INIT_SCRIPT_SED = src/tools/remove_lua_comments.sed src/tools/compact_c_ffi.sed src/tools/squeeze_blank_lines.sed
128128
EMBED_SCRIPT_SED = src/tools/embed_to_c.sed src/tools/add_script_c_decl.sed
129129

130130
ifneq (,$(CODE_SIGN_IDENTITY))

src/godot_ffi.lua

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ typedef struct godot_variant {
128128
// Math type definitions copied from HGDN
129129
typedef union godot_vector2 {
130130
// raw data, must be the first field for guaranteeing ABI compatibility with Godot
131-
uint8_t data[sizeof(godot_real[2])];
131+
uint8_t _dont_touch_that[sizeof(godot_real[2])];
132132
// float elements
133133
godot_real elements[2];
134134
// xy
@@ -145,7 +145,7 @@ typedef union godot_vector2 {
145145

146146
typedef union godot_vector3 {
147147
// raw data, must be the first field for guaranteeing ABI compatibility with Godot
148-
uint8_t data[sizeof(godot_real[3])];
148+
uint8_t _dont_touch_that[sizeof(godot_real[3])];
149149
// float elements
150150
godot_real elements[3];
151151
// xyz
@@ -169,7 +169,7 @@ typedef union godot_vector3 {
169169

170170
typedef union godot_color {
171171
// raw data, must be the first field for guaranteeing ABI compatibility with Godot
172-
uint8_t data[sizeof(godot_real[4])];
172+
uint8_t _dont_touch_that[sizeof(godot_real[4])];
173173
godot_real elements[4];
174174
struct { godot_real r, g, b, a; };
175175
struct { godot_vector2 rg; godot_vector2 ba; };
@@ -180,22 +180,22 @@ typedef union godot_color {
180180

181181
typedef union godot_rect2 {
182182
// raw data, must be the first field for guaranteeing ABI compatibility with Godot
183-
uint8_t data[sizeof(godot_real[4])];
183+
uint8_t _dont_touch_that[sizeof(godot_real[4])];
184184
godot_real elements[4];
185185
struct { godot_real x, y, width, height; };
186186
struct { godot_vector2 position; godot_vector2 size; };
187187
} godot_rect2;
188188

189189
typedef union godot_plane {
190190
// raw data, must be the first field for guaranteeing ABI compatibility with Godot
191-
uint8_t data[sizeof(godot_real[4])];
191+
uint8_t _dont_touch_that[sizeof(godot_real[4])];
192192
godot_real elements[4];
193193
struct { godot_vector3 normal; godot_real d; };
194194
} godot_plane;
195195

196196
typedef union godot_quat {
197197
// raw data, must be the first field for guaranteeing ABI compatibility with Godot
198-
uint8_t data[sizeof(godot_real[4])];
198+
uint8_t _dont_touch_that[sizeof(godot_real[4])];
199199
godot_real elements[4];
200200
struct { godot_real x, y, z, w; };
201201
struct { godot_vector2 xy; godot_vector2 zw; };
@@ -206,29 +206,29 @@ typedef union godot_quat {
206206

207207
typedef union godot_basis {
208208
// raw data, must be the first field for guaranteeing ABI compatibility with Godot
209-
uint8_t data[sizeof(godot_real[9])];
209+
uint8_t _dont_touch_that[sizeof(godot_real[9])];
210210
godot_real elements[9];
211211
godot_vector3 rows[3];
212212
} godot_basis;
213213

214214
typedef union godot_aabb {
215215
// raw data, must be the first field for guaranteeing ABI compatibility with Godot
216-
uint8_t data[sizeof(godot_real[6])];
216+
uint8_t _dont_touch_that[sizeof(godot_real[6])];
217217
godot_real elements[6];
218218
struct { godot_vector3 position, size; };
219219
} godot_aabb;
220220

221221
typedef union godot_transform2d {
222222
// raw data, must be the first field for guaranteeing ABI compatibility with Godot
223-
uint8_t data[sizeof(godot_real[6])];
223+
uint8_t _dont_touch_that[sizeof(godot_real[6])];
224224
godot_real elements[6];
225225
godot_vector2 columns[3];
226226
struct { godot_vector2 x, y, origin; };
227227
} godot_transform2d;
228228

229229
typedef union godot_transform {
230230
// raw data, must be the first field for guaranteeing ABI compatibility with Godot
231-
uint8_t data[sizeof(godot_real[12])];
231+
uint8_t _dont_touch_that[sizeof(godot_real[12])];
232232
godot_real elements[12];
233233
struct { godot_basis basis; godot_vector3 origin; };
234234
} godot_transform;

src/tools/compact_c_ffi.sed

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
/cdef\[\[/,/\]\]/ {
2-
# Remove indentation
3-
s/^[[:space:]]*//
42
# Remove C comments
53
s/[[:space:]]*\/\/.*//
64
# Minify unused private fields
7-
s/_dont_touch_that/d/
5+
s/_dont_touch_that/_/
86
# Remove function parameter names
97
/\(\*/ {
10-
s/[_a-zA-Z0-9]*(,|\);)/\1/g
8+
s/[[:space:]]*[_a-zA-Z0-9]*(,|\);)/\1/g
119
}
12-
# Remove spaces before/after punctuation
13-
s/[[:space:]]*([^_a-zA-Z0-9])[[:space:]]*/\1/g
14-
# Remove empty lines
15-
/^$/d
10+
# Remove unused enum/struct/union names when they're typedef'd
11+
s/typedef (enum|struct|union) [_a-zA-Z0-9]*/typedef \1/
1612
}
1713

0 commit comments

Comments
 (0)