Copyright | © 2007–2012 Gracjan Polak; © 2012–2016 Ömer Sinan Ağacan; © 2017-2021 Albert Krewinkel |
---|---|
License | MIT |
Maintainer | Albert Krewinkel <tarleb+hslua@zeitkraut.de> |
Stability | beta |
Portability | non-portable (depends on GHC) |
Safe Haskell | None |
Language | Haskell2010 |
Raw bindings to functions and constants of the auxiliary library.
Synopsis
- luaL_getmetafield :: State -> StackIndex -> CString -> IO TypeCode
- luaL_getmetatable :: State -> CString -> IO TypeCode
- luaL_loadbuffer :: State -> Ptr CChar -> CSize -> CString -> IO StatusCode
- luaL_loadfile :: State -> Ptr CChar -> IO StatusCode
- luaL_loadfilex :: State -> Ptr CChar -> Ptr CChar -> IO StatusCode
- luaL_openlibs :: State -> IO ()
- luaL_newmetatable :: State -> CString -> IO LuaBool
- luaL_ref :: State -> StackIndex -> IO CInt
- luaL_testudata :: State -> StackIndex -> CString -> IO (Ptr ())
- luaL_traceback :: State -> State -> CString -> CInt -> IO ()
- luaL_unref :: State -> StackIndex -> CInt -> IO ()
- luaL_where :: State -> CInt -> IO ()
- loadedTableRegistryField :: String
- preloadTableRegistryField :: String
- data Reference
- fromReference :: Reference -> CInt
- toReference :: CInt -> Reference
The Auxiliary Library
:: State | |
-> StackIndex | obj |
-> CString | e |
-> IO TypeCode |
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
luaL_getmetatable :: State -> CString -> IO TypeCode Source #
Pushes onto the stack the metatable associated with name tname in
the registry (see
) (nil if there is no
metatable associated with that name). Returns the type of the pushed
value.luaL_newmetatable
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.
:: State | |
-> Ptr CChar | filename |
-> IO StatusCode |
Equivalent to luaL_loadfilex with mode equal to NULL
.
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.
luaL_openlibs :: State -> IO () Source #
Opens all standard Lua libraries into the given state.
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.
:: State | |
-> StackIndex | t |
-> 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
frees a
reference and its associated object.luaL_unref
If the object at the top of the stack is nil, luaL_ref
returns the
constant
. The constant
LUA_REFNIL
is guaranteed to be different
from any reference returned by LUA_NOREF
luaL_ref
.
:: State | l |
-> StackIndex | arg |
-> CString | tname |
-> IO (Ptr ()) |
Checks whether the function argument arg
is a userdata of the
type tname
(see
) and returns the userdata
address (see luaL_newmetatable
). Returns lua_touserdata
NULL
if the
test fails.
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.
:: State | |
-> StackIndex | t |
-> CInt | ref |
-> IO () |
Releases reference ref
from the table at index t
(see
). The entry is removed from the table, so that the
referred object can be collected. The reference luaL_ref
ref
is also freed
to be used again.
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
loadedTableRegistryField :: String Source #
Key, in the registry, for table of loaded modules.
preloadTableRegistryField :: String Source #
Key, in the registry, for table of preloaded loaders.
References
Reference to a stored value.
fromReference :: Reference -> CInt Source #
Convert a reference to its C representation.
toReference :: CInt -> Reference Source #
Create a reference from its C representation.