mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Add methods to get argument count of methods
Added to: * `Callable`s * `Object`s * `ClassDB` * `Script(Instance)`s
This commit is contained in:
parent
0ace0a1292
commit
59bcc2888c
50 changed files with 821 additions and 3 deletions
|
@ -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"))) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue