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):concat("\n")
|
||||||
end
|
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
|
return snippets
|
||||||
|
|
|
@ -8,15 +8,11 @@ local snippets = require "generator.snippets"
|
||||||
local tmpl = [[
|
local tmpl = [[
|
||||||
-- Auto generated file (Do not manually edit this file!)
|
-- Auto generated file (Do not manually edit this file!)
|
||||||
|
|
||||||
# if module.signals then
|
local record $(mod_name)
|
||||||
local enum signals
|
# if #module.signals then
|
||||||
# for _, signal in ipairs(module.signals) do
|
$(snippets.indent(snippets.render_enum("Signal", module.signals)))
|
||||||
"$(signal.name)"
|
|
||||||
# end
|
|
||||||
end
|
|
||||||
|
|
||||||
# end -- /signals
|
# end -- /signals
|
||||||
local record $(mod_name)
|
|
||||||
# if #module.methods then
|
# if #module.methods then
|
||||||
-- Object methods
|
-- Object methods
|
||||||
$(snippets.indent(snippets.render_record_functions(module.methods)))
|
$(snippets.indent(snippets.render_record_functions(module.methods)))
|
||||||
|
|
Loading…
Reference in New Issue