Home Explore Blog CI



neovim

50th chunk of `runtime/doc/luaref.txt`
706a0b9a4d8f76d80edc2962c38643ded2d35d37e43586800000000100000fa3

luaL_openlibs                                                  *luaL_openlibs()*
>c
    void luaL_openlibs (lua_State *L);
<
        Opens all standard Lua libraries into the given state. See also
        |lua-openlibs| for details on how to open individual libraries.

luaL_optint                                                      *luaL_optint()*
>c
    int luaL_optint (lua_State *L, int narg, int d);
<
        If the function argument `narg` is a number, returns this number cast
        to an `int`. If this argument is absent or is `nil`, returns `d`.
        Otherwise, raises an error.

luaL_optinteger                                              *luaL_optinteger()*
>c
    lua_Integer luaL_optinteger (lua_State *L,
                                 int narg,
                                 lua_Integer d);
<
        If the function argument `narg` is a number, returns this number cast
        to a `lua_Integer` (see |lua_Integer|). If this argument is
        absent or is `nil`, returns `d`. Otherwise, raises an error.

luaL_optlong                                                    *luaL_optlong()*
>c
    long luaL_optlong (lua_State *L, int narg, long d);
<
        If the function argument `narg` is a number, returns this number cast
        to a `long`. If this argument is absent or is `nil`, returns `d`.
        Otherwise, raises an error.

luaL_optlstring                                              *luaL_optlstring()*
>c
    const char *luaL_optlstring (lua_State *L,
                                 int narg,
                                 const char *d,
                                 size_t *l);
<
        If the function argument `narg` is a string, returns this string. If
        this argument is absent or is `nil`, returns `d`. Otherwise, raises an
        error.

        If `l` is not `NULL`, fills the position `*l` with the results' length.

luaL_optnumber                                                *luaL_optnumber()*
>c
    lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number d);
<
        If the function argument `narg` is a number, returns this number. If
        this argument is absent or is `nil`, returns `d`. Otherwise, raises an
        error.

luaL_optstring                                                *luaL_optstring()*
>c
    const char *luaL_optstring (lua_State *L,
                                int narg,
                                const char *d);
<
        If the function argument `narg` is a string, returns this string. If
        this argument is absent or is `nil`, returns `d`. Otherwise, raises an
        error.

luaL_prepbuffer                                              *luaL_prepbuffer()*
>c
    char *luaL_prepbuffer (luaL_Buffer *B);
<
        Returns an address to a space of size `LUAL_BUFFERSIZE` where you can
        copy a string to be added to buffer `B` (see |luaL_Buffer|).
        After copying the string into this space you must call `luaL_addsize`
        (see |luaL_addsize()|) with the size of the string to actually
        add it to the buffer.

luaL_pushresult                                              *luaL_pushresult()*
>c
    void luaL_pushresult (luaL_Buffer *B);
<
        Finishes the use of buffer `B` leaving the final string on the top of
        the stack.

luaL_ref                                                            *luaL_ref()*
>c
    int luaL_ref (lua_State *L, int t);
<
        Creates and returns a `reference`, in the table at index `t`, for the
        object at the top of the stack (and pops the object).

        A reference is a unique integer key. As long as you do not manually
        add integer keys into table `t`, `luaL_ref` ensures the uniqueness of
        the key it returns. You can retrieve an object referred by reference
        `r` by calling `lua_rawgeti(L, t, r)` (see |lua_rawgeti()|).
        Function `luaL_unref` (see |luaL_unref()|) frees a reference and
        its associated object.

        If the object at the top

Title: Lua Auxiliary Library: Argument Handling, Buffers, and References
Summary
This section details functions from the Lua auxiliary library for handling optional function arguments of various types (int, integer, long, string, number) with default values. It also covers buffer manipulation functions (luaL_prepbuffer, luaL_pushresult) for accumulating strings and the reference system (luaL_ref) for storing and retrieving values from a table using unique integer keys.