mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 00:13:30 +00:00
Merge pull request #82808 from dalexeev/gds-vararg
GDScript: Add support for variadic functions
This commit is contained in:
commit
0f05e91889
33 changed files with 416 additions and 65 deletions
|
@ -2338,6 +2338,7 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_
|
|||
codegen.generator->write_start(p_script, func_name, is_static, rpc_config, return_type);
|
||||
|
||||
int optional_parameters = 0;
|
||||
GDScriptCodeGenerator::Address vararg_addr;
|
||||
|
||||
if (p_func) {
|
||||
for (int i = 0; i < p_func->parameters.size(); i++) {
|
||||
|
@ -2353,6 +2354,11 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_
|
|||
}
|
||||
}
|
||||
|
||||
if (p_func->is_vararg()) {
|
||||
vararg_addr = codegen.add_local(p_func->rest_parameter->identifier->name, _gdtype_from_datatype(p_func->rest_parameter->get_datatype(), codegen.script));
|
||||
method_info.flags |= METHOD_FLAG_VARARG;
|
||||
}
|
||||
|
||||
method_info.default_arguments.append_array(p_func->default_arg_values);
|
||||
}
|
||||
|
||||
|
@ -2519,6 +2525,10 @@ GDScriptFunction *GDScriptCompiler::_parse_function(Error &r_error, GDScript *p_
|
|||
gd_function->return_type.kind = GDScriptDataType::BUILTIN;
|
||||
gd_function->return_type.builtin_type = Variant::NIL;
|
||||
}
|
||||
|
||||
if (p_func->is_vararg()) {
|
||||
gd_function->_vararg_index = vararg_addr.address;
|
||||
}
|
||||
}
|
||||
|
||||
gd_function->method_info = method_info;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue