ws-cleanup: shared plumbing: Err.from, core/Sniff, Pcm.drain, Bits.msbPut; DUP lint; tools/move.py
- core/Err.from(message, offset?, kind?): the private-submodule -> Err plumbing (a kind, or a 'code: ' prefix / 'truncated' / 'past the end' in the message) that Brotli, Bzip2, Zstd, Jpeg, WOFF2, FBX, plist, msgpack and bmfont each wrote. - core/Sniff (new): Sniff.text(r, n, trim?) (the start of a text file without its BOM), Sniff.dropBom(s), Sniff.magic(r, s); 13 text formats' sniff / decode BOM handling goes through it. - codecs/Pcm.drain(dec, source?, maxFrames?): a format's decode() through its open(); the collect-the-Decoder loops of aac, aiff, au, caf, flac, m4a, mp3, opus, vorbis and wav are one call each. - core/Bits.msbPut: the MSB-first bit writer the MP3 / MP2 / FLAC encoders each copied. - tools/lint_rules.py DUP: a function body of 12+ code lines repeated token for token in another module fails. - tools/move.py: moves a module and rewrites every reference (requires, deps, headers, fixture INPUTS, docs). - tools/fixtures/zstd.py: the incompressible corpus is smaller (zstd.luau 15.1 -> 13.4 MB; every fixture module is now under 14.3 MB). - tools/bench.luau: MPEG-1 also runs with the api's LuaJIT trace limits; the sections that compare tuned / default limits set them explicitly (jitTune), so the order of sections no longer leaks the tuning.
This commit is contained in:
1 parent
3243404374
commit
763f4a7c04
44 files changed
+374
-370
No files matched your search
@@ -98,18 +98,7 @@ local function fetcher(opts: DecodeOptions?): Read.Fetch
|
||||
end
|
||||
end
|
||||
|
||||
local function toErr(msg: any, offset: number?): Err.Err
|
||||
local s = tostring(msg)
|
||||
local code = Err.CORRUPT
|
||||
if string.sub(s, 1, 12) == "unsupported:" then
|
||||
code, s = Err.UNSUPPORTED, string.sub(s, 13)
|
||||
elseif string.sub(s, 1, 6) == "limit:" then
|
||||
code, s = Err.LIMIT, string.sub(s, 7)
|
||||
elseif string.find(s, "truncated", 1, true) or string.find(s, "runs past", 1, true) then
|
||||
code = Err.TRUNCATED
|
||||
end
|
||||
return Err.new(code, s, offset)
|
||||
end
|
||||
local toErr = Err.from
|
||||
|
||||
-- tree(r, opts?) -> the node tree { name = "", children = { { name, props, children } } }, version, binary | nil, Err.
|
||||
-- Property values: numbers, booleans, strings, buffers (raw), Arrays { array = true, type, count, data = f64 buffer }.
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ requires
|
||||
local Err = require("@formats/core/Err")
|
||||
local Sniff = require("@formats/core/Sniff")
|
||||
local Bytes = require("@formats/core/Bytes")
|
||||
local Types = require("@formats/Types")
|
||||
local Json = require("@formats/codecs/Json")
|
||||
@@ -30,7 +31,7 @@ local Gltf = {
|
||||
category = "model",
|
||||
extensions = { "gltf", "glb" },
|
||||
mime = { "model/gltf+json", "model/gltf-binary" },
|
||||
deps = { "core/Err", "core/Bytes", "Types", "codecs/Json", "core/Base64" },
|
||||
deps = { "core/Err", "core/Bytes", "Types", "codecs/Json", "core/Base64", "core/Sniff" },
|
||||
caps = { decode = true, encode = true, binary = true, materials = true, animation = true, skins = true, morphTargets = true, cameras = true, lights = true },
|
||||
}
|
||||
|
||||
@@ -60,7 +61,7 @@ function Gltf.sniff(r: Bytes.Reader): number
|
||||
return 1
|
||||
end
|
||||
local head = r:peek(1024)
|
||||
local s = string.gsub(head, "^\239\187\191", "")
|
||||
local s = Sniff.dropBom(head)
|
||||
if string.find(s, "^%s*{") and string.find(s, "\"asset\"", 1, true) then
|
||||
return 0.9
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user