[init] Respect mode parameter for subtables.

master
Lorenzo Cogotti 2 years ago
parent 6ecb087511
commit 26631c607d

@ -20,7 +20,7 @@ local function isfinite(x)
return x ~= math.huge and x ~= -math.huge and x == x
end
local function keys(k, i)
local function keys(k, i, mode)
local t = type(k)
if t == 'boolean' then
@ -39,13 +39,13 @@ local function keys(k, i)
return "["..k.."]"
elseif t == 'table' then
return "["..dopack(k, i+1).."]"
return "["..dopack(k, i+1, mode).."]"
else
error("Can't serialize.pack() table with key `"..tostring(k).."'.")
end
end
local function vals(v, i)
local function vals(v, i, mode)
local t = type(v)
if t == 'boolean' then
@ -59,7 +59,7 @@ local function vals(v, i)
return tostring(v)
elseif t == 'table' then
return dopack(v, i+1)
return dopack(v, i+1, mode)
else
error("Can't serialize.pack() table with value `"..tostring(v).."'.")
end
@ -78,7 +78,7 @@ function dopack(o, i, mode)
goto skip
end
fields[#fields + 1] = ("%s%s"):format(is, vals(v, i))
fields[#fields + 1] = ("%s%s"):format(is, vals(v, i, mode))
::skip:: seen[k] = true
end
@ -89,7 +89,7 @@ function dopack(o, i, mode)
goto skip
end
local f = ("%s%s = %s"):format(is, keys(k, i), vals(v, i))
local f = ("%s%s = %s"):format(is, keys(k, i, mode), vals(v, i, mode))
fields[#fields + 1] = f

Loading…
Cancel
Save