mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
update sprotoparser for lua 5.3
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
local lpeg = require "lpeg"
|
local lpeg = require "lpeg"
|
||||||
local bit32 = require "bit32"
|
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
local P = lpeg.P
|
local P = lpeg.P
|
||||||
@@ -196,18 +195,14 @@ end
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
local function packbytes(str)
|
local function packbytes(str)
|
||||||
local size = #str
|
str = string.pack("<s4",str)
|
||||||
return string.char(bit32.extract(size,0,8))..
|
return str
|
||||||
string.char(bit32.extract(size,8,8))..
|
|
||||||
string.char(bit32.extract(size,16,8))..
|
|
||||||
string.char(bit32.extract(size,24,8))..
|
|
||||||
str
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function packvalue(id)
|
local function packvalue(id)
|
||||||
id = (id + 1) * 2
|
id = (id + 1) * 2
|
||||||
assert(id >=0 and id < 65536)
|
local str = string.pack("<I2", id)
|
||||||
return string.char(bit32.extract(id, 0, 8)) .. string.char(bit32.extract(id, 8, 8))
|
return str
|
||||||
end
|
end
|
||||||
|
|
||||||
local function packfield(f)
|
local function packfield(f)
|
||||||
|
|||||||
Reference in New Issue
Block a user