Make ilua output iterable userdata as tables

This means anything with __len and __pairs metamethods.
This commit is contained in:
Celtic Minstrel 2019-11-17 14:10:39 -05:00
parent ece5490fd9
commit 981fa93a40

View file

@ -84,8 +84,13 @@ function ilua.val2str(val)
else
return '{'..ilua.join(val,',')..'}'
end
--elseif tp == 'userdata' then
elseif tp == 'userdata' then
local mt = getmetatable(val)
if mt.__len and mt.__pairs then
return '{'..ilua.join(val,',')..'}'
else
return tostring(val)
end
elseif tp == 'string' then
return "'"..val.."'"
elseif tp == 'number' then