Merge pull request #90916 from Naros/expose-classdb-class-get-property-default-value

Expose `ClassDB::class_get_property_default_value` method
This commit is contained in:
Rémi Verschelde 2024-04-22 22:18:26 +02:00
commit 2980a6b295
No known key found for this signature in database
GPG Key ID: C3336907360768E1
3 changed files with 21 additions and 0 deletions

View File

@ -1442,6 +1442,15 @@ Error ClassDB::class_set_property(Object *p_object, const StringName &p_property
return OK;
}
Variant ClassDB::class_get_property_default_value(const StringName &p_class, const StringName &p_property) const {
bool valid;
Variant ret = ::ClassDB::class_get_default_property_value(p_class, p_property, &valid);
if (valid) {
return ret;
}
return Variant();
}
bool ClassDB::class_has_method(const StringName &p_class, const StringName &p_method, bool p_no_inheritance) const {
return ::ClassDB::has_method(p_class, p_method, p_no_inheritance);
}
@ -1580,6 +1589,8 @@ void ClassDB::_bind_methods() {
::ClassDB::bind_method(D_METHOD("class_get_property", "object", "property"), &ClassDB::class_get_property);
::ClassDB::bind_method(D_METHOD("class_set_property", "object", "property", "value"), &ClassDB::class_set_property);
::ClassDB::bind_method(D_METHOD("class_get_property_default_value", "class", "property"), &ClassDB::class_get_property_default_value);
::ClassDB::bind_method(D_METHOD("class_has_method", "class", "method", "no_inheritance"), &ClassDB::class_has_method, DEFVAL(false));
::ClassDB::bind_method(D_METHOD("class_get_method_argument_count", "class", "method", "no_inheritance"), &ClassDB::class_get_method_argument_count, DEFVAL(false));

View File

@ -447,6 +447,8 @@ public:
Variant class_get_property(Object *p_object, const StringName &p_property) const;
Error class_set_property(Object *p_object, const StringName &p_property, const Variant &p_value) const;
Variant class_get_property_default_value(const StringName &p_class, const StringName &p_property) const;
bool class_has_method(const StringName &p_class, const StringName &p_method, bool p_no_inheritance = false) const;
int class_get_method_argument_count(const StringName &p_class, const StringName &p_method, bool p_no_inheritance = false) const;

View File

@ -91,6 +91,14 @@
Returns the value of [param property] of [param object] or its ancestry.
</description>
</method>
<method name="class_get_property_default_value" qualifiers="const">
<return type="Variant" />
<param index="0" name="class" type="StringName" />
<param index="1" name="property" type="StringName" />
<description>
Returns the default value of [param property] of [param class] or its ancestor classes.
</description>
</method>
<method name="class_get_property_list" qualifiers="const">
<return type="Dictionary[]" />
<param index="0" name="class" type="StringName" />