add cache and rename some files

This commit is contained in:
2026-01-15 15:41:19 +01:00
parent 7879f15726
commit b64815d9ab
4753 changed files with 931902 additions and 1 deletions

View File

@@ -0,0 +1,359 @@
---@meta _
---#DES 'arg'
---@type string[]
arg = {}
---#DES 'assert'
---@generic T
---@param v? T
---@param message? any
---@param ... any
---@return T
---@return any ...
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
---@param ... any
---@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|userdata
---@return userdata
---@nodiscard
function newproxy(proxy) end
---@version 5.1
---#DES 'module'
---@param name string
---@param ... any
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
---@param ... any
---@return boolean success
---@return any result
---@return any ...
function pcall(f, arg1, ...) end
---#DES 'print'
---@param ... any
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|"#"
---@param ... any
---@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
---@class metatable
---@field __mode 'v'|'k'|'kv'|nil
---@field __metatable any|nil
---@field __tostring (fun(t):string)|nil
---@field __gc fun(t)|nil
---@field __add (fun(t1,t2):any)|nil
---@field __sub (fun(t1,t2):any)|nil
---@field __mul (fun(t1,t2):any)|nil
---@field __div (fun(t1,t2):any)|nil
---@field __mod (fun(t1,t2):any)|nil
---@field __pow (fun(t1,t2):any)|nil
---@field __unm (fun(t):any)|nil
---#if VERSION >= 5.3 then
---@field __idiv (fun(t1,t2):any)|nil
---@field __band (fun(t1,t2):any)|nil
---@field __bor (fun(t1,t2):any)|nil
---@field __bxor (fun(t1,t2):any)|nil
---@field __bnot (fun(t):any)|nil
---@field __shl (fun(t1,t2):any)|nil
---@field __shr (fun(t1,t2):any)|nil
---#end
---@field __concat (fun(t1,t2):any)|nil
---@field __len (fun(t):integer)|nil
---@field __eq (fun(t1,t2):boolean)|nil
---@field __lt (fun(t1,t2):boolean)|nil
---@field __le (fun(t1,t2):boolean)|nil
---@field __index table|(fun(t,k):any)|nil
---@field __newindex table|fun(t,k,v)|nil
---@field __call (fun(t,...):...)|nil
---#if VERSION > 5.1 or VERSION == JIT then
---@field __pairs (fun(t):((fun(t,k,v):any,any),any,any))|nil
---#end
---#if VERSION == JIT or VERSION == 5.2 then
---@field __ipairs (fun(t):(fun(t,k,v):(integer|nil),any))|nil
---#end
---#if VERSION >= 5.4 then
---@field __close (fun(t,errobj):any)|nil
---#end
---#DES 'setmetatable'
---@param table table
---@param metatable? 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"
---#if VERSION == JIT then
---| "cdata"
---#end
---#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
---@param ... any
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 any ...
function xpcall(f, err) end
---#else
---#DES 'xpcall>5.2'
---@param f async fun(...):...
---@param msgh function
---@param arg1? any
---@param ... any
---@return boolean success
---@return any result
---@return any ...
function xpcall(f, msgh, arg1, ...) end
---#end
---@version 5.1
---#DES 'unpack'
---@generic T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
---@param list {
--- [1]?: T1,
--- [2]?: T2,
--- [3]?: T3,
--- [4]?: T4,
--- [5]?: T5,
--- [6]?: T6,
--- [7]?: T7,
--- [8]?: T8,
--- [9]?: T9,
--- [10]?: T10,
---}
---@param i? integer
---@param j? integer
---@return T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
---@nodiscard
function unpack(list, i, j) end
---@version 5.1
---@generic T1, T2, T3, T4, T5, T6, T7, T8, T9
---@param list {[1]: T1, [2]: T2, [3]: T3, [4]: T4, [5]: T5, [6]: T6, [7]: T7, [8]: T8, [9]: T9 }
---@return T1, T2, T3, T4, T5, T6, T7, T8, T9
---@nodiscard
function unpack(list) end

View File

@@ -0,0 +1,77 @@
---#if not JIT then DISABLE() end
---@meta bit
---@version JIT
---@class bitlib
bit = {}
---@param x integer
---@return integer y
---@nodiscard
function bit.tobit(x) end
---@param x integer
---@param n? integer
---@return string y
---@nodiscard
function bit.tohex(x, n) end
---@param x integer
---@return integer y
---@nodiscard
function bit.bnot(x) end
---@param x integer
---@param ... integer
---@return integer y
---@nodiscard
function bit.bor(x, ...) end
---@param x integer
---@param ... integer
---@return integer y
---@nodiscard
function bit.band(x, ...) end
---@param x integer
---@param ... integer
---@return integer y
---@nodiscard
function bit.bxor(x, ...) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.lshift(x, n) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.rshift(x, n) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.arshift(x, n) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.rol(x, n) end
---@param x integer
---@param n integer
---@return integer y
---@nodiscard
function bit.ror(x, n) end
---@param x integer
---@return integer y
---@nodiscard
function bit.bswap(x) end
return bit

View File

@@ -0,0 +1,86 @@
---#if VERSION ~= 5.2 then DISABLE() end
---@meta bit32
---@version 5.2
---#DES 'bit32'
---@class bit32lib
bit32 = {}
---#DES 'bit32.arshift'
---@param x integer
---@param disp integer
---@return integer
---@nodiscard
function bit32.arshift(x, disp) end
---#DES 'bit32.band'
---@return integer
---@nodiscard
function bit32.band(...) end
---#DES 'bit32.bnot'
---@param x integer
---@return integer
---@nodiscard
function bit32.bnot(x) end
---#DES 'bit32.bor'
---@return integer
---@nodiscard
function bit32.bor(...) end
---#DES 'bit32.btest'
---@return boolean
---@nodiscard
function bit32.btest(...) end
---#DES 'bit32.bxor'
---@return integer
---@nodiscard
function bit32.bxor(...) end
---#DES 'bit32.extract'
---@param n integer
---@param field integer
---@param width? integer
---@return integer
---@nodiscard
function bit32.extract(n, field, width) end
---#DES 'bit32.replace'
---@param n integer
---@param v integer
---@param field integer
---@param width? integer
---@nodiscard
function bit32.replace(n, v, field, width) end
---#DES 'bit32.lrotate'
---@param x integer
---@param distp integer
---@return integer
---@nodiscard
function bit32.lrotate(x, distp) end
---#DES 'bit32.lshift'
---@param x integer
---@param distp integer
---@return integer
---@nodiscard
function bit32.lshift(x, distp) end
---#DES 'bit32.rrotate'
---@param x integer
---@param distp integer
---@return integer
---@nodiscard
function bit32.rrotate(x, distp) end
---#DES 'bit32.rshift'
---@param x integer
---@param distp integer
---@return integer
---@nodiscard
function bit32.rshift(x, distp) end
return bit32

View File

@@ -0,0 +1,16 @@
---@meta _
---@class unknown
---@class any
---@class nil
---@class boolean
---@class true: boolean
---@class false: boolean
---@class number
---@class integer: number
---@class thread
---@class table<K, V>: { [K]: V }
---@class string: stringlib
---@class userdata
---@class lightuserdata
---@class function

View File

