Home Explore Blog CI



neovim

48th chunk of `runtime/doc/luaref.txt`
5e2aaa280ee7cda9a009b971c1fc6a877816c1b20954f6be0000000100000fa0
 if the
        stack cannot grow to that size. `msg` is an additional text to go into
        the error message.

luaL_checkstring                                            *luaL_checkstring()*
>c
    const char *luaL_checkstring (lua_State *L, int narg);
<
        Checks whether the function argument `narg` is a string and returns
        this string.

luaL_checktype                                                *luaL_checktype()*
>c
    void luaL_checktype (lua_State *L, int narg, int t);
<
        Checks whether the function argument `narg` has type `t` (see
        |lua_type()|).

luaL_checkudata                                              *luaL_checkudata()*
>c
    void *luaL_checkudata (lua_State *L, int narg, const char *tname);
<
        Checks whether the function argument `narg` is a userdata of the type
        `tname` (see |luaL_newmetatable()|).

luaL_dofile                                                      *luaL_dofile()*
>c
    int luaL_dofile (lua_State *L, const char *filename);
<
        Loads and runs the given file. It is defined as the following macro:
>c
               (luaL_loadfile(L, filename) || lua_pcall(L, 0, LUA_MULTRET, 0))
<
        It returns 0 if there are no errors or 1 in case of errors.

luaL_dostring                                                  *luaL_dostring()*
>c
    int luaL_dostring (lua_State *L, const char *str);
<
        Loads and runs the given string. It is defined as the following macro:
>c
               (luaL_loadstring(L, str) || lua_pcall(L, 0, LUA_MULTRET, 0))
<
        It returns 0 if there are no errors or 1 in case of errors.

luaL_error                                                        *luaL_error()*
>c
    int luaL_error (lua_State *L, const char *fmt, ...);
<
        Raises an error. The error message format is given by `fmt` plus any
        extra arguments, following the same rules of `lua_pushfstring` (see
        |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.

        This function never returns, but it is an idiom to use it in C
        functions as `return luaL_error(` `args` `)`.

luaL_getmetafield                                          *luaL_getmetafield()*
>c
    int luaL_getmetafield (lua_State *L, int obj, const char *e);
<
        Pushes onto the stack the field `e` from the metatable of the object
        at index `obj`. If the object does not have a metatable, or if the
        metatable does not have this field, returns 0 and pushes nothing.

luaL_getmetatable                                          *luaL_getmetatable()*
>c
    void luaL_getmetatable (lua_State *L, const char *tname);
<
        Pushes onto the stack the metatable associated with name `tname` in
        the registry (see |luaL_newmetatable()|).

luaL_gsub                                                          *luaL_gsub()*
>c
    const char *luaL_gsub (lua_State *L,
                           const char *s,
                           const char *p,
                           const char *r);
<
        Creates a copy of string `s` by replacing any occurrence of the string
        `p` with the string `r`. Pushes the resulting string on the stack and
        returns it.

luaL_loadbuffer                                              *luaL_loadbuffer()*
>c
    int luaL_loadbuffer (lua_State *L,
                         const char *buff,
                         size_t sz,
                         const char *name);
<
        Loads a buffer as a Lua chunk. This function uses `lua_load` (see
        |lua_load()|) to load the chunk in the buffer pointed to by
        `buff` with size `sz`.

        This function returns the same results as `lua_load`. `name` is the
        chunk name, used for debug information and error messages.

luaL_loadfile                                                  *luaL_loadfile()*
>c
    int luaL_loadfile (lua_State *L,

Title: Lua Auxiliary Library: Loading, Running, and Error Handling Functions
Summary
This section details functions from the Lua Auxiliary Library for loading and running code (luaL_dofile, luaL_dostring, luaL_loadbuffer, luaL_loadfile), generating errors (luaL_error), accessing metatables (luaL_getmetafield, luaL_getmetatable), and string substitution (luaL_gsub). The functions `luaL_checkstack`, `luaL_checkstring`, `luaL_checktype`, and `luaL_checkudata` for argument checking are also included.