dotfiles from arch
This commit is contained in:
@@ -0,0 +1,455 @@
|
||||
---@meta _
|
||||
|
||||
---
|
||||
---独立版Lua的启动参数。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-arg"])
|
||||
---
|
||||
---@type string[]
|
||||
arg = {}
|
||||
|
||||
---
|
||||
---如果其参数 `v` 的值为假(`nil` 或 `false`), 它就调用 [error](command:extension.lua.doc?["en-us/54/manual.html/pdf-error"]); 否则,返回所有的参数。 在错误情况时, `message` 指那个错误对象; 如果不提供这个参数,参数默认为 `"assertion failed!"` 。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-assert"])
|
||||
---
|
||||
---@generic T
|
||||
---@param v? T
|
||||
---@param message? any
|
||||
---@param ... any
|
||||
---@return T
|
||||
---@return any ...
|
||||
function assert(v, message, ...) end
|
||||
|
||||
---@alias gcoptions
|
||||
---|>"collect" # 做一次完整的垃圾收集循环。
|
||||
---| "stop" # 停止垃圾收集器的运行。
|
||||
---| "restart" # 重启垃圾收集器的自动运行。
|
||||
---| "count" # 以 K 字节数为单位返回 Lua 使用的总内存数。
|
||||
---| "step" # 单步运行垃圾收集器。 步长“大小”由 `arg` 控制。
|
||||
---| "isrunning" # 返回表示收集器是否在工作的布尔值。
|
||||
---| "incremental" # 改变收集器模式为增量模式。
|
||||
---| "generational" # 改变收集器模式为分代模式。
|
||||
|
||||
---
|
||||
---这个函数是垃圾收集器的通用接口。 通过参数 opt 它提供了一组不同的功能。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-collectgarbage"])
|
||||
---
|
||||
---@param opt? gcoptions
|
||||
---@param ... any
|
||||
---@return any
|
||||
function collectgarbage(opt, ...) end
|
||||
|
||||
---
|
||||
---打开该名字的文件,并执行文件中的 Lua 代码块。 不带参数调用时, `dofile` 执行标准输入的内容(`stdin`)。 返回该代码块的所有返回值。 对于有错误的情况,`dofile` 将错误反馈给调用者 (即,`dofile` 没有运行在保护模式下)。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-dofile"])
|
||||
---
|
||||
---@param filename? string
|
||||
---@return any ...
|
||||
function dofile(filename) end
|
||||
|
||||
---
|
||||
---中止上一次保护函数调用, 将错误对象 `message` 返回。 函数 `error` 永远不会返回。
|
||||
---
|
||||
---当 `message` 是一个字符串时,通常 `error` 会把一些有关出错位置的信息附加在消息的前头。 level 参数指明了怎样获得出错位置。
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-error"])
|
||||
---
|
||||
---@param message any
|
||||
---@param level? integer
|
||||
function error(message, level) end
|
||||
|
||||
---
|
||||
---一个全局变量(非函数), 内部储存有全局环境(参见 [§2.2](command:extension.lua.doc?["en-us/54/manual.html/2.2"]))。 Lua 自己不使用这个变量; 改变这个变量的值不会对任何环境造成影响,反之亦然。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-_G"])
|
||||
---
|
||||
---@class _G
|
||||
_G = {}
|
||||
|
||||
---@version 5.1
|
||||
---
|
||||
---返回给定函数的环境。`f` 可以是一个Lua函数,也可是一个表示调用栈层级的数字。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-getfenv"])
|
||||
---
|
||||
---@param f? integer|async fun(...):...
|
||||
---@return table
|
||||
---@nodiscard
|
||||
function getfenv(f) end
|
||||
|
||||
---
|
||||
---如果 `object` 不包含元表,返回 `nil` 。 否则,如果在该对象的元表中有 `"__metatable"` 域时返回其关联值, 没有时返回该对象的元表。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-getmetatable"])
|
||||
---
|
||||
---@param object any
|
||||
---@return table metatable
|
||||
---@nodiscard
|
||||
function getmetatable(object) end
|
||||
|
||||
---
|
||||
---返回三个值(迭代函数、表 `t` 以及 `0` ), 如此,以下代码
|
||||
---```lua
|
||||
--- for i,v in ipairs(t) do body end
|
||||
---```
|
||||
---将迭代键值对 `(1,t[1]) ,(2,t[2]), ...` ,直到第一个空值。
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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" # 只能是二进制代码块。
|
||||
---| "t" # 只能是文本代码块。
|
||||
---|>"bt" # 可以是二进制也可以是文本。
|
||||
|
||||
---
|
||||
---加载一个代码块。
|
||||
---
|
||||
---如果 `chunk` 是一个字符串,代码块指这个字符串。 如果 `chunk` 是一个函数, `load` 不断地调用它获取代码块的片断。 每次对 `chunk` 的调用都必须返回一个字符串紧紧连接在上次调用的返回串之后。 当返回空串、`nil`、或是不返回值时,都表示代码块结束。
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-load"])
|
||||
---
|
||||
---@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
|
||||
|
||||
---
|
||||
---从文件 `filename` 或标准输入(如果文件名未提供)中获取代码块。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-loadfile"])
|
||||
---
|
||||
---@param filename? string
|
||||
---@param mode? loadmode
|
||||
---@param env? table
|
||||
---@return function?
|
||||
---@return string? error_message
|
||||
---@nodiscard
|
||||
function loadfile(filename, mode, env) end
|
||||
|
||||
---@version 5.1
|
||||
---
|
||||
---使用给定字符串加载代码块。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
---
|
||||
---创建一个模块。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-module"])
|
||||
---
|
||||
---@param name string
|
||||
---@param ... any
|
||||
function module(name, ...) end
|
||||
|
||||
---
|
||||
---运行程序来遍历表中的所有域。 第一个参数是要遍历的表,第二个参数是表中的某个键。 `next` 返回该键的下一个键及其关联的值。 如果用 `nil` 作为第二个参数调用 `next` 将返回初始键及其关联值。 当以最后一个键去调用,或是以 `nil` 调用一张空表时, `next` 返回 `nil`。 如果不提供第二个参数,将认为它就是 `nil`。 特别指出,你可以用 `next(t)` 来判断一张表是否是空的。
|
||||
---
|
||||
---索引在遍历过程中的次序无定义, 即使是数字索引也是这样。 (如果想按数字次序遍历表,可以使用数字形式的 `for` 。)
|
||||
---
|
||||
---当在遍历过程中你给表中并不存在的域赋值, `next` 的行为是未定义的。 然而你可以去修改那些已存在的域。 特别指出,你可以清除一些已存在的域。
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-next"])
|
||||
---
|
||||
---@generic K, V
|
||||
---@param table table<K, V>
|
||||
---@param index? K
|
||||
---@return K?
|
||||
---@return V?
|
||||
---@nodiscard
|
||||
function next(table, index) end
|
||||
|
||||
---
|
||||
---如果 `t` 有元方法 `__pairs`, 以 `t` 为参数调用它,并返回其返回的前三个值。
|
||||
---
|
||||
---否则,返回三个值:`next` 函数, 表 `t`,以及 `nil`。 因此以下代码
|
||||
---```lua
|
||||
--- for k,v in pairs(t) do body end
|
||||
---```
|
||||
---能迭代表 `t` 中的所有键值对。
|
||||
---
|
||||
---参见函数 [next](command:extension.lua.doc?["en-us/54/manual.html/pdf-next"]) 中关于迭代过程中修改表的风险。
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
|
||||
---
|
||||
---传入参数,以 *保护模式* 调用函数 `f` 。 这意味着 `f` 中的任何错误不会抛出; 取而代之的是,`pcall` 会将错误捕获到,并返回一个状态码。 第一个返回值是状态码(一个布尔量), 当没有错误时,其为真。 此时,`pcall` 同样会在状态码后返回所有调用的结果。 在有错误时,`pcall` 返回 `false` 加错误消息。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-pcall"])
|
||||
---
|
||||
---@param f async fun(...):...
|
||||
---@param arg1? any
|
||||
---@param ... any
|
||||
---@return boolean success
|
||||
---@return any result
|
||||
---@return any ...
|
||||
function pcall(f, arg1, ...) end
|
||||
|
||||
---
|
||||
---接收任意数量的参数,并将它们的值打印到 `stdout`。 它用 `tostring` 函数将每个参数都转换为字符串。 `print` 不用于做格式化输出。仅作为看一下某个值的快捷方式。 多用于调试。 完整的对输出的控制,请使用 [string.format](command:extension.lua.doc?["en-us/54/manual.html/pdf-string.format"]) 以及 [io.write](command:extension.lua.doc?["en-us/54/manual.html/pdf-io.write"])。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-print"])
|
||||
---
|
||||
---@param ... any
|
||||
function print(...) end
|
||||
|
||||
---
|
||||
---在不触发任何元方法的情况下 检查 `v1` 是否和 `v2` 相等。 返回一个布尔量。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-rawequal"])
|
||||
---
|
||||
---@param v1 any
|
||||
---@param v2 any
|
||||
---@return boolean
|
||||
---@nodiscard
|
||||
function rawequal(v1, v2) end
|
||||
|
||||
---
|
||||
---在不触发任何元方法的情况下 获取 `table[index]` 的值。 `table` 必须是一张表; `index` 可以是任何值。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-rawget"])
|
||||
---
|
||||
---@param table table
|
||||
---@param index any
|
||||
---@return any
|
||||
---@nodiscard
|
||||
function rawget(table, index) end
|
||||
|
||||
---
|
||||
---在不触发任何元方法的情况下 返回对象 `v` 的长度。 `v` 可以是表或字符串。 它返回一个整数。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-rawlen"])
|
||||
---
|
||||
---@param v table|string
|
||||
---@return integer len
|
||||
---@nodiscard
|
||||
function rawlen(v) end
|
||||
|
||||
---
|
||||
---在不触发任何元方法的情况下 将 `table[index]` 设为 `value。` `table` 必须是一张表, `index` 可以是 `nil` 与 `NaN` 之外的任何值。 `value` 可以是任何 Lua 值。
|
||||
---这个函数返回 `table`。
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-rawset"])
|
||||
---
|
||||
---@param table table
|
||||
---@param index any
|
||||
---@param value any
|
||||
---@return table
|
||||
function rawset(table, index, value) end
|
||||
|
||||
---
|
||||
---如果 `index` 是个数字, 那么返回参数中第 `index` 个之后的部分; 负的数字会从后向前索引(`-1` 指最后一个参数)。 否则,`index` 必须是字符串 `"#"`, 此时 `select` 返回参数的个数。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-select"])
|
||||
---
|
||||
---@param index integer|"#"
|
||||
---@param ... any
|
||||
---@return any
|
||||
---@nodiscard
|
||||
function select(index, ...) end
|
||||
|
||||
---@version 5.1
|
||||
---
|
||||
---设置给定函数的环境。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
---@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
|
||||
---@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
|
||||
---@field __pairs (fun(t):((fun(t,k,v):any,any),any,any))|nil
|
||||
---@field __close (fun(t,errobj):any)|nil
|
||||
|
||||
---
|
||||
---给指定表设置元表。 (你不能在 Lua 中改变其它类型值的元表,那些只能在 C 里做。) 如果 `metatable` 是 `nil`, 将指定表的元表移除。 如果原来那张元表有 `"__metatable"` 域,抛出一个错误。
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-setmetatable"])
|
||||
---
|
||||
---@param table table
|
||||
---@param metatable? metatable|table
|
||||
---@return table
|
||||
function setmetatable(table, metatable) end
|
||||
|
||||
---
|
||||
---如果调用的时候没有 `base`, `tonumber` 尝试把参数转换为一个数字。 如果参数已经是一个数字,或是一个可以转换为数字的字符串, `tonumber` 就返回这个数字; 否则返回 `nil`。
|
||||
---
|
||||
---字符串的转换结果可能是整数也可能是浮点数, 这取决于 Lua 的转换文法(参见 [§3.1](command:extension.lua.doc?["en-us/54/manual.html/3.1"]))。 (字符串可以有前置和后置的空格,可以带符号。)
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-tonumber"])
|
||||
---
|
||||
---@overload fun(e: string, base: integer):integer
|
||||
---@param e any
|
||||
---@return number?
|
||||
---@nodiscard
|
||||
function tonumber(e) end
|
||||
|
||||
---
|
||||
---可以接收任何类型,它将其转换为人可阅读的字符串形式。 浮点数总被转换为浮点数的表现形式(小数点形式或是指数形式)。 (如果想完全控制数字如何被转换,可以使用 [string.format](command:extension.lua.doc?["en-us/54/manual.html/pdf-string.format"])。)
|
||||
---如果 `v` 有 `"__tostring"` 域的元表, `tostring` 会以 `v` 为参数调用它。 并用它的结果作为返回值。
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-tostring"])
|
||||
---
|
||||
---@param v any
|
||||
---@return string
|
||||
---@nodiscard
|
||||
function tostring(v) end
|
||||
|
||||
---@alias type
|
||||
---| "nil"
|
||||
---| "number"
|
||||
---| "string"
|
||||
---| "boolean"
|
||||
---| "table"
|
||||
---| "function"
|
||||
---| "thread"
|
||||
---| "userdata"
|
||||
|
||||
---
|
||||
---将参数的类型编码为一个字符串返回。 函数可能的返回值有 `"nil"` (一个字符串,而不是 `nil` 值), `"number"`, `"string"`, `"boolean"`, `"table"`, `"function"`, `"thread"`, `"userdata"`。
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-type"])
|
||||
---
|
||||
---@param v any
|
||||
---@return type type
|
||||
---@nodiscard
|
||||
function type(v) end
|
||||
|
||||
---
|
||||
---一个包含有当前解释器版本号的全局变量(并非函数)。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-_VERSION"])
|
||||
---
|
||||
_VERSION = "Lua 5.4"
|
||||
|
||||
---@version >5.4
|
||||
---
|
||||
---使用所有参数组成的字符串消息来发送警告。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-warn"])
|
||||
---
|
||||
---@param message string
|
||||
---@param ... any
|
||||
function warn(message, ...) end
|
||||
|
||||
---
|
||||
---传入参数,以 *保护模式* 调用函数 `f` 。这个函数和 `pcall` 类似。 不过它可以额外设置一个消息处理器 `msgh`。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-xpcall"])
|
||||
---
|
||||
---@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
|
||||
|
||||
---@version 5.1
|
||||
---
|
||||
---返回给定 `list` 中的所有元素。 改函数等价于
|
||||
---```lua
|
||||
---return list[i], list[i+1], ···, list[j]
|
||||
---```
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
@@ -0,0 +1,76 @@
|
||||
---@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
|
||||
@@ -0,0 +1,156 @@
|
||||
---@meta bit32
|
||||
|
||||
---@version 5.2
|
||||
---
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32"])
|
||||
---
|
||||
---@class bit32lib
|
||||
bit32 = {}
|
||||
|
||||
---
|
||||
---返回 `x` 向右位移 `disp` 位的结果。`disp` 为负时向左位移。这是算数位移操作,左侧的空位使用 `x` 的高位填充,右侧空位使用 `0` 填充。
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.arshift"])
|
||||
---
|
||||
---@param x integer
|
||||
---@param disp integer
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
function bit32.arshift(x, disp) end
|
||||
|
||||
---
|
||||
---返回参数按位与的结果。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.band"])
|
||||
---
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
function bit32.band(...) end
|
||||
|
||||
---
|
||||
---返回 `x` 按位取反的结果。
|
||||
---
|
||||
---```lua
|
||||
---assert(bit32.bnot(x) ==
|
||||
---(-1 - x) % 2^32)
|
||||
---```
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.bnot"])
|
||||
---
|
||||
---@param x integer
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
function bit32.bnot(x) end
|
||||
|
||||
---
|
||||
---返回参数按位或的结果。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.bor"])
|
||||
---
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
function bit32.bor(...) end
|
||||
|
||||
---
|
||||
---参数按位与的结果不为0时,返回 `true` 。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.btest"])
|
||||
---
|
||||
---@return boolean
|
||||
---@nodiscard
|
||||
function bit32.btest(...) end
|
||||
|
||||
---
|
||||
---返回参数按位异或的结果。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.bxor"])
|
||||
---
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
function bit32.bxor(...) end
|
||||
|
||||
---
|
||||
---返回 `n` 中第 `field` 到第 `field + width - 1` 位组成的结果。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.extract"])
|
||||
---
|
||||
---@param n integer
|
||||
---@param field integer
|
||||
---@param width? integer
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
function bit32.extract(n, field, width) end
|
||||
|
||||
---
|
||||
---返回 `v` 的第 `field` 到第 `field + width - 1` 位替换 `n` 的对应位后的结果。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.replace"])
|
||||
---
|
||||
---@param n integer
|
||||
---@param v integer
|
||||
---@param field integer
|
||||
---@param width? integer
|
||||
---@nodiscard
|
||||
function bit32.replace(n, v, field, width) end
|
||||
|
||||
---
|
||||
---返回 `x` 向左旋转 `disp` 位的结果。`disp` 为负时向右旋转。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.lrotate"])
|
||||
---
|
||||
---@param x integer
|
||||
---@param distp integer
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
function bit32.lrotate(x, distp) end
|
||||
|
||||
---
|
||||
---返回 `x` 向左位移 `disp` 位的结果。`disp` 为负时向右位移。空位总是使用 `0` 填充。
|
||||
---
|
||||
---```lua
|
||||
---assert(bit32.lshift(b, disp) ==
|
||||
---(b * 2^disp) % 2^32)
|
||||
---```
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.lshift"])
|
||||
---
|
||||
---@param x integer
|
||||
---@param distp integer
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
function bit32.lshift(x, distp) end
|
||||
|
||||
---
|
||||
---返回 `x` 向右旋转 `disp` 位的结果。`disp` 为负时向左旋转。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.rrotate"])
|
||||
---
|
||||
---@param x integer
|
||||
---@param distp integer
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
function bit32.rrotate(x, distp) end
|
||||
|
||||
---
|
||||
---返回 `x` 向右位移 `disp` 位的结果。`disp` 为负时向左位移。空位总是使用 `0` 填充。
|
||||
---
|
||||
---```lua
|
||||
---assert(bit32.lshift(b, disp) ==
|
||||
---(b * 2^disp) % 2^32)
|
||||
---```
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-bit32.rshift"])
|
||||
---
|
||||
---@param x integer
|
||||
---@param distp integer
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
function bit32.rshift(x, distp) end
|
||||
|
||||
return bit32
|
||||
@@ -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
|
||||
@@ -0,0 +1,96 @@
|
||||
---@meta coroutine
|
||||
|
||||
---
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-coroutine"])
|
||||
---
|
||||
---@class coroutinelib
|
||||
coroutine = {}
|
||||
|
||||
---
|
||||
---创建一个主体函数为 `f` 的新协程。 f 必须是一个 Lua 的函数。 返回这个新协程,它是一个类型为 `"thread"` 的对象。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-coroutine.create"])
|
||||
---
|
||||
---@param f async fun(...):...
|
||||
---@return thread
|
||||
---@nodiscard
|
||||
function coroutine.create(f) end
|
||||
|
||||
---
|
||||
---如果协程 `co` 可以让出,则返回真。`co` 默认为正在运行的协程。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-coroutine.isyieldable"])
|
||||
---
|
||||
---@param co? thread
|
||||
---@return boolean
|
||||
---@nodiscard
|
||||
function coroutine.isyieldable(co) end
|
||||
|
||||
---@version >5.4
|
||||
---
|
||||
---关闭协程 `co`,并关闭它所有等待 *to-be-closed* 的变量,并将协程状态设为 `dead` 。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-coroutine.close"])
|
||||
---
|
||||
---@param co thread
|
||||
---@return boolean noerror
|
||||
---@return any errorobject
|
||||
function coroutine.close(co) end
|
||||
|
||||
---
|
||||
---开始或继续协程 `co` 的运行。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-coroutine.resume"])
|
||||
---
|
||||
---@param co thread
|
||||
---@param val1? any
|
||||
---@return boolean success
|
||||
---@return any ...
|
||||
function coroutine.resume(co, val1, ...) end
|
||||
|
||||
---
|
||||
---返回当前正在运行的协程加一个布尔量。 如果当前运行的协程是主线程,其为真。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-coroutine.running"])
|
||||
---
|
||||
---@return thread running
|
||||
---@return boolean ismain
|
||||
---@nodiscard
|
||||
function coroutine.running() end
|
||||
|
||||
---
|
||||
---以字符串形式返回协程 `co` 的状态。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-coroutine.status"])
|
||||
---
|
||||
---@param co thread
|
||||
---@return
|
||||
---| '"running"' # 正在运行。
|
||||
---| '"suspended"' # 挂起或是还没有开始运行。
|
||||
---| '"normal"' # 是活动的,但并不在运行。
|
||||
---| '"dead"' # 运行完主体函数或因错误停止。
|
||||
---@nodiscard
|
||||
function coroutine.status(co) end
|
||||
|
||||
---
|
||||
---创建一个主体函数为 `f` 的新协程。 f 必须是一个 Lua 的函数。 返回一个函数, 每次调用该函数都会延续该协程。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-coroutine.wrap"])
|
||||
---
|
||||
---@param f async fun(...):...
|
||||
---@return fun(...):...
|
||||
---@nodiscard
|
||||
function coroutine.wrap(f) end
|
||||
|
||||
---
|
||||
---挂起正在调用的协程的执行。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-coroutine.yield"])
|
||||
---
|
||||
---@async
|
||||
---@return any ...
|
||||
function coroutine.yield(...) end
|
||||
|
||||
return coroutine
|
||||
@@ -0,0 +1,268 @@
|
||||
---@meta debug
|
||||
|
||||
---
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
---@field nparams integer
|
||||
---@field isvararg boolean
|
||||
---@field func function
|
||||
---@field ftransfer integer
|
||||
---@field ntransfer integer
|
||||
---@field activelines table
|
||||
|
||||
---
|
||||
---进入一个用户交互模式,运行用户输入的每个字符串。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-debug.debug"])
|
||||
---
|
||||
function debug.debug() end
|
||||
|
||||
---@version 5.1
|
||||
---
|
||||
---返回对象 `o` 的环境。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-debug.getfenv"])
|
||||
---
|
||||
---@param o any
|
||||
---@return table
|
||||
---@nodiscard
|
||||
function debug.getfenv(o) end
|
||||
|
||||
---
|
||||
---返回三个表示线程钩子设置的值: 当前钩子函数,当前钩子掩码,当前钩子计数 。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-debug.gethook"])
|
||||
---
|
||||
---@param co? thread
|
||||
---@return function hook
|
||||
---@return string mask
|
||||
---@return integer count
|
||||
---@nodiscard
|
||||
function debug.gethook(co) end
|
||||
|
||||
---@alias infowhat string
|
||||
---|+"n" # `name` 和 `namewhat`
|
||||
---|+"S" # `source`,`short_src`,`linedefined`,`lalinedefined`,和 `what`
|
||||
---|+"l" # `currentline`
|
||||
---|+"t" # `istailcall`
|
||||
---|+"u" # `nups`、`nparams` 和 `isvararg`
|
||||
---|+"f" # `func`
|
||||
---|+"r" # `ftransfer` 和 `ntransfer`
|
||||
---|+"L" # `activelines`
|
||||
|
||||
---
|
||||
---返回关于一个函数信息的表。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
|
||||
---
|
||||
---返回在栈的 `f` 层处函数的索引为 `index` 的局部变量的名字和值。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-debug.getlocal"])
|
||||
---
|
||||
---@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
|
||||
|
||||
---
|
||||
---返回给定 `value` 的元表。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-debug.getmetatable"])
|
||||
---
|
||||
---@param object any
|
||||
---@return table metatable
|
||||
---@nodiscard
|
||||
function debug.getmetatable(object) end
|
||||
|
||||
---
|
||||
---返回注册表。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-debug.getregistry"])
|
||||
---
|
||||
---@return table
|
||||
---@nodiscard
|
||||
function debug.getregistry() end
|
||||
|
||||
---
|
||||
---返回函数 `f` 的第 `up` 个上值的名字和值。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-debug.getupvalue"])
|
||||
---
|
||||
---@param f async fun(...):...
|
||||
---@param up integer
|
||||
---@return string name
|
||||
---@return any value
|
||||
---@nodiscard
|
||||
function debug.getupvalue(f, up) end
|
||||
|
||||
---
|
||||
---返回关联在 `u` 上的第 `n` 个 `Lua` 值,以及一个布尔,`false`表示值不存在。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-debug.getuservalue"])
|
||||
---
|
||||
---@param u userdata
|
||||
---@param n? integer
|
||||
---@return any
|
||||
---@return boolean
|
||||
---@nodiscard
|
||||
function debug.getuservalue(u, n) end
|
||||
|
||||
---
|
||||
---### **已在 `Lua 5.4.2` 中废弃**
|
||||
---
|
||||
---设置新的C栈限制。该限制控制Lua中嵌套调用的深度,以避免堆栈溢出。
|
||||
---
|
||||
---如果设置成功,该函数返回之前的限制;否则返回`false`。
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-debug.setcstacklimit"])
|
||||
---
|
||||
---@deprecated
|
||||
---@param limit integer
|
||||
---@return integer|boolean
|
||||
function debug.setcstacklimit(limit) end
|
||||
|
||||
---
|
||||
---将 `table` 设置为 `object` 的环境。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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" # 每当 Lua 调用一个函数时,调用钩子。
|
||||
---|+"r" # 每当 Lua 从一个函数内返回时,调用钩子。
|
||||
---|+"l" # 每当 Lua 进入新的一行时,调用钩子。
|
||||
|
||||
---
|
||||
---将一个函数作为钩子函数设入。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
|
||||
---
|
||||
---将 `value` 赋给 栈上第 `level` 层函数的第 `local` 个局部变量。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
|
||||
---
|
||||
---将 `value` 的元表设为 `table` (可以是 `nil`)。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-debug.setmetatable"])
|
||||
---
|
||||
---@generic T
|
||||
---@param value T
|
||||
---@param meta? table
|
||||
---@return T value
|
||||
function debug.setmetatable(value, meta) end
|
||||
|
||||
---
|
||||
---将 `value` 设为函数 `f` 的第 `up` 个上值。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-debug.setupvalue"])
|
||||
---
|
||||
---@param f async fun(...):...
|
||||
---@param up integer
|
||||
---@param value any
|
||||
---@return string name
|
||||
function debug.setupvalue(f, up, value) end
|
||||
|
||||
---
|
||||
---将 `value` 设为 `udata` 的第 `n` 个关联值。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-debug.setuservalue"])
|
||||
---
|
||||
---@param udata userdata
|
||||
---@param value any
|
||||
---@param n? integer
|
||||
---@return userdata udata
|
||||
function debug.setuservalue(udata, value, n) end
|
||||
|
||||
---
|
||||
---返回调用栈的栈回溯信息。 字符串可选项 `message` 被添加在栈回溯信息的开头。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
---
|
||||
---返回指定函数第 `n` 个上值的唯一标识符(一个轻量用户数据)。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-debug.upvalueid"])
|
||||
---
|
||||
---@param f async fun(...):...
|
||||
---@param n integer
|
||||
---@return lightuserdata id
|
||||
---@nodiscard
|
||||
function debug.upvalueid(f, n) end
|
||||
|
||||
---@version >5.2, JIT
|
||||
---
|
||||
---让 Lua 闭包 `f1` 的第 `n1` 个上值 引用 `Lua` 闭包 `f2` 的第 `n2` 个上值。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
@@ -0,0 +1,121 @@
|
||||
---@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
|
||||
@@ -0,0 +1,265 @@
|
||||
---@meta io
|
||||
|
||||
---
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-io"])
|
||||
---
|
||||
---@class iolib
|
||||
---
|
||||
---标准输入。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-io.stdin"])
|
||||
---
|
||||
---@field stdin file*
|
||||
---
|
||||
---标准输出。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-io.stdout"])
|
||||
---
|
||||
---@field stdout file*
|
||||
---
|
||||
---标准错误。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-io.stderr"])
|
||||
---
|
||||
---@field stderr file*
|
||||
io = {}
|
||||
|
||||
---@alias openmode
|
||||
---|>"r" # 读模式。
|
||||
---| "w" # 写模式。
|
||||
---| "a" # 追加模式。
|
||||
---| "r+" # 更新模式,所有之前的数据都保留。
|
||||
---| "w+" # 更新模式,所有之前的数据都删除。
|
||||
---| "a+" # 追加更新模式,所有之前的数据都保留,只允许在文件尾部做写入。
|
||||
---| "rb" # 读模式。(二进制方式)
|
||||
---| "wb" # 写模式。(二进制方式)
|
||||
---| "ab" # 追加模式。(二进制方式)
|
||||
---| "r+b" # 更新模式,所有之前的数据都保留。(二进制方式)
|
||||
---| "w+b" # 更新模式,所有之前的数据都删除。(二进制方式)
|
||||
---| "a+b" # 追加更新模式,所有之前的数据都保留,只允许在文件尾部做写入。(二进制方式)
|
||||
|
||||
---
|
||||
---关闭 `file` 或默认输出文件。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-io.close"])
|
||||
---
|
||||
---@param file? file*
|
||||
---@return boolean? suc
|
||||
---@return exitcode? exitcode
|
||||
---@return integer? code
|
||||
function io.close(file) end
|
||||
|
||||
---
|
||||
---将写入的数据保存到默认输出文件中。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-io.flush"])
|
||||
---
|
||||
function io.flush() end
|
||||
|
||||
---
|
||||
---设置 `file` 为默认输入文件。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-io.input"])
|
||||
---
|
||||
---@overload fun():file*
|
||||
---@param file string|file*
|
||||
function io.input(file) end
|
||||
|
||||
---
|
||||
---------
|
||||
---```lua
|
||||
---for c in io.lines(filename, ...) do
|
||||
--- body
|
||||
---end
|
||||
---```
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-io.lines"])
|
||||
---
|
||||
---@param filename string?
|
||||
---@param ... readmode
|
||||
---@return fun():any, ...
|
||||
function io.lines(filename, ...) end
|
||||
|
||||
---
|
||||
---用字符串 `mode` 指定的模式打开一个文件。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-io.open"])
|
||||
---
|
||||
---@param filename string
|
||||
---@param mode? openmode
|
||||
---@return file*?
|
||||
---@return string? errmsg
|
||||
---@nodiscard
|
||||
function io.open(filename, mode) end
|
||||
|
||||
---
|
||||
---设置 `file` 为默认输出文件。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-io.output"])
|
||||
---
|
||||
---@overload fun():file*
|
||||
---@param file string|file*
|
||||
function io.output(file) end
|
||||
|
||||
---@alias popenmode
|
||||
---| "r" # 从这个程序中读取数据。(二进制方式)
|
||||
---| "w" # 向这个程序写入输入。(二进制方式)
|
||||
|
||||
---
|
||||
---用一个分离进程开启程序 `prog` 。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-io.popen"])
|
||||
---
|
||||
---@param prog string
|
||||
---@param mode? popenmode
|
||||
---@return file*?
|
||||
---@return string? errmsg
|
||||
function io.popen(prog, mode) end
|
||||
|
||||
---
|
||||
---读文件 `file`, 指定的格式决定了要读什么。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-io.read"])
|
||||
---
|
||||
---@param ... readmode
|
||||
---@return any
|
||||
---@return any ...
|
||||
---@nodiscard
|
||||
function io.read(...) end
|
||||
|
||||
---
|
||||
---如果成功,返回一个临时文件的句柄。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-io.tmpfile"])
|
||||
---
|
||||
---@return file*
|
||||
---@nodiscard
|
||||
function io.tmpfile() end
|
||||
|
||||
---@alias filetype
|
||||
---| "file" # 是一个打开的文件句柄。
|
||||
---| "closed file" # 是一个关闭的文件句柄。
|
||||
---| `nil` # 不是文件句柄。
|
||||
|
||||
---
|
||||
---检查 `obj` 是否是合法的文件句柄。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-io.type"])
|
||||
---
|
||||
---@param file file*
|
||||
---@return filetype
|
||||
---@nodiscard
|
||||
function io.type(file) end
|
||||
|
||||
---
|
||||
---将参数的值逐个写入默认输出文件。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-io.write"])
|
||||
---
|
||||
---@return file*
|
||||
---@return string? errmsg
|
||||
function io.write(...) end
|
||||
|
||||
---
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-file"])
|
||||
---
|
||||
---@class file*
|
||||
local file = {}
|
||||
|
||||
---@alias readmode integer|string
|
||||
---| "n" # 读取一个数字,根据 Lua 的转换文法返回浮点数或整数。
|
||||
---| "a" # 从当前位置开始读取整个文件。
|
||||
---|>"l" # 读取一行并忽略行结束标记。
|
||||
---| "L" # 读取一行并保留行结束标记。
|
||||
|
||||
---@alias exitcode "exit"|"signal"
|
||||
|
||||
---
|
||||
---关闭 `file`。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-file:close"])
|
||||
---
|
||||
---@return boolean? suc
|
||||
---@return exitcode? exitcode
|
||||
---@return integer? code
|
||||
function file:close() end
|
||||
|
||||
---
|
||||
---将写入的数据保存到 `file` 中。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-file:flush"])
|
||||
---
|
||||
function file:flush() end
|
||||
|
||||
---
|
||||
---------
|
||||
---```lua
|
||||
---for c in file:lines(...) do
|
||||
--- body
|
||||
---end
|
||||
---```
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-file:lines"])
|
||||
---
|
||||
---@param ... readmode
|
||||
---@return fun():any, ...
|
||||
function file:lines(...) end
|
||||
|
||||
---
|
||||
---读文件 `file`, 指定的格式决定了要读什么。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-file:read"])
|
||||
---
|
||||
---@param ... readmode
|
||||
---@return any
|
||||
---@return any ...
|
||||
---@nodiscard
|
||||
function file:read(...) end
|
||||
|
||||
---@alias seekwhence
|
||||
---| "set" # 基点为 0 (文件开头)。
|
||||
---|>"cur" # 基点为当前位置。
|
||||
---| "end" # 基点为文件尾。
|
||||
|
||||
---
|
||||
---设置及获取基于文件开头处计算出的位置。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-file:seek"])
|
||||
---
|
||||
---@param whence? seekwhence
|
||||
---@param offset? integer
|
||||
---@return integer offset
|
||||
---@return string? errmsg
|
||||
function file:seek(whence, offset) end
|
||||
|
||||
---@alias vbuf
|
||||
---| "no" # 不缓冲;输出操作立刻生效。
|
||||
---| "full" # 完全缓冲;只有在缓存满或调用 flush 时才做输出操作。
|
||||
---| "line" # 行缓冲;输出将缓冲到每次换行前。
|
||||
|
||||
---
|
||||
---设置输出文件的缓冲模式。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-file:setvbuf"])
|
||||
---
|
||||
---@param mode vbuf
|
||||
---@param size? integer
|
||||
function file:setvbuf(mode, size) end
|
||||
|
||||
---
|
||||
---将参数的值逐个写入 `file`。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-file:write"])
|
||||
---
|
||||
---@param ... string|number
|
||||
---@return file*?
|
||||
---@return string? errmsg
|
||||
function file:write(...) end
|
||||
|
||||
return io
|
||||
@@ -0,0 +1,42 @@
|
||||
---@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
|
||||
@@ -0,0 +1,19 @@
|
||||
---@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
|
||||
@@ -0,0 +1,119 @@
|
||||
---@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
|
||||
@@ -0,0 +1,381 @@
|
||||
---@meta math
|
||||
|
||||
---
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math"])
|
||||
---
|
||||
---@class mathlib
|
||||
---
|
||||
---一个比任何数字值都大的浮点数。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.huge"])
|
||||
---
|
||||
---@field huge number
|
||||
---
|
||||
---Miss locale <math.maxinteger>
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.maxinteger"])
|
||||
---
|
||||
---@field maxinteger integer
|
||||
---
|
||||
---Miss locale <math.mininteger>
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.mininteger"])
|
||||
---
|
||||
---@field mininteger integer
|
||||
---
|
||||
---*π* 的值。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.pi"])
|
||||
---
|
||||
---@field pi number
|
||||
math = {}
|
||||
|
||||
---
|
||||
---返回 `x` 的绝对值。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.abs"])
|
||||
---
|
||||
---@generic Number: number
|
||||
---@param x Number
|
||||
---@return Number
|
||||
---@nodiscard
|
||||
function math.abs(x) end
|
||||
|
||||
---
|
||||
---返回 `x` 的反余弦值(用弧度表示)。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.acos"])
|
||||
---
|
||||
---@param x number
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.acos(x) end
|
||||
|
||||
---
|
||||
---返回 `x` 的反正弦值(用弧度表示)。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.asin"])
|
||||
---
|
||||
---@param x number
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.asin(x) end
|
||||
|
||||
---
|
||||
---返回 `y/x` 的反正切值(用弧度表示)。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.atan"])
|
||||
---
|
||||
---@param y number
|
||||
---@param x? number
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.atan(y, x) end
|
||||
|
||||
---@version <5.2
|
||||
---
|
||||
---返回 `y/x` 的反正切值(用弧度表示)。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.atan2"])
|
||||
---
|
||||
---@param y number
|
||||
---@param x number
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.atan2(y, x) end
|
||||
|
||||
---
|
||||
---返回不小于 `x` 的最小整数值。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.ceil"])
|
||||
---
|
||||
---@param x number
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
function math.ceil(x) end
|
||||
|
||||
---
|
||||
---返回 `x` 的余弦(假定参数是弧度)。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.cos"])
|
||||
---
|
||||
---@param x number
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.cos(x) end
|
||||
|
||||
---@version <5.2
|
||||
---
|
||||
---返回 `x` 的双曲余弦(假定参数是弧度)。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.cosh"])
|
||||
---
|
||||
---@param x number
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.cosh(x) end
|
||||
|
||||
---
|
||||
---将角 `x` 从弧度转换为角度。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.deg"])
|
||||
---
|
||||
---@param x number
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.deg(x) end
|
||||
|
||||
---
|
||||
---返回 `e^x` 的值 (e 为自然对数的底)。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.exp"])
|
||||
---
|
||||
---@param x number
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.exp(x) end
|
||||
|
||||
---
|
||||
---返回不大于 `x` 的最大整数值。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.floor"])
|
||||
---
|
||||
---@param x number
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
function math.floor(x) end
|
||||
|
||||
---
|
||||
---返回 `x` 除以 `y`,将商向零圆整后的余数。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.fmod"])
|
||||
---
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.fmod(x, y) end
|
||||
|
||||
---@version <5.2
|
||||
---
|
||||
---将 `x` 分解为尾数与指数,返回值符合 `x = m * (2 ^ e)` 。`e` 是一个整数,`m` 是 [0.5, 1) 之间的规格化小数 (`x` 为0时 `m` 为0)。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.frexp"])
|
||||
---
|
||||
---@param x number
|
||||
---@return number m
|
||||
---@return number e
|
||||
---@nodiscard
|
||||
function math.frexp(x) end
|
||||
|
||||
---@version <5.2
|
||||
---
|
||||
---返回 `m * (2 ^ e)` 。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.ldexp"])
|
||||
---
|
||||
---@param m number
|
||||
---@param e number
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.ldexp(m, e) end
|
||||
|
||||
---
|
||||
---回以指定底的 `x` 的对数。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.log"])
|
||||
---
|
||||
---@param x number
|
||||
---@param base? integer
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.log(x, base) end
|
||||
|
||||
---@version <5.1
|
||||
---
|
||||
---返回 `x` 的以10为底的对数。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.log10"])
|
||||
---
|
||||
---@param x number
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.log10(x) end
|
||||
|
||||
---
|
||||
---返回参数中最大的值, 大小由 Lua 操作 `<` 决定。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.max"])
|
||||
---
|
||||
---@generic Number: number
|
||||
---@param x Number
|
||||
---@param ... Number
|
||||
---@return Number
|
||||
---@nodiscard
|
||||
function math.max(x, ...) end
|
||||
|
||||
---
|
||||
---返回参数中最小的值, 大小由 Lua 操作 `<` 决定。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.min"])
|
||||
---
|
||||
---@generic Number: number
|
||||
---@param x Number
|
||||
---@param ... Number
|
||||
---@return Number
|
||||
---@nodiscard
|
||||
function math.min(x, ...) end
|
||||
|
||||
---
|
||||
---返回 `x` 的整数部分和小数部分。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.modf"])
|
||||
---
|
||||
---@param x number
|
||||
---@return integer
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.modf(x) end
|
||||
|
||||
---@version <5.2
|
||||
---
|
||||
---返回 `x ^ y` 。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.pow"])
|
||||
---
|
||||
---@param x number
|
||||
---@param y number
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.pow(x, y) end
|
||||
|
||||
---
|
||||
---将角 `x` 从角度转换为弧度。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.rad"])
|
||||
---
|
||||
---@param x number
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.rad(x) end
|
||||
|
||||
---
|
||||
---* `math.random()`: 返回 [0,1) 区间内一致分布的浮点伪随机数。
|
||||
---* `math.random(n)`: 返回 [1, n] 区间内一致分布的整数伪随机数。
|
||||
---* `math.random(m, n)`: 返回 [m, n] 区间内一致分布的整数伪随机数。
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
|
||||
---
|
||||
---* `math.randomseed(x, y)`: 将 `x` 与 `y` 连接为128位的种子来重新初始化伪随机生成器。
|
||||
---* `math.randomseed(x)`: 等同于 `math.randomseed(x, 0)` 。
|
||||
---* `math.randomseed()`: Generates a seed with a weak attempt for randomness.(不会翻)
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.randomseed"])
|
||||
---
|
||||
---@param x? integer
|
||||
---@param y? integer
|
||||
function math.randomseed(x, y) end
|
||||
|
||||
---
|
||||
---返回 `x` 的正弦值(假定参数是弧度)。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.sin"])
|
||||
---
|
||||
---@param x number
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.sin(x) end
|
||||
|
||||
---@version <5.2
|
||||
---
|
||||
---返回 `x` 的双曲正弦值(假定参数是弧度)。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.sinh"])
|
||||
---
|
||||
---@param x number
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.sinh(x) end
|
||||
|
||||
---
|
||||
---返回 `x` 的平方根。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.sqrt"])
|
||||
---
|
||||
---@param x number
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.sqrt(x) end
|
||||
|
||||
---
|
||||
---返回 `x` 的正切值(假定参数是弧度)。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.tan"])
|
||||
---
|
||||
---@param x number
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.tan(x) end
|
||||
|
||||
---@version <5.2
|
||||
---
|
||||
---返回 `x` 的双曲正切值(假定参数是弧度)。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.tanh"])
|
||||
---
|
||||
---@param x number
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function math.tanh(x) end
|
||||
|
||||
---@version >5.3
|
||||
---
|
||||
---Miss locale <math.tointeger>
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.tointeger"])
|
||||
---
|
||||
---@param x any
|
||||
---@return integer?
|
||||
---@nodiscard
|
||||
function math.tointeger(x) end
|
||||
|
||||
---@version >5.3
|
||||
---
|
||||
---Miss locale <math.type>
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.type"])
|
||||
---
|
||||
---@param x any
|
||||
---@return
|
||||
---| '"integer"'
|
||||
---| '"float"'
|
||||
---| 'nil'
|
||||
---@nodiscard
|
||||
function math.type(x) end
|
||||
|
||||
---@version >5.3
|
||||
---
|
||||
---Miss locale <math.ult>
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-math.ult"])
|
||||
---
|
||||
---@param m integer
|
||||
---@param n integer
|
||||
---@return boolean
|
||||
---@nodiscard
|
||||
function math.ult(m, n) end
|
||||
|
||||
return math
|
||||
@@ -0,0 +1,242 @@
|
||||
---@meta os
|
||||
|
||||
---
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-os"])
|
||||
---
|
||||
---@class oslib
|
||||
os = {}
|
||||
|
||||
---
|
||||
---返回程序使用的按秒计 CPU 时间的近似值。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-os.clock"])
|
||||
---
|
||||
---@return number
|
||||
---@nodiscard
|
||||
function os.clock() end
|
||||
|
||||
---@class osdate:osdateparam
|
||||
---
|
||||
---四位数字
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-osdate.year"])
|
||||
---
|
||||
---@field year integer|string
|
||||
---
|
||||
---1-12
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-osdate.month"])
|
||||
---
|
||||
---@field month integer|string
|
||||
---
|
||||
---1-31
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-osdate.day"])
|
||||
---
|
||||
---@field day integer|string
|
||||
---
|
||||
---0-23
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-osdate.hour"])
|
||||
---
|
||||
---@field hour integer|string
|
||||
---
|
||||
---0-59
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-osdate.min"])
|
||||
---
|
||||
---@field min integer|string
|
||||
---
|
||||
---0-61
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-osdate.sec"])
|
||||
---
|
||||
---@field sec integer|string
|
||||
---
|
||||
---星期几,1-7,星期天为 1
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-osdate.wday"])
|
||||
---
|
||||
---@field wday integer|string
|
||||
---
|
||||
---当年的第几天,1-366
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-osdate.yday"])
|
||||
---
|
||||
---@field yday integer|string
|
||||
---
|
||||
---夏令时标记,一个布尔量
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-osdate.isdst"])
|
||||
---
|
||||
---@field isdst boolean
|
||||
|
||||
---
|
||||
---返回一个包含日期及时刻的字符串或表。 格式化方法取决于所给字符串 `format`。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-os.date"])
|
||||
---
|
||||
---@param format? string
|
||||
---@param time? integer
|
||||
---@return string|osdate
|
||||
---@nodiscard
|
||||
function os.date(format, time) end
|
||||
|
||||
---
|
||||
---返回以秒计算的时刻 `t1` 到 `t2` 的差值。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-os.difftime"])
|
||||
---
|
||||
---@param t2 integer
|
||||
---@param t1 integer
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
function os.difftime(t2, t1) end
|
||||
|
||||
---
|
||||
---调用系统解释器执行 `command`。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-os.execute"])
|
||||
---
|
||||
---@param command? string
|
||||
---@return boolean? suc
|
||||
---@return exitcode? exitcode
|
||||
---@return integer? code
|
||||
function os.execute(command) end
|
||||
|
||||
---
|
||||
---调用 ISO C 函数 `exit` 终止宿主程序。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-os.exit"])
|
||||
---
|
||||
---@param code? boolean|integer
|
||||
---@param close? boolean
|
||||
function os.exit(code, close) end
|
||||
|
||||
---
|
||||
---返回进程环境变量 `varname` 的值。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-os.getenv"])
|
||||
---
|
||||
---@param varname string
|
||||
---@return string?
|
||||
---@nodiscard
|
||||
function os.getenv(varname) end
|
||||
|
||||
---
|
||||
---删除指定名字的文件。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-os.remove"])
|
||||
---
|
||||
---@param filename string
|
||||
---@return boolean suc
|
||||
---@return string? errmsg
|
||||
function os.remove(filename) end
|
||||
|
||||
---
|
||||
---将名字为 `oldname` 的文件或目录更名为 `newname`。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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"
|
||||
|
||||
---
|
||||
---设置程序的当前区域。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-os.setlocale"])
|
||||
---
|
||||
---@param locale string|nil
|
||||
---@param category? localecategory
|
||||
---@return string localecategory
|
||||
function os.setlocale(locale, category) end
|
||||
|
||||
---@class osdateparam
|
||||
---
|
||||
---四位数字
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-osdate.year"])
|
||||
---
|
||||
---@field year integer|string
|
||||
---
|
||||
---1-12
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-osdate.month"])
|
||||
---
|
||||
---@field month integer|string
|
||||
---
|
||||
---1-31
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-osdate.day"])
|
||||
---
|
||||
---@field day integer|string
|
||||
---
|
||||
---0-23
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-osdate.hour"])
|
||||
---
|
||||
---@field hour (integer|string)?
|
||||
---
|
||||
---0-59
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-osdate.min"])
|
||||
---
|
||||
---@field min (integer|string)?
|
||||
---
|
||||
---0-61
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-osdate.sec"])
|
||||
---
|
||||
---@field sec (integer|string)?
|
||||
---
|
||||
---星期几,1-7,星期天为 1
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-osdate.wday"])
|
||||
---
|
||||
---@field wday (integer|string)?
|
||||
---
|
||||
---当年的第几天,1-366
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-osdate.yday"])
|
||||
---
|
||||
---@field yday (integer|string)?
|
||||
---
|
||||
---夏令时标记,一个布尔量
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-osdate.isdst"])
|
||||
---
|
||||
---@field isdst boolean?
|
||||
|
||||
---
|
||||
---当不传参数时,返回当前时刻。 如果传入一张表,就返回由这张表表示的时刻。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-os.time"])
|
||||
---
|
||||
---@param date? osdateparam
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
function os.time(date) end
|
||||
|
||||
---
|
||||
---返回一个可用于临时文件的文件名字符串。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-os.tmpname"])
|
||||
---
|
||||
---@return string
|
||||
---@nodiscard
|
||||
function os.tmpname() end
|
||||
|
||||
return os
|
||||
@@ -0,0 +1,107 @@
|
||||
---@meta package
|
||||
|
||||
---
|
||||
---加载一个模块,返回该模块的返回值(`nil`时为`true`)与搜索器返回的加载数据。默认搜索器的加载数据指示了加载位置,对于文件来说就是文件路径。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-require"])
|
||||
---
|
||||
---@param modname string
|
||||
---@return unknown
|
||||
---@return unknown loaderdata
|
||||
function require(modname) end
|
||||
|
||||
---
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-package"])
|
||||
---
|
||||
---@class packagelib
|
||||
---
|
||||
---这个路径被 `require` 在 C 加载器中做搜索时用到。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-package.cpath"])
|
||||
---
|
||||
---@field cpath string
|
||||
---
|
||||
---用于 `require` 控制哪些模块已经被加载的表。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-package.loaded"])
|
||||
---
|
||||
---@field loaded table
|
||||
---
|
||||
---这个路径被 `require` 在 Lua 加载器中做搜索时用到。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-package.path"])
|
||||
---
|
||||
---@field path string
|
||||
---
|
||||
---保存有一些特殊模块的加载器。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-package.preload"])
|
||||
---
|
||||
---@field preload table
|
||||
package = {}
|
||||
|
||||
---
|
||||
---一个描述有一些为包管理准备的编译期配置信息的串。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-package.config"])
|
||||
---
|
||||
package.config = [[
|
||||
/
|
||||
;
|
||||
?
|
||||
!
|
||||
-]]
|
||||
|
||||
---@version <5.1
|
||||
---
|
||||
---用于 `require` 控制如何加载模块的表。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-package.loaders"])
|
||||
---
|
||||
package.loaders = {}
|
||||
|
||||
---
|
||||
---让宿主程序动态链接 C 库 `libname` 。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-package.loadlib"])
|
||||
---
|
||||
---@param libname string
|
||||
---@param funcname string
|
||||
---@return any
|
||||
function package.loadlib(libname, funcname) end
|
||||
|
||||
---
|
||||
---用于 `require` 控制如何加载模块的表。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-package.searchers"])
|
||||
---
|
||||
---@version >5.2
|
||||
package.searchers = {}
|
||||
|
||||
---
|
||||
---在指定 `path` 中搜索指定的 `name` 。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
|
||||
---
|
||||
---给 `module` 设置一个元表,该元表的 `__index` 域为全局环境,这样模块便会继承全局环境的值。可作为 `module` 函数的选项。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-package.seeall"])
|
||||
---
|
||||
---@version <5.1
|
||||
---@param module table
|
||||
function package.seeall(module) end
|
||||
|
||||
return package
|
||||
@@ -0,0 +1,219 @@
|
||||
---@meta string
|
||||
|
||||
---
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-string"])
|
||||
---
|
||||
---@class stringlib
|
||||
string = {}
|
||||
|
||||
---
|
||||
---返回字符 `s[i]`, `s[i+1]`, ... ,`s[j]` 的内部数字编码。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-string.byte"])
|
||||
---
|
||||
---@param s string|number
|
||||
---@param i? integer
|
||||
---@param j? integer
|
||||
---@return integer ...
|
||||
---@nodiscard
|
||||
function string.byte(s, i, j) end
|
||||
|
||||
---
|
||||
---接收零或更多的整数。 返回和参数数量相同长度的字符串。 其中每个字符的内部编码值等于对应的参数值。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-string.char"])
|
||||
---
|
||||
---@param byte integer
|
||||
---@param ... integer
|
||||
---@return string
|
||||
---@nodiscard
|
||||
function string.char(byte, ...) end
|
||||
|
||||
---
|
||||
---返回包含有以二进制方式表示的(一个 *二进制代码块* )指定函数的字符串。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-string.dump"])
|
||||
---
|
||||
---@param f async fun(...):...
|
||||
---@param strip? boolean
|
||||
---@return string
|
||||
---@nodiscard
|
||||
function string.dump(f, strip) end
|
||||
|
||||
---
|
||||
---查找第一个字符串中匹配到的 `pattern`(参见 [§6.4.1](command:extension.lua.doc?["en-us/54/manual.html/6.4.1"]))。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
|
||||
---
|
||||
---返回不定数量参数的格式化版本,格式化串为第一个参数。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-string.format"])
|
||||
---
|
||||
---@param s string|number
|
||||
---@param ... any
|
||||
---@return string
|
||||
---@nodiscard
|
||||
function string.format(s, ...) end
|
||||
|
||||
---
|
||||
---返回一个迭代器函数。 每次调用这个函数都会继续以 `pattern` (参见 [§6.4.1](command:extension.lua.doc?["en-us/54/manual.html/6.4.1"])) 对 s 做匹配,并返回所有捕获到的值。
|
||||
---
|
||||
---下面这个例子会循环迭代字符串 s 中所有的单词, 并逐行打印:
|
||||
---```lua
|
||||
--- s =
|
||||
---"hello world from Lua"
|
||||
--- for w in string.gmatch(s, "%a+") do
|
||||
--- print(w)
|
||||
--- end
|
||||
---```
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-string.gmatch"])
|
||||
---
|
||||
---@param s string|number
|
||||
---@param pattern string|number
|
||||
---@param init? integer
|
||||
---@return fun():string, ...
|
||||
function string.gmatch(s, pattern, init) end
|
||||
|
||||
---
|
||||
---将字符串 s 中,所有的(或是在 n 给出时的前 n 个) pattern (参见 [§6.4.1](command:extension.lua.doc?["en-us/54/manual.html/6.4.1"]))都替换成 repl ,并返回其副本。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
|
||||
---
|
||||
---返回其长度。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-string.len"])
|
||||
---
|
||||
---@param s string|number
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
function string.len(s) end
|
||||
|
||||
---
|
||||
---将其中的大写字符都转为小写后返回其副本。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-string.lower"])
|
||||
---
|
||||
---@param s string|number
|
||||
---@return string
|
||||
---@nodiscard
|
||||
function string.lower(s) end
|
||||
|
||||
---
|
||||
---在字符串 s 中找到第一个能用 pattern (参见 [§6.4.1](command:extension.lua.doc?["en-us/54/manual.html/6.4.1"]))匹配到的部分。 如果能找到,match 返回其中的捕获物; 否则返回 nil 。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
---
|
||||
---返回一个打包了(即以二进制形式序列化) v1, v2 等值的二进制字符串。 字符串 fmt 为打包格式(参见 [§6.4.2](command:extension.lua.doc?["en-us/54/manual.html/6.4.2"]))。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
---
|
||||
---返回以指定格式用 [string.pack](command:extension.lua.doc?["en-us/54/manual.html/pdf-string.pack"]) 打包的字符串的长度。 格式化字符串中不可以有变长选项 's' 或 'z' (参见 [§6.4.2](command:extension.lua.doc?["en-us/54/manual.html/6.4.2"]))。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-string.packsize"])
|
||||
---
|
||||
---@param fmt string
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
function string.packsize(fmt) end
|
||||
|
||||
---
|
||||
---返回 `n` 个字符串 `s` 以字符串 `sep` 为分割符连在一起的字符串。 默认的 `sep` 值为空字符串(即没有分割符)。 如果 `n` 不是正数则返回空串。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-string.rep"])
|
||||
---
|
||||
---@param s string|number
|
||||
---@param n integer
|
||||
---@param sep? string|number
|
||||
---@return string
|
||||
---@nodiscard
|
||||
function string.rep(s, n, sep) end
|
||||
|
||||
---
|
||||
---返回字符串 s 的翻转串。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-string.reverse"])
|
||||
---
|
||||
---@param s string|number
|
||||
---@return string
|
||||
---@nodiscard
|
||||
function string.reverse(s) end
|
||||
|
||||
---
|
||||
---返回字符串的子串, 该子串从 `i` 开始到 `j` 为止。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
---
|
||||
---返回以格式 fmt (参见 [§6.4.2](command:extension.lua.doc?["en-us/54/manual.html/6.4.2"])) 打包在字符串 s (参见 string.pack) 中的值。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-string.unpack"])
|
||||
---
|
||||
---@param fmt string
|
||||
---@param s string
|
||||
---@param pos? integer
|
||||
---@return any ...
|
||||
---@nodiscard
|
||||
function string.unpack(fmt, s, pos) end
|
||||
|
||||
---
|
||||
---接收一个字符串,将其中的小写字符都转为大写后返回其副本。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-string.upper"])
|
||||
---
|
||||
---@param s string|number
|
||||
---@return string
|
||||
---@nodiscard
|
||||
function string.upper(s) end
|
||||
|
||||
return string
|
||||
@@ -0,0 +1,353 @@
|
||||
---@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
|
||||
@@ -0,0 +1,165 @@
|
||||
---@meta table
|
||||
|
||||
---
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-table"])
|
||||
---
|
||||
---@class tablelib
|
||||
table = {}
|
||||
|
||||
---
|
||||
---提供一个列表,其所有元素都是字符串或数字,返回字符串 `list[i]..sep..list[i+1] ··· sep..list[j]`。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
|
||||
---
|
||||
---在 `list` 的位置 `pos` 处插入元素 `value`。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
---
|
||||
---返回给定表的最大正数索引,如果表没有正数索引,则返回零。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-table.maxn"])
|
||||
---
|
||||
---@param table table
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
function table.maxn(table) end
|
||||
|
||||
---@version >5.3, JIT
|
||||
---
|
||||
---将元素从表 `a1` 移到表 `a2`。
|
||||
---```lua
|
||||
---a2[t],··· =
|
||||
---a1[f],···,a1[e]
|
||||
---return a2
|
||||
---```
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
---
|
||||
---返回用所有参数以键 `1`,`2`, 等填充的新表, 并将 `"n"` 这个域设为参数的总数。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-table.pack"])
|
||||
---
|
||||
---@return table
|
||||
---@nodiscard
|
||||
function table.pack(...) end
|
||||
|
||||
---
|
||||
---移除 `list` 中 `pos` 位置上的元素,并返回这个被移除的值。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-table.remove"])
|
||||
---
|
||||
---@param list table
|
||||
---@param pos? integer
|
||||
---@return any
|
||||
function table.remove(list, pos) end
|
||||
|
||||
---
|
||||
---在表内从 `list[1]` 到 `list[#list]` *原地* 对其间元素按指定次序排序。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
---
|
||||
---返回列表中的元素。 这个函数等价于
|
||||
---```lua
|
||||
--- return list[i], list[i+1], ···, list[j]
|
||||
---```
|
||||
---i 默认为 1 ,j 默认为 #list。
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
---
|
||||
---遍历表中的每一个元素,并以key和value执行回调函数。如果回调函数返回一个非nil值则循环终止,并且返回这个值。该函数等同pair(list),比pair(list)更慢。不推荐使用
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
---
|
||||
---遍历数组中的每一个元素,并以索引号index和value执行回调函数。如果回调函数返回一个非nil值则循环终止,并且返回这个值。该函数等同ipair(list),比ipair(list)更慢。不推荐使用
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-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
|
||||
---
|
||||
---返回表的长度。该函数等价于#list。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-table.getn"])
|
||||
---
|
||||
---@generic T
|
||||
---@param list T[]
|
||||
---@return integer
|
||||
---@nodiscard
|
||||
---@deprecated
|
||||
function table.getn(list) end
|
||||
|
||||
return table
|
||||
@@ -0,0 +1,17 @@
|
||||
---@meta table.clear
|
||||
|
||||
---@version JIT
|
||||
---
|
||||
---清除表中所有的键值对,但是保留已经分配的数组或哈希的大小。当需要清除从多个位置链接的表和/或回收表供同一上下文使用时,这将十分有用。这避免了管理反向链接,节省了分配和增量数组或哈希部分增长的开销。在使用前需要先引入。
|
||||
---```lua
|
||||
--- require("table.clear").
|
||||
---```
|
||||
---请注意,此功能用于非常特殊的情况。在大多数情况下,最好用新表替换(通常是单个)链接,GC 完成回收工作。
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-table.clear"])
|
||||
---
|
||||
---@param tab table
|
||||
local function clear(tab) end
|
||||
|
||||
return clear
|
||||
@@ -0,0 +1,19 @@
|
||||
---@meta table.new
|
||||
|
||||
---@version JIT
|
||||
---
|
||||
---创建一个有初始容量的表,就像 C API 等价于 `lua_createtable()`。对于数据量庞大的表,如果最终的容量是已知的,这将十分有用,因为动态对表进行扩容是十分昂贵的。`narray` 参数指定类数组成员的数量,`nhash` 参数指定类哈希成员的数量。在使用前需要先引入。
|
||||
---
|
||||
---```lua
|
||||
--- require("table.new")
|
||||
---```
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-table.new"])
|
||||
---
|
||||
---@param narray integer
|
||||
---@param nhash integer
|
||||
---@return table
|
||||
local function new(narray, nhash) end
|
||||
|
||||
return new
|
||||
@@ -0,0 +1,86 @@
|
||||
---@meta utf8
|
||||
|
||||
---@version >5.3
|
||||
---
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-utf8"])
|
||||
---
|
||||
---@class utf8lib
|
||||
---
|
||||
---用于精确匹配到一个 UTF-8 字节序列的模式,它假定处理的对象是一个合法的 UTF-8 字符串。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-utf8.charpattern"])
|
||||
---
|
||||
---@field charpattern string
|
||||
utf8 = {}
|
||||
|
||||
---
|
||||
---接收零或多个整数, 将每个整数转换成对应的 UTF-8 字节序列,并返回这些序列连接到一起的字符串。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-utf8.char"])
|
||||
---
|
||||
---@param code integer
|
||||
---@param ... integer
|
||||
---@return string
|
||||
---@nodiscard
|
||||
function utf8.char(code, ...) end
|
||||
|
||||
---
|
||||
---返回一系列的值,可以让
|
||||
---```lua
|
||||
---for p, c in utf8.codes(s) do
|
||||
--- body
|
||||
---end
|
||||
---```
|
||||
---迭代出字符串 s 中所有的字符。 这里的 p 是位置(按字节数)而 c 是每个字符的编号。 如果处理到一个不合法的字节序列,将抛出一个错误。
|
||||
---
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-utf8.codes"])
|
||||
---
|
||||
---@param s string
|
||||
---@param lax? boolean
|
||||
---@return fun(s: string, p: integer):integer, integer
|
||||
function utf8.codes(s, lax) end
|
||||
|
||||
---
|
||||
---以整数形式返回 `s` 中 从位置 `i` 到 `j` 间(包括两端) 所有字符的编号。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-utf8.codepoint"])
|
||||
---
|
||||
---@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
|
||||
|
||||
---
|
||||
---返回字符串 `s` 中 从位置 `i` 到 `j` 间 (包括两端) UTF-8 字符的个数。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-utf8.len"])
|
||||
---
|
||||
---@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
|
||||
|
||||
---
|
||||
---返回编码在 `s` 中的第 `n` 个字符的开始位置(按字节数) (从位置 `i` 处开始统计)。
|
||||
---
|
||||
---[查看文档](command:extension.lua.doc?["en-us/54/manual.html/pdf-utf8.offset"])
|
||||
---
|
||||
---@param s string
|
||||
---@param n integer
|
||||
---@param i? integer
|
||||
---@return integer p
|
||||
---@nodiscard
|
||||
function utf8.offset(s, n, i) end
|
||||
|
||||
return utf8
|
||||
Reference in New Issue
Block a user