Home Explore Blog CI



neovim

28th chunk of `runtime/doc/luaref.txt`
716e913c4bd72c7be1220ebe0e5429d7660f0bbaa7602b020000000100000fa6
 lua_Writer writer, void *data);
<
        Dumps a function as a binary chunk. Receives a Lua function on the top
        of the stack and produces a binary chunk that, if loaded again,
        results in a function equivalent to the one dumped. As it produces
        parts of the chunk, `lua_dump` calls function `writer` (see
        |lua_Writer|) with the given `data` to write them.

        The value returned is the error code returned by the last call to the
        writer; 0 means no errors.

        This function does not pop the Lua function from the stack.

lua_equal                                                          *lua_equal()*
>c
    int lua_equal (lua_State *L, int index1, int index2);
<
        Returns 1 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 0. Also returns 0
        if any of the indices is non valid.

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

lua_gc                                                                *lua_gc()*
>c
    int lua_gc (lua_State *L, int what, int data);
<
        Controls the garbage collector.

        This function performs several tasks, according to the value of the
        parameter `what`:

        - `LUA_GCSTOP`      stops the garbage collector.
        - `LUA_GCRESTART`   restarts the garbage collector.
        - `LUA_GCCOLLECT`   performs a full garbage-collection cycle.
        - `LUA_GCCOUNT`     returns the current amount of memory (in Kbytes) in
                          use by Lua.
        - `LUA_GCCOUNTB`    returns the remainder of dividing the current
                          amount of bytes of memory in use by Lua by 1024.
        - `LUA_GCSTEP`      performs an incremental step of garbage collection.
                          The step "size" is controlled by `data` (larger
                          values mean more steps) in a non-specified way. If
                          you want to control the step size you must
                          experimentally tune the value of `data`. The
                          function returns 1 if the step finished a
                          garbage-collection cycle.
        - `LUA_GCSETPAUSE`  sets `data` /100 as the new value for the
                          `pause` of the collector (see |lua-gc|).
                          The function returns the previous value of the
                          pause.
        - `LUA_GCSETSTEPMUL`sets `data` /100 as the new value for the
                          `step` `multiplier`  of the collector (see
                          |lua-gc|). The function returns the
                          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

Title: Lua C API: Error Handling, Garbage Collection, Memory Allocation, and Table Access
Summary
This section outlines several Lua C API functions. `lua_error` generates a Lua error, triggering a long jump and thus never returns. `lua_gc` controls the garbage collector, allowing to stop, restart, collect, count memory usage, perform incremental steps, and set pause and step multiplier values. `lua_getallocf` retrieves the memory-allocation function and its associated user data for a Lua state. `lua_getfenv` pushes the environment table of a value onto the stack. `lua_getfield` retrieves the value of a field in a table at a given index, potentially triggering a metamethod. The next function will likely be `lua_getglobal`.