diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-17 11:31:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-17 11:31:54 +0100 |
| commit | b21026e061006a746ce06eb5908a94d896e84796 (patch) | |
| tree | 2076ff2e3961b321e21d728f8ab53f36317c218a /include/godot_cpp | |
| parent | 151ea35c5fbb0254e0d3d29e230270b60852915f (diff) | |
| parent | 0c6e26dabed18681c09a87f32903725331e2e25e (diff) | |
| download | redot-cpp-b21026e061006a746ce06eb5908a94d896e84796.tar.gz | |
Merge pull request #950 from DmitriySalnikov/typed-ptr-method-call-support-and-ref-class-name
Added property info for Object's and Ref's and ported the implementation of the `check` method
Diffstat (limited to 'include/godot_cpp')
| -rw-r--r-- | include/godot_cpp/classes/ref.hpp | 4 | ||||
| -rw-r--r-- | include/godot_cpp/core/binder_common.hpp | 8 | ||||
| -rw-r--r-- | 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 465500b..bac942f 100644 --- a/include/godot_cpp/classes/ref.hpp +++ b/include/godot_cpp/classes/ref.hpp @@ -276,7 +276,7 @@ struct GetTypeInfo<Ref<T>, typename EnableIf<TypeInherits<RefCounted, T>::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<const Ref<T> &, typename EnableIf<TypeInherits<RefCounted, T> 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 86c59c3..c96498f 100644 --- a/include/godot_cpp/core/binder_common.hpp +++ b/include/godot_cpp/core/binder_common.hpp @@ -122,7 +122,13 @@ struct VariantCaster<const T &> { template <typename T> struct VariantObjectClassChecker { static _FORCE_INLINE_ bool check(const Variant &p_variant) { - return true; + using TStripped = std::remove_pointer_t<T>; + if constexpr (std::is_base_of<Object, TStripped>::value) { + Object *obj = p_variant; + return Object::cast_to<TStripped>(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 47644d4..509bfb7 100644 --- a/include/godot_cpp/core/type_info.hpp +++ b/include/godot_cpp/core/type_info.hpp @@ -201,7 +201,7 @@ struct GetTypeInfo<T *, typename EnableIf<TypeInherits<Object, T>::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<const T *, typename EnableIf<TypeInherits<Object, T>::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()); } }; |
