Core: Fix Callable.get_bound_arguments{,_count}() return incorrect data

This commit is contained in:
Danil Alexeev
2024-11-01 02:28:21 +03:00
parent 1bffd6c73b
commit e379cc76e5
9 changed files with 150 additions and 63 deletions

View File

@ -206,19 +206,17 @@ int Callable::get_bound_arguments_count() const {
}
}
void Callable::get_bound_arguments_ref(Vector<Variant> &r_arguments, int &r_argcount) const {
void Callable::get_bound_arguments_ref(Vector<Variant> &r_arguments) const {
if (!is_null() && is_custom()) {
custom->get_bound_arguments(r_arguments, r_argcount);
custom->get_bound_arguments(r_arguments);
} else {
r_arguments.clear();
r_argcount = 0;
}
}
Array Callable::get_bound_arguments() const {
Vector<Variant> arr;
int ac;
get_bound_arguments_ref(arr, ac);
get_bound_arguments_ref(arr);
Array ret;
ret.resize(arr.size());
for (int i = 0; i < arr.size(); i++) {
@ -227,6 +225,14 @@ Array Callable::get_bound_arguments() const {
return ret;
}
int Callable::get_unbound_arguments_count() const {
if (!is_null() && is_custom()) {
return custom->get_unbound_arguments_count();
} else {
return 0;
}
}
CallableCustom *Callable::get_custom() const {
ERR_FAIL_COND_V_MSG(!is_custom(), nullptr,
vformat("Can't get custom on non-CallableCustom \"%s\".", operator String()));
@ -464,9 +470,12 @@ int CallableCustom::get_bound_arguments_count() const {
return 0;
}
void CallableCustom::get_bound_arguments(Vector<Variant> &r_arguments, int &r_argcount) const {
r_arguments = Vector<Variant>();
r_argcount = 0;
void CallableCustom::get_bound_arguments(Vector<Variant> &r_arguments) const {
r_arguments.clear();
}
int CallableCustom::get_unbound_arguments_count() const {
return 0;
}
CallableCustom::CallableCustom() {