瀏覽代碼

Sync godot-headers and fix build after "Create GDExtension clases for PhysicsServer3D".

bruvzg 3 年之前
父節點
當前提交
93de1b2b0b
共有 4 個文件被更改,包括 486 次插入512 次删除
  1. 26 4
      binding_generator.py
  2. 436 508
      godot-headers/extension_api.json
  3. 2 0
      godot-headers/godot/gdnative_interface.h
  4. 22 0
      include/godot_cpp/core/object.hpp

+ 26 - 4
binding_generator.py

@@ -870,13 +870,29 @@ def generate_engine_classes_bindings(api, output_dir, use_template_get_node):
         result.append(f"#ifndef {header_guard}")
         result.append(f"#define {header_guard}")
 
+        used_classes = []
+        expanded_format = native_struct["format"].replace("(", " ").replace(")", ";").replace(",", ";")
+        for field in expanded_format.split(";"):
+            field_type = field.strip().split(" ")[0].split("::")[0]
+            if field_type != "" and not is_included_type(field_type) and not is_pod_type(field_type):
+                if not field_type in used_classes:
+                    used_classes.append(field_type)
+
         result.append("")
+
+        for included in used_classes:
+            result.append(f"#include <godot_cpp/{get_include_path(included)}>")
+
+        if len(used_classes) > 0:
+            result.append("")
+
         result.append("namespace godot {")
         result.append("")
 
         result.append(f"struct {struct_name} {{")
-        for field in native_struct["format"].split(","):
-            result.append(f"\t{field};")
+        for field in native_struct["format"].split(";"):
+            if field != "":
+                result.append(f"\t{field};")
         result.append("};")
 
         result.append("")
@@ -1582,10 +1598,15 @@ def is_pod_type(type_name):
     return type_name in [
         "Nil",
         "void",
-        "int",
-        "float",
         "bool",
+        "real_t",
+        "float",
         "double",
+        "int",
+        "int8_t",
+        "uint8_t",
+        "int16_t",
+        "uint16_t",
         "int32_t",
         "int64_t",
         "uint32_t",
@@ -1601,6 +1622,7 @@ def is_included_type(type_name):
         "AABB",
         "Basis",
         "Color",
+        "ObjectID",
         "Plane",
         "Quaternion",
         "Rect2",

文件差異過大導致無法顯示
+ 436 - 508
godot-headers/extension_api.json


+ 2 - 0
godot-headers/godot/gdnative_interface.h

@@ -306,6 +306,8 @@ typedef struct {
 	void (*print_warning)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line);
 	void (*print_script_error)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line);
 
+	uint64_t (*get_native_struct_size)(const char *p_name);
+
 	/* GODOT VARIANT */
 
 	/* variant general */

+ 22 - 0
include/godot_cpp/core/object.hpp

@@ -134,6 +134,28 @@ MethodInfo::MethodInfo(const PropertyInfo &p_ret, const char *p_name, const Args
 	arguments = { args... };
 }
 
+class ObjectID {
+	uint64_t id = 0;
+
+public:
+	_FORCE_INLINE_ bool is_ref_counted() const { return (id & (uint64_t(1) << 63)) != 0; }
+	_FORCE_INLINE_ bool is_valid() const { return id != 0; }
+	_FORCE_INLINE_ bool is_null() const { return id == 0; }
+	_FORCE_INLINE_ operator uint64_t() const { return id; }
+	_FORCE_INLINE_ operator int64_t() const { return id; }
+
+	_FORCE_INLINE_ bool operator==(const ObjectID &p_id) const { return id == p_id.id; }
+	_FORCE_INLINE_ bool operator!=(const ObjectID &p_id) const { return id != p_id.id; }
+	_FORCE_INLINE_ bool operator<(const ObjectID &p_id) const { return id < p_id.id; }
+
+	_FORCE_INLINE_ void operator=(int64_t p_int64) { id = p_int64; }
+	_FORCE_INLINE_ void operator=(uint64_t p_uint64) { id = p_uint64; }
+
+	_FORCE_INLINE_ ObjectID() {}
+	_FORCE_INLINE_ explicit ObjectID(const uint64_t p_id) { id = p_id; }
+	_FORCE_INLINE_ explicit ObjectID(const int64_t p_id) { id = p_id; }
+};
+
 class ObjectDB {
 public:
 	static Object *get_instance(uint64_t p_object_id) {

部分文件因文件數量過多而無法顯示