Skip to content

Commit efc16b4

Browse files
committed
In generated methods, only construct the method StringName the first time
1 parent d627942 commit efc16b4

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

binding_generator.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,9 +1453,8 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us
14531453

14541454
if is_singleton:
14551455
result.append(f"{class_name} *{class_name}::get_singleton() {{")
1456-
result.append(f"\tconst StringName _gde_class_name = {class_name}::get_class_static();")
14571456
result.append(
1458-
"\tstatic GDExtensionObjectPtr singleton_obj = internal::gdextension_interface_global_get_singleton(_gde_class_name._native_ptr());"
1457+
f"\tstatic GDExtensionObjectPtr singleton_obj = internal::gdextension_interface_global_get_singleton({class_name}::get_class_static()._native_ptr());"
14591458
)
14601459
result.append("#ifdef DEBUG_ENABLED")
14611460
result.append("\tERR_FAIL_COND_V(singleton_obj == nullptr, nullptr);")
@@ -1480,10 +1479,8 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us
14801479
result.append(method_signature + " {")
14811480

14821481
# Method body.
1483-
result.append(f"\tconst StringName _gde_class_name = {class_name}::get_class_static();")
1484-
result.append(f'\tconst StringName _gde_method_name = "{method["name"]}";')
14851482
result.append(
1486-
f'\tstatic GDExtensionMethodBindPtr _gde_method_bind = internal::gdextension_interface_classdb_get_method_bind(_gde_class_name._native_ptr(), _gde_method_name._native_ptr(), {method["hash"]});'
1483+
f'\tstatic GDExtensionMethodBindPtr _gde_method_bind = internal::gdextension_interface_classdb_get_method_bind({class_name}::get_class_static()._native_ptr(), StringName("{method["name"]}")._native_ptr(), {method["hash"]});'
14871484
)
14881485
method_call = "\t"
14891486
has_return = "return_value" in method and method["return_value"]["type"] != "void"
@@ -1773,9 +1770,8 @@ def generate_utility_functions(api, output_dir):
17731770

17741771
# Function body.
17751772

1776-
source.append(f'\tconst StringName _gde_function_name = "{function["name"]}";')
17771773
source.append(
1778-
f'\tstatic GDExtensionPtrUtilityFunction _gde_function = internal::gdextension_interface_variant_get_ptr_utility_function(_gde_function_name._native_ptr(), {function["hash"]});'
1774+
f'\tstatic GDExtensionPtrUtilityFunction _gde_function = internal::gdextension_interface_variant_get_ptr_utility_function(StringName("{function["name"]}")._native_ptr(), {function["hash"]});'
17791775
)
17801776
has_return = "return_type" in function and function["return_type"] != "void"
17811777
if has_return:

0 commit comments

Comments
 (0)