diff options
Diffstat (limited to 'modules/gdscript/gdscript.cpp')
-rw-r--r-- | modules/gdscript/gdscript.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 94aa077014..8e74de4242 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -354,6 +354,21 @@ bool GDScript::has_static_method(const StringName &p_method) const { return member_functions.has(p_method) && member_functions[p_method]->is_static(); } +int GDScript::get_script_method_argument_count(const StringName &p_method, bool *r_is_valid) const { + HashMap<StringName, GDScriptFunction *>::ConstIterator E = member_functions.find(p_method); + if (!E) { + if (r_is_valid) { + *r_is_valid = false; + } + return 0; + } + + if (r_is_valid) { + *r_is_valid = true; + } + return E->value->get_argument_count(); +} + MethodInfo GDScript::get_method_info(const StringName &p_method) const { HashMap<StringName, GDScriptFunction *>::ConstIterator E = member_functions.find(p_method); if (!E) { @@ -1916,6 +1931,25 @@ bool GDScriptInstance::has_method(const StringName &p_method) const { return false; } +int GDScriptInstance::get_method_argument_count(const StringName &p_method, bool *r_is_valid) const { + const GDScript *sptr = script.ptr(); + while (sptr) { + HashMap<StringName, GDScriptFunction *>::ConstIterator E = sptr->member_functions.find(p_method); + if (E) { + if (r_is_valid) { + *r_is_valid = true; + } + return E->value->get_argument_count(); + } + sptr = sptr->_base; + } + + if (r_is_valid) { + *r_is_valid = false; + } + return 0; +} + Variant GDScriptInstance::callp(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) { GDScript *sptr = script.ptr(); if (unlikely(p_method == SNAME("_ready"))) { |