@@ -0,0 +1,68 @@
---@meta coroutine
---#DES 'coroutine'
---@class coroutinelib
coroutine = {}
---#DES 'coroutine.create'
---@param f async fun(...):...
---@return thread
---@nodiscard
function coroutine.create(f) end
---#if VERSION >= 5.4 then
---#DES 'coroutine.isyieldable>5.4'
---@param co? thread
---@return boolean
---@nodiscard
function coroutine.isyieldable(co) end
---#else
---@version >5.2
---#DES 'coroutine.isyieldable'
---@return boolean
---@nodiscard
function coroutine.isyieldable() end
---#end
---@version >5.4
---#DES 'coroutine.close'
---@param co thread
---@return boolean noerror
---@return any errorobject
function coroutine.close(co) end
---#DES 'coroutine.resume'
---@param co thread
---@param val1? any
---@return boolean success
---@return any ...
function coroutine.resume(co, val1, ...) end
---#DES 'coroutine.running'
---@return thread running
---@return boolean ismain
---@nodiscard
function coroutine.running() end
---#DES 'coroutine.status'
---@param co thread
---@return
---| '"running"' # ---#DESTAIL 'costatus.running'
---| '"suspended"' # ---#DESTAIL 'costatus.suspended'
---| '"normal"' # ---#DESTAIL 'costatus.normal'
---| '"dead"' # ---#DESTAIL 'costatus.dead'
---@nodiscard
function coroutine.status(co) end
---#DES 'coroutine.wrap'
---@param f async fun(...):...
---@return fun(...):...
---@nodiscard
function coroutine.wrap(f) end
---#DES 'coroutine.yield'
---@async
---@return any ...
function coroutine.yield(...) end
return coroutine

View File

@@ -0,0 +1,221 @@
---@meta debug
---#DES 'debug'
---@class debuglib
debug = {}
---@class debuginfo
---@field name string
---@field namewhat string
---@field source string
---@field short_src string
---@field linedefined integer
---@field lastlinedefined integer
---@field what string
---@field currentline integer
---@field istailcall boolean
---@field nups integer
---#if VERSION >= 5.2 or JIT then
---@field nparams integer
---@field isvararg boolean
---#end
---@field func function
---#if VERSION >= 5.4 then
---@field ftransfer integer
---@field ntransfer integer
---#end
---@field activelines table
---#DES 'debug.debug'
function debug.debug() end
---@version 5.1
---#DES 'debug.getfenv'
---@param o any
---@return table
---@nodiscard
function debug.getfenv(o) end
---#DES 'debug.gethook'
---@param co? thread
---@return function hook
---@return string mask
---@return integer count
---@nodiscard
function debug.gethook(co) end
---@alias infowhat string
---|+"n" # ---#DESTAIL 'infowhat.n'
---|+"S" # ---#DESTAIL 'infowhat.S'
---|+"l" # ---#DESTAIL 'infowhat.l'
---|+"t" # ---#DESTAIL 'infowhat.t'
---#if VERSION <= 5.1 and not JIT then
---|+"u" # ---#DESTAIL 'infowhat.u<5.1'
---#else
---|+"u" # ---#DESTAIL 'infowhat.u>5.2'
---#end
---|+"f" # ---#DESTAIL 'infowhat.f'
---#if VERSION >= 5.4 then
---|+"r" # ---#DESTAIL 'infowhat.r'
---#end
---|+"L" # ---#DESTAIL 'infowhat.L'
---#DES 'debug.getinfo'
---@overload fun(f: integer|function, what?: infowhat):debuginfo
---@param thread thread
---@param f integer|async fun(...):...
---@param what? infowhat
---@return debuginfo
---@nodiscard
function debug.getinfo(thread, f, what) end
---#if VERSION <= 5.1 and not JIT then
---#DES 'debug.getlocal<5.1'
---@overload fun(level: integer, index: integer):string, any
---@param thread thread
---@param level integer
---@param index integer
---@return string name
---@return any value
---@nodiscard
function debug.getlocal(thread, level, index) end
---#else
---#DES 'debug.getlocal>5.2'
---@overload fun(f: integer|async fun(...):..., index: integer):string, any
---@param thread thread
---@param f integer|async fun(...):...
---@param index integer
---@return string name
---@return any value
---@nodiscard
function debug.getlocal(thread, f, index) end
---#end
---#DES 'debug.getmetatable'
---@param object any
---@return table metatable
---@nodiscard
function debug.getmetatable(object) end
---#DES 'debug.getregistry'
---@return table
---@nodiscard
function debug.getregistry() end
---#DES 'debug.getupvalue'
---@param f async fun(...):...
---@param up integer
---@return string name
---@return any value
---@nodiscard
function debug.getupvalue(f, up) end
---#if VERSION >= 5.4 then
---#DES 'debug.getuservalue>5.4'
---@param u userdata
---@param n? integer
---@return any
---@return boolean
---@nodiscard
function debug.getuservalue(u, n) end
---#elseif VERSION >= 5.2 or JIT then
---#DES 'debug.getuservalue<5.3'
---@param u userdata
---@return any
---@nodiscard
function debug.getuservalue(u) end
---#end
---#DES 'debug.setcstacklimit'
---@deprecated
---@param limit integer
---@return integer|boolean
function debug.setcstacklimit(limit) end
---#DES 'debug.setfenv'
---@version 5.1
---@generic T
---@param object T
---@param env table
---@return T object
function debug.setfenv(object, env) end
---@alias hookmask string
---|+"c" # ---#DESTAIL 'hookmask.c'
---|+"r" # ---#DESTAIL 'hookmask.r'
---|+"l" # ---#DESTAIL 'hookmask.l'
---#DES 'debug.sethook'
---@overload fun(hook: (async fun(...):...), mask: hookmask, count?: integer)
---@overload fun(thread: thread):...
---@overload fun(...):...
---@param thread thread
---@param hook async fun(...):...
---@param mask hookmask
---@param count? integer
function debug.sethook(thread, hook, mask, count) end
---#DES 'debug.setlocal'
---@overload fun(level: integer, index: integer, value: any):string
---@param thread thread
---@param level integer
---@param index integer
---@param value any
---@return string name
function debug.setlocal(thread, level, index, value) end
---#DES 'debug.setmetatable'
---@generic T
---@param value T
---@param meta? table
---@return T value
function debug.setmetatable(value, meta) end
---#DES 'debug.setupvalue'
---@param f async fun(...):...
---@param up integer
---@param value any
---@return string name
function debug.setupvalue(f, up, value) end
---#if VERSION >= 5.4 then
---#DES 'debug.setuservalue>5.4'
---@param udata userdata
---@param value any
---@param n? integer
---@return userdata udata
function debug.setuservalue(udata, value, n) end
---#elseif VERSION >= 5.2 or JIT then
---#DES 'debug.setuservalue<5.3'
---@param udata userdata
---@param value any
---@return userdata udata
function debug.setuservalue(udata, value) end
---#end
---#DES 'debug.traceback'
---@overload fun(message?: any, level?: integer): string
---@param thread thread
---@param message? any
---@param level? integer
---@return string message
---@nodiscard
function debug.traceback(thread, message, level) end
---@version >5.2, JIT
---#DES 'debug.upvalueid'
---@param f async fun(...):...
---@param n integer
---@return lightuserdata id
---@nodiscard
function debug.upvalueid(f, n) end
---@version >5.2, JIT
---#DES 'debug.upvaluejoin'
---@param f1 async fun(...):...
---@param n1 integer
---@param f2 async fun(...):...
---@param n2 integer
function debug.upvaluejoin(f1, n1, f2, n2) end
return debug

View File

