feat(generator): basic Object Properties render
This commit is contained in:
parent
1fa62b7955
commit
73320768df
|
@ -3,6 +3,7 @@ local List = require "pl.List"
|
||||||
local stringx = require "pl.stringx"
|
local stringx = require "pl.stringx"
|
||||||
local template = require "pl.template"
|
local template = require "pl.template"
|
||||||
local utils = require "utils"
|
local utils = require "utils"
|
||||||
|
local Variable_Info = require "entity.Variable_Info"
|
||||||
|
|
||||||
local snippets = {}
|
local snippets = {}
|
||||||
|
|
||||||
|
@ -44,6 +45,12 @@ function snippets.render_record_functions(items: List<Function_Info.Function_Inf
|
||||||
end):concat("\n")
|
end):concat("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function snippets.render_record_properties(items: List<Variable_Info.Variable_Info>): string
|
||||||
|
return items:map(function(item: Variable_Info.Variable_Info): string
|
||||||
|
return snippets.render_typed_variable(item.name, item.types)
|
||||||
|
end):concat("\n")
|
||||||
|
end
|
||||||
|
|
||||||
function snippets.render_enum(name: string, values: List<string>): string
|
function snippets.render_enum(name: string, values: List<string>): string
|
||||||
local tmpl = [[
|
local tmpl = [[
|
||||||
enum $(name)
|
enum $(name)
|
||||||
|
|
|
@ -16,7 +16,12 @@ $(snippets.indent(snippets.render_enum("Signal", module.signals)))
|
||||||
# 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)))
|
||||||
|
|
||||||
# end -- /methods
|
# end -- /methods
|
||||||
|
# if #module.properties then
|
||||||
|
-- Object properties
|
||||||
|
$(snippets.indent(snippets.render_record_properties(module.properties)))
|
||||||
|
# end -- /properties
|
||||||
end
|
end
|
||||||
|
|
||||||
return $(module.record_name)
|
return $(module.record_name)
|
||||||
|
|
Loading…
Reference in New Issue