mirror of
https://github.com/gvx/bitser.git
synced 2024-11-11 01:44:21 +00:00
Don't add cdata to seen!
This commit is contained in:
parent
cd6ac6f7cb
commit
1a9f3d7631
@ -242,7 +242,7 @@ serialize_value = function(value, seen)
|
||||
return
|
||||
end
|
||||
local t = type(value)
|
||||
if t ~= 'number' and t ~= 'boolean' and t ~= 'nil' then
|
||||
if t ~= 'number' and t ~= 'boolean' and t ~= 'nil' and t ~= 'cdata' then
|
||||
seen[value] = seen[SEEN_LEN]
|
||||
seen[SEEN_LEN] = seen[SEEN_LEN] + 1
|
||||
end
|
||||
|
@ -12,12 +12,9 @@ struct nested_struct {
|
||||
};
|
||||
]]
|
||||
|
||||
local bitser = require 'bitser'
|
||||
|
||||
local int_data = ffi.new('int', 5)
|
||||
|
||||
local struct_data = ffi.new('struct nested_struct', {10, {20, 30}})
|
||||
|
||||
local value = ffi.new('struct { int a; double b; }', 42, 1.25)
|
||||
|
||||
return {int_data, struct_data, value}, 1000, 3
|
||||
return {int_data, struct_data, {ffi.new("int",1),5,ffi.new("int",67)}}, 1000, 3
|
@ -332,4 +332,7 @@ describe("bitser", function()
|
||||
local v = bitser.dumps(ffi.new('struct { int a; }'))
|
||||
assert.has_error(function() bitser.loads(v) end)
|
||||
end)
|
||||
it("can read and write simple multiple cdata of the same ctype without getting confused", function()
|
||||
test_serdeser({ffi.new('double', 42.5), ffi.new('double', 12), ffi.new('double', 0.01)})
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user