summaryrefslogtreecommitdiff
path: root/meta/3rd/OpenResty
diff options
context:
space:
mode:
authorMichael Martin <flrgh@protonmail.com>2021-12-21 18:12:20 -0800
committerMichael Martin <flrgh@protonmail.com>2021-12-21 18:12:20 -0800
commit17da081e1abf752b79eab76067c27f738fccb927 (patch)
tree7e67428de22b07885403c61e748d8880b4b9eb36 /meta/3rd/OpenResty
parent20912f9febfa3c6cea4c11379425971a5b4de7bf (diff)
downloadlua-language-server-17da081e1abf752b79eab76067c27f738fccb927.zip
chore: add more luajit annotations from https://github.com/openresty/luajit2
Diffstat (limited to 'meta/3rd/OpenResty')
-rw-r--r--meta/3rd/OpenResty/library/jit.lua32
-rw-r--r--meta/3rd/OpenResty/library/thread.exdata.lua44
-rw-r--r--meta/3rd/OpenResty/library/thread.exdata2.lua8
3 files changed, 82 insertions, 2 deletions
diff --git a/meta/3rd/OpenResty/library/jit.lua b/meta/3rd/OpenResty/library/jit.lua
new file mode 100644
index 00000000..1adb40fa
--- /dev/null
+++ b/meta/3rd/OpenResty/library/jit.lua
@@ -0,0 +1,32 @@
+---@meta
+
+
+--- Returns (and optionally sets) the current PRNG state (an array of 8 Lua
+--- numbers with 32-bit integer values) currently used by the JIT compiler.
+---
+--- When the `state` argument is non-nil, it is expected to be an array of up to 8
+--- unsigned Lua numbers, each with value less than 2\*\*32-1. This will set the
+--- current PRNG state and return the state that was overridden.
+---
+--- **Note:** For backward compatibility, `state` argument can also be an unsigned
+--- Lua number less than 2\*\*32-1.
+---
+--- **Note:** When the `state` argument is an array and less than 8 numbers, or the
+--- `state` is a number, the remaining positions are filled with zeros.
+---
+--- Usage:
+---
+--- ```lua
+--- local state = jit.prngstate()
+--- local oldstate = jit.prngstate{ a, b, c, ... }
+---
+--- jit.prngstate(32) -- {32, 0, 0, 0, 0, 0, 0, 0}
+--- jit.prngstate{432, 23, 50} -- {432, 23, 50, 0, 0, 0, 0, 0}
+--- ```
+---
+--- **Note:** This API has no effect if LuaJIT is compiled with
+--- `-DLUAJIT_DISABLE_JIT`, and will return a table with all `0`.
+---
+---@param state? integer[]
+---@return integer[] state
+function jit.prngstate(state) end
diff --git a/meta/3rd/OpenResty/library/thread.exdata.lua b/meta/3rd/OpenResty/library/thread.exdata.lua
index cdd657c6..22573d84 100644
--- a/meta/3rd/OpenResty/library/thread.exdata.lua
+++ b/meta/3rd/OpenResty/library/thread.exdata.lua
@@ -1,3 +1,43 @@
---@meta
-function thread_exdata() end
-return thread_exdata \ No newline at end of file
+
+--- **syntax:** *exdata = th_exdata(data?)*
+---
+--- This API allows for embedding user data into a thread (`lua_State`).
+---
+--- The retrieved `exdata` value on the Lua land is represented as a cdata object
+--- of the ctype `void*`.
+---
+--- As of this version, retrieving the `exdata` (i.e. `th_exdata()` without any
+--- argument) can be JIT compiled.
+---
+--- Usage:
+---
+--- ```lua
+--- local th_exdata = require "thread.exdata"
+---
+--- th_exdata(0xdeadbeefLL) -- set the exdata of the current Lua thread
+--- local exdata = th_exdata() -- fetch the exdata of the current Lua thread
+--- ```
+---
+--- Also available are the following public C API functions for manipulating
+--- `exdata` on the C land:
+---
+--- ```C
+--- void lua_setexdata(lua_State *L, void *exdata);
+--- void *lua_getexdata(lua_State *L);
+--- ```
+---
+--- The `exdata` pointer is initialized to `NULL` when the main thread is created.
+--- Any child Lua thread will inherit its parent's `exdata`, but still can override
+--- it.
+---
+--- **Note:** This API will not be available if LuaJIT is compiled with
+--- `-DLUAJIT_DISABLE_FFI`.
+---
+--- **Note bis:** This API is used internally by the OpenResty core, and it is
+--- strongly discouraged to use it yourself in the context of OpenResty.
+---@param data? any
+---@return any? data
+local function exdata(data) end
+
+return exdata \ No newline at end of file
diff --git a/meta/3rd/OpenResty/library/thread.exdata2.lua b/meta/3rd/OpenResty/library/thread.exdata2.lua
new file mode 100644
index 00000000..0387849d
--- /dev/null
+++ b/meta/3rd/OpenResty/library/thread.exdata2.lua
@@ -0,0 +1,8 @@
+---@meta
+
+--- Similar to `thread.exdata` but for a 2nd separate user data as a pointer value.
+---@param data? any
+---@return any? data
+local function exdata2(data) end
+
+return exdata2