Module lua/utils¶
-
void *
luaL_pushcdata
(struct lua_State *L, uint32_t ctypeid)¶ Push cdata of given
ctypeid
onto the stack.CTypeID must be used from FFI at least once. Allocated memory returned uninitialized. Only numbers and pointers are supported.
Parameters: - L (lua_State*) – Lua State
- ctypeid (uint32_t) – FFI’s CTypeID of this cdata
Returns: memory associated with this cdata
See also: luaL_checkcdata()
-
void *
luaL_checkcdata
(struct lua_State *L, int idx, uint32_t *ctypeid)¶ Checks whether the function argument
idx
is a cdataParameters: - L (lua_State*) – Lua State
- idx (int) – stack index
- ctypeid (uint32_t*) – output argument. FFI’s CTypeID of returned cdata
Returns: memory associated with this cdata
See also: luaL_pushcdata()
-
void
luaL_setcdatagc
(struct lua_State *L, int idx)¶ Sets finalizer function on a cdata object.
Equivalent to call ffi.gc(obj, function). Finalizer function must be on the top of the stack.
Parameters: - L (lua_State*) – Lua State
- idx (int) – stack index
-
uint32_t
luaL_ctypeid
(struct lua_State *L, const char *ctypename)¶ Return CTypeID (FFI) of given СDATA type
Parameters: - L (lua_State*) – Lua State
- char* ctypename (const) – C type name as string (e.g. “struct request” or “uint32_t”)
Returns: CTypeID
See also: luaL_pushcdata(), luaL_checkcdata()
-
int
luaL_cdef
(struct lua_State *L, const char *ctypename)¶ Declare symbols for FFI
Parameters: - L (lua_State*) – Lua State
- char* ctypename (const) – C definitions (e.g. “struct stat”)
Returns: 0 on success
Returns: LUA_ERRRUN
,LUA_ERRMEM` or ``LUA_ERRERR
otherwise.See also:
ffi.cdef(def)
-
void
luaL_pushuint64
(struct lua_State *L, uint64_t val)¶ Push uint64_t onto the stack
Parameters: - L (lua_State*) – Lua State
- val (uint64_t) – value to push
-
void
luaL_pushint64
(struct lua_State *L, int64_t val)¶ Push int64_t onto the stack
Parameters: - L (lua_State*) – Lua State
- val (int64_t) – value to push
-
uint64_t
luaL_checkuint64
(struct lua_State *L, int idx)¶ Checks whether the argument idx is a uint64 or a convertable string and returns this number.
Throws: error if the argument can’t be converted
-
uint64_t
luaL_checkint64
(struct lua_State *L, int idx)¶ Checks whether the argument idx is a int64 or a convertable string and returns this number.
Throws: error if the argument can’t be converted
-
uint64_t
luaL_touint64
(struct lua_State *L, int idx)¶ Checks whether the argument idx is a uint64 or a convertable string and returns this number.
Returns: the converted number or 0 of argument can’t be converted
-
int64_t
luaL_toint64
(struct lua_State *L, int idx)¶ Checks whether the argument idx is a int64 or a convertable string and returns this number.
Returns: the converted number or 0 of argument can’t be converted