Skip to content

Commit

Permalink
snabbco#700 - Allow for missing optional containers snabb set
Browse files Browse the repository at this point in the history
This allows you to miss out optional arguments where there is a
container without any required leaves in it. Previous you would often
get a casting error when they were left empty of omitted.
  • Loading branch information
Jessica Tallon committed Feb 6, 2017
1 parent 567239b commit 7f8d684
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/lib/yang/data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,16 @@ local function struct_parser(keyword, members, ctype)
return parse1(P)
end
local struct_t = ctype and typeof(ctype)
local function finish(out)
-- FIXME check mandatory values.
if struct_t then return struct_t(out) else return out end
local function finish(out, leaf)
-- FIXME check mandatory values.
if struct_t then
local ret
if out == nil then ret = struct_t()
else ret = struct_t(out) end
return ret
else
return out
end
end
return {init=init, parse=parse, finish=finish}
end
Expand Down

0 comments on commit 7f8d684

Please sign in to comment.