HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulelua-2.3.2Haskell2010

Lua.Auxiliary

Raw bindings to functions and constants of the auxiliary library.

  • 1 type
  • 16 values
  • Packagelua-2.3.2
  • Exports17
  • LanguageHaskell2010
  • LicenceMIT
  • SourceAuxiliary.hs

The Auxiliary Library

12 declarations

Pushes onto the stack the field e from the metatable of the object at index obj and returns the type of the pushed value. If the object does not have a metatable, or if the metatable does not have this field, pushes nothing and returns LUA_TNIL.

valueluaL_loadbuffer
  1. :: State
  2. -> Ptr CChar

    buff

  3. -> CSize

    sz

  4. -> CString

    name

  5. -> IO StatusCode
#

Loads a buffer as a Lua chunk. This function uses 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.

valueluaL_loadfilex
  1. :: State
  2. -> Ptr CChar

    filename

  3. -> Ptr CChar

    mode

  4. -> IO StatusCode
#

Loads a file as a Lua chunk. This function uses lua_load to load the chunk in the file named filename. If filename is NULL, then it loads from the standard input. The first line in the file is ignored if it starts with a #.

The string mode works as in function lua_load.

This function returns the same results as lua_load, but it has an extra error code LUA_ERRFILE for file-related errors (e.g., it cannot open or read the file).

As lua_load, this function only loads the chunk; it does not run it.

valueluaL_newmetatable
  1. :: State
  2. -> CString

    tname

  3. -> IO LuaBool
#

If the registry already has the key tname, returns 0. Otherwise, creates a new table to be used as a metatable for userdata, adds to this new table the pair __name = tname, adds to the registry the pair [tname] = new table, and returns 1. (The entry __name is used by some error-reporting functions.)

In both cases pushes onto the stack the final value associated with tname in the registry.

valueluaL_ref
  1. :: State
  2. -> StackIndex

    t

  3. -> IO CInt
#

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. Function luaL_unref frees a reference and its associated object.

If the object at the top of the stack is nil, luaL_ref returns the constant LUA_REFNIL. The constant LUA_NOREF is guaranteed to be different from any reference returned by luaL_ref.

valueluaL_traceback
  1. :: State

    l

  2. -> State

    l1

  3. -> CString

    msg

  4. -> CInt

    level

  5. -> IO ()
#

Creates and pushes a traceback of the stack l1. If msg is not NULL it is appended at the beginning of the traceback. The level parameter tells at which level to start the traceback.

valueluaL_unref
  1. :: State
  2. -> StackIndex

    t

  3. -> CInt

    ref

  4. -> IO ()
#

Releases reference ref from the table at index t (see luaL_ref). The entry is removed from the table, so that the referred object can be collected. The reference ref is also freed to be used again.

valueluaL_where
  1. :: State

    l

  2. -> CInt

    lvl

  3. -> IO ()
#

Pushes onto the stack a string identifying the current position of the control at level lvl in the call stack. Typically this string has the following format:

chunkname:currentline:

Level 0 is the running function, level 1 is the function that called the running function, etc.

This function is used to build a prefix for error messages.

Registry fields

References