From 0c6e26dabed18681c09a87f32903725331e2e25e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=A1=D0=B0?= =?UTF-8?q?=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2?= Date: Tue, 6 Dec 2022 08:33:13 +0300 Subject: [PATCH] Added property info for ptr and ref + ported the implementation of the `check` method --- include/godot_cpp/classes/ref.hpp | 4 ++-- include/godot_cpp/core/binder_common.hpp | 8 +++++++- include/godot_cpp/core/type_info.hpp | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/godot_cpp/classes/ref.hpp b/include/godot_cpp/classes/ref.hpp index 465500b4..bac942fd 100644 --- a/include/godot_cpp/classes/ref.hpp +++ b/include/godot_cpp/classes/ref.hpp @@ -276,7 +276,7 @@ struct GetTypeInfo, typename EnableIf::value> static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; static inline PropertyInfo get_class_info() { - return make_property_info(Variant::Type::OBJECT, T::get_class_static()); + return make_property_info(Variant::Type::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, T::get_class_static()); } }; @@ -286,7 +286,7 @@ struct GetTypeInfo &, typename EnableIf static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; static inline PropertyInfo get_class_info() { - return make_property_info(Variant::Type::OBJECT, T::get_class_static()); + return make_property_info(Variant::Type::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, T::get_class_static()); } }; diff --git a/include/godot_cpp/core/binder_common.hpp b/include/godot_cpp/core/binder_common.hpp index 86c59c34..c96498f6 100644 --- a/include/godot_cpp/core/binder_common.hpp +++ b/include/godot_cpp/core/binder_common.hpp @@ -122,7 +122,13 @@ struct VariantCaster { template struct VariantObjectClassChecker { static _FORCE_INLINE_ bool check(const Variant &p_variant) { - return true; + using TStripped = std::remove_pointer_t; + if constexpr (std::is_base_of::value) { + Object *obj = p_variant; + return Object::cast_to(p_variant) || !obj; + } else { + return true; + } } }; diff --git a/include/godot_cpp/core/type_info.hpp b/include/godot_cpp/core/type_info.hpp index 47644d48..509bfb7b 100644 --- a/include/godot_cpp/core/type_info.hpp +++ b/include/godot_cpp/core/type_info.hpp @@ -201,7 +201,7 @@ struct GetTypeInfo::value>::type> static const GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT; static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; static inline PropertyInfo get_class_info() { - return make_property_info(Variant::Type::OBJECT, T::get_class_static()); + return make_property_info(Variant::Type::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, T::get_class_static()); } }; @@ -210,7 +210,7 @@ struct GetTypeInfo::value>: static const GDExtensionVariantType VARIANT_TYPE = GDEXTENSION_VARIANT_TYPE_OBJECT; static const GDExtensionClassMethodArgumentMetadata METADATA = GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE; static inline PropertyInfo get_class_info() { - return make_property_info(Variant::Type::OBJECT, T::get_class_static()); + return make_property_info(Variant::Type::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, T::get_class_static()); } };