Added rawstring option for metamethods that return raw values (ref #10).

This commit is contained in:
Paul Kulchenko 2013-12-30 11:49:08 -08:00
parent 4e4a19df1d
commit 41e7fffcb5

View File

@ -49,7 +49,9 @@ local function s(t, opts)
if type(mt) == 'table' and (mt.__serialize or mt.__tostring) then -- knows how to serialize itself if type(mt) == 'table' and (mt.__serialize or mt.__tostring) then -- knows how to serialize itself
seen[t] = insref or spath seen[t] = insref or spath
if mt.__serialize then t = mt.__serialize(t) else t = tostring(t) end if mt.__serialize then t = mt.__serialize(t) else t = tostring(t) end
ttype = type(t) end -- new value falls through to be serialized ttype = type(t)
if ttype == 'string' and opts.rawstring then return tag..t end
end -- new value falls through to be serialized
if ttype == "table" then if ttype == "table" then
if level >= maxl then return tag..'{}'..comment('max', level) end if level >= maxl then return tag..'{}'..comment('max', level) end
seen[t] = insref or spath seen[t] = insref or spath