Skip to content

Commit b65fb7a

Browse files
committed
add luv library annotations
1 parent a3835a0 commit b65fb7a

24 files changed

+5108
-0
lines changed

meta/3rd/luv/config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"files" : [],
3+
"words" : [
4+
"require.*'luv'.*",
5+
"require.*\"luv\".*"
6+
],
7+
"settings" : {}
8+
}

meta/3rd/luv/library/errors.lua

Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
---@meta
2+
3+
---@alias uv.errno.E2BIG "E2BIG" # argument list too long.
4+
---@alias uv.errno.EACCES "EACCES" # permission denied.
5+
---@alias uv.errno.EADDRINUSE "EADDRINUSE" # address already in use.
6+
---@alias uv.errno.EADDRNOTAVAIL "EADDRNOTAVAIL" # address not available.
7+
---@alias uv.errno.EAFNOSUPPORT "EAFNOSUPPORT" # address family not supported.
8+
---@alias uv.errno.EAGAIN "EAGAIN" # resource temporarily unavailable.
9+
---@alias uv.errno.EAI_ADDRFAMILY "EAI_ADDRFAMILY" # address family not supported.
10+
---@alias uv.errno.EAI_AGAIN "EAI_AGAIN" # temporary failure.
11+
---@alias uv.errno.EAI_BADFLAGS "EAI_BADFLAGS" # bad ai_flags value.
12+
---@alias uv.errno.EAI_BADHINTS "EAI_BADHINTS" # invalid value for hints.
13+
---@alias uv.errno.EAI_CANCELED "EAI_CANCELED" # request canceled.
14+
---@alias uv.errno.EAI_FAIL "EAI_FAIL" # permanent failure.
15+
---@alias uv.errno.EAI_FAMILY "EAI_FAMILY" # ai_family not supported.
16+
---@alias uv.errno.EAI_MEMORY "EAI_MEMORY" # out of memory.
17+
---@alias uv.errno.EAI_NODATA "EAI_NODATA" # no address.
18+
---@alias uv.errno.EAI_NONAME "EAI_NONAME" # unknown node or service.
19+
---@alias uv.errno.EAI_OVERFLOW "EAI_OVERFLOW" # argument buffer overflow.
20+
---@alias uv.errno.EAI_PROTOCOL "EAI_PROTOCOL" # resolved protocol is unknown.
21+
---@alias uv.errno.EAI_SERVICE "EAI_SERVICE" # service not available for socket type.
22+
---@alias uv.errno.EAI_SOCKTYPE "EAI_SOCKTYPE" # socket type not supported.
23+
---@alias uv.errno.EALREADY "EALREADY" # connection already in progress.
24+
---@alias uv.errno.EBADF "EBADF" # bad file descriptor.
25+
---@alias uv.errno.EBUSY "EBUSY" # resource busy or locked.
26+
---@alias uv.errno.ECANCELED "ECANCELED" # operation canceled.
27+
---@alias uv.errno.ECHARSET "ECHARSET" # invalid Unicode character.
28+
---@alias uv.errno.ECONNABORTED "ECONNABORTED" # software caused connection abort.
29+
---@alias uv.errno.ECONNREFUSED "ECONNREFUSED" # connection refused.
30+
---@alias uv.errno.ECONNRESET "ECONNRESET" # connection reset by peer.
31+
---@alias uv.errno.EDESTADDRREQ "EDESTADDRREQ" # destination address required.
32+
---@alias uv.errno.EEXIST "EEXIST" # file already exists.
33+
---@alias uv.errno.EFAULT "EFAULT" # bad address in system call argument.
34+
---@alias uv.errno.EFBIG "EFBIG" # file too large.
35+
---@alias uv.errno.EFTYPE "EFTYPE" # inappropriate file type or format.
36+
---@alias uv.errno.EHOSTUNREACH "EHOSTUNREACH" # host is unreachable.
37+
---@alias uv.errno.EILSEQ "EILSEQ" # illegal byte sequence.
38+
---@alias uv.errno.EINTR "EINTR" # interrupted system call.
39+
---@alias uv.errno.EINVAL "EINVAL" # invalid argument.
40+
---@alias uv.errno.EIO "EIO" # i/o error.
41+
---@alias uv.errno.EISCONN "EISCONN" # socket is already connected.
42+
---@alias uv.errno.EISDIR "EISDIR" # illegal operation on a directory.
43+
---@alias uv.errno.ELOOP "ELOOP" # too many symbolic links encountered.
44+
---@alias uv.errno.EMFILE "EMFILE" # too many open files.
45+
---@alias uv.errno.EMLINK "EMLINK" # too many links.
46+
---@alias uv.errno.EMSGSIZE "EMSGSIZE" # message too long.
47+
---@alias uv.errno.ENAMETOOLONG "ENAMETOOLONG" # name too long.
48+
---@alias uv.errno.ENETDOWN "ENETDOWN" # network is down.
49+
---@alias uv.errno.ENETUNREACH "ENETUNREACH" # network is unreachable.
50+
---@alias uv.errno.ENFILE "ENFILE" # file table overflow.
51+
---@alias uv.errno.ENOBUFS "ENOBUFS" # no buffer space available.
52+
---@alias uv.errno.ENODEV "ENODEV" # no such device.
53+
---@alias uv.errno.ENOENT "ENOENT" # no such file or directory.
54+
---@alias uv.errno.ENOMEM "ENOMEM" # not enough memory.
55+
---@alias uv.errno.ENONET "ENONET" # machine is not on the network.
56+
---@alias uv.errno.ENOPROTOOPT "ENOPROTOOPT" # protocol not available.
57+
---@alias uv.errno.ENOSPC "ENOSPC" # no space left on device.
58+
---@alias uv.errno.ENOSYS "ENOSYS" # function not implemented.
59+
---@alias uv.errno.ENOTCONN "ENOTCONN" # socket is not connected.
60+
---@alias uv.errno.ENOTDIR "ENOTDIR" # not a directory.
61+
---@alias uv.errno.ENOTEMPTY "ENOTEMPTY" # directory not empty.
62+
---@alias uv.errno.ENOTSOCK "ENOTSOCK" # socket operation on non-socket.
63+
---@alias uv.errno.ENOTSUP "ENOTSUP" # operation not supported on socket.
64+
---@alias uv.errno.ENOTTY "ENOTTY" # inappropriate ioctl for device.
65+
---@alias uv.errno.ENXIO "ENXIO" # no such device or address.
66+
---@alias uv.errno.EOF "EOF" # end of file.
67+
---@alias uv.errno.EOVERFLOW "EOVERFLOW" # value too large for defined data type.
68+
---@alias uv.errno.EPERM "EPERM" # operation not permitted.
69+
---@alias uv.errno.EPIPE "EPIPE" # broken pipe.
70+
---@alias uv.errno.EPROTO "EPROTO" # protocol error.
71+
---@alias uv.errno.EPROTONOSUPPORT "EPROTONOSUPPORT" # protocol not supported.
72+
---@alias uv.errno.EPROTOTYPE "EPROTOTYPE" # protocol wrong type for socket.
73+
---@alias uv.errno.ERANGE "ERANGE" # result too large.
74+
---@alias uv.errno.EROFS "EROFS" # read-only file system.
75+
---@alias uv.errno.ESHUTDOWN "ESHUTDOWN" # cannot send after transport endpoint shutdown.
76+
---@alias uv.errno.ESOCKTNOSUPPORT "ESOCKTNOSUPPORT" # socket type not supported.
77+
---@alias uv.errno.ESPIPE "ESPIPE" # invalid seek.
78+
---@alias uv.errno.ESRCH "ESRCH" # no such process.
79+
---@alias uv.errno.ETIMEDOUT "ETIMEDOUT" # connection timed out.
80+
---@alias uv.errno.ETXTBSY "ETXTBSY" # text file is busy.
81+
---@alias uv.errno.EXDEV "EXDEV" # cross-device link not permitted.
82+
---@alias uv.errno.UNKNOWN "UNKNOWN" # unknown error.
83+
84+
85+
--- An error string with the format {name}: {message}
86+
---
87+
--- * {name} is the error name provided internally by uv_err_name (e.g. "ENOENT")
88+
--- * {message} is a human-readable message provided internally by uv_strerror
89+
---
90+
---@alias uv.error.message string
91+
92+
93+
--- An error name string
94+
---
95+
---@alias uv.error.name
96+
---| "E2BIG" # argument list too long
97+
---| "EACCES" # permission denied
98+
---| "EADDRINUSE" # address already in use
99+
---| "EADDRNOTAVAIL" # address not available
100+
---| "EAFNOSUPPORT" # address family not supported
101+
---| "EAGAIN" # resource temporarily unavailable
102+
---| "EAI_ADDRFAMILY" # address family not supported
103+
---| "EAI_AGAIN" # temporary failure
104+
---| "EAI_BADFLAGS" # bad ai_flags value
105+
---| "EAI_BADHINTS" # invalid value for hints
106+
---| "EAI_CANCELED" # request canceled
107+
---| "EAI_FAIL" # permanent failure
108+
---| "EAI_FAMILY" # ai_family not supported
109+
---| "EAI_MEMORY" # out of memory
110+
---| "EAI_NODATA" # no address
111+
---| "EAI_NONAME" # unknown node or service
112+
---| "EAI_OVERFLOW" # argument buffer overflow
113+
---| "EAI_PROTOCOL" # resolved protocol is unknown
114+
---| "EAI_SERVICE" # service not available for socket type
115+
---| "EAI_SOCKTYPE" # socket type not supported
116+
---| "EALREADY" # connection already in progress
117+
---| "EBADF" # bad file descriptor
118+
---| "EBUSY" # resource busy or locked
119+
---| "ECANCELED" # operation canceled
120+
---| "ECHARSET" # invalid Unicode character
121+
---| "ECONNABORTED" # software caused connection abort
122+
---| "ECONNREFUSED" # connection refused
123+
---| "ECONNRESET" # connection reset by peer
124+
---| "EDESTADDRREQ" # destination address required
125+
---| "EEXIST" # file already exists
126+
---| "EFAULT" # bad address in system call argument
127+
---| "EFBIG" # file too large
128+
---| "EFTYPE" # inappropriate file type or format
129+
---| "EHOSTUNREACH" # host is unreachable
130+
---| "EILSEQ" # illegal byte sequence
131+
---| "EINTR" # interrupted system call
132+
---| "EINVAL" # invalid argument
133+
---| "EIO" # i/o error
134+
---| "EISCONN" # socket is already connected
135+
---| "EISDIR" # illegal operation on a directory
136+
---| "ELOOP" # too many symbolic links encountered
137+
---| "EMFILE" # too many open files
138+
---| "EMLINK" # too many links
139+
---| "EMSGSIZE" # message too long
140+
---| "ENAMETOOLONG" # name too long
141+
---| "ENETDOWN" # network is down
142+
---| "ENETUNREACH" # network is unreachable
143+
---| "ENFILE" # file table overflow
144+
---| "ENOBUFS" # no buffer space available
145+
---| "ENODEV" # no such device
146+
---| "ENOENT" # no such file or directory
147+
---| "ENOMEM" # not enough memory
148+
---| "ENONET" # machine is not on the network
149+
---| "ENOPROTOOPT" # protocol not available
150+
---| "ENOSPC" # no space left on device
151+
---| "ENOSYS" # function not implemented
152+
---| "ENOTCONN" # socket is not connected
153+
---| "ENOTDIR" # not a directory
154+
---| "ENOTEMPTY" # directory not empty
155+
---| "ENOTSOCK" # socket operation on non-socket
156+
---| "ENOTSUP" # operation not supported on socket
157+
---| "ENOTTY" # inappropriate ioctl for device
158+
---| "ENXIO" # no such device or address
159+
---| "EOF" # end of file
160+
---| "EOVERFLOW" # value too large for defined data type
161+
---| "EPERM" # operation not permitted
162+
---| "EPIPE" # broken pipe
163+
---| "EPROTO" # protocol error
164+
---| "EPROTONOSUPPORT" # protocol not supported
165+
---| "EPROTOTYPE" # protocol wrong type for socket
166+
---| "ERANGE" # result too large
167+
---| "EROFS" # read-only file system
168+
---| "ESHUTDOWN" # cannot send after transport endpoint shutdown
169+
---| "ESOCKTNOSUPPORT" # socket type not supported
170+
---| "ESPIPE" # invalid seek
171+
---| "ESRCH" # no such process
172+
---| "ETIMEDOUT" # connection timed out
173+
---| "ETXTBSY" # text file is busy
174+
---| "EXDEV" # cross-device link not permitted
175+
---| "UNKNOWN" # unknown error
176+
177+
178+
--- A table value which exposes error constants as a map, where the key is the error name (without the UV_ prefix) and its value is a negative number.
179+
---
180+
---@class uv.errno : table
181+
---
182+
---@field E2BIG integer # argument list too long.
183+
---@field EACCES integer # permission denied.
184+
---@field EADDRINUSE integer # address already in use.
185+
---@field EADDRNOTAVAIL integer # address not available.
186+
---@field EAFNOSUPPORT integer # address family not supported.
187+
---@field EAGAIN integer # resource temporarily unavailable.
188+
---@field EAI_ADDRFAMILY integer # address family not supported.
189+
---@field EAI_AGAIN integer # temporary failure.
190+
---@field EAI_BADFLAGS integer # bad ai_flags value.
191+
---@field EAI_BADHINTS integer # invalid value for hints.
192+
---@field EAI_CANCELED integer # request canceled.
193+
---@field EAI_FAIL integer # permanent failure.
194+
---@field EAI_FAMILY integer # ai_family not supported.
195+
---@field EAI_MEMORY integer # out of memory.
196+
---@field EAI_NODATA integer # no address.
197+
---@field EAI_NONAME integer # unknown node or service.
198+
---@field EAI_OVERFLOW integer # argument buffer overflow.
199+
---@field EAI_PROTOCOL integer # resolved protocol is unknown.
200+
---@field EAI_SERVICE integer # service not available for socket type.
201+
---@field EAI_SOCKTYPE integer # socket type not supported.
202+
---@field EALREADY integer # connection already in progress.
203+
---@field EBADF integer # bad file descriptor.
204+
---@field EBUSY integer # resource busy or locked.
205+
---@field ECANCELED integer # operation canceled.
206+
---@field ECHARSET integer # invalid Unicode character.
207+
---@field ECONNABORTED integer # software caused connection abort.
208+
---@field ECONNREFUSED integer # connection refused.
209+
---@field ECONNRESET integer # connection reset by peer.
210+
---@field EDESTADDRREQ integer # destination address required.
211+
---@field EEXIST integer # file already exists.
212+
---@field EFAULT integer # bad address in system call argument.
213+
---@field EFBIG integer # file too large.
214+
---@field EFTYPE integer # inappropriate file type or format.
215+
---@field EHOSTUNREACH integer # host is unreachable.
216+
---@field EILSEQ integer # illegal byte sequence.
217+
---@field EINTR integer # interrupted system call.
218+
---@field EINVAL integer # invalid argument.
219+
---@field EIO integer # i/o error.
220+
---@field EISCONN integer # socket is already connected.
221+
---@field EISDIR integer # illegal operation on a directory.
222+
---@field ELOOP integer # too many symbolic links encountered.
223+
---@field EMFILE integer # too many open files.
224+
---@field EMLINK integer # too many links.
225+
---@field EMSGSIZE integer # message too long.
226+
---@field ENAMETOOLONG integer # name too long.
227+
---@field ENETDOWN integer # network is down.
228+
---@field ENETUNREACH integer # network is unreachable.
229+
---@field ENFILE integer # file table overflow.
230+
---@field ENOBUFS integer # no buffer space available.
231+
---@field ENODEV integer # no such device.
232+
---@field ENOENT integer # no such file or directory.
233+
---@field ENOMEM integer # not enough memory.
234+
---@field ENONET integer # machine is not on the network.
235+
---@field ENOPROTOOPT integer # protocol not available.
236+
---@field ENOSPC integer # no space left on device.
237+
---@field ENOSYS integer # function not implemented.
238+
---@field ENOTCONN integer # socket is not connected.
239+
---@field ENOTDIR integer # not a directory.
240+
---@field ENOTEMPTY integer # directory not empty.
241+
---@field ENOTSOCK integer # socket operation on non-socket.
242+
---@field ENOTSUP integer # operation not supported on socket.
243+
---@field ENOTTY integer # inappropriate ioctl for device.
244+
---@field ENXIO integer # no such device or address.
245+
---@field EOF integer # end of file.
246+
---@field EOVERFLOW integer # value too large for defined data type.
247+
---@field EPERM integer # operation not permitted.
248+
---@field EPIPE integer # broken pipe.
249+
---@field EPROTO integer # protocol error.
250+
---@field EPROTONOSUPPORT integer # protocol not supported.
251+
---@field EPROTOTYPE integer # protocol wrong type for socket.
252+
---@field ERANGE integer # result too large.
253+
---@field EROFS integer # read-only file system.
254+
---@field ESHUTDOWN integer # cannot send after transport endpoint shutdown.
255+
---@field ESOCKTNOSUPPORT integer # socket type not supported.
256+
---@field ESPIPE integer # invalid seek.
257+
---@field ESRCH integer # no such process.
258+
---@field ETIMEDOUT integer # connection timed out.
259+
---@field ETXTBSY integer # text file is busy.
260+
---@field EXDEV integer # cross-device link not permitted.
261+
---@field UNKNOWN integer # unknown error.

