Fixed an issue with luaffi that returns getmetatable(ffi.C) as true.

This commit is contained in:
Paul Kulchenko 2013-06-11 00:02:22 -07:00
parent 0c1483c799
commit 2d09171357

View File

@ -1,4 +1,4 @@
local n, v = "serpent", 0.23 -- (C) 2012-13 Paul Kulchenko; MIT License
local n, v = "serpent", 0.231 -- (C) 2012-13 Paul Kulchenko; MIT License
local c, d = "Paul Kulchenko", "Lua serializer and pretty printer"
local snum = {[tostring(1/0)]='1/0 --[[math.huge]]',[tostring(-1/0)]='-1/0 --[[-math.huge]]',[tostring(0/0)]='0/0'}
local badtype = {thread = true, userdata = true, cdata = true}
@ -46,7 +46,7 @@ local function s(t, opts)
if seen[t] then -- already seen this element
table.insert(sref, spath..space..'='..space..seen[t])
return tag..'nil'..comment('ref', level) end
if mt 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
if mt.__serialize then t = mt.__serialize(t) else t = tostring(t) end
ttype = type(t) end -- new value falls through to be serialized