@@ -0,0 +1,122 @@
---#if not JIT then DISABLE() end
---@meta ffi
---@class ffi.namespace*: table
---@field [string] function
---@class ffi.ctype*: userdata
---@overload fun(init?: any, ...): ffi.cdata*
---@overload fun(nelem?: integer, init?: any, ...): ffi.cdata*
local ctype
---@class ffi.cdecl*: string
---@class ffi.cdata*: userdata
---@alias ffi.ct* ffi.ctype*|ffi.cdecl*|ffi.cdata*
---@class ffi.cb*: ffi.cdata*
local cb
---@class ffi.VLA*: userdata
---@class ffi.VLS*: userdata
---@version JIT
---@class ffilib
---@field C ffi.namespace*
---@field os string
---@field arch string
local ffi = {}
---@param def string
---@param params? any
function ffi.cdef(def, params, ...) end
---@param name string
---@param global? boolean
---@return ffi.namespace* clib
---@nodiscard
function ffi.load(name, global) end
---@overload fun(ct: ffi.ct*, init: any, ...)
---@param ct ffi.ct*
---@param nelem? integer
---@param init? any
---@return ffi.cdata* cdata
---@nodiscard
function ffi.new(ct, nelem, init, ...) end
---@param ct ffi.ct*
---@param params? any
---@return ffi.ctype* ctype
---@nodiscard
function ffi.typeof(ct, params, ...) end
---@param ct ffi.ct*
---@param init any
---@return ffi.cdata* cdata
---@nodiscard
function ffi.cast(ct, init) end
---@param ct ffi.ct*
---@param metatable table
---@return ffi.ctype* ctype
function ffi.metatype(ct, metatable) end
---@param cdata ffi.cdata*
---@param finalizer? function
---@return ffi.cdata* cdata
function ffi.gc(cdata, finalizer) end
---@param ct ffi.ct*
---@param nelem? integer
---@return integer|nil size
---@nodiscard
function ffi.sizeof(ct, nelem) end
---@param ct ffi.ct*
---@return integer align
---@nodiscard
function ffi.alignof(ct) end
---@param ct ffi.ct*
---@param field string
---@return integer ofs
---@return integer? bpos
---@return integer? bsize
---@nodiscard
function ffi.offsetof(ct, field) end
---@param ct ffi.ct*
---@param obj any
---@return boolean status
---@nodiscard
function ffi.istype(ct, obj) end
---@param newerr? integer
---@return integer err
---@nodiscard
function ffi.errno(newerr) end
---@param ptr any
---@param len? integer
---@return string str
function ffi.string(ptr, len) end
---@overload fun(dst: any, str: string)
---@param dst any
---@param src any
---@param len integer
function ffi.copy(dst, src, len) end
---@param dst any
---@param len integer
---@param c? any
function ffi.fill(dst, len, c) end
---@param param string
---@return boolean status
function ffi.abi(param) end
function cb:free() end
---@param func function
function cb:set(func) end
return ffi

View File

@@ -0,0 +1,170 @@
---@meta io
---#DES 'io'
---@class iolib
---#DES 'io.stdin'
---@field stdin file*
---#DES 'io.stdout'
---@field stdout file*
---#DES 'io.stderr'
---@field stderr file*
io = {}
---@alias openmode
---|>"r" # ---#DESTAIL 'openmode.r'
---| "w" # ---#DESTAIL 'openmode.w'
---| "a" # ---#DESTAIL 'openmode.a'
---| "r+" # ---#DESTAIL 'openmode.r+'
---| "w+" # ---#DESTAIL 'openmode.w+'
---| "a+" # ---#DESTAIL 'openmode.a+'
---| "rb" # ---#DESTAIL 'openmode.rb'
---| "wb" # ---#DESTAIL 'openmode.wb'
---| "ab" # ---#DESTAIL 'openmode.ab'
---| "r+b" # ---#DESTAIL 'openmode.r+b'
---| "w+b" # ---#DESTAIL 'openmode.w+b'
---| "a+b" # ---#DESTAIL 'openmode.a+b'
---#DES 'io.close'
---@param file? file*
---@return boolean? suc
---@return exitcode? exitcode
---@return integer? code
function io.close(file) end
---#DES 'io.flush'
function io.flush() end
---#DES 'io.input'
---@overload fun():file*
---@param file string|file*
function io.input(file) end
---#DES 'io.lines'
---@param filename string?
---@param ... readmode
---@return fun():any, ...
function io.lines(filename, ...) end
---#DES 'io.open'
---@param filename string
---@param mode? openmode
---@return file*?
---@return string? errmsg
---@nodiscard
function io.open(filename, mode) end
---#DES 'io.output'
---@overload fun():file*
---@param file string|file*
function io.output(file) end
---@alias popenmode
---| "r" # ---#DESTAIL 'popenmode.r'
---| "w" # ---#DESTAIL 'popenmode.w'
---#DES 'io.popen'
---@param prog string
---@param mode? popenmode
---@return file*?
---@return string? errmsg
function io.popen(prog, mode) end
---#DES 'io.read'
---@param ... readmode
---@return any
---@return any ...
---@nodiscard
function io.read(...) end
---#DES 'io.tmpfile'
---@return file*
---@nodiscard
function io.tmpfile() end
---@alias filetype
---| "file" # ---#DESTAIL 'filetype.file'
---| "closed file" # ---#DESTAIL 'filetype.closed file'
---| `nil` # ---#DESTAIL 'filetype.nil'
---#DES 'io.type'
---@param file file*
---@return filetype
---@nodiscard
function io.type(file) end
---#DES 'io.write'
---@return file*
---@return string? errmsg
function io.write(...) end
---#DES 'file'
---@class file*
local file = {}
---@alias readmode integer|string
---#if VERSION >= 5.3 then
---| "n" # ---#DESTAIL 'readmode.n'
---| "a" # ---#DESTAIL 'readmode.a'
---|>"l" # ---#DESTAIL 'readmode.l'
---| "L" # ---#DESTAIL 'readmode.L'
---#else
---| "*n" # ---#DESTAIL 'readmode.n'
---| "*a" # ---#DESTAIL 'readmode.a'
---|>"*l" # ---#DESTAIL 'readmode.l'
---#if JIT then
---| "*L" # ---#DESTAIL 'readmode.L'
---#end
---#end
---@alias exitcode "exit"|"signal"
---#DES 'file:close'
---@return boolean? suc
---@return exitcode? exitcode
---@return integer? code
function file:close() end
---#DES 'file:flush'
function file:flush() end
---#DES 'file:lines'
---@param ... readmode
---@return fun():any, ...
function file:lines(...) end
---#DES 'file:read'
---@param ... readmode
---@return any
---@return any ...
---@nodiscard
function file:read(...) end
---@alias seekwhence
---| "set" # ---#DESTAIL 'seekwhence.set'
---|>"cur" # ---#DESTAIL 'seekwhence.cur'
---| "end" # ---#DESTAIL 'seekwhence.end'
---#DES 'file:seek'
---@param whence? seekwhence
---@param offset? integer
---@return integer offset
---@return string? errmsg
function file:seek(whence, offset) end
---@alias vbuf
---| "no" # ---#DESTAIL 'vbuf.no'
---| "full" # ---#DESTAIL 'vbuf.full'
---| "line" # ---#DESTAIL 'vbuf.line'
---#DES 'file:setvbuf'
---@param mode vbuf
---@param size? integer
function file:setvbuf(mode, size) end
---#DES 'file:write'
---@param ... string|number
---@return file*?
---@return string? errmsg
function file:write(...) end
return io

