Implement module section types "Signals" (#18) #23
|
@ -44,4 +44,22 @@ function snippets.render_record_functions(items: List<Function_Info.Function_Inf
|
|||
end):concat("\n")
|
||||
end
|
||||
|
||||
function snippets.render_enum(name: string, values: List<string>): string
|
||||
local tmpl = [[
|
||||
enum $(name)
|
||||
$(indent(body))
|
||||
end
|
||||
]]
|
||||
|
||||
local tmpl_args = {
|
||||
name = name,
|
||||
body = values:map(function(value: string): string
|
||||
return string.format('"%s"', value)
|
||||
end):concat("\n"),
|
||||
indent = snippets.indent,
|
||||
}
|
||||
|
||||
return utils.do_or_fail(template.substitute, tmpl, tmpl_args)
|
||||
end
|
||||
|
||||
return snippets
|
||||
|
|
|
@ -8,15 +8,11 @@ local snippets = require "generator.snippets"
|
|||
local tmpl = [[
|
||||
-- Auto generated file (Do not manually edit this file!)
|
||||
|
||||
# if module.signals then
|
||||
local enum signals
|
||||
# for _, signal in ipairs(module.signals) do
|
||||
"$(signal.name)"
|
||||
# end
|
||||
end
|
||||
local record $(mod_name)
|
||||
# if #module.signals then
|
||||
$(snippets.indent(snippets.render_enum("Signal", module.signals)))
|
||||
|
||||
# end -- /signals
|
||||
local record $(mod_name)
|
||||
# if #module.methods then
|
||||
-- Object methods
|
||||
$(snippets.indent(snippets.render_record_functions(module.methods)))
|
||||
|
|
Loading…
Reference in New Issue