diff options
author | David Snopek <dsnopek@gmail.com> | 2024-02-12 14:33:20 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-12 14:33:20 -0600 |
commit | 9a13efa0e30a502d44b0352cb1beee77b81d4112 (patch) | |
tree | 39d09f456185e8a999237683d85671e556226be5 /include/godot_cpp | |
parent | 7c547c6c6bb91d3044cfb1dd17c0fa98e9a93287 (diff) | |
parent | 6a3753c076fd6b709066a07bdc864f270090d8a9 (diff) | |
download | redot-cpp-9a13efa0e30a502d44b0352cb1beee77b81d4112.tar.gz |
Merge pull request #1363 from Daylily-Zeleen/daylily-zeleen/fix_object_return_value_of_builtin_types_methods
Fix object return value of builtin types' methods.
Diffstat (limited to 'include/godot_cpp')
-rw-r--r-- | include/godot_cpp/core/builtin_ptrcall.hpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/godot_cpp/core/builtin_ptrcall.hpp b/include/godot_cpp/core/builtin_ptrcall.hpp index 87311b8..19250d8 100644 --- a/include/godot_cpp/core/builtin_ptrcall.hpp +++ b/include/godot_cpp/core/builtin_ptrcall.hpp @@ -32,6 +32,7 @@ #define GODOT_BUILTIN_PTRCALL_HPP #include <gdextension_interface.h> +#include <godot_cpp/core/object.hpp> #include <array> @@ -39,6 +40,17 @@ namespace godot { namespace internal { +template <class O, class... Args> +O *_call_builtin_method_ptr_ret_obj(const GDExtensionPtrBuiltInMethod method, GDExtensionTypePtr base, const Args &...args) { + GodotObject *ret = nullptr; + std::array<GDExtensionConstTypePtr, sizeof...(Args)> call_args = { { (GDExtensionConstTypePtr)args... } }; + method(base, call_args.data(), &ret, sizeof...(Args)); + if (ret == nullptr) { + return nullptr; + } + return reinterpret_cast<O *>(internal::get_object_instance_binding(ret)); +} + template <class... Args> void _call_builtin_constructor(const GDExtensionPtrConstructor constructor, GDExtensionTypePtr base, Args... args) { std::array<GDExtensionConstTypePtr, sizeof...(Args)> call_args = { { (GDExtensionConstTypePtr)args... } }; |