diff options
Diffstat (limited to 'include/godot_cpp/classes/wrapped.hpp')
-rw-r--r-- | include/godot_cpp/classes/wrapped.hpp | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/include/godot_cpp/classes/wrapped.hpp b/include/godot_cpp/classes/wrapped.hpp index d297945..91e29eb 100644 --- a/include/godot_cpp/classes/wrapped.hpp +++ b/include/godot_cpp/classes/wrapped.hpp @@ -60,15 +60,17 @@ protected: void _get_property_list(List<PropertyInfo> *p_list) const {} bool _property_can_revert(const StringName &p_name) const { return false; } bool _property_get_revert(const StringName &p_name, Variant &r_property) const { return false; } + void _validate_property(PropertyInfo &p_property) const {} String _to_string() const { return "[" + String(get_class_static()) + ":" + itos(get_instance_id()) + "]"; } - static void notification_bind(GDExtensionClassInstancePtr p_instance, int32_t p_what) {} + static void notification_bind(GDExtensionClassInstancePtr p_instance, int32_t p_what, GDExtensionBool p_reversed) {} static GDExtensionBool set_bind(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value) { return false; } static GDExtensionBool get_bind(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret) { return false; } static const GDExtensionPropertyInfo *get_property_list_bind(GDExtensionClassInstancePtr p_instance, uint32_t *r_count) { return nullptr; } static void free_property_list_bind(GDExtensionClassInstancePtr p_instance, const GDExtensionPropertyInfo *p_list) {} static GDExtensionBool property_can_revert_bind(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name) { return false; } static GDExtensionBool property_get_revert_bind(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret) { return false; } + static GDExtensionBool validate_property_bind(GDExtensionClassInstancePtr p_instance, GDExtensionPropertyInfo *p_property) { return false; } static void to_string_bind(GDExtensionClassInstancePtr p_instance, GDExtensionBool *r_is_valid, GDExtensionStringPtr r_out) {} // The only reason this has to be held here, is when we return results of `_get_property_list` to Godot, we pass @@ -142,16 +144,20 @@ protected: return (void(::godot::Wrapped::*)(::godot::List<::godot::PropertyInfo> * p_list) const) & m_class::_get_property_list; \ } \ \ - static bool (::godot::Wrapped::*_get_property_can_revert())(const ::godot::StringName &p_name) { \ - return (bool(::godot::Wrapped::*)(const ::godot::StringName &p_name)) & m_class::_property_can_revert; \ + static bool (::godot::Wrapped::*_get_property_can_revert())(const ::godot::StringName &p_name) const { \ + return (bool(::godot::Wrapped::*)(const ::godot::StringName &p_name) const) & m_class::_property_can_revert; \ } \ \ - static bool (::godot::Wrapped::*_get_property_get_revert())(const ::godot::StringName &p_name, ::godot::Variant &) { \ - return (bool(::godot::Wrapped::*)(const ::godot::StringName &p_name, ::godot::Variant &)) & m_class::_property_get_revert; \ + static bool (::godot::Wrapped::*_get_property_get_revert())(const ::godot::StringName &p_name, ::godot::Variant &) const { \ + return (bool(::godot::Wrapped::*)(const ::godot::StringName &p_name, ::godot::Variant &) const) & m_class::_property_get_revert; \ } \ \ - static ::godot::String (::godot::Wrapped::*_get_to_string())() { \ - return (::godot::String(::godot::Wrapped::*)()) & m_class::_to_string; \ + static void (::godot::Wrapped::*_get_validate_property())(::godot::PropertyInfo & p_property) const { \ + return (void(::godot::Wrapped::*)(::godot::PropertyInfo & p_property) const) & m_class::_validate_property; \ + } \ + \ + static ::godot::String (::godot::Wrapped::*_get_to_string())() const { \ + return (::godot::String(::godot::Wrapped::*)() const) & m_class::_to_string; \ } \ \ template <class T, class B> \ @@ -187,13 +193,13 @@ public: return new_object->_owner; \ } \ \ - static void notification_bind(GDExtensionClassInstancePtr p_instance, int32_t p_what) { \ + static void notification_bind(GDExtensionClassInstancePtr p_instance, int32_t p_what, GDExtensionBool p_reversed) { \ if (p_instance && m_class::_get_notification()) { \ if (m_class::_get_notification() != m_inherits::_get_notification()) { \ m_class *cls = reinterpret_cast<m_class *>(p_instance); \ return cls->_notification(p_what); \ } \ - m_inherits::notification_bind(p_instance, p_what); \ + m_inherits::notification_bind(p_instance, p_what, p_reversed); \ } \ } \ \ @@ -267,6 +273,21 @@ public: return false; \ } \ \ + static GDExtensionBool validate_property_bind(GDExtensionClassInstancePtr p_instance, GDExtensionPropertyInfo *p_property) { \ + bool ret = false; \ + if (p_instance && m_class::_get_validate_property()) { \ + ret = m_inherits::validate_property_bind(p_instance, p_property); \ + if (m_class::_get_validate_property() != m_inherits::_get_validate_property()) { \ + m_class *cls = reinterpret_cast<m_class *>(p_instance); \ + ::godot::PropertyInfo info(p_property); \ + cls->_validate_property(info); \ + info._update(p_property); \ + return true; \ + } \ + } \ + return ret; \ + } \ + \ static void to_string_bind(GDExtensionClassInstancePtr p_instance, GDExtensionBool *r_is_valid, GDExtensionStringPtr r_out) { \ if (p_instance && m_class::_get_to_string()) { \ if (m_class::_get_to_string() != m_inherits::_get_to_string()) { \ @@ -337,15 +358,19 @@ protected: return nullptr; \ } \ \ - static bool (Wrapped::*_get_property_can_revert())(const ::godot::StringName &p_name) { \ + static bool (Wrapped::*_get_property_can_revert())(const ::godot::StringName &p_name) const { \ + return nullptr; \ + } \ + \ + static bool (Wrapped::*_get_property_get_revert())(const ::godot::StringName &p_name, Variant &) const { \ return nullptr; \ } \ \ - static bool (Wrapped::*_get_property_get_revert())(const ::godot::StringName &p_name, Variant &) { \ + static void (Wrapped::*_get_validate_property())(::godot::PropertyInfo & p_property) const { \ return nullptr; \ } \ \ - static String (Wrapped::*_get_to_string())() { \ + static String (Wrapped::*_get_to_string())() const { \ return nullptr; \ } \ \ |