Skip to content

Commit 0efc6cd

Browse files
authored
Merge pull request #1423 from AThousandShips/style_fix
Fix some style details in generation
2 parents ed1e963 + e7a13e3 commit 0efc6cd

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

binding_generator.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -797,14 +797,16 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
797797

798798
vararg = method["is_vararg"]
799799
if vararg:
800-
result.append("\ttemplate<typename... Args>")
800+
result.append("\ttemplate <typename... Args>")
801801

802802
method_signature = "\t"
803803
if "is_static" in method and method["is_static"]:
804804
method_signature += "static "
805805

806806
if "return_type" in method:
807-
method_signature += f'{correct_type(method["return_type"])} '
807+
method_signature += f'{correct_type(method["return_type"])}'
808+
if not method_signature.endswith("*"):
809+
method_signature += " "
808810
else:
809811
method_signature += "void "
810812

@@ -1222,7 +1224,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
12221224
continue
12231225

12241226
method_signature = make_signature(class_name, method, for_builtin=True)
1225-
result.append(method_signature + "{")
1227+
result.append(method_signature + " {")
12261228

12271229
method_call = "\t"
12281230
is_ref = False
@@ -1642,8 +1644,6 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
16421644
vararg = "is_vararg" in method and method["is_vararg"]
16431645

16441646
method_signature = "\t"
1645-
if vararg:
1646-
method_signature += "private: "
16471647
method_signature += make_signature(
16481648
class_name, method, for_header=True, use_template_get_node=use_template_get_node
16491649
)
@@ -1722,16 +1722,16 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
17221722
if class_name == "Object":
17231723
result.append("")
17241724

1725-
result.append("\ttemplate<typename T>")
1725+
result.append("\ttemplate <typename T>")
17261726
result.append("\tstatic T *cast_to(Object *p_object);")
17271727

1728-
result.append("\ttemplate<typename T>")
1728+
result.append("\ttemplate <typename T>")
17291729
result.append("\tstatic const T *cast_to(const Object *p_object);")
17301730

17311731
result.append("\tvirtual ~Object() = default;")
17321732

17331733
elif use_template_get_node and class_name == "Node":
1734-
result.append("\ttemplate<typename T>")
1734+
result.append("\ttemplate <typename T>")
17351735
result.append(
17361736
"\tT *get_node(const NodePath &p_path) const { return Object::cast_to<T>(get_node_internal(p_path)); }"
17371737
)
@@ -1773,7 +1773,7 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
17731773

17741774
vararg = "is_vararg" in method and method["is_vararg"]
17751775
if vararg:
1776-
method_signature = "\ttemplate<typename... Args> static "
1776+
method_signature = "\ttemplate <typename... Args> static "
17771777
else:
17781778
method_signature = "\tstatic "
17791779

@@ -1787,7 +1787,9 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
17871787
False,
17881788
)
17891789
if return_type is not None:
1790-
method_signature += return_type + " "
1790+
method_signature += return_type
1791+
if not method_signature.endswith("*"):
1792+
method_signature += " "
17911793
else:
17921794
method_signature += "void "
17931795

@@ -2415,7 +2417,7 @@ def make_varargs_template(
24152417
if with_public_declare:
24162418
function_signature = "public: "
24172419

2418-
function_signature += "template<typename... Args> "
2420+
function_signature += "template <typename... Args> "
24192421

24202422
if static:
24212423
function_signature += "static "
@@ -2469,7 +2471,7 @@ def make_varargs_template(
24692471
args_array += "Variant(p_args)... };"
24702472
result.append(args_array)
24712473
result.append(f"\tstd::array<const Variant *, {len(method_arguments)} + sizeof...(Args)> call_args;")
2472-
result.append("\tfor(size_t i = 0; i < variant_args.size(); i++) {")
2474+
result.append("\tfor (size_t i = 0; i < variant_args.size(); i++) {")
24732475
result.append("\t\tcall_args[i] = &variant_args[i];")
24742476
result.append("\t}")
24752477

@@ -2735,7 +2737,7 @@ def correct_type(type_name, meta=None, use_alias=True):
27352737
return f"Ref<{type_name}>"
27362738
if type_name == "Object" or is_engine_class(type_name):
27372739
return f"{type_name} *"
2738-
if type_name.endswith("*"):
2740+
if type_name.endswith("*") and not type_name.endswith("**") and not type_name.endswith(" *"):
27392741
return f"{type_name[:-1]} *"
27402742
return type_name
27412743

0 commit comments

Comments
 (0)