View File

@@ -0,0 +1,43 @@
---#if not JIT then DISABLE() end
---@meta jit
---@version JIT
---@class jitlib
---@field version string
---@field version_num number
---@field os 'Windows'|'Linux'|'OSX'|'BSD'|'POSIX'|'Other'
---@field arch 'x86'|'x64'|'arm'|'arm64'|'arm64be'|'ppc'|'ppc64'|'ppc64le'|'mips'|'mipsel'|'mips64'|'mips64el'|string
jit = {}
---@overload fun(...):...
---@param func function|boolean
---@param recursive? boolean
function jit.on(func, recursive)
end
---@overload fun(...):...
---@param func function|boolean
---@param recursive? boolean
function jit.off(func, recursive)
end
---@overload fun(...):...
---@overload fun(tr: number)
---@param func function|boolean
---@param recursive? boolean
function jit.flush(func, recursive)
end
---@return boolean status
---@return string ...
---@nodiscard
function jit.status()
end
jit.opt = {}
---@param ... any flags
function jit.opt.start(...)
end
return jit

View File

@@ -0,0 +1,20 @@
---#if not JIT then DISABLE() end
---@meta jit.profile
local profile = {}
---@param mode string
---@param func fun(L: thread, samples: integer, vmst: string)
function profile.start(mode, func)
end
function profile.stop()
end
---@overload fun(th: thread, fmt: string, depth: integer)
---@param fmt string
---@param depth integer
function profile.dumpstack(fmt, depth)
end
return profile

View File

@@ -0,0 +1,120 @@
---#if not JIT then DISABLE() end
---@meta jit.util
---@class Trace
---@class Proto
local util = {}
---@class jit.funcinfo.lua
local funcinfo = {
linedefined = 0,
lastlinedefined = 0,
stackslots = 0,
params = 0,
bytecodes = 0,
gcconsts = 0,
nconsts = 0,
upvalues = 0,
currentline = 0,
isvararg = false,
children = false,
source = "",
loc = "",
---@type Proto[]
proto = {}
}
---@class jit.funcinfo.c
---@field ffid integer|nil
local funcinfo2 = {
addr = 0,
upvalues = 0,
}
---@param func function
---@param pc? integer
---@return jit.funcinfo.c|jit.funcinfo.lua info
function util.funcinfo(func, pc)
end
---@param func function
---@param pc integer
---@return integer? ins
---@return integer? m
function util.funcbc(func, pc)
end
---@param func function
---@param idx integer
---@return any? k
function util.funck(func, idx)
end
---@param func function
---@param idx integer
---@return string? name
function util.funcuvname(func, idx)
end
---@class jit.traceinfo
local traceinfo = {
nins = 0,
nk = 0,
link = 0,
nexit = 0,
linktype = ""
}
---@param tr Trace
---@return jit.traceinfo? info
function util.traceinfo(tr)
end
---@param tr Trace
---@param ref integer
---@return integer? m
---@return integer? ot
---@return integer? op1
---@return integer? op2
---@return integer? prev
function util.traceir(tr, ref)
end
---@param tr Trace
---@param idx integer
---@return any? k
---@return integer? t
---@return integer? slot
function util.tracek(tr, idx)
end
---@class jit.snap : integer[]
---@param tr Trace
---@param sn integer
---@return jit.snap? snap
function util.tracesnap(tr, sn)
end
---@param tr Trace
---@return string? mcode
---@return integer? addr
---@return integer? loop
function util.tracemc(tr)
end
---@overload fun(exitno: integer): integer
---@param tr Trace
---@param exitno integer
---@return integer? addr
function util.traceexitstub(tr, exitno)
end
---@param idx integer
---@return integer? addr
function util.ircalladdr(idx)
end
return util

View File

@@ -0,0 +1,255 @@
---@meta math
---#DES 'math'
---@class mathlib
---#DES 'math.huge'
---@field huge number
---#if VERSION >= 5.3 then
---#DES 'math.maxinteger'
---@field maxinteger integer
---#DES 'math.mininteger'
---@field mininteger integer
---#end
---#DES 'math.pi'
---@field pi number
math = {}
---#DES 'math.abs'
---@generic Number: number
---@param x Number
---@return Number
---@nodiscard
function math.abs(x) end
---#DES 'math.acos'
---@param x number
---@return number
---@nodiscard
function math.acos(x) end
---#DES 'math.asin'
---@param x number
---@return number
---@nodiscard
function math.asin(x) end
---#if VERSION <= 5.2 then
---#DES 'math.atan<5.2'
---@param y number
---@return number
---@nodiscard
function math.atan(y) end
---#else
---#DES 'math.atan>5.3'
---@param y number
---@param x? number
---@return number
---@nodiscard
function math.atan(y, x) end
---#end
---@version <5.2
---#DES 'math.atan2'
---@param y number
---@param x number
---@return number
---@nodiscard
function math.atan2(y, x) end
---#DES 'math.ceil'
---@param x number
---@return integer
---@nodiscard
function math.ceil(x) end
---#DES 'math.cos'
---@param x number
---@return number
---@nodiscard
function math.cos(x) end
---@version <5.2
---#DES 'math.cosh'
---@param x number
---@return number
---@nodiscard
function math.cosh(x) end
---#DES 'math.deg'
---@param x number
---@return number
---@nodiscard
function math.deg(x) end
---#DES 'math.exp'
---@param x number
---@return number
---@nodiscard
function math.exp(x) end
---#DES 'math.floor'
---@param x number
---@return integer
---@nodiscard
function math.floor(x) end
---#DES 'math.fmod'
---@param x number
---@param y number
---@return number
---@nodiscard
function math.fmod(x, y) end
---@version <5.2
---#DES 'math.frexp'
---@param x number
---@return number m
---@return number e
---@nodiscard
function math.frexp(x) end
---@version <5.2
---#DES 'math.ldexp'
---@param m number
---@param e number
---@return number
---@nodiscard
function math.ldexp(m, e) end
---#if VERSION <= 5.1 and not JIT then
---#DES 'math.log<5.1'
---@param x number
---@return number
---@nodiscard
function math.log(x) end
---#else
---#DES 'math.log>5.2'
---@param x number
---@param base? integer
---@return number
---@nodiscard
function math.log(x, base) end
---#end
---@version <5.1
---#DES 'math.log10'
---@param x number
---@return number
---@nodiscard
function math.log10(x) end
---#DES 'math.max'
---@generic Number: number
---@param x Number
---@param ... Number
---@return Number
---@nodiscard
function math.max(x, ...) end
---#DES 'math.min'
---@generic Number: number
---@param x Number
---@param ... Number
---@return Number
---@nodiscard
function math.min(x, ...) end
---#DES 'math.modf'
---@param x number
---@return integer
---@return number
---@nodiscard
function math.modf(x) end
---@version <5.2
---#DES 'math.pow'
---@param x number
---@param y number
---@return number
---@nodiscard
function math.pow(x, y) end
---#DES 'math.rad'
---@param x number
---@return number
---@nodiscard
function math.rad(x) end
---#DES 'math.random'
---@overload fun():number
---@overload fun(m: integer):integer
---@param m integer
---@param n integer
---@return integer
---@nodiscard
function math.random(m, n) end
---#if VERSION >= 5.4 then
---#DES 'math.randomseed>5.4'
---@param x? integer
---@param y? integer
function math.randomseed(x, y) end
---#else
---#DES 'math.randomseed<5.3'
---@param x integer
function math.randomseed(x) end
---#end
---#DES 'math.sin'
---@param x number
---@return number
---@nodiscard
function math.sin(x) end
---@version <5.2
---#DES 'math.sinh'
---@param x number
---@return number
---@nodiscard
function math.sinh(x) end
---#DES 'math.sqrt'
---@param x number
---@return number
---@nodiscard
function math.sqrt(x) end
---#DES 'math.tan'
---@param x number
---@return number
---@nodiscard
function math.tan(x) end
---@version <5.2
---#DES 'math.tanh'
---@param x number
---@return number
---@nodiscard
function math.tanh(x) end
---@version >5.3
---#DES 'math.tointeger'
---@param x any
---@return integer?
---@nodiscard
function math.tointeger(x) end
---@version >5.3
---#DES 'math.type'
---@param x any
---@return
---| '"integer"'
---| '"float"'
---| 'nil'
---@nodiscard
function math.type(x) end
---@version >5.3
---#DES 'math.ult'
---@param m integer
---@param n integer
---@return boolean
---@nodiscard
function math.ult(m, n) end
return math

