fix(generator): clean up parameter record
This commit is contained in:
parent
453c9f2949
commit
fc9e26b9c9
|
@ -15,6 +15,7 @@ local record Module
|
||||||
render_enum: function(name: string, values: List<string>): string
|
render_enum: function(name: string, values: List<string>): string
|
||||||
render_record_properties: function(items: List<Variable_Info.Variable_Info>): 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_record: function(name: string, items: List<Variable_Info.Variable_Info>): string
|
||||||
|
render_records_from_Parameters: function(items: List<Function_Info.Parameter>): string
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,27 +53,31 @@ function snippets.render_anonymous_function_signature(item: Function_Info.Functi
|
||||||
return utils.do_or_fail(template.substitute, tmpl, tmpl_args)
|
return utils.do_or_fail(template.substitute, tmpl, tmpl_args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
return param.types:map(function(t: Type_Info.Type_Info): string
|
||||||
|
if t.record_entries and (t.record_entries as Map<string, List<Type_Info.Type_Info>>):len() > 0 then
|
||||||
|
local properties: List<Variable_Info.Variable_Info> = List()
|
||||||
|
for name, types in (t.record_entries as Map<string, List<Type_Info.Type_Info>>):iter() do
|
||||||
|
properties:append(Variable_Info(name, types))
|
||||||
|
end
|
||||||
|
|
||||||
|
return snippets.render_record(t.name, properties)
|
||||||
|
end
|
||||||
|
return ""
|
||||||
|
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
|
function snippets.render_record_functions(items: List<Function_Info.Function_Info>): string
|
||||||
return items:map(function(item: Function_Info.Function_Info): string
|
return items:map(function(item: Function_Info.Function_Info): string
|
||||||
return string.format(
|
return string.format(
|
||||||
"%s%s",
|
"%s%s",
|
||||||
item.parameters:map(function(param: Function_Info.Parameter): string
|
snippets.render_records_from_Parameters(item.parameters),
|
||||||
if #param.types == 0 then
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
|
|
||||||
return param.types:map(function(t: Type_Info.Type_Info): string
|
|
||||||
if t.record_entries and (t.record_entries as Map<string, List<Type_Info.Type_Info>>):len() > 0 then
|
|
||||||
local properties: List<Variable_Info.Variable_Info> = List()
|
|
||||||
for name, types in (t.record_entries as Map<string, List<Type_Info.Type_Info>>):iter() do
|
|
||||||
properties:append(Variable_Info(name, types))
|
|
||||||
end
|
|
||||||
|
|
||||||
return snippets.render_record(t.name, properties)
|
|
||||||
end
|
|
||||||
return ""
|
|
||||||
end):concat("\n")
|
|
||||||
end):concat("\n"),
|
|
||||||
snippets.render_anonymous_function_signature(item))
|
snippets.render_anonymous_function_signature(item))
|
||||||
end):concat("\n")
|
end):concat("\n")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue