fix(generator): clean up parameter record
ci/woodpecker/pr/lint Pipeline was successful Details
ci/woodpecker/pr/build Pipeline was successful Details

This commit is contained in:
Aire-One 2022-11-06 19:09:39 +01:00
parent 453c9f2949
commit fc9e26b9c9
1 changed files with 22 additions and 17 deletions

View File

@ -15,6 +15,7 @@ local record Module
render_enum: function(name: string, values: List<string>): string
render_record_properties: function(items: List<Variable_Info.Variable_Info>): string
render_record: function(name: string, items: List<Variable_Info.Variable_Info>): string
render_records_from_Parameters: function(items: List<Function_Info.Parameter>): string
end
@ -52,11 +53,8 @@ function snippets.render_anonymous_function_signature(item: Function_Info.Functi
return utils.do_or_fail(template.substitute, tmpl, tmpl_args)
end
function snippets.render_record_functions(items: List<Function_Info.Function_Info>): string
return items:map(function(item: Function_Info.Function_Info): string
return string.format(
"%s%s",
item.parameters:map(function(param: Function_Info.Parameter): string
function snippets.render_records_from_Parameters(items: List<Function_Info.Parameter>): string
return items:map(function(param: Function_Info.Parameter): string
if #param.types == 0 then
return ""
end
@ -71,8 +69,15 @@ function snippets.render_record_functions(items: List<Function_Info.Function_Inf
return snippets.render_record(t.name, properties)
end
return ""
end):concat("\n")
end):concat("\n"),
end):filter(function(p: string): boolean return #p > 0 end):concat("\n")
end):filter(function(p: string): boolean return #p > 0 end):concat("\n")
end
function snippets.render_record_functions(items: List<Function_Info.Function_Info>): string
return items:map(function(item: Function_Info.Function_Info): string
return string.format(
"%s%s",
snippets.render_records_from_Parameters(item.parameters),
snippets.render_anonymous_function_signature(item))
end):concat("\n")
end