From 64be8c15070b8854087706ebca371c7f49fb53af Mon Sep 17 00:00:00 2001 From: George Marques Date: Sat, 28 Jan 2023 13:59:34 -0300 Subject: [PATCH 1/2] Use std type traits instead of intrinsics This removes warnings and mimics what has been done in Godot itself. --- include/godot_cpp/core/memory.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/godot_cpp/core/memory.hpp b/include/godot_cpp/core/memory.hpp index 4a5a16b0..d17e05ef 100644 --- a/include/godot_cpp/core/memory.hpp +++ b/include/godot_cpp/core/memory.hpp @@ -108,7 +108,7 @@ public: template void memdelete(T *p_class, typename std::enable_if>::type * = nullptr) { - if (!__has_trivial_destructor(T)) { + if (!std::is_trivially_destructible::value) { p_class->~T(); } @@ -122,7 +122,7 @@ void memdelete(T *p_class) { template void memdelete_allocator(T *p_class) { - if (!__has_trivial_destructor(T)) { + if (!std::is_trivially_destructible::value) { p_class->~T(); } @@ -145,7 +145,7 @@ T *memnew_arr_template(size_t p_elements, const char *p_descr = "") { ERR_FAIL_COND_V(!mem, failptr); *(mem - 1) = p_elements; - if (!__has_trivial_constructor(T)) { + if (!std::is_trivially_destructible::value) { T *elems = (T *)mem; /* call operator new */ @@ -161,7 +161,7 @@ template void memdelete_arr(T *p_class) { uint64_t *ptr = (uint64_t *)p_class; - if (!__has_trivial_destructor(T)) { + if (!std::is_trivially_destructible::value) { uint64_t elem_count = *(ptr - 1); for (uint64_t i = 0; i < elem_count; i++) { From 1c625befa34339902361783383da2a510789398c Mon Sep 17 00:00:00 2001 From: George Marques Date: Sat, 28 Jan 2023 14:01:27 -0300 Subject: [PATCH 2/2] Support typed array default values in extension API The API JSON has changed syntax for default values of typed arrays. This detects the new format and use initializer lists (currently empty since the TypedArray class does not support initializer list construction and default values are always empty arrays). --- binding_generator.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/binding_generator.py b/binding_generator.py index 9919b735..6ce4379f 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -2129,6 +2129,8 @@ def correct_default_value(value, type_name): return value_map[value] if value == "": return f"{type_name}()" + if value.startswith("Array["): + return f"{{}}" return value