summaryrefslogtreecommitdiffstats
path: root/core/object/script_language_extension.h
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-09-07 13:51:44 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-09-07 13:51:44 +0200
commitd1c94eef062a33f314ddea541eddb827c3289bda (patch)
tree8009386ecd1f90b17018e778a217b72b46899fc8 /core/object/script_language_extension.h
parent8dc15e84290831b4571f7cdb87708f08b96cf43b (diff)
parent3e7a6e058a1fb7ea38a6dd155679db9116fc11d9 (diff)
downloadredot-engine-d1c94eef062a33f314ddea541eddb827c3289bda.tar.gz
Merge pull request #81261 from dsnopek/gdextension-validate-property
Allow implementing `ScriptInstance::validate_property()` from GDExtension
Diffstat (limited to 'core/object/script_language_extension.h')
-rw-r--r--core/object/script_language_extension.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/core/object/script_language_extension.h b/core/object/script_language_extension.h
index bf5ad3c107..c7218d99a6 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<StringName *>(gdext_prop.name);
+ p_property.class_name = *reinterpret_cast<StringName *>(gdext_prop.class_name);
+ p_property.hint = (PropertyHint)gdext_prop.hint;
+ p_property.hint_string = *reinterpret_cast<String *>(gdext_prop.hint_string);
+ p_property.usage = gdext_prop.usage;
+ }
+ }
}
virtual bool property_can_revert(const StringName &p_name) const override {