Merge pull request #93141 from RadiantUwU/add_static_classdb_calls
Implement `ClassDB::class_call_static_method`
This commit is contained in:
commit
2e825c7d9c
@ -1501,6 +1501,23 @@ TypedArray<Dictionary> ClassDB::class_get_method_list(const StringName &p_class,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Variant ClassDB::class_call_static_method(const Variant **p_arguments, int p_argcount, Callable::CallError &r_call_error) {
|
||||||
|
if (p_argcount < 2) {
|
||||||
|
r_call_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
|
||||||
|
return Variant::NIL;
|
||||||
|
}
|
||||||
|
if (!p_arguments[0]->is_string() || !p_arguments[1]->is_string()) {
|
||||||
|
r_call_error.error = Callable::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||||
|
return Variant::NIL;
|
||||||
|
}
|
||||||
|
StringName class_ = *p_arguments[0];
|
||||||
|
StringName method = *p_arguments[1];
|
||||||
|
const MethodBind *bind = ::ClassDB::get_method(class_, method);
|
||||||
|
ERR_FAIL_NULL_V_MSG(bind, Variant::NIL, "Cannot find static method.");
|
||||||
|
ERR_FAIL_COND_V_MSG(!bind->is_static(), Variant::NIL, "Method is not static.");
|
||||||
|
return bind->call(nullptr, p_arguments + 2, p_argcount - 2, r_call_error);
|
||||||
|
}
|
||||||
|
|
||||||
PackedStringArray ClassDB::class_get_integer_constant_list(const StringName &p_class, bool p_no_inheritance) const {
|
PackedStringArray ClassDB::class_get_integer_constant_list(const StringName &p_class, bool p_no_inheritance) const {
|
||||||
List<String> constants;
|
List<String> constants;
|
||||||
::ClassDB::get_integer_constant_list(p_class, &constants, p_no_inheritance);
|
::ClassDB::get_integer_constant_list(p_class, &constants, p_no_inheritance);
|
||||||
@ -1623,6 +1640,8 @@ void ClassDB::_bind_methods() {
|
|||||||
|
|
||||||
::ClassDB::bind_method(D_METHOD("class_get_method_list", "class", "no_inheritance"), &ClassDB::class_get_method_list, DEFVAL(false));
|
::ClassDB::bind_method(D_METHOD("class_get_method_list", "class", "no_inheritance"), &ClassDB::class_get_method_list, DEFVAL(false));
|
||||||
|
|
||||||
|
::ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "class_call_static_method", &ClassDB::class_call_static_method, MethodInfo("class_call_static_method", PropertyInfo(Variant::STRING_NAME, "class"), PropertyInfo(Variant::STRING_NAME, "method")));
|
||||||
|
|
||||||
::ClassDB::bind_method(D_METHOD("class_get_integer_constant_list", "class", "no_inheritance"), &ClassDB::class_get_integer_constant_list, DEFVAL(false));
|
::ClassDB::bind_method(D_METHOD("class_get_integer_constant_list", "class", "no_inheritance"), &ClassDB::class_get_integer_constant_list, DEFVAL(false));
|
||||||
|
|
||||||
::ClassDB::bind_method(D_METHOD("class_has_integer_constant", "class", "name"), &ClassDB::class_has_integer_constant);
|
::ClassDB::bind_method(D_METHOD("class_has_integer_constant", "class", "name"), &ClassDB::class_has_integer_constant);
|
||||||
|
@ -460,6 +460,7 @@ public:
|
|||||||
int class_get_method_argument_count(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;
|
||||||
|
|
||||||
TypedArray<Dictionary> class_get_method_list(const StringName &p_class, bool p_no_inheritance = false) const;
|
TypedArray<Dictionary> class_get_method_list(const StringName &p_class, bool p_no_inheritance = false) const;
|
||||||
|
Variant class_call_static_method(const Variant **p_arguments, int p_argcount, Callable::CallError &r_call_error);
|
||||||
|
|
||||||
PackedStringArray class_get_integer_constant_list(const StringName &p_class, bool p_no_inheritance = false) const;
|
PackedStringArray class_get_integer_constant_list(const StringName &p_class, bool p_no_inheritance = false) const;
|
||||||
bool class_has_integer_constant(const StringName &p_class, const StringName &p_name) const;
|
bool class_has_integer_constant(const StringName &p_class, const StringName &p_name) const;
|
||||||
|
@ -16,6 +16,14 @@
|
|||||||
Returns [code]true[/code] if objects can be instantiated from the specified [param class], otherwise returns [code]false[/code].
|
Returns [code]true[/code] if objects can be instantiated from the specified [param class], otherwise returns [code]false[/code].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="class_call_static_method" qualifiers="vararg">
|
||||||
|
<return type="Variant" />
|
||||||
|
<param index="0" name="class" type="StringName" />
|
||||||
|
<param index="1" name="method" type="StringName" />
|
||||||
|
<description>
|
||||||
|
Calls a static method on a class.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="class_exists" qualifiers="const">
|
<method name="class_exists" qualifiers="const">
|
||||||
<return type="bool" />
|
<return type="bool" />
|
||||||
<param index="0" name="class" type="StringName" />
|
<param index="0" name="class" type="StringName" />
|
||||||
|
Loading…
Reference in New Issue
Block a user