From 9b4c5f056220b55cfe2e33f2758a6579dda62c24 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Tue, 30 Apr 2024 19:06:51 +0200 Subject: [PATCH 01/11] [SCons] Add option to build without threads This is relevant for the Web platform, where builds with and without threads are incompatible. (cherry picked from commit b0296bb562af0ff812b732586c06ae6b3f96ef84) --- test/project/example.gdextension | 16 ++++++++++++++-- tools/godotcpp.py | 7 +++++++ tools/web.py | 5 +++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/test/project/example.gdextension b/test/project/example.gdextension index 30279e6..93872c5 100644 --- a/test/project/example.gdextension +++ b/test/project/example.gdextension @@ -21,5 +21,17 @@ android.debug.x86_64 = "res://bin/libgdexample.android.template_debug.x86_64.so" android.release.x86_64 = "res://bin/libgdexample.android.template_release.x86_64.so" android.debug.arm64 = "res://bin/libgdexample.android.template_debug.arm64.so" android.release.arm64 = "res://bin/libgdexample.android.template_release.arm64.so" -web.debug.wasm32 = "res://bin/libgdexample.web.template_debug.wasm32.wasm" -web.release.wasm32 = "res://bin/libgdexample.web.template_release.wasm32.wasm" +ios.debug = "res://bin/libgdexample.ios.template_debug.xcframework" +ios.release = "res://bin/libgdexample.ios.template_release.xcframework" +web.debug.threads.wasm32 = "res://bin/libgdexample.web.template_debug.wasm32.wasm" +web.release.threads.wasm32 = "res://bin/libgdexample.web.template_release.wasm32.wasm" +web.debug.wasm32 = "res://bin/libgdexample.web.template_debug.wasm32.nothreads.wasm" +web.release.wasm32 = "res://bin/libgdexample.web.template_release.wasm32.nothreads.wasm" + +[dependencies] +ios.debug = { + "res://bin/libgodot-cpp.ios.template_debug.xcframework": "" +} +ios.release = { + "res://bin/libgodot-cpp.ios.template_release.xcframework": "" +} diff --git a/tools/godotcpp.py b/tools/godotcpp.py index cc2b02f..e16b17d 100644 --- a/tools/godotcpp.py +++ b/tools/godotcpp.py @@ -267,6 +267,8 @@ def options(opts, env): ) ) + opts.Add(BoolVariable(key="threads", help="Enable threading support", default=env.get("threads", True))) + # compiledb opts.Add( BoolVariable( @@ -396,6 +398,9 @@ def generate(env): tool.generate(env) + if env["threads"]: + env.Append(CPPDEFINES=["THREADS_ENABLED"]) + if env.editor_build: env.Append(CPPDEFINES=["TOOLS_ENABLED"]) @@ -436,6 +441,8 @@ def generate(env): suffix += "." + env["arch"] if env["ios_simulator"]: suffix += ".simulator" + if not env["threads"]: + suffix += ".nothreads" env["suffix"] = suffix # Exposed when included from another project env["OBJSUFFIX"] = suffix + env["OBJSUFFIX"] diff --git a/tools/web.py b/tools/web.py index 79b4b24..8953325 100644 --- a/tools/web.py +++ b/tools/web.py @@ -34,8 +34,9 @@ def generate(env): env["SHLIBSUFFIX"] = ".wasm" # Thread support (via SharedArrayBuffer). - env.Append(CCFLAGS=["-s", "USE_PTHREADS=1"]) - env.Append(LINKFLAGS=["-s", "USE_PTHREADS=1"]) + if env["threads"]: + env.Append(CCFLAGS=["-s", "USE_PTHREADS=1"]) + env.Append(LINKFLAGS=["-s", "USE_PTHREADS=1"]) # Build as side module (shared library). env.Append(CPPFLAGS=["-s", "SIDE_MODULE=1"]) From 9e860a84a0343693beffb11ddaf2c3c9a19264af Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Fri, 14 Jun 2024 01:42:39 +0200 Subject: [PATCH 02/11] [Web] Force emcc to use "wasm" longjmp mode SUPPORT_LONGJMP have changed since emscripten 3.1.32 to default to "wasm" mode when exceptions are enabled, and "emscripten" mode when disabled. While we generally doesn't use exception in core, linked libraries may need them, and emscripten don't plan to support WASM EH + Emscripten SjLj in the long term. (cherry picked from commit 1bb543b6f4234a967f1d89dca78e380208177635) --- tools/web.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/web.py b/tools/web.py index 8953325..dea42b2 100644 --- a/tools/web.py +++ b/tools/web.py @@ -35,12 +35,16 @@ def generate(env): # Thread support (via SharedArrayBuffer). if env["threads"]: - env.Append(CCFLAGS=["-s", "USE_PTHREADS=1"]) - env.Append(LINKFLAGS=["-s", "USE_PTHREADS=1"]) + env.Append(CCFLAGS=["-sUSE_PTHREADS=1"]) + env.Append(LINKFLAGS=["-sUSE_PTHREADS=1"]) # Build as side module (shared library). - env.Append(CPPFLAGS=["-s", "SIDE_MODULE=1"]) - env.Append(LINKFLAGS=["-s", "SIDE_MODULE=1"]) + env.Append(CPPFLAGS=["-sSIDE_MODULE=1"]) + env.Append(LINKFLAGS=["-sSIDE_MODULE=1"]) + + # Force wasm longjmp mode. + env.Append(CCFLAGS=["-sSUPPORT_LONGJMP='wasm'"]) + env.Append(LINKFLAGS=["-sSUPPORT_LONGJMP='wasm'"]) env.Append(CPPDEFINES=["WEB_ENABLED", "UNIX_ENABLED"]) From 09b735ac97c37cbf655b1336267d450c0fd485a5 Mon Sep 17 00:00:00 2001 From: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Date: Sat, 13 Jul 2024 16:24:13 +0200 Subject: [PATCH 03/11] [CI] Upload build cache before running tests (cherry picked from commit 76b38de01a31c5c1762c4b8239e7a51ebea84bef) --- .../action.yml | 9 ++++----- .github/actions/godot-cache-save/action.yml | 17 +++++++++++++++++ .github/workflows/ci.yml | 10 ++++++++-- 3 files changed, 29 insertions(+), 7 deletions(-) rename .github/actions/{godot-cache => godot-cache-restore}/action.yml (77%) create mode 100644 .github/actions/godot-cache-save/action.yml diff --git a/.github/actions/godot-cache/action.yml b/.github/actions/godot-cache-restore/action.yml similarity index 77% rename from .github/actions/godot-cache/action.yml rename to .github/actions/godot-cache-restore/action.yml index 2d7afc8..5df5776 100644 --- a/.github/actions/godot-cache/action.yml +++ b/.github/actions/godot-cache-restore/action.yml @@ -1,5 +1,5 @@ -name: Setup Godot build cache -description: Setup Godot build cache. +name: Restore Godot build cache +description: Restore Godot build cache. inputs: cache-name: description: The cache base name (job name by default). @@ -10,9 +10,8 @@ inputs: runs: using: "composite" steps: - # Upload cache on completion and check it out now - - name: Load .scons_cache directory - uses: actions/cache@v3 + - name: Restore .scons_cache directory + uses: actions/cache/restore@v3 with: path: ${{inputs.scons-cache}} key: ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} diff --git a/.github/actions/godot-cache-save/action.yml b/.github/actions/godot-cache-save/action.yml new file mode 100644 index 0000000..b7cbf91 --- /dev/null +++ b/.github/actions/godot-cache-save/action.yml @@ -0,0 +1,17 @@ +name: Save Godot build cache +description: Save Godot build cache. +inputs: + cache-name: + description: The cache base name (job name by default). + default: "${{github.job}}" + scons-cache: + description: The SCons cache path. + default: "${{github.workspace}}/.scons-cache/" +runs: + using: "composite" + steps: + - name: Save SCons cache directory + uses: actions/cache/save@v4 + with: + path: ${{inputs.scons-cache}} + key: ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30ae04f..de82d11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -99,8 +99,8 @@ jobs: with: submodules: recursive - - name: Setup Godot build cache - uses: ./.github/actions/godot-cache + - name: Restore Godot build cache + uses: ./.github/actions/godot-cache-restore with: cache-name: ${{ matrix.cache-name }} continue-on-error: true @@ -153,6 +153,12 @@ jobs: cd test scons platform=${{ matrix.platform }} verbose=yes target=template_release ${{ matrix.flags }} + - name: Save Godot build cache + uses: ./.github/actions/godot-cache-save + with: + cache-name: ${{ matrix.cache-name }} + continue-on-error: true + - name: Download latest Godot artifacts uses: dsnopek/action-download-artifact@1322f74e2dac9feed2ee76a32d9ae1ca3b4cf4e9 if: ${{ matrix.run-tests && env.GODOT_TEST_VERSION == 'master' }} From bc6cfd70d84acafd3b09e86db554aad8da1f8e11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 18 Jul 2024 10:35:16 +0200 Subject: [PATCH 04/11] SCons: Remove old Python 2 compat code (cherry picked from commit 958776dfc3ea845e3a92384cf5b57b54229d9b28) --- tools/ios.py | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/tools/ios.py b/tools/ios.py index d84aecd..3f92bda 100644 --- a/tools/ios.py +++ b/tools/ios.py @@ -1,3 +1,4 @@ +import codecs import os import subprocess import sys @@ -5,17 +6,6 @@ import sys import common_compiler_flags from SCons.Variables import BoolVariable -if sys.version_info < (3,): - - def decode_utf8(x): - return x - -else: - import codecs - - def decode_utf8(x): - return codecs.utf_8_decode(x)[0] - def has_ios_osxcross(): return "OSXCROSS_IOS" in os.environ @@ -53,9 +43,9 @@ def generate(env): if sys.platform == "darwin": if env["IOS_SDK_PATH"] == "": try: - env["IOS_SDK_PATH"] = decode_utf8( + env["IOS_SDK_PATH"] = codecs.utf_8_decode( subprocess.check_output(["xcrun", "--sdk", sdk_name, "--show-sdk-path"]).strip() - ) + )[0] except (subprocess.CalledProcessError, OSError): raise ValueError( "Failed to find SDK path while running xcrun --sdk {} --show-sdk-path.".format(sdk_name) From 9a4ba00b0e7a7618db022d44936e9e8cdd600faa Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Wed, 31 Jul 2024 20:06:07 -0400 Subject: [PATCH 05/11] Make sure `_get` and `_set` dispatch up the class hierarchy (cherry picked from commit c77d44f3f6abbacfc5b4a5efff580387e8b297b8) --- include/godot_cpp/classes/wrapped.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/godot_cpp/classes/wrapped.hpp b/include/godot_cpp/classes/wrapped.hpp index d325fed..d50e5ab 100644 --- a/include/godot_cpp/classes/wrapped.hpp +++ b/include/godot_cpp/classes/wrapped.hpp @@ -212,23 +212,27 @@ public: } \ \ static GDExtensionBool set_bind(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value) { \ - if (p_instance && m_class::_get_set()) { \ + if (p_instance) { \ + if (m_inherits::set_bind(p_instance, p_name, p_value)) { \ + return true; \ + } \ if (m_class::_get_set() != m_inherits::_get_set()) { \ m_class *cls = reinterpret_cast(p_instance); \ return cls->_set(*reinterpret_cast(p_name), *reinterpret_cast(p_value)); \ } \ - return m_inherits::set_bind(p_instance, p_name, p_value); \ } \ return false; \ } \ \ static GDExtensionBool get_bind(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret) { \ - if (p_instance && m_class::_get_get()) { \ + if (p_instance) { \ + if (m_inherits::get_bind(p_instance, p_name, r_ret)) { \ + return true; \ + } \ if (m_class::_get_get() != m_inherits::_get_get()) { \ m_class *cls = reinterpret_cast(p_instance); \ return cls->_get(*reinterpret_cast(p_name), *reinterpret_cast<::godot::Variant *>(r_ret)); \ } \ - return m_inherits::get_bind(p_instance, p_name, r_ret); \ } \ return false; \ } \ From d529fc5b69e4efe3c2ec8d278999ab49f32f8422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaim=20=28Jo=C3=ABl=20Lamotte=29?= <142265+Klaim@users.noreply.github.com> Date: Thu, 8 Aug 2024 02:10:41 +0200 Subject: [PATCH 06/11] removes warnings generated by GDCLASS usage This change removes the warnings (unused parameters) coming from code injected by the GDCLASS macro. Contrary to warnings coming from the normal source code which can be suppressed with most compiles by specifying the include directories of this library as external or system, when the code is injected through a macro it is considered in the context of the user, which is the source code of user of the library. That forces the users to modify their code to hide the warnings coming from the mandatory `GDCLASS` here. That's why it's important to remove these warning from that specific macro and ideally any other macro that the user must use. (cherry picked from commit 738859f49bf34b176116729f56dd2e57e2fd9b86) --- include/godot_cpp/classes/wrapped.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/godot_cpp/classes/wrapped.hpp b/include/godot_cpp/classes/wrapped.hpp index d50e5ab..33efc82 100644 --- a/include/godot_cpp/classes/wrapped.hpp +++ b/include/godot_cpp/classes/wrapped.hpp @@ -120,7 +120,7 @@ struct EngineClassRegistration { #define GDCLASS(m_class, m_inherits) \ private: \ - void operator=(const m_class &p_rval) {} \ + void operator=(const m_class & /*p_rval*/) {} \ friend class ::godot::ClassDB; \ \ protected: \ @@ -308,7 +308,7 @@ public: } \ } \ \ - static void free(void *data, GDExtensionClassInstancePtr ptr) { \ + static void free(void * /*data*/, GDExtensionClassInstancePtr ptr) { \ if (ptr) { \ m_class *cls = reinterpret_cast(ptr); \ cls->~m_class(); \ @@ -316,14 +316,14 @@ public: } \ } \ \ - static void *_gde_binding_create_callback(void *p_token, void *p_instance) { \ + static void *_gde_binding_create_callback(void * /*p_token*/, void * /*p_instance*/) { \ return nullptr; \ } \ \ - static void _gde_binding_free_callback(void *p_token, void *p_instance, void *p_binding) { \ + static void _gde_binding_free_callback(void * /*p_token*/, void * /*p_instance*/, void * /*p_binding*/) { \ } \ \ - static GDExtensionBool _gde_binding_reference_callback(void *p_token, void *p_instance, GDExtensionBool p_reference) { \ + static GDExtensionBool _gde_binding_reference_callback(void * /*p_token*/, void * /*p_instance*/, GDExtensionBool /*p_reference*/) { \ return true; \ } \ \ From 67145b323bc7f9ff5e5e054a89ef50267b9ee182 Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Tue, 20 Aug 2024 14:53:22 +0200 Subject: [PATCH 07/11] Avoid hardcoded type conversion for metadata The engine uses the names `int` and `float` to refer to the 64-bit types, so in the bindings generator we have a hardcoded conversion for those types. But this type conversion should not be used for metadata. Even though the underlying type should still be 64-bit for interop, metadata is meant to specify the correct type to expose. So if metadata says `float` it means the type is really meant to be a 32-bit `float` and not `double`. Other hardcoded type conversions (`int` and `Nil`) won't ever be metadata. This change corrects the `float` type, to use the right type in the generated C++ code. Before we were always using `double` due to this type conversion. (cherry picked from commit 48291990817fbaa8cc2d0307a16d7345bf62da52) --- binding_generator.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/binding_generator.py b/binding_generator.py index 7911a7e..d153825 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -2451,8 +2451,6 @@ def correct_type(type_name, meta=None, use_alias=True): if meta is not None: if "int" in meta: return f"{meta}_t" - elif meta in type_conversion: - return type_conversion[type_name] else: return meta if type_name in type_conversion: From 76c0a4b4aeb7946760f5e59ed3c9b8575a0ae80d Mon Sep 17 00:00:00 2001 From: Mikael Hermansson Date: Wed, 21 Aug 2024 20:19:33 +0200 Subject: [PATCH 08/11] Fix incorrect generation of some C++ operators (cherry picked from commit 9949d09f3eb43827595e8eab8ada0628da77782a) --- binding_generator.py | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/binding_generator.py b/binding_generator.py index d153825..4825765 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -671,14 +671,14 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl if "operators" in builtin_api: for operator in builtin_api["operators"]: - if operator["name"] not in ["in", "xor"]: + if is_valid_cpp_operator(operator["name"]): if "right_type" in operator: result.append( - f'\t{correct_type(operator["return_type"])} operator{operator["name"]}({type_for_parameter(operator["right_type"])}p_other) const;' + f'\t{correct_type(operator["return_type"])} operator{get_operator_cpp_name(operator["name"])}({type_for_parameter(operator["right_type"])}p_other) const;' ) else: result.append( - f'\t{correct_type(operator["return_type"])} operator{operator["name"].replace("unary", "")}() const;' + f'\t{correct_type(operator["return_type"])} operator{get_operator_cpp_name(operator["name"])}() const;' ) # Copy assignment. @@ -1110,10 +1110,10 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl if "operators" in builtin_api: for operator in builtin_api["operators"]: - if operator["name"] not in ["in", "xor"]: + if is_valid_cpp_operator(operator["name"]): if "right_type" in operator: result.append( - f'{correct_type(operator["return_type"])} {class_name}::operator{operator["name"]}({type_for_parameter(operator["right_type"])}p_other) const {{' + f'{correct_type(operator["return_type"])} {class_name}::operator{get_operator_cpp_name(operator["name"])}({type_for_parameter(operator["right_type"])}p_other) const {{' ) (encode, arg_name) = get_encoded_arg("other", operator["right_type"], None) result += encode @@ -1123,7 +1123,7 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl result.append("}") else: result.append( - f'{correct_type(operator["return_type"])} {class_name}::operator{operator["name"].replace("unary", "")}() const {{' + f'{correct_type(operator["return_type"])} {class_name}::operator{get_operator_cpp_name(operator["name"])}() const {{' ) result.append( f'\treturn internal::_call_builtin_operator_ptr<{get_gdextension_type(correct_type(operator["return_type"]))}>(_method_bindings.operator_{get_operator_id_name(operator["name"])}, (GDExtensionConstTypePtr)&opaque, (GDExtensionConstTypePtr)nullptr);' @@ -2562,6 +2562,38 @@ def get_operator_id_name(op): return op_id_map[op] +def get_operator_cpp_name(op): + op_cpp_map = { + "==": "==", + "!=": "!=", + "<": "<", + "<=": "<=", + ">": ">", + ">=": ">=", + "+": "+", + "-": "-", + "*": "*", + "/": "/", + "unary-": "-", + "unary+": "+", + "%": "%", + "<<": "<<", + ">>": ">>", + "&": "&", + "|": "|", + "^": "^", + "~": "~", + "and": "&&", + "or": "||", + "not": "!", + } + return op_cpp_map[op] + + +def is_valid_cpp_operator(op): + return op not in ["**", "xor", "in"] + + def get_default_value_for_type(type_name): if type_name == "int": return "0" From 592a7762cd098a4b0cf74cda3d70cc1ea98ec21e Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 22 Aug 2024 21:04:51 -0700 Subject: [PATCH 09/11] [4.2] Fix missing MAKE_TYPED_ARRAY_INFO for Packed*Arrays (cherry picked from commit a0d56336c38f3dd71d120098441329c45709ab11) --- include/godot_cpp/core/type_info.hpp | 20 +++++++++----------- test/src/example.cpp | 14 ++++++++++++++ test/src/example.h | 1 + 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/include/godot_cpp/core/type_info.hpp b/include/godot_cpp/core/type_info.hpp index e1f2b20..71d7828 100644 --- a/include/godot_cpp/core/type_info.hpp +++ b/include/godot_cpp/core/type_info.hpp @@ -393,17 +393,15 @@ MAKE_TYPED_ARRAY_INFO(Callable, Variant::CALLABLE) MAKE_TYPED_ARRAY_INFO(Signal, Variant::SIGNAL) MAKE_TYPED_ARRAY_INFO(Dictionary, Variant::DICTIONARY) MAKE_TYPED_ARRAY_INFO(Array, Variant::ARRAY) -/* -MAKE_TYPED_ARRAY_INFO(Vector, Variant::PACKED_BYTE_ARRAY) -MAKE_TYPED_ARRAY_INFO(Vector, Variant::PACKED_INT32_ARRAY) -MAKE_TYPED_ARRAY_INFO(Vector, Variant::PACKED_INT64_ARRAY) -MAKE_TYPED_ARRAY_INFO(Vector, Variant::PACKED_FLOAT32_ARRAY) -MAKE_TYPED_ARRAY_INFO(Vector, Variant::PACKED_FLOAT64_ARRAY) -MAKE_TYPED_ARRAY_INFO(Vector, Variant::PACKED_STRING_ARRAY) -MAKE_TYPED_ARRAY_INFO(Vector, Variant::PACKED_VECTOR2_ARRAY) -MAKE_TYPED_ARRAY_INFO(Vector, Variant::PACKED_VECTOR3_ARRAY) -MAKE_TYPED_ARRAY_INFO(Vector, Variant::PACKED_COLOR_ARRAY) -*/ +MAKE_TYPED_ARRAY_INFO(PackedByteArray, Variant::PACKED_BYTE_ARRAY) +MAKE_TYPED_ARRAY_INFO(PackedInt32Array, Variant::PACKED_INT32_ARRAY) +MAKE_TYPED_ARRAY_INFO(PackedInt64Array, Variant::PACKED_INT64_ARRAY) +MAKE_TYPED_ARRAY_INFO(PackedFloat32Array, Variant::PACKED_FLOAT32_ARRAY) +MAKE_TYPED_ARRAY_INFO(PackedFloat64Array, Variant::PACKED_FLOAT64_ARRAY) +MAKE_TYPED_ARRAY_INFO(PackedStringArray, Variant::PACKED_STRING_ARRAY) +MAKE_TYPED_ARRAY_INFO(PackedVector2Array, Variant::PACKED_VECTOR2_ARRAY) +MAKE_TYPED_ARRAY_INFO(PackedVector3Array, Variant::PACKED_VECTOR3_ARRAY) +MAKE_TYPED_ARRAY_INFO(PackedColorArray, Variant::PACKED_COLOR_ARRAY) #define CLASS_INFO(m_type) (GetTypeInfo::get_class_info()) diff --git a/test/src/example.cpp b/test/src/example.cpp index eded7ea..3c3d747 100644 --- a/test/src/example.cpp +++ b/test/src/example.cpp @@ -147,6 +147,7 @@ void Example::_bind_methods() { ClassDB::bind_method(D_METHOD("test_string_ops"), &Example::test_string_ops); ClassDB::bind_method(D_METHOD("test_str_utility"), &Example::test_str_utility); ClassDB::bind_method(D_METHOD("test_string_is_forty_two"), &Example::test_string_is_forty_two); + ClassDB::bind_method(D_METHOD("test_typed_array_of_packed"), &Example::test_typed_array_of_packed); ClassDB::bind_method(D_METHOD("test_vector_ops"), &Example::test_vector_ops); ClassDB::bind_method(D_METHOD("test_vector_init_list"), &Example::test_vector_init_list); @@ -327,6 +328,19 @@ bool Example::test_string_is_forty_two(const String &p_string) const { return strcmp(p_string.utf8().ptr(), "forty two") == 0; } +TypedArray Example::test_typed_array_of_packed() const { + TypedArray arr; + PackedInt32Array packed_arr1; + packed_arr1.push_back(1); + packed_arr1.push_back(2); + arr.push_back(packed_arr1); + PackedInt32Array packed_arr2; + packed_arr2.push_back(3); + packed_arr2.push_back(4); + arr.push_back(packed_arr2); + return arr; +} + int Example::test_vector_ops() const { PackedInt32Array arr; arr.push_back(10); diff --git a/test/src/example.h b/test/src/example.h index 4983caa..12fbe09 100644 --- a/test/src/example.h +++ b/test/src/example.h @@ -126,6 +126,7 @@ public: String test_string_ops() const; String test_str_utility() const; bool test_string_is_forty_two(const String &p_str) const; + TypedArray test_typed_array_of_packed() const; int test_vector_ops() const; int test_vector_init_list() const; From d421c984615210863ebe4c6304be6ca782975ee9 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Sat, 24 Aug 2024 11:56:27 +0200 Subject: [PATCH 10/11] [Web/SCons] Use CCFLAGS for SIDE_MODULE option Was using CPPFLAGS, but should use the explicit scons CCFLAGS which makes it clear they are applied to both the C and C++ compiler. CPPFLAGS was also fine (they are preprocessor flags, also applied to both C and C++), but we should try to stay consistent with what we do in Godot. (cherry picked from commit f36acd8e312c916c7e53364e1b0bd8eec3e4410e) --- tools/web.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/web.py b/tools/web.py index dea42b2..c8f07c5 100644 --- a/tools/web.py +++ b/tools/web.py @@ -39,7 +39,7 @@ def generate(env): env.Append(LINKFLAGS=["-sUSE_PTHREADS=1"]) # Build as side module (shared library). - env.Append(CPPFLAGS=["-sSIDE_MODULE=1"]) + env.Append(CCFLAGS=["-sSIDE_MODULE=1"]) env.Append(LINKFLAGS=["-sSIDE_MODULE=1"]) # Force wasm longjmp mode. From fad74366cdb1d72aee58a8b53ed90c71ed298f66 Mon Sep 17 00:00:00 2001 From: "George L. Albany" Date: Sun, 25 Aug 2024 07:55:58 +0000 Subject: [PATCH 11/11] Fix GCC 14 -Wtemplate-id-cdtor warning As was fixed with godotengine/godot#91208 (cherry picked from commit 7b31f39beaca1a98307402f53d69f3657f3bed86) --- include/godot_cpp/templates/safe_refcount.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/godot_cpp/templates/safe_refcount.hpp b/include/godot_cpp/templates/safe_refcount.hpp index 12e6840..98cb04b 100644 --- a/include/godot_cpp/templates/safe_refcount.hpp +++ b/include/godot_cpp/templates/safe_refcount.hpp @@ -132,7 +132,7 @@ public: } } - _ALWAYS_INLINE_ explicit SafeNumeric(T p_value = static_cast(0)) { + _ALWAYS_INLINE_ explicit SafeNumeric(T p_value = static_cast(0)) { set(p_value); } };