meta/3rd/luv/library/luv_dir_t.lua

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---@meta
2+
3+
--- luv_dir_t
4+
---
5+
---@class uv.luv_dir_t : userdata
6+
local dir
7+
8+
--- Closes a directory stream returned by a successful `uv.fs_opendir()` call.
9+
---
10+
---@return boolean|nil success
11+
---@return uv.error.message|nil err
12+
---@return uv.error.name|nil err_name
13+
---
14+
---@overload fun(self:uv.luv_dir_t, callback:uv.fs_closedir.callback):uv.uv_fs_t
15+
function dir:closedir() end
16+
17+
--- Iterates over the directory stream `luv_dir_t` returned by a successful
18+
--- `uv.fs_opendir()` call. A table of data tables is returned where the number
19+
--- of entries `n` is equal to or less than the `entries` parameter used in
20+
--- the associated `uv.fs_opendir()` call.
21+
---
22+
--- **Returns (sync version):** `table` or `fail`
23+
--- - `[1, 2, 3, ..., n]` : `table`
24+
--- - `name` : `string`
25+
--- - `type` : `string`
26+
---
27+
--- **Returns (async version):** `uv_fs_t userdata`
28+
---
29+
---@return uv.fs_readdir.entry[]|nil entries
30+
---@return uv.error.message|nil err
31+
---@return uv.error.name|nil err_name
32+
---
33+
---@overload fun(self:uv.luv_dir_t, callback:uv.fs_readdir.callback):uv.uv_fs_t
34+
function dir:readdir() end

