mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 08:23:29 +00:00
GDScript: Add support for variadic functions
This commit is contained in:
parent
3b963ab8b6
commit
ee121ef80e
33 changed files with 416 additions and 65 deletions
|
@ -508,9 +508,22 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionN
|
|||
parameters += " = " + parameter->initializer->reduced_value.to_json_string();
|
||||
}
|
||||
}
|
||||
if (p_func->is_vararg()) {
|
||||
if (!p_func->parameters.is_empty()) {
|
||||
parameters += ", ";
|
||||
}
|
||||
const ParameterNode *rest_param = p_func->rest_parameter;
|
||||
parameters += "..." + rest_param->identifier->name + ": " + rest_param->get_datatype().to_string();
|
||||
}
|
||||
r_symbol.detail += parameters + ")";
|
||||
if (p_func->get_datatype().is_hard_type()) {
|
||||
r_symbol.detail += " -> " + p_func->get_datatype().to_string();
|
||||
|
||||
const DataType return_type = p_func->get_datatype();
|
||||
if (return_type.is_hard_type()) {
|
||||
if (return_type.kind == DataType::BUILTIN && return_type.builtin_type == Variant::NIL) {
|
||||
r_symbol.detail += " -> void";
|
||||
} else {
|
||||
r_symbol.detail += " -> " + return_type.to_string();
|
||||
}
|
||||
}
|
||||
|
||||
List<GDScriptParser::SuiteNode *> function_nodes;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue