mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 00:13:30 +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
|
@ -32,6 +32,28 @@
|
|||
|
||||
#include "core/object/script_language.h"
|
||||
|
||||
int ScriptInstance::get_method_argument_count(const StringName &p_method, bool *r_is_valid) const {
|
||||
// Default implementation simply traverses hierarchy.
|
||||
Ref<Script> script = get_script();
|
||||
while (script.is_valid()) {
|
||||
bool valid = false;
|
||||
int ret = script->get_script_method_argument_count(p_method, &valid);
|
||||
if (valid) {
|
||||
if (r_is_valid) {
|
||||
*r_is_valid = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
script = script->get_base_script();
|
||||
}
|
||||
|
||||
if (r_is_valid) {
|
||||
*r_is_valid = false;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Variant ScriptInstance::call_const(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
|
||||
return callp(p_method, p_args, p_argcount, r_error);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue