Crate lua_shared

source ·

Macros§

Enums§

Statics§

Functions§

  • Raises an error with the following message, where func is retrieved from the call stack
  • Checks whether the function has an argument of any type (including nil) at position index.
  • Checks whether the function argument index is a number and returns this number cast to a lua_Integer.
  • 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.
  • Checks whether the function argument index is a number and returns this number.
  • 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.
  • Checks whether the function argument index has type typ. See lua_type for the encoding of types for typ.
  • Checks whether the function argument index is a userdata of the type type_name (see Lnewmetatable).
  • 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.
  • 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.
  • 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.
  • Opens all standard Lua libraries into the given state.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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
  • 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.
  • 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).
  • 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.
  • Pushes onto the stack the environment table of the value at the given index.
  • 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).
  • 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.
  • 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.
  • 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.
  • 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.
  • Returns true if the value at the given index is a C function, and true otherwise.
  • Returns true if the value at the given index is a number or a string convertible to a number, and false otherwise.
  • 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.
  • Returns true if the value at the given index is a userdata (either full or light), and false otherwise.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • Calls a function in protected mode.
  • Pushes a boolean value with value bool onto the stack.
  • Pushes a new C closure onto the stack.
  • Pushes rust function/closure to lua stack.
  • Pushes a number with value number onto the stack.
  • Pushes a light userdata onto the stack.
  • 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.
  • Pushes a nil value onto the stack.
  • Pushes a number with value number onto the stack.
  • 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.
  • Pushes the thread represented by state onto the stack. Returns 1 if this thread is the main thread of its state.
  • Pushes a copy of the element at the given index onto the stack.
  • 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.
  • Similar to gettable (lua_gettable), but does a raw access (i.e., without metamethods).
  • 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.
  • Similar to settable (lua_settable), but does a raw assignment (i.e., without metamethods).
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • Pops a table from the stack and sets it as the new metatable for the value at the given acceptable index.
  • 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.
  • 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.
  • 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.
  • Converts a value at the given acceptable index to a C function. That value must be a C function; otherwise, returns NULL.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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§