Skip to content

Commit 3d4d004

Browse files
authored
Merge pull request #729 from bruvzg/static_methods
Add support for static method bindings.
2 parents c6109fb + 2802739 commit 3d4d004

File tree

2 files changed

+12045
-504
lines changed

2 files changed

+12045
-504
lines changed

binding_generator.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,12 +1119,21 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us
11191119
return_type = method["return_value"]["type"]
11201120
meta_type = method["return_value"]["meta"] if "meta" in method["return_value"] else None
11211121
if is_pod_type(return_type) or is_variant(return_type) or is_enum(return_type):
1122-
method_call += f"return internal::_call_native_mb_ret<{get_gdnative_type(correct_type(return_type, meta_type))}>(___method_bind, _owner"
1122+
if method["is_static"]:
1123+
method_call += f"return internal::_call_native_mb_ret<{get_gdnative_type(correct_type(return_type, meta_type))}>(___method_bind, nullptr"
1124+
else:
1125+
method_call += f"return internal::_call_native_mb_ret<{get_gdnative_type(correct_type(return_type, meta_type))}>(___method_bind, _owner"
11231126
elif is_refcounted(return_type):
1124-
method_call += f"return Ref<{return_type}>::___internal_constructor(internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, _owner"
1127+
if method["is_static"]:
1128+
method_call += f"return Ref<{return_type}>::___internal_constructor(internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, _nullptr"
1129+
else:
1130+
method_call += f"return Ref<{return_type}>::___internal_constructor(internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, _owner"
11251131
is_ref = True
11261132
else:
1127-
method_call += f"return internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, _owner"
1133+
if method["is_static"]:
1134+
method_call += f"return internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, nullptr"
1135+
else:
1136+
method_call += f"return internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, _owner"
11281137
else:
11291138
method_call += f"internal::_call_native_mb_no_ret(___method_bind, _owner"
11301139

@@ -1511,7 +1520,9 @@ def make_signature(
15111520

15121521
function_signature += ")"
15131522

1514-
if "is_const" in function_data and function_data["is_const"]:
1523+
if "is_static" in function_data and function_data["is_static"] and for_header:
1524+
function_signature = "static " + function_signature
1525+
elif "is_const" in function_data and function_data["is_const"]:
15151526
function_signature += " const"
15161527

15171528
return function_signature

0 commit comments

Comments
 (0)