Commit dd446637 authored by François Perrad's avatar François Perrad
Browse files

remove set_number'integer'

parent c4df4768
......@@ -2,6 +2,7 @@ Revision history for lua-MessagePack
0.4.0
refactor without types_map indirection
remove set_number'integer'
0.3.7 Sun Dec 4 17:30:00 2016
better use of string.pack (Lua 5.3)
......
......@@ -24,7 +24,7 @@ the _interesting_ value is the second.
#### set_number( str )
Configures the behaviour of `pack`.
The valid options are `'double'`, `'float'` and `'integer'`.
The valid options are `'double'` and `'float'`.
The default is _usually_ `'double'`.
#### set_integer( str ) DEPRECATED
......
......@@ -8,7 +8,6 @@ if not r then
end
local SIZEOF_NUMBER = string.pack and #string.pack('n', 0.0) or 8
local NUMBER_INTEGRAL = math.type and (math.type(0.0) == math.type(0)) or false
local maxinteger
local mininteger
if not jit and _VERSION < 'Lua 5.3' then
......@@ -17,7 +16,6 @@ if not jit and _VERSION < 'Lua 5.3' then
local luac = string.dump(loadstring "a = 1")
local header = { luac:sub(1, 12):byte(1, 12) }
SIZEOF_NUMBER = header[11]
NUMBER_INTEGRAL = 1 == header[12]
end
local assert = assert
......@@ -456,9 +454,7 @@ packers['double'] = function (buffer, n)
end
local set_number = function (number)
if number == 'integer' then
packers['number'] = packers['signed']
elseif number == 'float' then
if number == 'float' then
packers['number'] = function (buffer, n)
if floor(n) == n and n < maxinteger and n > mininteger then
packers['integer'](buffer, n)
......@@ -873,9 +869,7 @@ end
set_string'string_compat'
set_integer'unsigned'
if NUMBER_INTEGRAL then
set_number'integer'
elseif SIZEOF_NUMBER == 4 then
if SIZEOF_NUMBER == 4 then
maxinteger = 16777215
mininteger = -maxinteger
m.small_lua = true
......
......@@ -282,9 +282,7 @@ packers['double'] = function (buffer, n)
end
local set_number = function (number)
if number == 'integer' then
packers['number'] = packers['signed']
elseif number == 'float' then
if number == 'float' then
packers['number'] = function (buffer, n)
if math_type(n) == 'integer' then
packers['integer'](buffer, n)
......@@ -622,9 +620,7 @@ end
set_string'string_compat'
set_integer'unsigned'
if math_type(0.0) == math_type(0) then
set_number'integer'
elseif #pack('n', 0.0) == 4 then
if #pack('n', 0.0) == 4 then
m.small_lua = true
unpackers[0xCB] = nil -- double
unpackers[0xCF] = nil -- uint64
......
......@@ -85,7 +85,7 @@ if not mp.small_lua then
end
end
plan(10 * (mp.small_lua and 60 or 69))
plan(9 * (mp.small_lua and 60 or 69))
-- see http://github.com/msgpack/msgpack/blob/master/test/cases_gen.rb
local source = [===[
......@@ -295,15 +295,3 @@ for _, val in mp.unpacker(mpac) do
end
i = i + 2
end
diag("set_number'integer'")
mp.set_number'integer'
i = 1
for _, val in mp.unpacker(mpac) do
if type(val) == 'table' then
is_deeply(mp.unpack(mp.pack(data[i])), data[i], "unpack/pack " .. data[i+1])
else
is(mp.unpack(mp.pack(data[i])), data[i], "unpack/pack " .. data[i+1])
end
i = i + 2
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment