@@ -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
@@ -359,11 +350,8 @@ def generate_builtin_bindings(api, output_dir, build_config):
359
350
variant_size_source = []
360
351
add_header ("variant_size.hpp" , variant_size_source )
361
352
362
- header_guard = "GODOT_CPP_VARIANT_SIZE_HPP"
363
- variant_size_source .append (f"#ifndef { header_guard } " )
364
- variant_size_source .append (f"#define { header_guard } " )
353
+ variant_size_source .append ("#pragma once" )
365
354
variant_size_source .append (f'#define GODOT_CPP_VARIANT_SIZE { builtin_sizes ["Variant" ]} ' )
366
- variant_size_source .append (f"#endif // ! { header_guard } " )
367
355
368
356
variant_size_file .write ("\n " .join (variant_size_source ))
369
357
@@ -443,8 +431,7 @@ def generate_builtin_bindings(api, output_dir, build_config):
443
431
builtin_header = []
444
432
add_header ("builtin_types.hpp" , builtin_header )
445
433
446
- builtin_header .append ("#ifndef GODOT_CPP_BUILTIN_TYPES_HPP" )
447
- builtin_header .append ("#define GODOT_CPP_BUILTIN_TYPES_HPP" )
434
+ builtin_header .append ("#pragma once" )
448
435
449
436
builtin_header .append ("" )
450
437
@@ -459,8 +446,6 @@ def generate_builtin_bindings(api, output_dir, build_config):
459
446
460
447
builtin_header .append ("" )
461
448
462
- builtin_header .append ("#endif // ! GODOT_CPP_BUILTIN_TYPES_HPP" )
463
-
464
449
builtin_header_file .write ("\n " .join (builtin_header ))
465
450
466
451
# Create a header with bindings for builtin types.
@@ -469,8 +454,7 @@ def generate_builtin_bindings(api, output_dir, build_config):
469
454
builtin_binds = []
470
455
add_header ("builtin_binds.hpp" , builtin_binds )
471
456
472
- builtin_binds .append ("#ifndef GODOT_CPP_BUILTIN_BINDS_HPP" )
473
- builtin_binds .append ("#define GODOT_CPP_BUILTIN_BINDS_HPP" )
457
+ builtin_binds .append ("#pragma once" )
474
458
builtin_binds .append ("" )
475
459
builtin_binds .append ("#include <godot_cpp/variant/builtin_types.hpp>" )
476
460
builtin_binds .append ("" )
@@ -482,7 +466,6 @@ def generate_builtin_bindings(api, output_dir, build_config):
482
466
builtin_binds .append (f"VARIANT_ENUM_CAST({ builtin_api ['name' ]} ::{ enum_api ['name' ]} );" )
483
467
484
468
builtin_binds .append ("" )
485
- builtin_binds .append ("#endif // ! GODOT_CPP_BUILTIN_BINDS_HPP" )
486
469
487
470
builtin_binds_file .write ("\n " .join (builtin_binds ))
488
471
@@ -498,9 +481,7 @@ def generate_builtin_class_vararg_method_implements_header(builtin_classes):
498
481
499
482
add_header ("builtin_vararg_methods.hpp" , result )
500
483
501
- header_guard = "GODOT_CPP_BUILTIN_VARARG_METHODS_HPP"
502
- result .append (f"#ifndef { header_guard } " )
503
- result .append (f"#define { header_guard } " )
484
+ result .append ("#pragma once" )
504
485
result .append ("" )
505
486
for builtin_api in builtin_classes :
506
487
if "methods" not in builtin_api :
@@ -515,8 +496,6 @@ def generate_builtin_class_vararg_method_implements_header(builtin_classes):
515
496
)
516
497
result .append ("" )
517
498
518
- result .append (f"#endif // ! { header_guard } " )
519
-
520
499
return "\n " .join (result )
521
500
522
501
@@ -526,12 +505,9 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
526
505
class_name = builtin_api ["name" ]
527
506
snake_class_name = camel_to_snake (class_name ).upper ()
528
507
529
- header_guard = f"GODOT_CPP_{ snake_class_name } _HPP"
530
-
531
508
add_header (f"{ snake_class_name .lower ()} .hpp" , result )
532
509
533
- result .append (f"#ifndef { header_guard } " )
534
- result .append (f"#define { header_guard } " )
510
+ result .append ("#pragma once" )
535
511
536
512
result .append ("" )
537
513
result .append ("#include <godot_cpp/core/defs.hpp>" )
@@ -960,8 +936,6 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
960
936
result .append ("" )
961
937
result .append ("} // namespace godot" )
962
938
963
- result .append ("" )
964
- result .append (f"#endif // ! { header_guard } " )
965
939
result .append ("" )
966
940
967
941
return "\n " .join (result )
@@ -1493,9 +1467,7 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
1493
1467
result = []
1494
1468
add_header (f"{ snake_struct_name } .hpp" , result )
1495
1469
1496
- header_guard = f"GODOT_CPP_{ snake_struct_name .upper ()} _HPP"
1497
- result .append (f"#ifndef { header_guard } " )
1498
- result .append (f"#define { header_guard } " )
1470
+ result .append ("#pragma once" )
1499
1471
1500
1472
used_classes = []
1501
1473
expanded_format = native_struct ["format" ].replace ("(" , " " ).replace (")" , ";" ).replace ("," , ";" )
@@ -1535,7 +1507,6 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
1535
1507
result .append ("" )
1536
1508
result .append ("} // namespace godot" )
1537
1509
result .append ("" )
1538
- result .append (f"#endif // ! { header_guard } " )
1539
1510
1540
1511
with header_filename .open ("w+" , encoding = "utf-8" ) as header_file :
1541
1512
header_file .write ("\n " .join (result ))
@@ -1551,11 +1522,7 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
1551
1522
1552
1523
add_header (f"{ snake_class_name .lower ()} .hpp" , result )
1553
1524
1554
- header_guard = f"GODOT_CPP_{ snake_class_name } _HPP"
1555
-
1556
- result .append (f"#ifndef { header_guard } " )
1557
- result .append (f"#define { header_guard } " )
1558
-
1525
+ result .append ("#pragma once" )
1559
1526
result .append ("" )
1560
1527
1561
1528
if len (fully_used_classes ) > 0 :
@@ -1844,7 +1811,6 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
1844
1811
result .append ("\t " )
1845
1812
result .append ("" )
1846
1813
1847
- result .append (f"#endif // ! { header_guard } " )
1848
1814
result .append ("" )
1849
1815
1850
1816
return "\n " .join (result )
@@ -2046,9 +2012,7 @@ def generate_global_constants(api, output_dir):
2046
2012
2047
2013
header_filename = include_gen_folder / "global_constants.hpp"
2048
2014
2049
- header_guard = "GODOT_CPP_GLOBAL_CONSTANTS_HPP"
2050
- header .append (f"#ifndef { header_guard } " )
2051
- header .append (f"#define { header_guard } " )
2015
+ header .append ("#pragma once" )
2052
2016
header .append ("" )
2053
2017
header .append ("#include <cstdint>" )
2054
2018
header .append ("" )
@@ -2078,7 +2042,6 @@ def generate_global_constants(api, output_dir):
2078
2042
header .append ("} // namespace godot" )
2079
2043
2080
2044
header .append ("" )
2081
- header .append (f"#endif // ! { header_guard } " )
2082
2045
2083
2046
with header_filename .open ("w+" , encoding = "utf-8" ) as header_file :
2084
2047
header_file .write ("\n " .join (header ))
@@ -2094,9 +2057,7 @@ def generate_version_header(api, output_dir):
2094
2057
2095
2058
header_file_path = include_gen_folder / header_filename
2096
2059
2097
- header_guard = "GODOT_CPP_VERSION_HPP"
2098
- header .append (f"#ifndef { header_guard } " )
2099
- header .append (f"#define { header_guard } " )
2060
+ header .append ("#pragma once" )
2100
2061
header .append ("" )
2101
2062
2102
2063
header .append (f"#define GODOT_VERSION_MAJOR { api ['header' ]['version_major' ]} " )
@@ -2105,8 +2066,6 @@ def generate_version_header(api, output_dir):
2105
2066
header .append (f"#define GODOT_VERSION_STATUS \" { api ['header' ]['version_status' ]} \" " )
2106
2067
header .append (f"#define GODOT_VERSION_BUILD \" { api ['header' ]['version_build' ]} \" " )
2107
2068
2108
- header .append ("" )
2109
- header .append (f"#endif // { header_guard } " )
2110
2069
header .append ("" )
2111
2070
2112
2071
with header_file_path .open ("w+" , encoding = "utf-8" ) as header_file :
@@ -2127,9 +2086,7 @@ def generate_global_constant_binds(api, output_dir):
2127
2086
2128
2087
header_filename = include_gen_folder / "global_constants_binds.hpp"
2129
2088
2130
- header_guard = "GODOT_CPP_GLOBAL_CONSTANTS_BINDS_HPP"
2131
- header .append (f"#ifndef { header_guard } " )
2132
- header .append (f"#define { header_guard } " )
2089
+ header .append ("#pragma once" )
2133
2090
header .append ("" )
2134
2091
header .append ("#include <godot_cpp/classes/global_constants.hpp>" )
2135
2092
header .append ("" )
@@ -2148,8 +2105,6 @@ def generate_global_constant_binds(api, output_dir):
2148
2105
2149
2106
header .append ("" )
2150
2107
2151
- header .append (f"#endif // ! { header_guard } " )
2152
-
2153
2108
with header_filename .open ("w+" , encoding = "utf-8" ) as header_file :
2154
2109
header_file .write ("\n " .join (header ))
2155
2110
@@ -2168,9 +2123,7 @@ def generate_utility_functions(api, output_dir):
2168
2123
2169
2124
header_filename = include_gen_folder / "utility_functions.hpp"
2170
2125
2171
- header_guard = "GODOT_CPP_UTILITY_FUNCTIONS_HPP"
2172
- header .append (f"#ifndef { header_guard } " )
2173
- header .append (f"#define { header_guard } " )
2126
+ header .append ("#pragma once" )
2174
2127
header .append ("" )
2175
2128
header .append ("#include <godot_cpp/variant/builtin_types.hpp>" )
2176
2129
header .append ("#include <godot_cpp/variant/variant.hpp>" )
@@ -2209,7 +2162,6 @@ def generate_utility_functions(api, output_dir):
2209
2162
header .append ("" )
2210
2163
header .append ("} // namespace godot" )
2211
2164
header .append ("" )
2212
- header .append (f"#endif // ! { header_guard } " )
2213
2165
2214
2166
with header_filename .open ("w+" , encoding = "utf-8" ) as header_file :
2215
2167
header_file .write ("\n " .join (header ))
0 commit comments