You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
GDScript: Add support for variadic functions
This commit is contained in:
@@ -2294,6 +2294,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++) {
|
||||
@@ -2309,6 +2310,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);
|
||||
}
|
||||
|
||||
@@ -2475,6 +2481,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;
|
||||
|
||||
Reference in New Issue
Block a user