diff --git a/core/extension/gdextension_interface.cpp b/core/extension/gdextension_interface.cpp index b6dfec33edd..a09b1f491e4 100644 --- a/core/extension/gdextension_interface.cpp +++ b/core/extension/gdextension_interface.cpp @@ -1055,6 +1055,7 @@ static GDExtensionScriptInstancePtr gdextension_script_instance_create(const GDE info_2->get_method_list_func = p_info->get_method_list_func; info_2->free_method_list_func = p_info->free_method_list_func; info_2->get_property_type_func = p_info->get_property_type_func; + info_2->validate_property_func = nullptr; info_2->has_method_func = p_info->has_method_func; info_2->call_func = p_info->call_func; info_2->notification_func = nullptr; diff --git a/core/extension/gdextension_interface.h b/core/extension/gdextension_interface.h index 102220c0fc4..4379e520b7a 100644 --- a/core/extension/gdextension_interface.h +++ b/core/extension/gdextension_interface.h @@ -373,6 +373,7 @@ typedef GDExtensionBool (*GDExtensionScriptInstanceGet)(GDExtensionScriptInstanc typedef const GDExtensionPropertyInfo *(*GDExtensionScriptInstanceGetPropertyList)(GDExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count); typedef void (*GDExtensionScriptInstanceFreePropertyList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionPropertyInfo *p_list); typedef GDExtensionVariantType (*GDExtensionScriptInstanceGetPropertyType)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionBool *r_is_valid); +typedef GDExtensionBool (*GDExtensionScriptInstanceValidateProperty)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionPropertyInfo *p_property); typedef GDExtensionBool (*GDExtensionScriptInstancePropertyCanRevert)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name); typedef GDExtensionBool (*GDExtensionScriptInstancePropertyGetRevert)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret); @@ -459,6 +460,7 @@ typedef struct { GDExtensionScriptInstanceGetMethodList get_method_list_func; GDExtensionScriptInstanceFreeMethodList free_method_list_func; GDExtensionScriptInstanceGetPropertyType get_property_type_func; + GDExtensionScriptInstanceValidateProperty validate_property_func; GDExtensionScriptInstanceHasMethod has_method_func; diff --git a/core/object/script_language_extension.h b/core/object/script_language_extension.h index bf5ad3c1076..c7218d99a62 100644 --- a/core/object/script_language_extension.h +++ b/core/object/script_language_extension.h @@ -688,7 +688,24 @@ public: return Variant::NIL; } virtual void validate_property(PropertyInfo &p_property) const override { - // TODO + if (native_info->validate_property_func) { + GDExtensionPropertyInfo gdext_prop = { + (GDExtensionVariantType)p_property.type, + &p_property.name, + &p_property.class_name, + (uint32_t)p_property.hint, + &p_property.hint_string, + p_property.usage, + }; + if (native_info->validate_property_func(instance, &gdext_prop)) { + p_property.type = (Variant::Type)gdext_prop.type; + p_property.name = *reinterpret_cast(gdext_prop.name); + p_property.class_name = *reinterpret_cast(gdext_prop.class_name); + p_property.hint = (PropertyHint)gdext_prop.hint; + p_property.hint_string = *reinterpret_cast(gdext_prop.hint_string); + p_property.usage = gdext_prop.usage; + } + } } virtual bool property_can_revert(const StringName &p_name) const override {