ws-cleanup-types: Types, api, host: honest annotations; return the full annotated value count
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
e35de41c9f
commit
2c15b97cd8
22 files changed
+147
-147
No files matched your search
@@ -429,7 +429,7 @@ function Decode.parse(b: buffer, base: number, n: number, opts: any, headerOnly:
|
||||
frame = f
|
||||
st.frame = f
|
||||
if headerOnly then
|
||||
return st
|
||||
return st, nil, nil
|
||||
end
|
||||
elseif SOF_REFUSED[m] then
|
||||
return nil, "unsupported", SOF_REFUSED[m] .. " JPEG"
|
||||
@@ -559,12 +559,12 @@ function Decode.parse(b: buffer, base: number, n: number, opts: any, headerOnly:
|
||||
st.icc = icc
|
||||
end
|
||||
if headerOnly then
|
||||
return st
|
||||
return st, nil, nil
|
||||
end
|
||||
if scans == 0 then
|
||||
return nil, "truncated", "no image data"
|
||||
end
|
||||
return st
|
||||
return st, nil, nil
|
||||
end
|
||||
|
||||
local SPACE_IDS = { gray = Color.GRAY, ycbcr = Color.YCC, rgb = Color.RGB, cmyk = Color.CMYK, ycck = Color.YCCK }
|
||||
@@ -697,7 +697,7 @@ end
|
||||
function Decode.outputYuv(st: State): (number?, number?, buffer?, string?)
|
||||
local f: Frame = st.frame
|
||||
if st.scale ~= 1 or f.precision ~= 8 then
|
||||
return nil
|
||||
return nil, nil, nil, nil
|
||||
end
|
||||
local comps = f.comps
|
||||
local space = colorSpaceOf(f, st.adobe, st.jfif)
|
||||
@@ -721,11 +721,11 @@ function Decode.outputYuv(st: State): (number?, number?, buffer?, string?)
|
||||
end
|
||||
end
|
||||
if not mode then
|
||||
return nil
|
||||
return nil, nil, nil, nil
|
||||
end
|
||||
for _, c in comps do
|
||||
if c.coef and not c.quant then
|
||||
return nil -- output() reports the missing table
|
||||
return nil, nil, nil, nil -- output() reports the missing table
|
||||
end
|
||||
end
|
||||
local w, h = f.width, f.height
|
||||
|
||||
@@ -319,7 +319,7 @@ function Lzma.filter(id: number, b: buffer, o: number, n: number, props: any?):
|
||||
return nil, Err.new(Err.CORRUPT, "bad delta filter properties")
|
||||
end
|
||||
Filters.delta(b, o, n, readu8(pb :: buffer, 0) + 1)
|
||||
return true
|
||||
return true, nil
|
||||
end
|
||||
local f = BCJ[id]
|
||||
if not f then
|
||||
@@ -332,7 +332,7 @@ function Lzma.filter(id: number, b: buffer, o: number, n: number, props: any?):
|
||||
return nil, Err.new(Err.CORRUPT, "bad BCJ filter properties")
|
||||
end
|
||||
f(b, o, n, start)
|
||||
return true
|
||||
return true, nil
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ xz
|
||||
|
||||
@@ -159,12 +159,12 @@ local function flatten(path: any, transform: Transform?, tolerance: number?, min
|
||||
local cmds = commands(path)
|
||||
local polys: { { number } } = {}
|
||||
if not cmds then
|
||||
return polys
|
||||
return polys, nil, nil, nil, nil
|
||||
end
|
||||
local m = transform or Raster.IDENTITY
|
||||
local a, b, c, d, e, f = m[1], m[2], m[3], m[4], m[5], m[6]
|
||||
if type(a) ~= "number" or type(b) ~= "number" or type(c) ~= "number" or type(d) ~= "number" or type(e) ~= "number" or type(f) ~= "number" then
|
||||
return polys
|
||||
return polys, nil, nil, nil, nil
|
||||
end
|
||||
local tol = tolerance or 0.1
|
||||
if type(tol) ~= "number" or not (tol > 0.001) then
|
||||
@@ -271,7 +271,7 @@ local function flatten(path: any, transform: Transform?, tolerance: number?, min
|
||||
table.insert(polys, cur)
|
||||
end
|
||||
if #polys == 0 or bx0 ~= bx0 or by0 ~= by0 or bx1 ~= bx1 or by1 ~= by1 then
|
||||
return polys
|
||||
return polys, nil, nil, nil, nil
|
||||
end
|
||||
return polys, bx0, by0, bx1, by1
|
||||
end
|
||||
@@ -411,7 +411,7 @@ function Raster.mask(path: any, opts: Options?): (Mask?, string?)
|
||||
local o: Options = opts or {}
|
||||
local polys, bx0, by0, bx1, by1 = Raster.flatten(path, o.transform, o.tolerance)
|
||||
if not bx0 then
|
||||
return nil
|
||||
return nil, nil
|
||||
end
|
||||
if abs(bx0 :: number) > LIMIT or abs(by0 :: number) > LIMIT or abs(bx1 :: number) > LIMIT or abs(by1 :: number) > LIMIT then
|
||||
return nil, "coordinates out of range"
|
||||
@@ -427,7 +427,7 @@ function Raster.mask(path: any, opts: Options?): (Mask?, string?)
|
||||
end
|
||||
local W, H = X1 - X0, Y1 - Y0
|
||||
if W <= 0 or H <= 0 then
|
||||
return nil
|
||||
return nil, nil
|
||||
end
|
||||
local maxPixels = if type(o.maxPixels) == "number" then o.maxPixels else 2 ^ 26
|
||||
if W * H > maxPixels then
|
||||
@@ -464,7 +464,7 @@ function Raster.mask(path: any, opts: Options?): (Mask?, string?)
|
||||
writeu8(cov, os + x, floor(v * 255 + 0.5))
|
||||
end
|
||||
end
|
||||
return { x = X0, y = Y0, width = W, height = H, coverage = cov }
|
||||
return { x = X0, y = Y0, width = W, height = H, coverage = cov }, nil
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ filling
|
||||
@@ -533,7 +533,7 @@ function Raster.fill(img: any, path: any, paint: any, opts: Options?): (boolean,
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
return true, nil
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ stroking
|
||||
|
||||
@@ -51,7 +51,7 @@ function Video.simpleDecoder(decodeOne: (data: buffer, packet: Types.Packet) ->
|
||||
if q then
|
||||
return q[1], q[2], q[3]
|
||||
end
|
||||
return nil
|
||||
return nil, nil, nil
|
||||
end
|
||||
function self.flush(_: any) end
|
||||
function self.reset(_: any)
|
||||
@@ -155,15 +155,15 @@ local function rawDecoder(track: Types.Track, _opts: any?): (Types.VideoCodecDec
|
||||
if pf == "yuv420p" and bits == 8 then
|
||||
local img = Types.Image.new(w, h, "yuv420p")
|
||||
buffer.copy(img.pixels, 0, data, 0, need)
|
||||
return img
|
||||
return img, nil
|
||||
elseif pf == "yv12" then
|
||||
local img = Types.Image.new(w, h, "yuv420p")
|
||||
buffer.copy(img.pixels, 0, data, 0, w * h)
|
||||
buffer.copy(img.pixels, w * h, data, w * h + cw * ch, cw * ch)
|
||||
buffer.copy(img.pixels, w * h + cw * ch, data, w * h, cw * ch)
|
||||
return img
|
||||
return img, nil
|
||||
end
|
||||
return rawPlanar(data, pf, bits, w, h)
|
||||
return rawPlanar(data, pf, bits, w, h), nil
|
||||
end
|
||||
local bpp = if pf == "bgra" or pf == "rgba" then 4 else 3
|
||||
local stride = if track.stride then track.stride else w * bpp
|
||||
@@ -185,7 +185,7 @@ local function rawDecoder(track: Types.Track, _opts: any?): (Types.VideoCodecDec
|
||||
buffer.writeu32(px, o + x * 4, a + b * 256 + c * 65536 + 0xff000000)
|
||||
end
|
||||
end
|
||||
return img
|
||||
return img, nil
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -269,7 +269,7 @@ local function mpeg1Decoder(_track: Types.Track, opts: any?): (Types.VideoCodecD
|
||||
if q then
|
||||
return q[1], q[2], q[3]
|
||||
end
|
||||
return nil
|
||||
return nil, nil, nil
|
||||
end
|
||||
function self.flush(_: any)
|
||||
for _ = 1, 4 do
|
||||
@@ -324,7 +324,7 @@ function Video.register(entry: Entry): (boolean, Err.Err?)
|
||||
for _, m in entry.matroska or {} do
|
||||
byMatroska[m] = entry.id
|
||||
end
|
||||
return true
|
||||
return true, nil
|
||||
end
|
||||
for _, e in BUILTIN do
|
||||
Video.register(e)
|
||||
|
||||
@@ -291,33 +291,33 @@ function Parse.events(s: string, opts: Options?): () -> (string?, any, any, any)
|
||||
if kw == "SYSTEM" then
|
||||
local q = match(s, "^[ \t\n]+()", p + 6) :: any
|
||||
if not q then
|
||||
return nil
|
||||
return nil, nil, nil
|
||||
end
|
||||
local sys, e = literal(q)
|
||||
if not sys then
|
||||
return nil
|
||||
return nil, nil, nil
|
||||
end
|
||||
return "", sys, e
|
||||
elseif kw == "PUBLIC" then
|
||||
local q = match(s, "^[ \t\n]+()", p + 6) :: any
|
||||
if not q then
|
||||
return nil
|
||||
return nil, nil, nil
|
||||
end
|
||||
local pub, e = literal(q)
|
||||
if not pub or find(pub, "[^ \r\n%w%-'()+,./:=?;!*#@$_%%]") then
|
||||
return nil
|
||||
return nil, nil, nil
|
||||
end
|
||||
local r = match(s, "^[ \t\n]+()", e) :: any
|
||||
if not r then
|
||||
return nil
|
||||
return nil, nil, nil
|
||||
end
|
||||
local sys, e2 = literal(r)
|
||||
if not sys then
|
||||
return nil
|
||||
return nil, nil, nil
|
||||
end
|
||||
return pub, sys, e2
|
||||
end
|
||||
return nil
|
||||
return nil, nil, nil
|
||||
end
|
||||
-- check an entity value's references and expand its character references (the rest expand when used)
|
||||
local function entityValue(v: string): string?
|
||||
|
||||
Reference in new issue
Block a user