View File

@@ -0,0 +1,134 @@
---@meta os
---#DES 'os'
---@class oslib
os = {}
---#DES 'os.clock'
---@return number
---@nodiscard
function os.clock() end
---@class osdate:osdateparam
---#DES 'osdate.year'
---@field year integer|string
---#DES 'osdate.month'
---@field month integer|string
---#DES 'osdate.day'
---@field day integer|string
---#DES 'osdate.hour'
---@field hour integer|string
---#DES 'osdate.min'
---@field min integer|string
---#DES 'osdate.sec'
---@field sec integer|string
---#DES 'osdate.wday'
---@field wday integer|string
---#DES 'osdate.yday'
---@field yday integer|string
---#DES 'osdate.isdst'
---@field isdst boolean
---#DES 'os.date'
---@param format? string
---@param time? integer
---@return string|osdate
---@nodiscard
function os.date(format, time) end
---#DES 'os.difftime'
---@param t2 integer
---@param t1 integer
---@return integer
---@nodiscard
function os.difftime(t2, t1) end
---#DES 'os.execute'
---#if VERSION <= 5.1 and not JIT then
---@param command? string
---@return integer code
function os.execute(command) end
---#else
---@param command? string
---@return boolean? suc
---@return exitcode? exitcode
---@return integer? code
function os.execute(command) end
---#end
---#if VERSION <= 5.1 and not JIT then
---#DES 'os.exit<5.1'
---@param code? integer
function os.exit(code, close) end
---#else
---#DES 'os.exit>5.2'
---@param code? boolean|integer
---@param close? boolean
function os.exit(code, close) end
---#end
---#DES 'os.getenv'
---@param varname string
---@return string?
---@nodiscard
function os.getenv(varname) end
---#DES 'os.remove'
---@param filename string
---@return boolean suc
---@return string? errmsg
function os.remove(filename) end
---#DES 'os.rename'
---@param oldname string
---@param newname string
---@return boolean suc
---@return string? errmsg
function os.rename(oldname, newname) end
---@alias localecategory
---|>"all"
---| "collate"
---| "ctype"
---| "monetary"
---| "numeric"
---| "time"
---#DES 'os.setlocale'
---@param locale string|nil
---@param category? localecategory
---@return string localecategory
function os.setlocale(locale, category) end
---@class osdateparam
---#DES 'osdate.year'
---@field year integer|string
---#DES 'osdate.month'
---@field month integer|string
---#DES 'osdate.day'
---@field day integer|string
---#DES 'osdate.hour'
---@field hour (integer|string)?
---#DES 'osdate.min'
---@field min (integer|string)?
---#DES 'osdate.sec'
---@field sec (integer|string)?
---#DES 'osdate.wday'
---@field wday (integer|string)?
---#DES 'osdate.yday'
---@field yday (integer|string)?
---#DES 'osdate.isdst'
---@field isdst boolean?
---#DES 'os.time'
---@param date? osdateparam
---@return integer
---@nodiscard
function os.time(date) end
---#DES 'os.tmpname'
---@return string
---@nodiscard
function os.tmpname() end
return os

View File

@@ -0,0 +1,66 @@
---@meta package
---#if VERSION >=5.4 then
---#DES 'require>5.4'
---@param modname string
---@return unknown
---@return unknown loaderdata
function require(modname) end
---#else
---#DES 'require<5.3'
---@param modname string
---@return unknown
function require(modname) end
---#end
---#DES 'package'
---@class packagelib
---#DES 'package.cpath'
---@field cpath string
---#DES 'package.loaded'
---@field loaded table
---#DES 'package.path'
---@field path string
---#DES 'package.preload'
---@field preload table
package = {}
---#DES 'package.config'
package.config = [[
/
;
?
!
-]]
---@version <5.1
---#DES 'package.loaders'
package.loaders = {}
---#DES 'package.loadlib'
---@param libname string
---@param funcname string
---@return any
function package.loadlib(libname, funcname) end
---#DES 'package.searchers'
---@version >5.2
package.searchers = {}
---#DES 'package.searchpath'
---@version >5.2,JIT
---@param name string
---@param path string
---@param sep? string
---@param rep? string
---@return string? filename
---@return string? errmsg
---@nodiscard
function package.searchpath(name, path, sep, rep) end
---#DES 'package.seeall'
---@version <5.1
---@param module table
function package.seeall(module) end
return package

View File

