@@ -51,11 +51,7 @@ def generate_mod_version(argcount, const=False, returns=False):
51
51
def generate_wrappers (target ):
52
52
max_versions = 12
53
53
54
- txt = """
55
- #ifndef GDEXTENSION_WRAPPERS_GEN_H
56
- #define GDEXTENSION_WRAPPERS_GEN_H
57
-
58
- """
54
+ txt = "#pragma once"
59
55
60
56
for i in range (max_versions + 1 ):
61
57
txt += "\n /* Module Wrapper " + str (i ) + " Arguments */\n "
@@ -64,8 +60,6 @@ def generate_wrappers(target):
64
60
txt += generate_mod_version (i , True , False )
65
61
txt += generate_mod_version (i , True , True )
66
62
67
- txt += "\n #endif\n "
68
-
69
63
with open (target , "w" , encoding = "utf-8" ) as f :
70
64
f .write (txt )
71
65
@@ -187,8 +181,7 @@ def generate_virtuals(target):
187
181
max_versions = 12
188
182
189
183
txt = """/* THIS FILE IS GENERATED DO NOT EDIT */
190
- #ifndef GDEXTENSION_GDVIRTUAL_GEN_H
191
- #define GDEXTENSION_GDVIRTUAL_GEN_H
184
+ #pragma once
192
185
193
186
"""
194
187
@@ -203,8 +196,6 @@ def generate_virtuals(target):
203
196
txt += generate_virtual_version (i , True , False , True )
204
197
txt += generate_virtual_version (i , True , True , True )
205
198
206
- txt += "#endif // GDEXTENSION_GDVIRTUAL_GEN_H\n "
207
-
208
199
with open (target , "w" , encoding = "utf-8" ) as f :
209
200
f .write (txt )
210
201
@@ -364,11 +355,8 @@ def generate_builtin_bindings(api, output_dir, build_config):
364
355
variant_size_source = []
365
356
add_header ("variant_size.hpp" , variant_size_source )
366
357
367
- header_guard = "GODOT_CPP_VARIANT_SIZE_HPP"
368
- variant_size_source .append (f"#ifndef { header_guard } " )
369
- variant_size_source .append (f"#define { header_guard } " )
358
+ variant_size_source .append ("#pragma once" )
370
359
variant_size_source .append (f'#define GODOT_CPP_VARIANT_SIZE { builtin_sizes ["Variant" ]} ' )
371
- variant_size_source .append (f"#endif // ! { header_guard } " )
372
360
373
361
variant_size_file .write ("\n " .join (variant_size_source ))
374
362
@@ -448,8 +436,7 @@ def generate_builtin_bindings(api, output_dir, build_config):
448
436
builtin_header = []
449
437
add_header ("builtin_types.hpp" , builtin_header )
450
438
451
- builtin_header .append ("#ifndef GODOT_CPP_BUILTIN_TYPES_HPP" )
452
- builtin_header .append ("#define GODOT_CPP_BUILTIN_TYPES_HPP" )
439
+ builtin_header .append ("#pragma once" )
453
440
454
441
builtin_header .append ("" )
455
442
@@ -464,8 +451,6 @@ def generate_builtin_bindings(api, output_dir, build_config):
464
451
465
452
builtin_header .append ("" )
466
453
467
- builtin_header .append ("#endif // ! GODOT_CPP_BUILTIN_TYPES_HPP" )
468
-
469
454
builtin_header_file .write ("\n " .join (builtin_header ))
470
455
471
456
# Create a header with bindings for builtin types.
@@ -474,8 +459,7 @@ def generate_builtin_bindings(api, output_dir, build_config):
474
459
builtin_binds = []
475
460
add_header ("builtin_binds.hpp" , builtin_binds )
476
461
477
- builtin_binds .append ("#ifndef GODOT_CPP_BUILTIN_BINDS_HPP" )
478
- builtin_binds .append ("#define GODOT_CPP_BUILTIN_BINDS_HPP" )
462
+ builtin_binds .append ("#pragma once" )
479
463
builtin_binds .append ("" )
480
464
builtin_binds .append ("#include <godot_cpp/variant/builtin_types.hpp>" )
481
465
builtin_binds .append ("" )
@@ -487,7 +471,6 @@ def generate_builtin_bindings(api, output_dir, build_config):
487
471
builtin_binds .append (f"VARIANT_ENUM_CAST({ builtin_api ['name' ]} ::{ enum_api ['name' ]} );" )
488
472
489
473
builtin_binds .append ("" )
490
- builtin_binds .append ("#endif // ! GODOT_CPP_BUILTIN_BINDS_HPP" )
491
474
492
475
builtin_binds_file .write ("\n " .join (builtin_binds ))
493
476
@@ -503,9 +486,7 @@ def generate_builtin_class_vararg_method_implements_header(builtin_classes):
503
486
504
487
add_header ("builtin_vararg_methods.hpp" , result )
505
488
506
- header_guard = "GODOT_CPP_BUILTIN_VARARG_METHODS_HPP"
507
- result .append (f"#ifndef { header_guard } " )
508
- result .append (f"#define { header_guard } " )
489
+ result .append ("#pragma once" )
509
490
result .append ("" )
510
491
for builtin_api in builtin_classes :
511
492
if "methods" not in builtin_api :
@@ -520,8 +501,6 @@ def generate_builtin_class_vararg_method_implements_header(builtin_classes):
520
501
)
521
502
result .append ("" )
522
503
523
- result .append (f"#endif // ! { header_guard } " )
524
-
525
504
return "\n " .join (result )
526
505
527
506
@@ -531,12 +510,9 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
531
510
class_name = builtin_api ["name" ]
532
511
snake_class_name = camel_to_snake (class_name ).upper ()
533
512
534
- header_guard = f"GODOT_CPP_{ snake_class_name } _HPP"
535
-
536
513
add_header (f"{ snake_class_name .lower ()} .hpp" , result )
537
514
538
- result .append (f"#ifndef { header_guard } " )
539
- result .append (f"#define { header_guard } " )
515
+ result .append ("#pragma once" )
540
516
541
517
result .append ("" )
542
518
result .append ("#include <godot_cpp/core/defs.hpp>" )
@@ -965,8 +941,6 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
965
941
result .append ("" )
966
942
result .append ("} // namespace godot" )
967
943
968
- result .append ("" )
969
- result .append (f"#endif // ! { header_guard } " )
970
944
result .append ("" )
971
945
972
946
return "\n " .join (result )
@@ -1498,9 +1472,7 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
1498
1472
result = []
1499
1473
add_header (f"{ snake_struct_name } .hpp" , result )
1500
1474
1501
- header_guard = f"GODOT_CPP_{ snake_struct_name .upper ()} _HPP"
1502
- result .append (f"#ifndef { header_guard } " )
1503
- result .append (f"#define { header_guard } " )
1475
+ result .append ("#pragma once" )
1504
1476
1505
1477
used_classes = []
1506
1478
expanded_format = native_struct ["format" ].replace ("(" , " " ).replace (")" , ";" ).replace ("," , ";" )
@@ -1540,7 +1512,6 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
1540
1512
result .append ("" )
1541
1513
result .append ("} // namespace godot" )
1542
1514
result .append ("" )
1543
- result .append (f"#endif // ! { header_guard } " )
1544
1515
1545
1516
with header_filename .open ("w+" , encoding = "utf-8" ) as header_file :
1546
1517
header_file .write ("\n " .join (result ))
@@ -1556,11 +1527,7 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
1556
1527
1557
1528
add_header (f"{ snake_class_name .lower ()} .hpp" , result )
1558
1529
1559
- header_guard = f"GODOT_CPP_{ snake_class_name } _HPP"
1560
-
1561
- result .append (f"#ifndef { header_guard } " )
1562
- result .append (f"#define { header_guard } " )
1563
-
1530
+ result .append ("#pragma once" )
1564
1531
result .append ("" )
1565
1532
1566
1533
if len (fully_used_classes ) > 0 :
@@ -1849,7 +1816,6 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
1849
1816
result .append ("\t " )
1850
1817
result .append ("" )
1851
1818
1852
- result .append (f"#endif // ! { header_guard } " )
1853
1819
result .append ("" )
1854
1820
1855
1821
return "\n " .join (result )
@@ -2051,9 +2017,7 @@ def generate_global_constants(api, output_dir):
2051
2017
2052
2018
header_filename = include_gen_folder / "global_constants.hpp"
2053
2019
2054
- header_guard = "GODOT_CPP_GLOBAL_CONSTANTS_HPP"
2055
- header .append (f"#ifndef { header_guard } " )
2056
- header .append (f"#define { header_guard } " )
2020
+ header .append ("#pragma once" )
2057
2021
header .append ("" )
2058
2022
header .append ("#include <cstdint>" )
2059
2023
header .append ("" )
@@ -2083,7 +2047,6 @@ def generate_global_constants(api, output_dir):
2083
2047
header .append ("} // namespace godot" )
2084
2048
2085
2049
header .append ("" )
2086
- header .append (f"#endif // ! { header_guard } " )
2087
2050
2088
2051
with header_filename .open ("w+" , encoding = "utf-8" ) as header_file :
2089
2052
header_file .write ("\n " .join (header ))
@@ -2099,9 +2062,7 @@ def generate_version_header(api, output_dir):
2099
2062
2100
2063
header_file_path = include_gen_folder / header_filename
2101
2064
2102
- header_guard = "GODOT_CPP_VERSION_HPP"
2103
- header .append (f"#ifndef { header_guard } " )
2104
- header .append (f"#define { header_guard } " )
2065
+ header .append ("#pragma once" )
2105
2066
header .append ("" )
2106
2067
2107
2068
header .append (f"#define GODOT_VERSION_MAJOR { api ['header' ]['version_major' ]} " )
@@ -2110,8 +2071,6 @@ def generate_version_header(api, output_dir):
2110
2071
header .append (f"#define GODOT_VERSION_STATUS \" { api ['header' ]['version_status' ]} \" " )
2111
2072
header .append (f"#define GODOT_VERSION_BUILD \" { api ['header' ]['version_build' ]} \" " )
2112
2073
2113
- header .append ("" )
2114
- header .append (f"#endif // { header_guard } " )
2115
2074
header .append ("" )
2116
2075
2117
2076
with header_file_path .open ("w+" , encoding = "utf-8" ) as header_file :
@@ -2132,9 +2091,7 @@ def generate_global_constant_binds(api, output_dir):
2132
2091
2133
2092
header_filename = include_gen_folder / "global_constants_binds.hpp"
2134
2093
2135
- header_guard = "GODOT_CPP_GLOBAL_CONSTANTS_BINDS_HPP"
2136
- header .append (f"#ifndef { header_guard } " )
2137
- header .append (f"#define { header_guard } " )
2094
+ header .append ("#pragma once" )
2138
2095
header .append ("" )
2139
2096
header .append ("#include <godot_cpp/classes/global_constants.hpp>" )
2140
2097
header .append ("" )
@@ -2153,8 +2110,6 @@ def generate_global_constant_binds(api, output_dir):
2153
2110
2154
2111
header .append ("" )
2155
2112
2156
- header .append (f"#endif // ! { header_guard } " )
2157
-
2158
2113
with header_filename .open ("w+" , encoding = "utf-8" ) as header_file :
2159
2114
header_file .write ("\n " .join (header ))
2160
2115
@@ -2173,9 +2128,7 @@ def generate_utility_functions(api, output_dir):
2173
2128
2174
2129
header_filename = include_gen_folder / "utility_functions.hpp"
2175
2130
2176
- header_guard = "GODOT_CPP_UTILITY_FUNCTIONS_HPP"
2177
- header .append (f"#ifndef { header_guard } " )
2178
- header .append (f"#define { header_guard } " )
2131
+ header .append ("#pragma once" )
2179
2132
header .append ("" )
2180
2133
header .append ("#include <godot_cpp/variant/builtin_types.hpp>" )
2181
2134
header .append ("#include <godot_cpp/variant/variant.hpp>" )
@@ -2214,7 +2167,6 @@ def generate_utility_functions(api, output_dir):
2214
2167
header .append ("" )
2215
2168
header .append ("} // namespace godot" )
2216
2169
header .append ("" )
2217
- header .append (f"#endif // ! { header_guard } " )
2218
2170
2219
2171
with header_filename .open ("w+" , encoding = "utf-8" ) as header_file :
2220
2172
header_file .write ("\n " .join (header ))
0 commit comments