Home Explore Blog CI



neovim

29th chunk of `runtime/doc/luaref.txt`
afe1598f4153f4e9c8821c78bbc425b2678b8412dae62e8a0000000100000fac
                  previous value of the step multiplier.

lua_getallocf                                                  *lua_getallocf()*
>c
    lua_Alloc lua_getallocf (lua_State *L, void **ud);
<
        Returns the memory-allocation function of a given state. If `ud` is
        not `NULL`, Lua stores in `*ud` the opaque pointer passed to
        `lua_newstate` (see |lua_newstate()|).

lua_getfenv                                                      *lua_getfenv()*
>c
    void lua_getfenv (lua_State *L, int index);
<
        Pushes onto the stack the environment table of the value at the given
        index.

lua_getfield                                                    *lua_getfield()*
>c
    void lua_getfield (lua_State *L, int index, const char *k);
<
        Pushes onto the stack the value `t[k]`, where `t` is the value at the
        given valid index `index`. As in Lua, this function may trigger a
        metamethod for the "index" event (see |lua-metatable|).

lua_getglobal                                                  *lua_getglobal()*
>c
    void lua_getglobal (lua_State *L, const char *name);
<
        Pushes onto the stack the value of the global `name`. It is defined as
        a macro:
>c
            #define lua_getglobal(L,s)  lua_getfield(L, LUA_GLOBALSINDEX, s)
<

lua_getmetatable                                            *lua_getmetatable()*
>c
    int lua_getmetatable (lua_State *L, int index);
<
        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.

lua_gettable                                                    *lua_gettable()*
>c
    void lua_gettable (lua_State *L, int index);
<
        Pushes onto the stack the value `t[k]`, where `t` is the value at the
        given valid index `index` and `k` is the value at the top of the
        stack.

        This function pops the key from the stack (putting the resulting value
        in its place). As in Lua, this function may trigger a metamethod for
        the "index" event (see |lua-metatable|).

lua_gettop                                                        *lua_gettop()*
>c
    int lua_gettop (lua_State *L);
<
        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 (and so
        0 means an empty stack).

lua_insert                                                        *lua_insert()*
>c
    void lua_insert (lua_State *L, int index);
<
        Moves the top element into the given valid index, shifting up the
        elements above this index to open space. Cannot be called with a
        pseudo-index, because a pseudo-index is not an actual stack position.

lua_Integer                                                        *lua_Integer*
>c
    typedef ptrdiff_t lua_Integer;
<
        The type used by the Lua API to represent integral values.

        By default it is a `ptrdiff_t`, which is usually the largest integral
        type the machine handles "comfortably".

lua_isboolean                                                  *lua_isboolean()*
>c
    int lua_isboolean (lua_State *L, int index);
<
        Returns 1 if the value at the given acceptable index has type boolean,
        and 0 otherwise.

lua_iscfunction                                              *lua_iscfunction()*
>c
    int lua_iscfunction (lua_State *L, int index);
<
        Returns 1 if the value at the given acceptable index is a C function,
        and 0 otherwise.

lua_isfunction                                                *lua_isfunction()*
>c
    int lua_isfunction (lua_State *L, int index);
<
        Returns 1 if the value at the given acceptable index is a function
        (either C or Lua), and 0 otherwise.

lua_islightuserdata                                      *lua_islightuserdata()*

Title: Lua C API: Global Variables, Metatables, Stack Manipulation, and Type Checking
Summary
This section details more Lua C API functions. `lua_getglobal` retrieves the value of a global variable by its name. `lua_getmetatable` pushes the metatable of a value onto the stack. `lua_gettable` retrieves a table element using a key from the stack. `lua_gettop` returns the index of the top element of the stack. `lua_insert` moves the top element to a given index. `lua_Integer` is the type used for representing integral values. `lua_isboolean`, `lua_iscfunction`, and `lua_isfunction` check if a value at a given index is a boolean, C function, or function, respectively. The next function will likely be `lua_islightuserdata`.