mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 23:31:53 -05:00
Add methods to get argument count of methods
Added to: * `Callable`s * `Object`s * `ClassDB` * `Script(Instance)`s
This commit is contained in:
@@ -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"))) {
|
||||
|
||||
Reference in New Issue
Block a user