meta/3rd/luv/library/luv_thread_t.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---@meta
2+
3+
--- luv_thread_t
4+
---
5+
---@class uv.luv_thread_t : userdata
6+
local thread
7+
8+
--- Returns a boolean indicating whether two threads are the same. This function is
9+
--- equivalent to the `__eq` metamethod.
10+
---
11+
---@param other_thread uv.luv_thread_t
12+
---@return boolean
13+
function thread:equal(other_thread) end
14+
15+
--- Waits for the `thread` to finish executing its entry function.
16+
---
17+
---@return boolean|nil success
18+
---@return uv.error.message|nil err
19+
---@return uv.error.name|nil err_name
20+
function thread:join() end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---@meta
2+
3+
--- luv_work_ctx_t
4+
---
5+
---@class uv.luv_work_ctx_t : userdata
6+
local work_ctx
7+
8+
--- Queues a work request which will run `work_callback` in a new Lua state in a
9+
--- thread from the threadpool with any additional arguments from `...`. Values
10+
--- returned from `work_callback` are passed to `after_work_callback`, which is
11+
--- called in the main loop thread.
12+
---
13+
---@param ... uv.threadargs
14+
---@return boolean|nil success
15+
---@return uv.error.message|nil err
16+
---@return uv.error.name|nil err_name
17+
function work_ctx:queue(...) end

0 commit comments

Comments
 (0)