diff options
author | David Snopek <dsnopek@gmail.com> | 2023-09-09 13:05:16 -0500 |
---|---|---|
committer | David Snopek <dsnopek@gmail.com> | 2023-09-10 11:17:59 -0500 |
commit | abef8e3874a688600e844b37833230a4163a2dce (patch) | |
tree | 8b8397a5e85925358e13c050ef0f20e8a47f40ef /core/object/object.cpp | |
parent | fc99492d3066098e938449b10e02f8e01d07e2d1 (diff) | |
download | redot-engine-abef8e3874a688600e844b37833230a4163a2dce.tar.gz |
Allow implementing `Object::_validate_property()` from GDExtension
Diffstat (limited to 'core/object/object.cpp')
-rw-r--r-- | core/object/object.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/core/object/object.cpp b/core/object/object.cpp index 0a0953f7dc..50026fc266 100644 --- a/core/object/object.cpp +++ b/core/object/object.cpp @@ -527,6 +527,27 @@ void Object::get_property_list(List<PropertyInfo> *p_list, bool p_reversed) cons void Object::validate_property(PropertyInfo &p_property) const { _validate_propertyv(p_property); + if (_extension && _extension->validate_property) { + // GDExtension uses a StringName rather than a String for property name. + StringName prop_name = p_property.name; + GDExtensionPropertyInfo gdext_prop = { + (GDExtensionVariantType)p_property.type, + &prop_name, + &p_property.class_name, + (uint32_t)p_property.hint, + &p_property.hint_string, + p_property.usage, + }; + if (_extension->validate_property(_extension_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; + }; + } + if (script_instance) { // Call it last to allow user altering already validated properties. script_instance->validate_property(p_property); } |