Skip to content

Commit 71f745c

Browse files
committed
update to also take missing classes/structs
1 parent 99e6857 commit 71f745c

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

binding_generator.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,9 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False):
222222
continue
223223

224224
header_filename = include_gen_folder / "variant" / (camel_to_snake(builtin_class["name"]) + ".hpp")
225-
header_compat_filename = include_gen_compat_folder / "variant" / (camel_to_snake(builtin_class["name"]) + ".hpp")
226225
source_filename = source_gen_folder / "variant" / (camel_to_snake(builtin_class["name"]) + ".cpp")
227226
if headers:
228227
files.append(str(header_filename.as_posix()))
229-
files.append(str(header_compat_filename.as_posix()))
230228
if sources:
231229
files.append(str(source_filename.as_posix()))
232230

@@ -236,11 +234,9 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False):
236234
engine_class["name"] = "ClassDBSingleton"
237235
engine_class["alias_for"] = "ClassDB"
238236
header_filename = include_gen_folder / "classes" / (camel_to_snake(engine_class["name"]) + ".hpp")
239-
header_compat_filename = include_gen_compat_folder / "classes" / (camel_to_snake(engine_class["name"]) + ".hpp")
240237
source_filename = source_gen_folder / "classes" / (camel_to_snake(engine_class["name"]) + ".cpp")
241238
if headers:
242239
files.append(str(header_filename.as_posix()))
243-
files.append(str(header_compat_filename.as_posix()))
244240
if sources:
245241
files.append(str(source_filename.as_posix()))
246242

@@ -251,10 +247,8 @@ def get_file_list(api_filepath, output_dir, headers=False, sources=False):
251247
snake_struct_name = camel_to_snake(struct_name)
252248

253249
header_filename = include_gen_folder / "classes" / (snake_struct_name + ".hpp")
254-
header_compat_filename = include_gen_compat_folder / "classes" / (snake_struct_name + ".hpp")
255250
if headers:
256251
files.append(str(header_filename.as_posix()))
257-
files.append(str(header_compat_filename.as_posix()))
258252

259253
if headers:
260254
for path in [
@@ -1485,6 +1479,7 @@ def generate_compat_includes(output_dir: Path, target_dir: Path):
14851479
result.append(f"#include <{file_godot_name}>")
14861480
result.append(f"#else")
14871481
result.append(f"#include <{file_godot_cpp_name}>")
1482+
result.append(f"using namespace godot;")
14881483
result.append(f"#endif")
14891484
result.append("")
14901485
result.append(f"#endif // ! {header_guard}")

compat_generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ def parse_header_file(file_path):
1111
content = file.read()
1212

1313
# Regular expressions to match different types
14-
class_pattern = r"class\s+([a-zA-Z_]\w*)\s*[:{]"
15-
struct_pattern = r"struct\s+([a-zA-Z_]\w*)\s*[:{]"
14+
struct_pattern = r"struct\s+[\w\s]*?([a-zA-Z_]\w*)\s*[:{]"
15+
class_pattern = r"class\s+[\w\s]*?([a-zA-Z_]\w*)\s*[:{]"
1616
define_pattern = r"#define\s+([a-zA-Z_]\w*)"
1717

1818
# Extract classes

module_converter.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
from header_matcher import match_headers
1010

1111
if __name__ == "__main__":
12-
if len(sys.argv) > 2:
13-
current_directory = os.path.join(os.getcwd(), sys.argv[1])
14-
godot_cpp_directory = os.path.join(os.getcwd(), sys.argv[2])
12+
if len(sys.argv) > 3:
13+
src_directory = os.path.join(os.getcwd(), sys.argv[1])
14+
godot_directory = os.path.join(os.getcwd(), sys.argv[2])
15+
godot_cpp_directory = os.path.join(os.getcwd(), sys.argv[3])
16+
else:
17+
raise Exception("Usage: python module_converter.py <source directory> <godot directory> <godot-cpp directory>")
1518
# Load the godot mappings
16-
with open(f"{godot_cpp_directory}/output_header_mapping.json", "r") as file:
19+
with open(f"{godot_directory}/output_header_mapping_godot.json", "r") as file:
1720
godot_mappings = json.load(file)
1821

1922
# Generate mappings for godot-cpp
@@ -22,9 +25,9 @@
2225
# Save matches to a file
2326
with open("header_matches.json", "w") as outfile:
2427
json.dump(matches, outfile, indent=4)
25-
current_directory = os.getcwd()
28+
src_directory = os.getcwd()
2629
# Go through folder specified through all files with .cpp, .h or .hpp
27-
for root, dirs, files in os.walk(current_directory):
30+
for root, dirs, files in os.walk(src_directory):
2831
for file in files:
2932
if file.endswith(".cpp") or file.endswith(".h") or file.endswith(".hpp"):
3033
with open(os.path.join(root, file), "r") as f:

0 commit comments

Comments
 (0)