Merge pull request #26528 from bojidar-bg/26047-gdscript-object-argument
Allow parameters passed to GDScript functions to be nulled
This commit is contained in:
commit
9db96d9f81
1 changed files with 9 additions and 4 deletions
|
@ -329,11 +329,16 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!argument_types[i].is_type(*p_args[i], true)) {
|
if (!argument_types[i].is_type(*p_args[i], true)) {
|
||||||
|
if (argument_types[i].is_type(Variant(), true)) {
|
||||||
|
memnew_placement(&stack[i], Variant);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
r_err.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
r_err.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
|
||||||
r_err.argument = i;
|
r_err.argument = i;
|
||||||
r_err.expected = argument_types[i].kind == GDScriptDataType::BUILTIN ? argument_types[i].builtin_type : Variant::OBJECT;
|
r_err.expected = argument_types[i].kind == GDScriptDataType::BUILTIN ? argument_types[i].builtin_type : Variant::OBJECT;
|
||||||
return Variant();
|
return Variant();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (argument_types[i].kind == GDScriptDataType::BUILTIN) {
|
if (argument_types[i].kind == GDScriptDataType::BUILTIN) {
|
||||||
Variant arg = Variant::construct(argument_types[i].builtin_type, &p_args[i], 1, r_err);
|
Variant arg = Variant::construct(argument_types[i].builtin_type, &p_args[i], 1, r_err);
|
||||||
memnew_placement(&stack[i], Variant(arg));
|
memnew_placement(&stack[i], Variant(arg));
|
||||||
|
|
Loading…
Reference in a new issue