summaryrefslogtreecommitdiff
path: root/meta/template/basic.lua
blob: 552aa9dba82a413d63929db265192944cac7ad93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
---@meta

---#DES 'arg'
---@type string[]
arg = {}

---#DES 'assert'
---@generic T
---@param v? T
---@param message? any
---@return T
function assert(v, message) end

---@alias gcoptions
---|>'"collect"'      # ---#DESTAIL 'cgopt.collect'
---| '"stop"'         # ---#DESTAIL 'cgopt.stop'
---| '"restart"'      # ---#DESTAIL 'cgopt.restart'
---| '"count"'        # ---#DESTAIL 'cgopt.count'
---| '"step"'         # ---#DESTAIL 'cgopt.step'
---| '"isrunning"'    # ---#DESTAIL 'cgopt.isrunning'
---#if VERSION >= 5.4 then
---| '"incremental"'  # ---#DESTAIL 'cgopt.incremental'
---| '"generational"' # ---#DESTAIL 'cgopt.generational'
---#else
---| '"setpause"'     # ---#DESTAIL 'cgopt.setpause'
---| '"setstepmul"'   # ---#DESTAIL 'cgopt.setstepmul'
---#end

---#if VERSION >= 5.4 then
---#DES 'collectgarbage'
---@param opt? gcoptions
---@return any
function collectgarbage(opt, ...) end
---#else
---#DES 'collectgarbage'
---@param opt? gcoptions
---@param arg? integer
---@return any
function collectgarbage(opt, arg) end
---#end

---#DES 'dofile'
---@param filename? string
---@return any ...
function dofile(filename) end

---#DES 'error'
---@param message any
---@param level?  integer
function error(message, level) end

---#DES '_G'
---@class _G
_G = {}

---@version 5.1
---#DES 'getfenv'
---@param f? integer|async fun()
---@return table
---@nodiscard
function getfenv(f) end

---#DES 'getmetatable'
---@param object any
---@return table metatable
---@nodiscard
function getmetatable(object) end

---#DES 'ipairs'
---@generic T: table, V
---@param t T
---@return fun(table: V[], i?: integer):integer, V
---@return T
---@return integer i
function ipairs(t) end

---@alias loadmode
---| '"b"'  # ---#DESTAIL 'loadmode.b'
---| '"t"'  # ---#DESTAIL 'loadmode.t'
---|>'"bt"' # ---#DESTAIL 'loadmode.bt'

---#if VERSION <= 5.1 and not JIT then
---#DES 'load<5.1'
---@param func       function
---@param chunkname? string
---@return function?
---@return string?   error_message
---@nodiscard
function load(func, chunkname) end
---#else
---#DES 'load>5.2'
---@param chunk      string|function
---@param chunkname? string
---@param mode?      loadmode
---@param env?       table
---@return function?
---@return string?   error_message
---@nodiscard
function load(chunk, chunkname, mode, env) end
---#end

---#if VERSION <= 5.1 and not JIT then
---#DES 'loadfile'
---@param filename? string
---@return function?
---@return string?  error_message
---@nodiscard
function loadfile(filename) end
---#else
---#DES 'loadfile'
---@param filename? string
---@param mode?     loadmode
---@param env?      table
---@return function?
---@return string?  error_message
---@nodiscard
function loadfile(filename, mode, env) end
---#end

---@version 5.1
---#DES 'loadstring'
---@param text       string
---@param chunkname? string
---@return function?
---@return string?   error_message
---@nodiscard
function loadstring(text, chunkname) end

---@version 5.1
---@param proxy boolean|table
---@return userdata
---@nodiscard
function newproxy(proxy) end

---@version 5.1
---#DES 'module'
---@param name string
function module(name, ...) end

---#DES 'next'
---@generic K, V
---@param table table<K, V>
---@param index? K
---@return K?
---@return V?
---@nodiscard
function next(table, index) end

---#DES 'pairs'
---@generic T: table, K, V
---@param t T
---@return fun(table: table<K, V>, index?: K):K, V
---@return T
function pairs(t) end

---#DES 'pcall'
---#if VERSION == 5.1 and not JIT then
---@param f     function
---#else
---@param f     async fun()
---#end
---@param arg1? any
---@return boolean success
---@return any result
---@return ...
function pcall(f, arg1, ...) end

---#DES 'print'
function print(...) end

---#DES 'rawequal'
---@param v1 any
---@param v2 any
---@return boolean
---@nodiscard
function rawequal(v1, v2) end

---#DES 'rawget'
---@param table table
---@param index any
---@return any
---@nodiscard
function rawget(table, index) end

---#DES 'rawlen'
---@param v table|string
---@return integer len
---@nodiscard
function rawlen(v) end

---#DES 'rawset'
---@param table table
---@param index any
---@param value any
---@return table
function rawset(table, index, value) end

---#DES 'select'
---@param index integer|'"#"'
---@return any
---@nodiscard
function select(index, ...) end

---@version 5.1
---#DES 'setfenv'
---@param f     async fun()|integer
---@param table table
---@return function
function setfenv(f, table) end

---#DES 'setmetatable'
---@param table      table
---@param metatable? table
---@return table
function setmetatable(table, metatable) end

---#DES 'tonumber'
---@overload fun(e: string, base: integer):integer
---@param e any
---@return number?
---@nodiscard
function tonumber(e) end

---#DES 'tostring'
---@param v any
---@return string
---@nodiscard
function tostring(v) end

---@alias type
---| '"nil"'
---| '"number"'
---| '"string"'
---| '"boolean"'
---| '"table"'
---| '"function"'
---| '"thread"'
---| '"userdata"'

---#DES 'type'
---@param v any
---@return type type
---@nodiscard
function type(v) end

---#DES '_VERSION'
---#if VERSION == 5.1 then
_VERSION = 'Lua 5.1'
---#elseif VERSION == 5.2 then
_VERSION = 'Lua 5.2'
---#elseif VERSION == 5.3 then
_VERSION = 'Lua 5.3'
---#elseif VERSION == 5.4 then
_VERSION = 'Lua 5.4'
---#end

---@version >5.4
---#DES 'warn'
---@param message string
function warn(message, ...) end

---#if VERSION == 5.1 and not JIT then
---#DES 'xpcall=5.1'
---@param f     function
---@param err   function
---@return boolean success
---@return any result
---@return ...
function xpcall(f, err) end
---#else
---#DES 'xpcall>5.2'
---@param f     async fun()
---@param msgh  function
---@param arg1? any
---@return boolean success
---@return any result
---@return ...
function xpcall(f, msgh, arg1, ...) end
---#end

---@version 5.1
---#DES 'unpack'
---@generic T
---@param list T[]
---@param i?   integer
---@param j?   integer
---@return T   ...
---@nodiscard
function unpack(list, i, j) end