@@ -0,0 +1,354 @@
---#if not JIT then DISABLE() end
---@meta string.buffer
---@version JIT
--- The string buffer library allows high-performance manipulation of string-like data.
---
--- Unlike Lua strings, which are constants, string buffers are mutable sequences of 8-bit (binary-transparent) characters. Data can be stored, formatted and encoded into a string buffer and later converted, extracted or decoded.
---
--- The convenient string buffer API simplifies common string manipulation tasks, that would otherwise require creating many intermediate strings. String buffers improve performance by eliminating redundant memory copies, object creation, string interning and garbage collection overhead. In conjunction with the FFI library, they allow zero-copy operations.
---
--- The string buffer libary also includes a high-performance serializer for Lua objects.
---
---
--- ## Streaming Serialization
---
--- In some contexts, it's desirable to do piecewise serialization of large datasets, also known as streaming.
---
--- This serialization format can be safely concatenated and supports streaming. Multiple encodings can simply be appended to a buffer and later decoded individually:
---
--- ```lua
--- local buf = buffer.new()
--- buf:encode(obj1)
--- buf:encode(obj2)
--- local copy1 = buf:decode()
--- local copy2 = buf:decode()
--- ```
---
--- Here's how to iterate over a stream:
---
--- ```lua
--- while #buf ~= 0 do
--- local obj = buf:decode()
--- -- Do something with obj.
--- end
--- ```
---
--- Since the serialization format doesn't prepend a length to its encoding, network applications may need to transmit the length, too.
--- Serialization Format Specification
---
--- This serialization format is designed for internal use by LuaJIT applications. Serialized data is upwards-compatible and portable across all supported LuaJIT platforms.
---
--- It's an 8-bit binary format and not human-readable. It uses e.g. embedded zeroes and stores embedded Lua string objects unmodified, which are 8-bit-clean, too. Encoded data can be safely concatenated for streaming and later decoded one top-level object at a time.
---
--- The encoding is reasonably compact, but tuned for maximum performance, not for minimum space usage. It compresses well with any of the common byte-oriented data compression algorithms.
---
--- Although documented here for reference, this format is explicitly not intended to be a 'public standard' for structured data interchange across computer languages (like JSON or MessagePack). Please do not use it as such.
---
--- The specification is given below as a context-free grammar with a top-level object as the starting point. Alternatives are separated by the | symbol and * indicates repeats. Grouping is implicit or indicated by {…}. Terminals are either plain hex numbers, encoded as bytes, or have a .format suffix.
---
--- ```
--- object → nil | false | true
--- | null | lightud32 | lightud64
--- | int | num | tab | tab_mt
--- | int64 | uint64 | complex
--- | string
---
--- nil → 0x00
--- false → 0x01
--- true → 0x02
---
--- null → 0x03 // NULL lightuserdata
--- lightud32 → 0x04 data.I // 32 bit lightuserdata
--- lightud64 → 0x05 data.L // 64 bit lightuserdata
---
--- int → 0x06 int.I // int32_t
--- num → 0x07 double.L
---
--- tab → 0x08 // Empty table
--- | 0x09 h.U h*{object object} // Key/value hash
--- | 0x0a a.U a*object // 0-based array
--- | 0x0b a.U a*object h.U h*{object object} // Mixed
--- | 0x0c a.U (a-1)*object // 1-based array
--- | 0x0d a.U (a-1)*object h.U h*{object object} // Mixed
--- tab_mt → 0x0e (index-1).U tab // Metatable dict entry
---
--- int64 → 0x10 int.L // FFI int64_t
--- uint64 → 0x11 uint.L // FFI uint64_t
--- complex → 0x12 re.L im.L // FFI complex
---
--- string → (0x20+len).U len*char.B
--- | 0x0f (index-1).U // String dict entry
---
--- .B = 8 bit
--- .I = 32 bit little-endian
--- .L = 64 bit little-endian
--- .U = prefix-encoded 32 bit unsigned number n:
--- 0x00..0xdf → n.B
--- 0xe0..0x1fdf → (0xe0|(((n-0xe0)>>8)&0x1f)).B ((n-0xe0)&0xff).B
--- 0x1fe0.. → 0xff n.I
--- ```
---
--- ## Error handling
---
--- Many of the buffer methods can throw an error. Out-of-memory or usage errors are best caught with an outer wrapper for larger parts of code. There's not much one can do after that, anyway.
---
--- OTOH you may want to catch some errors individually. Buffer methods need to receive the buffer object as the first argument. The Lua colon-syntax `obj:method()` does that implicitly. But to wrap a method with `pcall()`, the arguments need to be passed like this:
---
--- ```lua
--- local ok, err = pcall(buf.encode, buf, obj)
--- if not ok then
--- -- Handle error in err.
--- end
--- ```
---
--- ## FFI caveats
---
--- The string buffer library has been designed to work well together with the FFI library. But due to the low-level nature of the FFI library, some care needs to be taken:
---
--- First, please remember that FFI pointers are zero-indexed. The space returned by `buf:reserve()` and `buf:ref()` starts at the returned pointer and ends before len bytes after that.
---
--- I.e. the first valid index is `ptr[0]` and the last valid index is `ptr[len-1]`. If the returned length is zero, there's no valid index at all. The returned pointer may even be `NULL`.
---
--- The space pointed to by the returned pointer is only valid as long as the buffer is not modified in any way (neither append, nor consume, nor reset, etc.). The pointer is also not a GC anchor for the buffer object itself.
---
--- Buffer data is only guaranteed to be byte-aligned. Casting the returned pointer to a data type with higher alignment may cause unaligned accesses. It depends on the CPU architecture whether this is allowed or not (it's always OK on x86/x64 and mostly OK on other modern architectures).
---
--- FFI pointers or references do not count as GC anchors for an underlying object. E.g. an array allocated with `ffi.new()` is anchored by `buf:set(array, len)`, but not by `buf:set(array+offset, len)`. The addition of the offset creates a new pointer, even when the offset is zero. In this case, you need to make sure there's still a reference to the original array as long as its contents are in use by the buffer.
---
--- Even though each LuaJIT VM instance is single-threaded (but you can create multiple VMs), FFI data structures can be accessed concurrently. Be careful when reading/writing FFI cdata from/to buffers to avoid concurrent accesses or modifications. In particular, the memory referenced by `buf:set(cdata, len)` must not be modified while buffer readers are working on it. Shared, but read-only memory mappings of files are OK, but only if the file does not change.
local buffer = {}
--- A buffer object is a garbage-collected Lua object. After creation with `buffer.new()`, it can (and should) be reused for many operations. When the last reference to a buffer object is gone, it will eventually be freed by the garbage collector, along with the allocated buffer space.
---
--- Buffers operate like a FIFO (first-in first-out) data structure. Data can be appended (written) to the end of the buffer and consumed (read) from the front of the buffer. These operations may be freely mixed.
---
--- The buffer space that holds the characters is managed automatically — it grows as needed and already consumed space is recycled. Use `buffer.new(size)` and `buf:free()`, if you need more control.
---
--- The maximum size of a single buffer is the same as the maximum size of a Lua string, which is slightly below two gigabytes. For huge data sizes, neither strings nor buffers are the right data structure — use the FFI library to directly map memory or files up to the virtual memory limit of your OS.
---
---@version JIT
---@class string.buffer : table
local buf = {}
--- A string, number, or any object obj with a __tostring metamethod to the buffer.
---
---@alias string.buffer.data string|number|table
--- Appends a string str, a number num or any object obj with a `__tostring` metamethod to the buffer. Multiple arguments are appended in the given order.
---
--- Appending a buffer to a buffer is possible and short-circuited internally. But it still involves a copy. Better combine the buffer writes to use a single buffer.
---
---@param data string.buffer.data
---@param ...? string.buffer.data
---@return string.buffer
function buf:put(data, ...) end
--- Appends the formatted arguments to the buffer. The format string supports the same options as string.format().
---
---@param format string
---@param ... string.buffer.data
---@return string.buffer
function buf:putf(format, ...) end
--- Appends the given len number of bytes from the memory pointed to by the FFI cdata object to the buffer. The object needs to be convertible to a (constant) pointer.
---
---@param cdata ffi.cdata*
---@param len integer
---@return string.buffer
function buf:putcdata(cdata, len) end
--- This method allows zero-copy consumption of a string or an FFI cdata object as a buffer. It stores a reference to the passed string str or the FFI cdata object in the buffer. Any buffer space originally allocated is freed. This is not an append operation, unlike the `buf:put*()` methods.
---
--- After calling this method, the buffer behaves as if `buf:free():put(str)` or `buf:free():put(cdata, len)` had been called. However, the data is only referenced and not copied, as long as the buffer is only consumed.
---
--- In case the buffer is written to later on, the referenced data is copied and the object reference is removed (copy-on-write semantics).
---
--- The stored reference is an anchor for the garbage collector and keeps the originally passed string or FFI cdata object alive.
---
---@param str string.buffer.data
---@return string.buffer
---@overload fun(self:string.buffer, cdata:ffi.cdata*, len:integer):string.buffer
function buf:set(str) end
--- Reset (empty) the buffer. The allocated buffer space is not freed and may be reused.
---@return string.buffer
function buf:reset() end
--- The buffer space of the buffer object is freed. The object itself remains intact, empty and may be reused.
---
--- Note: you normally don't need to use this method. The garbage collector automatically frees the buffer space, when the buffer object is collected. Use this method, if you need to free the associated memory immediately.
function buf:free() end
--- The reserve method reserves at least size bytes of write space in the buffer. It returns an uint8_t * FFI cdata pointer ptr that points to this space.
---
--- The available length in bytes is returned in len. This is at least size bytes, but may be more to facilitate efficient buffer growth. You can either make use of the additional space or ignore len and only use size bytes.
---
--- This, along with `buf:commit()` allow zero-copy use of C read-style APIs:
---
--- ```lua
--- local MIN_SIZE = 65536
--- repeat
--- local ptr, len = buf:reserve(MIN_SIZE)
--- local n = C.read(fd, ptr, len)
--- if n == 0 then break end -- EOF.
--- if n < 0 then error("read error") end
--- buf:commit(n)
--- until false
--- ```
---
--- The reserved write space is not initialized. At least the used bytes must be written to before calling the commit method. There's no need to call the commit method, if nothing is added to the buffer (e.g. on error).
---@param size integer
---@return ffi.cdata* ptr # an uint8_t * FFI cdata pointer that points to this space
---@return integer len # available length (bytes)
function buf:reserve(size) end
--- Appends the used bytes of the previously returned write space to the buffer data.
---@param used integer
---@return string.buffer
function buf:commit(used) end
--- Skips (consumes) len bytes from the buffer up to the current length of the buffer data.
---@param len integer
---@return string.buffer
function buf:skip(len) end
--- Consumes the buffer data and returns one or more strings. If called without arguments, the whole buffer data is consumed. If called with a number, up to `len` bytes are consumed. A `nil` argument consumes the remaining buffer space (this only makes sense as the last argument). Multiple arguments consume the buffer data in the given order.
---
--- Note: a zero length or no remaining buffer data returns an empty string and not `nil`.
---
---@param len? integer
---@param ... integer|nil
---@return string ...
function buf:get(len, ...) end
--- Creates a string from the buffer data, but doesn't consume it. The buffer remains unchanged.
---
--- Buffer objects also define a `__tostring metamethod`. This means buffers can be passed to the global `tostring()` function and many other functions that accept this in place of strings. The important internal uses in functions like `io.write()` are short-circuited to avoid the creation of an intermediate string object.
---@return string
function buf:tostring() end
--- Returns an uint8_t * FFI cdata pointer ptr that points to the buffer data. The length of the buffer data in bytes is returned in len.
---
--- The returned pointer can be directly passed to C functions that expect a buffer and a length. You can also do bytewise reads (`local x = ptr[i]`) or writes (`ptr[i] = 0x40`) of the buffer data.
---
--- In conjunction with the `buf:skip()` method, this allows zero-copy use of C write-style APIs:
---
--- ```lua
--- repeat
--- local ptr, len = buf:ref()
--- if len == 0 then break end
--- local n = C.write(fd, ptr, len)
--- if n < 0 then error("write error") end
--- buf:skip(n)
--- until n >= len
--- ```
---
--- Unlike Lua strings, buffer data is not implicitly zero-terminated. It's not safe to pass ptr to C functions that expect zero-terminated strings. If you're not using len, then you're doing something wrong.
---
---@return ffi.cdata* ptr # an uint8_t * FFI cdata pointer that points to the buffer data.
---@return integer len # length of the buffer data in bytes
function buf:ref() end
--- Serializes (encodes) the Lua object to the buffer
---
--- This function may throw an error when attempting to serialize unsupported object types, circular references or deeply nested tables.
---@param obj string.buffer.data
---@return string.buffer
function buf:encode(obj) end
--- De-serializes one object from the buffer.
---
--- The returned object may be any of the supported Lua types — even `nil`.
---
--- This function may throw an error when fed with malformed or incomplete encoded data.
---
--- Leaves any left-over data in the buffer.
---
--- Attempting to de-serialize an FFI type will throw an error, if the FFI library is not built-in or has not been loaded, yet.
---
---@return string.buffer.data|nil obj
function buf:decode() end
--- Serializes (encodes) the Lua object obj
---
--- This function may throw an error when attempting to serialize unsupported object types, circular references or deeply nested tables.
---@param obj string.buffer.data
---@return string
function buffer.encode(obj) end
--- De-serializes (decodes) the string to a Lua object
---
--- The returned object may be any of the supported Lua types — even `nil`.
---
--- Throws an error when fed with malformed or incomplete encoded data.
--- Throws an error when there's left-over data after decoding a single top-level object.
---
--- Attempting to de-serialize an FFI type will throw an error, if the FFI library is not built-in or has not been loaded, yet.
---
---@param str string
---@return string.buffer.data|nil obj
function buffer.decode(str) end
--- Creates a new buffer object.
---
--- The optional size argument ensures a minimum initial buffer size. This is strictly an optimization when the required buffer size is known beforehand. The buffer space will grow as needed, in any case.
---
--- The optional table options sets various serialization options.
---
---@param size? integer
---@param options? string.buffer.serialization.opts
---@return string.buffer
function buffer.new(size, options) end
--- Serialization Options
---
--- The options table passed to buffer.new() may contain the following members (all optional):
---
--- * `dict` is a Lua table holding a dictionary of strings that commonly occur as table keys of objects you are serializing. These keys are compactly encoded as indexes during serialization. A well chosen dictionary saves space and improves serialization performance.
---
--- * `metatable` is a Lua table holding a dictionary of metatables for the table objects you are serializing.
---
--- dict needs to be an array of strings and metatable needs to be an array of tables. Both starting at index 1 and without holes (no nil inbetween). The tables are anchored in the buffer object and internally modified into a two-way index (don't do this yourself, just pass a plain array). The tables must not be modified after they have been passed to buffer.new().
---
--- The dict and metatable tables used by the encoder and decoder must be the same. Put the most common entries at the front. Extend at the end to ensure backwards-compatibility — older encodings can then still be read. You may also set some indexes to false to explicitly drop backwards-compatibility. Old encodings that use these indexes will throw an error when decoded.
---
--- Metatables that are not found in the metatable dictionary are ignored when encoding. Decoding returns a table with a nil metatable.
---
--- Note: parsing and preparation of the options table is somewhat expensive. Create a buffer object only once and recycle it for multiple uses. Avoid mixing encoder and decoder buffers, since the buf:set() method frees the already allocated buffer space:
---
--- ```lua
--- local options = {
--- dict = { "commonly", "used", "string", "keys" },
--- }
--- local buf_enc = buffer.new(options)
--- local buf_dec = buffer.new(options)
---
--- local function encode(obj)
--- return buf_enc:reset():encode(obj):get()
--- end
---
--- local function decode(str)
--- return buf_dec:set(str):decode()
--- end
--- ```
---@class string.buffer.serialization.opts
---@field dict string[]
---@field metatable table[]
return buffer

View File

@@ -0,0 +1,161 @@
---@meta string
---#DES 'string'
---@class stringlib
string = {}
---#DES 'string.byte'
---@param s string|number
---@param i? integer
---@param j? integer
---@return integer ...
---@nodiscard
function string.byte(s, i, j) end
---#DES 'string.char'
---@param byte integer
---@param ... integer
---@return string
---@nodiscard
function string.char(byte, ...) end
---#DES 'string.dump'
---#if VERSION >= 5.3 or JIT then
---@param f async fun(...):...
---@param strip? boolean
---@return string
---@nodiscard
function string.dump(f, strip) end
---#else
---@param f async fun(...):...
---@return string
---@nodiscard
function string.dump(f) end
---#end
---#DES 'string.find'
---@param s string|number
---@param pattern string|number
---@param init? integer
---@param plain? boolean
---@return integer|nil start
---@return integer|nil end
---@return any|nil ... captured
---@nodiscard
function string.find(s, pattern, init, plain) end
---#DES 'string.format'
---@param s string|number
---@param ... any
---@return string
---@nodiscard
function string.format(s, ...) end
---#DES 'string.gmatch'
---#if VERSION <= 5.3 then
---@param s string|number
---@param pattern string|number
---@return fun():string, ...
---@nodiscard
function string.gmatch(s, pattern) end
---#else
---@param s string|number
---@param pattern string|number
---@param init? integer
---@return fun():string, ...
function string.gmatch(s, pattern, init) end
---#end
---#DES 'string.gsub'
---@param s string|number
---@param pattern string|number
---@param repl string|number|table|function
---@param n? integer
---@return string
---@return integer count
function string.gsub(s, pattern, repl, n) end
---#DES 'string.len'
---@param s string|number
---@return integer
---@nodiscard
function string.len(s) end
---#DES 'string.lower'
---@param s string|number
---@return string
---@nodiscard
function string.lower(s) end
---#DES 'string.match'
---@param s string|number
---@param pattern string|number
---@param init? integer
---@return any ...
---@nodiscard
function string.match(s, pattern, init) end
---@version >5.3
---#DES 'string.pack'
---@param fmt string
---@param v1 string|number
---@param v2? string|number
---@param ... string|number
---@return string binary
---@nodiscard
function string.pack(fmt, v1, v2, ...) end
---@version >5.3
---#DES 'string.packsize'
---@param fmt string
---@return integer
---@nodiscard
function string.packsize(fmt) end
---#if VERSION <= 5.1 and not JIT then
---#DES 'string.rep<5.1'
---@param s string|number
---@param n integer
---@return string
---@nodiscard
function string.rep(s, n) end
---#else
---#DES 'string.rep>5.2'
---@param s string|number
---@param n integer
---@param sep? string|number
---@return string
---@nodiscard
function string.rep(s, n, sep) end
---#end
---#DES 'string.reverse'
---@param s string|number
---@return string
---@nodiscard
function string.reverse(s) end
---#DES 'string.sub'
---@param s string|number
---@param i integer
---@param j? integer
---@return string
---@nodiscard
function string.sub(s, i, j) end
---@version >5.3
---#DES 'string.unpack'
---@param fmt string
---@param s string
---@param pos? integer
---@return any ...
---@nodiscard
function string.unpack(fmt, s, pos) end
---#DES 'string.upper'
---@param s string|number
---@return string
---@nodiscard
function string.upper(s) end
return string

View File

@@ -0,0 +1,9 @@
---#if not JIT then DISABLE() end
---@meta table.clear
---@version JIT
---#DES 'table.clear'
---@param tab table
local function clear(tab) end
return clear

View File

@@ -0,0 +1,106 @@
---@meta table
---#DES 'table'
---@class tablelib
table = {}
---#DES 'table.concat'
---@param list table
---@param sep? string
---@param i? integer
---@param j? integer
---@return string
---@nodiscard
function table.concat(list, sep, i, j) end
---#DES 'table.insert'
---@overload fun(list: table, value: any)
---@param list table
---@param pos integer
---@param value any
function table.insert(list, pos, value) end
---@version <5.1
---#DES 'table.maxn'
---@param table table
---@return integer
---@nodiscard
function table.maxn(table) end
---@version >5.3, JIT
---#DES 'table.move'
---@param a1 table
---@param f integer
---@param e integer
---@param t integer
---@param a2? table
---@return table a2
function table.move(a1, f, e, t, a2) end
---@version >5.2, JIT
---#DES 'table.pack'
---@return table
---@nodiscard
function table.pack(...) end
---#DES 'table.remove'
---@param list table
---@param pos? integer
---@return any
function table.remove(list, pos) end
---#DES 'table.sort'
---@generic T
---@param list T[]
---@param comp? fun(a: T, b: T):boolean
function table.sort(list, comp) end
---@version >5.2, JIT
---#DES 'table.unpack'
---@generic T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
---@param list {
--- [1]?: T1,
--- [2]?: T2,
--- [3]?: T3,
--- [4]?: T4,
--- [5]?: T5,
--- [6]?: T6,
--- [7]?: T7,
--- [8]?: T8,
--- [9]?: T9,
--- [10]?: T10,
---}
---@param i? integer
---@param j? integer
---@return T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
---@nodiscard
function table.unpack(list, i, j) end
---@version <5.1, JIT
---#DES 'table.foreach'
---@generic T
---@param list any
---@param callback fun(key: string, value: any):T|nil
---@return T|nil
---@deprecated
function table.foreach(list, callback) end
---@version <5.1, JIT
---#DES 'table.foreachi'
---@generic T
---@param list any
---@param callback fun(key: string, value: any):T|nil
---@return T|nil
---@deprecated
function table.foreachi(list, callback) end
---@version <5.1, JIT
---#DES 'table.getn'
---@generic T
---@param list T[]
---@return integer
---@nodiscard
---@deprecated
function table.getn(list) end
return table

View File

@@ -0,0 +1,11 @@
---#if not JIT then DISABLE() end
---@meta table.new
---@version JIT
---#DES 'table.new'
---@param narray integer
---@param nhash integer
---@return table
local function new(narray, nhash) end
return new

View File

@@ -0,0 +1,78 @@
---#if VERSION <= 5.2 then DISABLE() end
---@meta utf8
---@version >5.3
---#DES 'utf8'
---@class utf8lib
---#DES 'utf8.charpattern'
---@field charpattern string
utf8 = {}
---#DES 'utf8.char'
---@param code integer
---@param ... integer
---@return string
---@nodiscard
function utf8.char(code, ...) end
---#DES 'utf8.codes'
---#if VERSION <= 5.3 then
---@param s string
---@return fun(s: string, p: integer):integer, integer
function utf8.codes(s) end
---#else
---@param s string
---@param lax? boolean
---@return fun(s: string, p: integer):integer, integer
function utf8.codes(s, lax) end
---#end
---#DES 'utf8.codepoint'
---#if VERSION <= 5.3 then
---@param s string
---@param i? integer
---@param j? integer
---@return integer code
---@return integer ...
---@nodiscard
function utf8.codepoint(s, i, j) end
---#else
---@param s string
---@param i? integer
---@param j? integer
---@param lax? boolean
---@return integer code
---@return integer ...
---@nodiscard
function utf8.codepoint(s, i, j, lax) end
---#end
---#DES 'utf8.len'
---#if VERSION <= 5.3 then
---@param s string
---@param i? integer
---@param j? integer
---@return integer?
---@return integer? errpos
---@nodiscard
function utf8.len(s, i, j) end
---#else
---@param s string
---@param i? integer
---@param j? integer
---@param lax? boolean
---@return integer?
---@return integer? errpos
---@nodiscard
function utf8.len(s, i, j, lax) end
---#end
---#DES 'utf8.offset'
---@param s string
---@param n integer
---@param i? integer
---@return integer p
---@nodiscard
function utf8.offset(s, n, i) end
return utf8