Skip to content

Commit 4616d0d

Browse files
committed
Fix a bunch of type errors
1 parent cb425a2 commit 4616d0d

File tree

6 files changed

+14
-16
lines changed

6 files changed

+14
-16
lines changed

src/arisu.lua

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,11 @@ function Arisu.run(appStatic)
4646
window.Window.fromEventLoop(eventLoop)
4747

4848
eventLoop:run(function(event, handler)
49-
handler:setMode("wait")
49+
handler:setMode("poll")
5050

5151
local message = app:event(event, handler)
5252
if message then
53-
local task = app:update(message, event.window)
54-
if task then
55-
print("i have a task and i must run")
56-
end
53+
app:update(message, event.window)
5754
end
5855
end)
5956
end

src/bindings/gdi.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ return {
8080

8181
---@type fun(): gdi.PIXELFORMATDESCRIPTOR
8282
newPFD = function()
83+
---@diagnostic disable-next-line: missing-return-value # ffi.new isn't typed properly for some reason
8384
return ffi.new("PIXELFORMATDESCRIPTOR", {
8485
nSize = ffi.sizeof("PIXELFORMATDESCRIPTOR"),
8586
nVersion = 1,

src/bindings/gl.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ if util.isUnix() then
9696
local glx = require("bindings.glx")
9797

9898
function fetchNonCoreFn(name)
99+
---@type function: We ensure nonCoreFnDefs has only function types
99100
return ffi.cast(nonCoreFnDefs[name], glx.getProcAddress(name))
100101
end
101102
else
@@ -194,7 +195,6 @@ return {
194195
SYNC_GPU_COMMANDS_COMPLETE = 0x9117,
195196
SYNC_FLUSH_COMMANDS_BIT = 0x00000001,
196197

197-
LESS = 0x0201,
198198
LESS = 0x0201,
199199
LESS_EQUAL = 0x0203,
200200
GREATER = 0x0204,

src/bindings/user32.lua

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,14 @@ ffi.cdef([[
137137
---@field right number
138138
---@field bottom number
139139

140+
---@class user32.LPCSTR: ffi.cdata*
141+
140142
local C = ffi.load("user32")
141143

142144
return {
143-
IDC_ARROW = ffi.cast("LPCSTR", 32512),
144-
IDC_HAND = ffi.cast("LPCSTR", 32649),
145-
146-
IDI_APPLICATION = ffi.cast("LPCSTR", 32512),
145+
IDC_ARROW = ffi.cast("LPCSTR", 32512) --[[@as user32.LPCSTR]],
146+
IDC_HAND = ffi.cast("LPCSTR", 32649) --[[@as user32.LPCSTR]],
147+
IDI_APPLICATION = ffi.cast("LPCSTR", 32512) --[[@as user32.LPCSTR]],
147148

148149
COLOR_WINDOW = 5,
149150

@@ -280,6 +281,7 @@ return {
280281

281282
---@type fun(): user32.WNDCLASSEXA
282283
newWndClassEx = function()
284+
---@diagnostic disable-next-line: missing-return-value # ffi.new isn't typed properly for some reason
283285
return ffi.new("WNDCLASSEXA", { cbSize = ffi.sizeof("WNDCLASSEXA") })
284286
end,
285287

@@ -294,10 +296,10 @@ return {
294296
---@type fun(hwnd: user32.HWND, Msg: number, wParam: number, lParam: number): number
295297
defWindowProc = C.DefWindowProcA,
296298

297-
---@type fun(hInstance: userdata, lpCursorName: string): userdata
299+
---@type fun(hInstance: userdata?, lpCursorName: string | user32.LPCSTR): userdata
298300
loadCursor = C.LoadCursorA,
299301

300-
---@type fun(hInstance: userdata, lpIconName: string): userdata
302+
---@type fun(hInstance: userdata?, lpIconName: string | user32.LPCSTR): userdata
301303
loadIcon = C.LoadIconA,
302304

303305
---@type fun(nIndex: number): userdata
@@ -308,8 +310,8 @@ return {
308310
return C.AdjustWindowRect(lpRect, dwStyle, bMenu and 1 or 0) ~= 0
309311
end,
310312

311-
---@type fun(): user32.RECT
312313
newRect = function()
314+
---@type user32.RECT
313315
return ffi.new("RECT")
314316
end,
315317
}

src/ui/element.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function Element:onClick(message)
7878
end
7979

8080
---@generic T
81-
---@param cons fun(): T
81+
---@param cons fun(x: number, y: number, elementWidth: number, elementWidth: number): T
8282
function Element:onMouseDown(cons)
8383
self.onmousedown = cons
8484
return self

src/window/win32.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,6 @@ function Win32EventLoop:run(callback)
207207
print("Error in event loop callback: " .. tostring(err))
208208
os.exit(1)
209209
end
210-
211-
return ok
212210
end
213211

214212
for _, window in pairs(self.windows) do

0 commit comments

Comments
 (0)