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.
Параметры: - L (lua_State*) – Lua State
- ctypeid (uint32_t) – FFI’s CTypeID of this cdata
Результат: memory associated with this cdata
See also: luaL_checkcdata()
-
void *
luaL_checkcdata
(struct lua_State *L, int idx, uint32_t *ctypeid)¶ Check whether the function argument
idx
is a cdata.Параметры: - L (lua_State*) – Lua State
- idx (int) – stack index
- ctypeid (uint32_t*) – output argument. FFI’s CTypeID of returned cdata
Результат: memory associated with this cdata
See also: luaL_pushcdata()
-
void
luaL_setcdatagc
(struct lua_State *L, int idx)¶ Set finalizer function on a cdata object.
Equivalent to call
ffi.gc(obj, function)
. Finalizer function must be on the top of the stack.Параметры: - 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.
Параметры: - L (lua_State*) – Lua State
- ctypename (const char*) – C type name as string (e.g. «struct request» or «uint32_t»)
Результат: CTypeID
See also: luaL_pushcdata(), luaL_checkcdata()
-
int
luaL_cdef
(struct lua_State *L, const char *ctypename)¶ Declare symbols for FFI.
Параметры: - L (lua_State*) – Lua State
- ctypename (const char*) – C definitions (e.g. «struct stat»)
Результат: 0 on success
Результат: LUA_ERRRUN
,LUA_ERRMEM
orLUA_ERRERR
otherwise.See also:
ffi.cdef(def)
-
void
luaL_pushuint64
(struct lua_State *L, uint64_t val)¶ Push uint64_t onto the stack.
Параметры: - 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.
Параметры: - L (lua_State*) – Lua State
- val (int64_t) – value to push
-
uint64_t
luaL_checkuint64
(struct lua_State *L, int idx)¶ Check whether the argument idx is a uint64 or a convertible string and returns this number.
Throws: error if the argument can’t be converted
-
uint64_t
luaL_checkint64
(struct lua_State *L, int idx)¶ Check whether the argument idx is a int64 or a convertible string and returns this number.
Throws: error if the argument can’t be converted
-
uint64_t
luaL_touint64
(struct lua_State *L, int idx)¶ Check whether the argument idx is a uint64 or a convertible string and returns this number.
Результат: the converted number or 0 of argument can’t be converted
-
int64_t
luaL_toint64
(struct lua_State *L, int idx)¶ Check whether the argument idx is a int64 or a convertible string and returns this number.
Результат: the converted number or 0 of argument can’t be converted
-
void
luaT_pushtuple
(struct lua_State *L, box_tuple_t *tuple)¶ Push a tuple onto the stack.
Параметры: - L (lua_State*) – Lua State
Throws: error on OOM
See also: luaT_istuple
-
box_tuple_t *
luaT_istuple
(struct lua_State *L, int idx)¶ Check whether
idx
is a tuple.Параметры: - L (lua_State*) – Lua State
- idx (int) – the stack index
Результат: non-NULL if
idx
is a tupleРезультат: NULL if
idx
is not a tuple
-
int
luaT_error
(lua_State *L)¶ Re-throw the last Tarantool error as a Lua object.
- See also: lua_error(),
- box_error_last().
-
int
luaT_cpcall
(lua_State *L, lua_CFunction func, void *ud)¶ Similar to lua_cpcall(), but with the proper support of Tarantool errors.
-
lua_State *
luaT_state
(void)¶ Get the global Lua state used by Tarantool.