diff options
author | David Snopek <dsnopek@gmail.com> | 2023-05-24 21:17:12 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-24 21:17:12 -0500 |
commit | 8052f818b47c163d3e0a19b13282d909ebfa55f2 (patch) | |
tree | 52ec76b9da866251232b46599710a64d54a81dd9 /include/godot_cpp/core/object.hpp | |
parent | 08bc2ef680cd8b536519d7f59c6f760e96a3d0a8 (diff) | |
parent | 431e30bc3273c83315725f56365845f0b89c0524 (diff) | |
download | redot-cpp-8052f818b47c163d3e0a19b13282d909ebfa55f2.tar.gz |
Merge pull request #1050 from dsnopek/object-correct-class
Ensure GDExtension class is the correct type for the Godot engine class
Diffstat (limited to 'include/godot_cpp/core/object.hpp')
-rw-r--r-- | include/godot_cpp/core/object.hpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/include/godot_cpp/core/object.hpp b/include/godot_cpp/core/object.hpp index 54ca4be..d66e388 100644 --- a/include/godot_cpp/core/object.hpp +++ b/include/godot_cpp/core/object.hpp @@ -52,6 +52,12 @@ namespace godot { +namespace internal { + +Object *get_object_instance_binding(GodotObject *); + +} // namespace internal + struct MethodInfo { StringName name; PropertyInfo return_val; @@ -128,7 +134,7 @@ public: if (obj == nullptr) { return nullptr; } - return reinterpret_cast<Object *>(internal::gdextension_interface_object_get_instance_binding(obj, internal::token, &Object::___binding_callbacks)); + return internal::get_object_instance_binding(obj); } }; @@ -142,7 +148,7 @@ T *Object::cast_to(Object *p_object) { if (casted == nullptr) { return nullptr; } - return reinterpret_cast<T *>(internal::gdextension_interface_object_get_instance_binding(casted, internal::token, &T::___binding_callbacks)); + return dynamic_cast<T *>(internal::get_object_instance_binding(casted)); } template <class T> @@ -155,7 +161,7 @@ const T *Object::cast_to(const Object *p_object) { if (casted == nullptr) { return nullptr; } - return reinterpret_cast<const T *>(internal::gdextension_interface_object_get_instance_binding(casted, internal::token, &T::___binding_callbacks)); + return dynamic_cast<const T *>(internal::get_object_instance_binding(casted)); } } // namespace godot |