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

pull/726/head
bruvzg 2022-03-16 20:33:06 +02:00
parent 7bcf579a37
commit 93de1b2b0b
No known key found for this signature in database
GPG Key ID: 7960FCF39844EC38
4 changed files with 4278 additions and 1132 deletions

View File

@ -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"#ifndef {header_guard}")
result.append(f"#define {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("") 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("namespace godot {")
result.append("") result.append("")
result.append(f"struct {struct_name} {{") result.append(f"struct {struct_name} {{")
for field in native_struct["format"].split(","): for field in native_struct["format"].split(";"):
result.append(f"\t{field};") if field != "":
result.append(f"\t{field};")
result.append("};") result.append("};")
result.append("") result.append("")
@ -1582,10 +1598,15 @@ def is_pod_type(type_name):
return type_name in [ return type_name in [
"Nil", "Nil",
"void", "void",
"int",
"float",
"bool", "bool",
"real_t",
"float",
"double", "double",
"int",
"int8_t",
"uint8_t",
"int16_t",
"uint16_t",
"int32_t", "int32_t",
"int64_t", "int64_t",
"uint32_t", "uint32_t",
@ -1601,6 +1622,7 @@ def is_included_type(type_name):
"AABB", "AABB",
"Basis", "Basis",
"Color", "Color",
"ObjectID",
"Plane", "Plane",
"Quaternion", "Quaternion",
"Rect2", "Rect2",

File diff suppressed because it is too large Load Diff

View File

@ -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_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); 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 */ /* GODOT VARIANT */
/* variant general */ /* variant general */

View File

@ -134,6 +134,28 @@ MethodInfo::MethodInfo(const PropertyInfo &p_ret, const char *p_name, const Args
arguments = { 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 { class ObjectDB {
public: public:
static Object *get_instance(uint64_t p_object_id) { static Object *get_instance(uint64_t p_object_id) {