local function tag_section(e)
local s = { }
for _, c in ipairs(e.childs or { e }) do
- if c.childs and not c:is(luci.uvl.errors.ERR_DEPENDENCY) then
+ if c.childs and not c:is('DEPENDENCY') then
table.insert( s, c.childs[1]:string() )
else
table.insert( s, c:string() )
end
-- hook helper
+function Node._run_hook(self, hook)
+ if type(self[hook]) == "function" then
+ return self[hook](self)
+ end
+end
+
function Node._run_hooks(self, ...)
local f
local r = false
end
function Delegator.set(self, name, node)
- if type(node) == "table" and getmetatable(node) == nil then
- node = Compound(unpack(node))
- end
- assert(type(node) == "function" or instanceof(node, Compound), "Invalid")
assert(not self.nodes[name], "Duplicate entry")
self.nodes[name] = node
end
function Delegator.insert_after(self, name, after)
- local n = #self.chain
+ local n = #self.chain + 1
for k, v in ipairs(self.chain) do
- if v == state then
+ if v == after then
n = k + 1
break
end
end
function Delegator.get(self, name)
- return self.nodes[name]
+ local node = self.nodes[name]
+
+ if type(node) == "string" then
+ node = load(node, name)
+ end
+
+ if type(node) == "table" and getmetatable(node) == nil then
+ node = Compound(unpack(node))
+ end
+
+ return node
end
function Delegator.parse(self, ...)
return FORM_NODATA
elseif stat > FORM_PROCEED
and (not newcurrent or not self:get(newcurrent)) then
- self:_run_hooks("on_done")
- return FORM_DONE
+ return self:_run_hook("on_done") or FORM_DONE
else
self.current = newcurrent or self.current
self.active = self:get(self.current)
if type(self.active) ~= "function" then
- self.active:parse(false)
- return FROM_PROCEED
+ self.active:populate_delegator(self)
+ local stat = self.active:parse(false)
+ if stat == FORM_SKIP then
+ return self:parse(...)
+ else
+ return FORM_PROCEED
+ end
else
return self:parse(...)
end
self.tag_reqerror = {}
self.tag_error = {}
self.deps = {}
+ self.subdeps = {}
--self.cast = "string"
self.track_missing = false
table.insert(self.vallist, tostring(val))
for i, deps in ipairs({...}) do
- table.insert(self.deps, {add = "-"..key, deps=deps})
+ self.subdeps[#self.subdeps + 1] = {add = "-"..key, deps=deps}
end
end