summaryrefslogtreecommitdiffstats
path: root/core/core_bind.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/core_bind.cpp')
-rw-r--r--core/core_bind.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index 36f662b92b..84f66c3479 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -1501,6 +1501,23 @@ TypedArray<Dictionary> ClassDB::class_get_method_list(const StringName &p_class,
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 {
List<String> constants;
::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_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_has_integer_constant", "class", "name"), &ClassDB::class_has_integer_constant);