ws-cleanup-types: Types, api, host: honest annotations; return the full annotated value count
This commit is contained in:
1 parent
59a0352ca6
commit
f209801579
22 files changed
+147
-147
No files matched your search
@@ -21,11 +21,11 @@ Ebml.UNKNOWN = -1
|
||||
-- vint(buf, pos, limit) -> value (marker removed), length | nil. All-ones values (unknown sizes) return -1.
|
||||
function Ebml.vint(buf: buffer, pos: number, limit: number): (number?, number?)
|
||||
if pos >= limit then
|
||||
return nil
|
||||
return nil, nil
|
||||
end
|
||||
local b = readu8(buf, pos)
|
||||
if b == 0 then
|
||||
return nil
|
||||
return nil, nil
|
||||
end
|
||||
local len = 1
|
||||
local mask = 0x80
|
||||
@@ -34,7 +34,7 @@ function Ebml.vint(buf: buffer, pos: number, limit: number): (number?, number?)
|
||||
mask = mask // 2
|
||||
end
|
||||
if pos + len > limit then
|
||||
return nil
|
||||
return nil, nil
|
||||
end
|
||||
local v = bit32.band(b, mask - 1)
|
||||
local allOnes = v == mask - 1
|
||||
@@ -55,10 +55,10 @@ end
|
||||
function Ebml.svint(buf: buffer, pos: number, limit: number): (number?, number?)
|
||||
local v, len = Ebml.vint(buf, pos, limit)
|
||||
if v == nil or len == nil then
|
||||
return nil
|
||||
return nil, nil
|
||||
end
|
||||
if v == -1 then
|
||||
return nil
|
||||
return nil, nil
|
||||
end
|
||||
return v - (2 ^ (7 * len - 1) - 1), len
|
||||
end
|
||||
@@ -66,12 +66,12 @@ end
|
||||
-- id(buf, pos, limit) -> the element ID with its marker bits, length | nil (IDs are 1..4 bytes)
|
||||
function Ebml.id(buf: buffer, pos: number, limit: number): (number?, number?)
|
||||
if pos >= limit then
|
||||
return nil
|
||||
return nil, nil
|
||||
end
|
||||
local b = readu8(buf, pos)
|
||||
local len = if b >= 0x80 then 1 elseif b >= 0x40 then 2 elseif b >= 0x20 then 3 elseif b >= 0x10 then 4 else 0
|
||||
if len == 0 or pos + len > limit then
|
||||
return nil
|
||||
return nil, nil
|
||||
end
|
||||
local v = b
|
||||
for i = 1, len - 1 do
|
||||
@@ -84,11 +84,11 @@ end
|
||||
function Ebml.header(buf: buffer, pos: number, limit: number): (number?, number?, number?)
|
||||
local id, il = Ebml.id(buf, pos, limit)
|
||||
if not id or not il then
|
||||
return nil
|
||||
return nil, nil, nil
|
||||
end
|
||||
local size, sl = Ebml.vint(buf, pos + il, limit)
|
||||
if not size or not sl then
|
||||
return nil
|
||||
return nil, nil, nil
|
||||
end
|
||||
return id, size, pos + il + sl
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user