소스 검색

Merge pull request #729 from bruvzg/static_methods

Add support for static method bindings.
Rémi Verschelde 3 년 전
부모
커밋
3d4d004fb6
2개의 변경된 파일227개의 추가작업 그리고 137개의 파일을 삭제
  1. 15 4
      binding_generator.py
  2. 212 133
      godot-headers/extension_api.json

+ 15 - 4
binding_generator.py

@@ -1119,12 +1119,21 @@ def generate_engine_class_source(class_api, used_classes, fully_used_classes, us
                     return_type = method["return_value"]["type"]
                     meta_type = method["return_value"]["meta"] if "meta" in method["return_value"] else None
                     if is_pod_type(return_type) or is_variant(return_type) or is_enum(return_type):
-                        method_call += f"return internal::_call_native_mb_ret<{get_gdnative_type(correct_type(return_type, meta_type))}>(___method_bind, _owner"
+                        if method["is_static"]:
+                            method_call += f"return internal::_call_native_mb_ret<{get_gdnative_type(correct_type(return_type, meta_type))}>(___method_bind, nullptr"
+                        else:
+                            method_call += f"return internal::_call_native_mb_ret<{get_gdnative_type(correct_type(return_type, meta_type))}>(___method_bind, _owner"
                     elif is_refcounted(return_type):
-                        method_call += f"return Ref<{return_type}>::___internal_constructor(internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, _owner"
+                        if method["is_static"]:
+                            method_call += f"return Ref<{return_type}>::___internal_constructor(internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, _nullptr"
+                        else:
+                            method_call += f"return Ref<{return_type}>::___internal_constructor(internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, _owner"
                         is_ref = True
                     else:
-                        method_call += f"return internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, _owner"
+                        if method["is_static"]:
+                            method_call += f"return internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, nullptr"
+                        else:
+                            method_call += f"return internal::_call_native_mb_ret_obj<{return_type}>(___method_bind, _owner"
                 else:
                     method_call += f"internal::_call_native_mb_no_ret(___method_bind, _owner"
 
@@ -1511,7 +1520,9 @@ def make_signature(
 
     function_signature += ")"
 
-    if "is_const" in function_data and function_data["is_const"]:
+    if "is_static" in function_data and function_data["is_static"] and for_header:
+        function_signature = "static " + function_signature
+    elif "is_const" in function_data and function_data["is_const"]:
         function_signature += " const"
 
     return function_signature

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 212 - 133
godot-headers/extension_api.json


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.