data formats: comments are specs only
This commit is contained in:
1 parent
0bd7b87d2b
commit
0452f26eef
18 files changed
+110
-224
No files matched your search
@@ -1,10 +1,6 @@
|
||||
--!strict
|
||||
--!native
|
||||
-- data/plist/Binary: the binary property list reader ("bplist00", CoreFoundation's format as documented in
|
||||
-- CFBinaryPList.c and implemented by Python's plistlib). Objects: null / bool / fill, ints (1, 2, 4, 8 bytes; 16-byte
|
||||
-- ints are read from their low 8 bytes), reals (4 / 8 bytes), dates, data, ASCII / UTF-16BE / UTF-8 strings, UIDs,
|
||||
-- arrays, sets (as arrays), dicts (Types.object, key order kept). Shared references decode to the same table; cycles
|
||||
-- are errors. Never throws: errors return nil, message.
|
||||
-- data/plist/Binary: binary plist reader ("bplist00", CFBinaryPList.c / Python's plistlib); 16-byte ints: low 8 bytes.
|
||||
local Types = require("@rosetta/Types")
|
||||
|
||||
local Binary = {}
|
||||
@@ -44,7 +40,6 @@ end
|
||||
|
||||
export type Options = { bigInts: ("number" | "string")?, maxDepth: number? }
|
||||
|
||||
-- decode(buf, base, len, opts) -> value | nil, message
|
||||
function Binary.decode(b: buffer, base: number, len: number, opts: Options?): (any, string?)
|
||||
if len < 40 then
|
||||
return nil, "truncated: shorter than header + trailer"
|
||||
@@ -130,7 +125,6 @@ function Binary.decode(b: buffer, base: number, len: number, opts: Options?): (a
|
||||
if h >= 0x80000000 and nib == 3 then
|
||||
v = (h - TWO32) * TWO32 + l
|
||||
elseif opts and opts.bigInts == "string" and h >= 0x200000 then
|
||||
-- exact decimal text of h * 2^32 + l
|
||||
local digits = {}
|
||||
local limbs = { h // 65536, h % 65536, l // 65536, l % 65536 }
|
||||
while limbs[1] + limbs[2] + limbs[3] + limbs[4] > 0 do
|
||||
|
||||
Reference in new issue
Block a user