Crate lua_shared

Source

Macros§

cstr
getglobal
pop
setglobal
upvalueindex

Enums§

LError
LoadMode
Status

Statics§

ENVIRONINDEX
GLOBALSINDEX
REGISTRYINDEX

Functions§

Largerror
Raises an error with the following message, where func is retrieved from the call stack
Lcheckany
Checks whether the function has an argument of any type (including nil) at position index.
Lcheckinteger
Checks whether the function argument index is a number and returns this number cast to a lua_Integer.
Lchecklstring
Checks whether the function argument index is a string and returns this string; if length is not NULL fills *length with the string’s length.
Lchecknumber
Checks whether the function argument index is a number and returns this number.
Lcheckstack
Grows the stack size to top + size elements, raising an error if the stack cannot grow to that size. msg is an additional text to go into the error message.
Lchecktype
Checks whether the function argument index has type typ. See lua_type for the encoding of types for typ.
Lcheckudata
Checks whether the function argument index is a userdata of the type type_name (see Lnewmetatable).
Lerror
Raises an error. The error message format is given by fmt plus any extra arguments, following the same rules of lua_pushfstring. It also adds at the beginning of the message the file name and the line number where the error occurred, if this information is available.
Lloadbufferx
Loads a buffer as a Lua chunk. This function uses lua_load to load the chunk in the buffer pointed to by buffer with size size.
Lnewmetatable
If the registry already has the key type_name, returns false. Otherwise, creates a new table to be used as a metatable for userdata, adds it to the registry with key type_name, and returns true.
Lopenlibs
Opens all standard Lua libraries into the given state.
Loptinteger
If the function argument index is a number, returns this number cast to a lua_Integer. If this argument is absent or is nil, returns default. Otherwise, raises an error.
Loptlstring
If the function argument index is a string, returns this string. If this argument is absent or is nil, returns default. Otherwise, raises an error.
Loptnumber
If the function argument index is a number, returns this number. If this argument is absent or is nil, returns default. Otherwise, raises an error.
Lpush_where
Pushes onto the stack a string identifying the current position of the control at level level in the call stack. Typically this string has the following format:
call
Calls a function.
checkstack
Ensures that the stack has space for at least n extra slots (that is, that you can safely push up to n values into it). It returns false if it cannot fulfill the request, either because it would cause the stack to be larger than a fixed maximum size (typically at least several thousand elements) or because it cannot allocate memory for the extra space. This function never shrinks the stack; if the stack already has space for the extra slots, it is left unchanged.
close
Destroys all objects in the given Lua state (calling the corresponding garbage-collection metamethods, if any) and frees all dynamic memory used by this state. In several platforms, you may not need to call this function, because all resources are naturally released when the host program ends. On the other hand, long-running programs that create multiple states, such as daemons or web servers, will probably need to close states as soon as they are not needed.
createtable
Creates a new empty table and pushes it onto the stack. The new table has space pre-allocated for array array elements and hash non-array elements. This pre-allocation is useful when you know exactly how many elements the table will have.
dump
equal
Returns true if the two values in acceptable indices index1 and index2 are equal, following the semantics of the Lua == operator (that is, may call metamethods). Otherwise returns false. Also returns false if any of the indices is non valid.
error
Generates a Lua error. The error message (which can actually be a Lua value of any type) must be on the stack top. This function does a long jump, and therefore never returns. (see luaL_error).
get_type
Returns the type of the value in the given valid index, or LUA_TNONE for a non-valid (but acceptable) index. The types returned by get_type (lua_type) are coded by the following constants defined in lua.h: LUA_TNIL (0), LUA_TNUMBER, LUA_TBOOLEAN, LUA_TSTRING, LUA_TTABLE, LUA_TFUNCTION, LUA_TUSERDATA, LUA_TTHREAD, and LUA_TLIGHTUSERDATA.
getfenv
Pushes onto the stack the environment table of the value at the given index.
getfield
Pushes onto the stack the value t[k], where t is the value at the given valid index. As in Lua, this function may trigger a metamethod for the “index” event (see §2.8).
getmetatable
Pushes onto the stack the metatable of the value at the given acceptable index. If the index is not valid, or if the value does not have a metatable, the function returns 0 and pushes nothing on the stack.
gettable
Pushes onto the stack the value t[k], where t is the value at the given valid index and k is the value at the top of the stack.
gettop
Returns the index of the top element in the stack. Because indices start at 1, this result is equal to the number of elements in the stack; in particular, 0 means an empty stack.
insert
Moves the top element into the given valid index, shifting up the elements above this index to open space. This function cannot be called with a pseudo-index, because a pseudo-index is not an actual stack position.
iscfunction
Returns true if the value at the given index is a C function, and true otherwise.
isnumber
Returns true if the value at the given index is a number or a string convertible to a number, and false otherwise.
isstring
Returns true if the value at the given index is a string or a number (which is always convertible to a string), and false otherwise.
isuserdata
Returns true if the value at the given index is a userdata (either full or light), and false otherwise.
lessthan
Returns true if the value at acceptable index index1 is smaller than the value at acceptable index index2, following the semantics of the Lua < operator (that is, may call metamethods). Otherwise returns false. Also returns 0 if any of the indices is non valid.
loadx
newstate
Creates a new Lua state. It calls lua_newstate with an allocator based on the standard C realloc function and then sets a panic function that prints an error message to the standard error output in case of fatal errors.
newthread
Creates a new thread, pushes it on the stack, and returns a pointer to a lua_State that represents this new thread. The new thread returned by this function shares with the original thread its global environment, but has an independent execution stack. There is no explicit function to close or to destroy a thread. Threads are subject to garbage collection, like any Lua object.
newuserdata
This function allocates a new block of memory with the given size, pushes onto the stack a new full userdata with the block address, and returns this address.
objlen
Returns the “length” of the value at the given acceptable index: for strings, this is the string length; for tables, this is the result of the length operator ('#'); for userdata, this is the size of the block of memory allocated for the userdata; for other values, it is 0.
open_base
open_bit
open_debug
open_jit
open_math
open_os
open_package
open_string
open_table
pcall
Calls a function in protected mode.
pushboolean
Pushes a boolean value with value bool onto the stack.
pushcclosure
Pushes a new C closure onto the stack.
pushfunction
Pushes rust function/closure to lua stack.
pushinteger
Pushes a number with value number onto the stack.
pushlightuserdata
Pushes a light userdata onto the stack.
pushlstring
Pushes the string pointed to by str with size len onto the stack. Lua makes (or reuses) an internal copy of the given string, so the memory at str can be freed or reused immediately after the function returns. The string can contain embedded zeros.
pushnil
Pushes a nil value onto the stack.
pushnumber
Pushes a number with value number onto the stack.
pushstring
Pushes the zero-terminated string pointed to by str onto the stack. Lua makes (or reuses) an internal copy of the given string, so the memory at str can be freed or reused immediately after the function returns. The string cannot contain embedded zeros; it is assumed to end at the first zero.
pushthread
Pushes the thread represented by state onto the stack. Returns 1 if this thread is the main thread of its state.
pushvalue
Pushes a copy of the element at the given index onto the stack.
rawequal
Returns true if the two values in acceptable indices index1 and index2 are primitively equal (that is, without calling metamethods). Otherwise returns false. Also returns false if any of the indices are non valid.
rawget
Similar to gettable (lua_gettable), but does a raw access (i.e., without metamethods).
rawgeti
Pushes onto the stack the value t[n], where t is the value at the given valid index. The access is raw; that is, it does not invoke metamethods.
rawset
Similar to settable (lua_settable), but does a raw assignment (i.e., without metamethods).
rawseti
Does the equivalent of t[n] = v, where t is the value at the given valid index and v is the value at the top of the stack.
remove
Removes the element at the given valid index, shifting down the elements above this index to fill the gap. This function cannot be called with a pseudo-index, because a pseudo-index is not an actual stack position.
replace
Moves the top element into the given valid index without shifting any element (therefore replacing the value at that given index), and then pops the top element.
setfenv
Pops a table from the stack and sets it as the new environment for the value at the given index. If the value at the given index is neither a function nor a thread nor a userdata, setfenv (lua_setfenv) returns 0. Otherwise it returns 1.
setfield
Does the equivalent to t[k] = v, where t is the value at the given valid index and v is the value at the top of the stack.
setmetatable
Pops a table from the stack and sets it as the new metatable for the value at the given acceptable index.
settable
Does the equivalent to t[k] = v, where t is the value at the given valid index, v is the value at the top of the stack, and k is the value just below the top.
settop
Accepts any index, or 0, and sets the stack top to this index. If the new top is larger than the old one, then the new elements are filled with nil. If index is 0, then all stack elements are removed.
toboolean
Converts the Lua value at the given acceptable index to a C boolean value (0 or 1). Like all tests in Lua, toboolean (lua_toboolean) returns true for any Lua value different from false and nil; otherwise it returns false. It also returns false when called with a non-valid index.
tocfunction
Converts a value at the given acceptable index to a C function. That value must be a C function; otherwise, returns NULL.
tointeger
Converts the Lua value at the given acceptable index to the signed integral type lua_Integer. The Lua value must be a number or a string convertible to a number (see §2.2.1); otherwise, tointeger (lua_tointeger) returns 0.
tolstring
Converts the Lua value at the given acceptable index to a C string. If len is not NULL, it also sets *len with the string length. The Lua value must be a string or a number; otherwise, the function returns NULL. If the value is a number, then tolstring also changes the actual value in the stack to a string.
tonumber
Converts the Lua value at the given acceptable index to the C type lua_Number (see lua_Number). The Lua value must be a number or a string convertible to a number (see §2.2.1); otherwise, tonumber (lua_tonumber) returns 0.
topointer
Converts the value at the given acceptable index to a generic C pointer (void*). The value can be a userdata, a table, a thread, or a function; otherwise, topointer (lua_topointer) returns NULL. Different objects will give different pointers. There is no way to convert the pointer back to its original value.
tothread
Converts the value at the given acceptable index to a Lua thread (represented as lua_State). This value must be a thread; otherwise, the function returns NULL.
touserdata
If the value at the given acceptable index is a full userdata, returns its block address. If the value is a light userdata, returns its pointer. Otherwise, returns NULL.
typename
Returns the name of the type encoded by the value tp, which must be one the values returned by get_type (lua_type).

Type Aliases§

Result
lua_CFunction
lua_Reader
lua_State
lua_Writer