Merge pull request #34 from akopytov/master

Support LuaJIT cdata and ctype values in Inspector:putValue().
This commit is contained in:
Enrique García Cota 2018-01-02 13:02:45 +01:00 committed by GitHub
commit e95f34834b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -296,7 +296,8 @@ function Inspector:putValue(v)
if tv == 'string' then if tv == 'string' then
self:puts(smartQuote(escape(v))) self:puts(smartQuote(escape(v)))
elseif tv == 'number' or tv == 'boolean' or tv == 'nil' then elseif tv == 'number' or tv == 'boolean' or tv == 'nil' or
tv == 'cdata' or tv == 'ctype' then
self:puts(tostring(v)) self:puts(tostring(v))
elseif tv == 'table' then elseif tv == 'table' then
self:putTable(v) self:putTable(v)

View File

@ -71,7 +71,8 @@ describe( 'inspect', function()
if is_luajit then if is_luajit then
it('works with luajit cdata', function() it('works with luajit cdata', function()
assert.equals('{ <cdata 1>, <cdata 2>, <cdata 3> }', inspect({ ffi.new("int", 1), ffi.typeof("int"), ffi.typeof("int")(1) })) assert.equals('{ cdata<int>: PTR, ctype<int>, cdata<int>: PTR }',
inspect({ ffi.new("int", 1), ffi.typeof("int"), ffi.typeof("int")(1) }):gsub('(0x%x+)','PTR'))
end) end)
end end