Skip to content

Commit 115ecdb

Browse files
committed
Add more handle class type hints, and fix typo
1 parent 30daab7 commit 115ecdb

2 files changed

Lines changed: 39 additions & 15 deletions

File tree

src/HeadlessWrapper.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-- This wrapper allows the program to run headless on any OS (in theory)
44
-- It can be run using a standard lua interpreter, although LuaJIT is preferable
55

6-
-- define global simplegraphic API functions. some of these have dummy function
6+
-- define global SimpleGraphic API functions. some of these have dummy function
77
-- bodies intended for headless use.
88
dofile("_SimpleGraphic.def.lua")
99

src/_SimpleGraphic.def.lua

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
---@param name string
1010
---@param func? fun()
1111
function SetCallback(name, func)
12+
---@diagnostic disable-next-line: undefined-global headless wrapper
1213
callbackTable[name] = func
1314
end
1415

1516
---@param name string
1617
---@return table
1718
function GetCallback(name)
19+
---@diagnostic disable-next-line: undefined-global headless wrapper
1820
return callbackTable[name]
1921
end
2022

@@ -24,20 +26,27 @@ function SetMainObject(object)
2426
end
2527

2628
---@class ImageHandle
27-
local imageHandleClass = { }
29+
local imageHandleClass = {}
2830
imageHandleClass.__index = imageHandleClass
2931

3032
---@return ImageHandle
3133
function NewImageHandle()
32-
return setmetatable({}, imageHandleClass)
34+
return setmetatable({}, imageHandleClass)
3335
end
3436

3537
---@param fileName string
3638
---@param ... "ASYNC"|"CLAMP"|"MIPMAP"
3739
function imageHandleClass:Load(fileName, ...)
38-
self.valid = true
40+
self.valid = true
3941
end
4042

43+
---@class ArtHandle
44+
local artHandleClass = {}
45+
46+
---@return integer width
47+
---@return integer height
48+
function artHandleClass:Size() end
49+
4150
---@alias ArtFlag "CLAMP"|"MIPMAP"|"NEAREST"
4251

4352
---@param art userdata ArtHandle
@@ -57,12 +66,12 @@ function imageHandleClass:LoadArtRectangle(art, x1, y1, x2, y2, ...) end
5766
function imageHandleClass:LoadArtArcBand(art, xC, yC, rMin, rMax, ...) end
5867

5968
function imageHandleClass:Unload()
60-
self.valid = false
69+
self.valid = false
6170
end
6271

6372
---@return boolean
6473
function imageHandleClass:IsValid()
65-
return self.valid
74+
return self.valid
6675
end
6776

6877
---@param priority number
@@ -71,7 +80,7 @@ function imageHandleClass:SetLoadingPriority(priority) end
7180
---@return integer width
7281
---@return integer height
7382
function imageHandleClass:ImageSize()
74-
return 1, 1
83+
return 1, 1
7584
end
7685

7786
---@param fileName string
@@ -233,7 +242,7 @@ end
233242
---@param text string
234243
---@return string
235244
function StripEscapes(text)
236-
local s, _ = text:gsub("%^%d",""):gsub("%^x%x%x%x%x%x%x","")
245+
local s, _ = text:gsub("%^%d", ""):gsub("%^x%x%x%x%x%x%x", "")
237246
return s
238247
end
239248

@@ -246,9 +255,24 @@ end
246255
---@param ... string
247256
function RenderInit(flag1, ...) end
248257

249-
---@param spec string
250-
---@param findDirectories boolean
251-
---@return userdata
258+
---@class FileSearchHandle
259+
local fileSearchHandleClass = {}
260+
261+
---@return boolean
262+
function fileSearchHandleClass:NextFile() end
263+
264+
---@return string
265+
function fileSearchHandleClass:GetFileName() end
266+
267+
---@return integer
268+
function fileSearchHandleClass:GetFileSize() end
269+
270+
---@return number
271+
function fileSearchHandleClass:GetFileModifiedTime() end
272+
273+
---@param spec string
274+
---@param findDirectories? boolean
275+
---@return FileSearchHandle
252276
function NewFileSearch(spec, findDirectories) end
253277

254278
---@param path string
@@ -367,7 +391,7 @@ function LoadModule(name, ...)
367391
if func then
368392
return func(...)
369393
else
370-
error("LoadModule() error loading '"..name.."': "..err)
394+
error("LoadModule() error loading '" .. name .. "': " .. err)
371395
end
372396
end
373397

@@ -382,7 +406,7 @@ function PLoadModule(modName, ...)
382406
if func then
383407
return PCall(func, ...)
384408
else
385-
error("PLoadModule() error loading '"..modName.."': "..err)
409+
error("PLoadModule() error loading '" .. modName .. "': " .. err)
386410
end
387411
end
388412

@@ -396,7 +420,7 @@ function PCall(func, ...)
396420
local ret = { pcall(func, ...) }
397421
if ret[1] then
398422
table.remove(ret, 1)
399-
---@diagnostic disable-next-line: redundant-return-value
423+
---@diagnostic disable-next-line: redundant-return-value headless wrapper
400424
return nil, unpack(ret)
401425
else
402426
return ret[2]
@@ -440,4 +464,4 @@ function Restart() end
440464
---@param msg string?
441465
function Exit(msg) end
442466

443-
function SetForeground() end
467+
function SetForeground() end

0 commit comments

Comments
 (0)