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 | ForeignFunctionInterface, CPP |
Safe Haskell | None |
Language | Haskell2010 |
- State manipulation
- Basic stack manipulation
- Access functions (stack -> Haskell)
- Push functions (Haskell -> stack)
- Get functions (Lua -> stack)
- Set functions (stack -> Lua)
- 'load' and 'call' functions (load and run Lua code)
- Coroutine functions
- Garbage-collection functions and options
- Miscellaneous functions
- Lua Libraries
Haskell bindings to Lua C API functions.
The exposed functions correspond closely to the respective C Lua API
functions. However, C API functions which can throw Lua errors are not
exported directly, as any errors would crash the program. Non-error
throwing hslua_
versions are provided instead. The hslua
ersatz
functions have worse performance than the original.
Some of the Lua functions may, directly or indirectly, call a Haskell
function, and trigger garbage collection, rescheduling etc. These
functions are always imported safely (i.e., with the safe
keyword).
However, all function can trigger garbage collection. If that can lead
to problems, then the package should be configured without flag
allow-unsafe-gc
.
Synopsis
- lua_close :: State -> IO ()
- lua_absindex :: State -> StackIndex -> IO StackIndex
- lua_gettop :: State -> IO StackIndex
- lua_settop :: State -> StackIndex -> IO ()
- lua_pushvalue :: State -> StackIndex -> IO ()
- lua_pop :: State -> StackIndex -> IO ()
- lua_copy :: State -> StackIndex -> StackIndex -> IO ()
- lua_remove :: State -> StackIndex -> IO ()
- lua_insert :: State -> StackIndex -> IO ()
- lua_replace :: State -> StackIndex -> IO ()
- lua_checkstack :: State -> CInt -> IO LuaBool
- lua_isnumber :: State -> StackIndex -> IO LuaBool
- lua_isinteger :: State -> StackIndex -> IO LuaBool
- lua_isstring :: State -> StackIndex -> IO LuaBool
- lua_iscfunction :: State -> StackIndex -> IO LuaBool
- lua_isuserdata :: State -> StackIndex -> IO LuaBool
- lua_type :: State -> StackIndex -> IO TypeCode
- lua_typename :: State -> TypeCode -> IO CString
- hslua_compare :: State -> StackIndex -> StackIndex -> CInt -> Ptr StatusCode -> IO LuaBool
- lua_rawequal :: State -> StackIndex -> StackIndex -> IO LuaBool
- lua_toboolean :: State -> StackIndex -> IO LuaBool
- lua_tocfunction :: State -> StackIndex -> IO CFunction
- lua_tointegerx :: State -> StackIndex -> Ptr LuaBool -> IO Integer
- lua_tonumberx :: State -> StackIndex -> Ptr LuaBool -> IO Number
- lua_tolstring :: State -> StackIndex -> Ptr CSize -> IO (Ptr CChar)
- lua_topointer :: State -> StackIndex -> IO (Ptr ())
- lua_tothread :: State -> StackIndex -> IO State
- lua_touserdata :: State -> StackIndex -> IO (Ptr a)
- lua_rawlen :: State -> StackIndex -> IO CSize
- lua_pushnil :: State -> IO ()
- lua_pushnumber :: State -> Number -> IO ()
- lua_pushinteger :: State -> Integer -> IO ()
- lua_pushlstring :: State -> Ptr CChar -> CSize -> IO ()
- lua_pushcclosure :: State -> CFunction -> NumArgs -> IO ()
- lua_pushboolean :: State -> LuaBool -> IO ()
- lua_pushlightuserdata :: State -> Ptr a -> IO ()
- lua_pushthread :: State -> IO CInt
- hslua_gettable :: State -> StackIndex -> Ptr StatusCode -> IO ()
- lua_rawget :: State -> StackIndex -> IO ()
- lua_rawgeti :: State -> StackIndex -> Integer -> IO ()
- lua_createtable :: State -> CInt -> CInt -> IO ()
- lua_newuserdata :: State -> CSize -> IO (Ptr ())
- lua_getmetatable :: State -> StackIndex -> IO LuaBool
- hslua_getglobal :: State -> CString -> CSize -> Ptr StatusCode -> IO ()
- hslua_settable :: State -> StackIndex -> Ptr StatusCode -> IO ()
- lua_rawset :: State -> StackIndex -> IO ()
- lua_rawseti :: State -> StackIndex -> Integer -> IO ()
- lua_setmetatable :: State -> StackIndex -> IO ()
- hslua_setglobal :: State -> CString -> CSize -> Ptr StatusCode -> IO ()
- lua_pcall :: State -> NumArgs -> NumResults -> StackIndex -> IO StatusCode
- lua_load :: State -> Reader -> Ptr () -> CString -> CString -> IO StatusCode
- lua_status :: State -> IO StatusCode
- lua_gc :: State -> CInt -> CInt -> IO CInt
- hslua_error :: State -> IO NumResults
- hslua_next :: State -> StackIndex -> Ptr StatusCode -> IO LuaBool
- hslua_concat :: State -> NumArgs -> Ptr StatusCode -> IO ()
- lua_pushglobaltable :: State -> IO ()
- luaL_openlibs :: State -> IO ()
- lua_open_base_ptr :: CFunction
- lua_open_table_ptr :: CFunction
- lua_open_io_ptr :: CFunction
- lua_open_os_ptr :: CFunction
- lua_open_string_ptr :: CFunction
- lua_open_math_ptr :: CFunction
- lua_open_debug_ptr :: CFunction
- lua_open_package_ptr :: CFunction
State manipulation
lua_close :: State -> IO () Source #
Wrapper of lua_close
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_close.
Basic stack manipulation
lua_absindex :: State -> StackIndex -> IO StackIndex Source #
Wrapper of lua_absindex
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_absindex.
lua_gettop :: State -> IO StackIndex Source #
Wrapper of lua_gettop
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_gettop.
lua_settop :: State -> StackIndex -> IO () Source #
Wrapper of lua_settop
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_settop.
lua_pushvalue :: State -> StackIndex -> IO () Source #
Wrapper of lua_pushvalue
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_pushvalue.
lua_pop :: State -> StackIndex -> IO () Source #
Wrapper of lua_pop
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_pop.
lua_copy :: State -> StackIndex -> StackIndex -> IO () Source #
Wrapper of lua_copy
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_copy.
lua_remove :: State -> StackIndex -> IO () Source #
Wrapper of lua_remove
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_remove.
lua_insert :: State -> StackIndex -> IO () Source #
Wrapper of lua_insert
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_insert.
lua_replace :: State -> StackIndex -> IO () Source #
Wrapper of lua_replace
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_replace.
lua_checkstack :: State -> CInt -> IO LuaBool Source #
Wrapper of lua_checkstack
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_checkstack.
Access functions (stack -> Haskell)
lua_isnumber :: State -> StackIndex -> IO LuaBool Source #
Wrapper of lua_isnumber
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_isnumber.
lua_isinteger :: State -> StackIndex -> IO LuaBool Source #
Wrapper of lua_isinteger
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_isinteger.
lua_isstring :: State -> StackIndex -> IO LuaBool Source #
Wrapper of lua_isstring
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_isstring.
lua_iscfunction :: State -> StackIndex -> IO LuaBool Source #
Wrapper of lua_iscfunction
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_iscfunction.
lua_isuserdata :: State -> StackIndex -> IO LuaBool Source #
Wrapper of lua_isuserdata
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_isuserdata.
lua_type :: State -> StackIndex -> IO TypeCode Source #
Wrapper of lua_type
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_type.
lua_typename :: State -> TypeCode -> IO CString Source #
Wrapper of lua_typename
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_typename.
hslua_compare :: State -> StackIndex -> StackIndex -> CInt -> Ptr StatusCode -> IO LuaBool Source #
Wrapper around -- @lua_compare@ which catches any Lua errors.
lua_rawequal :: State -> StackIndex -> StackIndex -> IO LuaBool Source #
Wrapper of lua_rawequal
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_rawequal.
lua_toboolean :: State -> StackIndex -> IO LuaBool Source #
Wrapper of lua_toboolean
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_toboolean.
lua_tocfunction :: State -> StackIndex -> IO CFunction Source #
Wrapper of lua_tocfunction
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_tocfunction.
lua_tointegerx :: State -> StackIndex -> Ptr LuaBool -> IO Integer Source #
Wrapper of lua_tointegerx
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_tointegerx.
lua_tonumberx :: State -> StackIndex -> Ptr LuaBool -> IO Number Source #
Wrapper of lua_tonumberx
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_tonumberx.
lua_tolstring :: State -> StackIndex -> Ptr CSize -> IO (Ptr CChar) Source #
Wrapper of lua_tolstring
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_tolstring.
lua_topointer :: State -> StackIndex -> IO (Ptr ()) Source #
Wrapper of lua_topointer
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_topointer.
lua_tothread :: State -> StackIndex -> IO State Source #
Wrapper of lua_tothread
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_tothread.
lua_touserdata :: State -> StackIndex -> IO (Ptr a) Source #
Wrapper of lua_touserdata
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_touserdata.
lua_rawlen :: State -> StackIndex -> IO CSize Source #
Wrapper of lua_rawlen
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_rawlen.
Push functions (Haskell -> stack)
lua_pushnil :: State -> IO () Source #
Wrapper of lua_pushnil
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_pushnil.
lua_pushnumber :: State -> Number -> IO () Source #
Wrapper of lua_pushnumber
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_pushnumber.
lua_pushinteger :: State -> Integer -> IO () Source #
Wrapper of lua_pushinteger
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_pushinteger.
lua_pushlstring :: State -> Ptr CChar -> CSize -> IO () Source #
Wrapper of lua_pushlstring
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_pushlstring.
lua_pushcclosure :: State -> CFunction -> NumArgs -> IO () Source #
Wrapper of lua_pushcclosure
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_pushcclosure.
lua_pushboolean :: State -> LuaBool -> IO () Source #
Wrapper of lua_pushboolean
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_pushboolean.
lua_pushlightuserdata :: State -> Ptr a -> IO () Source #
Wrapper of lua_pushlightuserdata
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_pushlightuserdata.
lua_pushthread :: State -> IO CInt Source #
Wrapper of lua_pushthread
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_pushthread.
Get functions (Lua -> stack)
hslua_gettable :: State -> StackIndex -> Ptr StatusCode -> IO () Source #
Wrapper around lua_gettable. which catches any Lua errors.
lua_rawget :: State -> StackIndex -> IO () Source #
Wrapper of lua_rawget
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_rawget.
lua_rawgeti :: State -> StackIndex -> Integer -> IO () Source #
Wrapper of lua_rawgeti
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_rawgeti.
lua_createtable :: State -> CInt -> CInt -> IO () Source #
Wrapper of lua_createtable
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_createtable.
lua_newuserdata :: State -> CSize -> IO (Ptr ()) Source #
Wrapper of lua_newuserdata
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_newuserdata.
lua_getmetatable :: State -> StackIndex -> IO LuaBool Source #
Wrapper of lua_getmetatable
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_getmetatable.
hslua_getglobal :: State -> CString -> CSize -> Ptr StatusCode -> IO () Source #
Wrapper around lua_getglobal which catches any Lua errors.
Set functions (stack -> Lua)
hslua_settable :: State -> StackIndex -> Ptr StatusCode -> IO () Source #
Wrapper around -- @lua_settable@ which catches any Lua errors.
lua_rawset :: State -> StackIndex -> IO () Source #
Wrapper of lua_rawset
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_rawset.
lua_rawseti :: State -> StackIndex -> Integer -> IO () Source #
Wrapper of lua_rawseti
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_rawseti.
lua_setmetatable :: State -> StackIndex -> IO () Source #
Wrapper of lua_setmetatable
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_setmetatable.
hslua_setglobal :: State -> CString -> CSize -> Ptr StatusCode -> IO () Source #
Wrapper around -- @lua_setglobal@ which catches any Lua errors.
'load' and 'call' functions (load and run Lua code)
lua_pcall :: State -> NumArgs -> NumResults -> StackIndex -> IO StatusCode Source #
Wrapper of lua_pcall
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_pcall.
lua_load :: State -> Reader -> Ptr () -> CString -> CString -> IO StatusCode Source #
Wrapper of lua_load
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_load.
Coroutine functions
lua_status :: State -> IO StatusCode Source #
Wrapper of lua_status
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_status.
Garbage-collection functions and options
lua_gc :: State -> CInt -> CInt -> IO CInt Source #
Wrapper of lua_gc
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_gc.
Miscellaneous functions
hslua_error :: State -> IO NumResults Source #
Replacement for lua_error; it uses the HsLua error signaling convention instead of raw Lua errors.
hslua_next :: State -> StackIndex -> Ptr StatusCode -> IO LuaBool Source #
Wrapper around lua_next which catches any Lua errors.
hslua_concat :: State -> NumArgs -> Ptr StatusCode -> IO () Source #
Wrapper around lua_concat which catches any Lua errors.
lua_pushglobaltable :: State -> IO () Source #
Wrapper of lua_pushglobaltable
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#lua_pushglobaltable.
Lua Libraries
luaL_openlibs :: State -> IO () Source #
Wrapper of luaL_openlibs
. See the Lua docs at
https://www.lua.org/manual/5.3/manual.html#luaL_openlibs.
lua_open_base_ptr :: CFunction Source #
Point to function opening the base library.
lua_open_table_ptr :: CFunction Source #
Point to function opening the table library.
lua_open_io_ptr :: CFunction Source #
Point to function opening the io library.
lua_open_os_ptr :: CFunction Source #
Point to function opening the os library.
lua_open_string_ptr :: CFunction Source #
Point to function opening the string library.
lua_open_math_ptr :: CFunction Source #
Point to function opening the math library.
lua_open_debug_ptr :: CFunction Source #
Point to function opening the debug library.
lua_open_package_ptr :: CFunction Source #
Point to function opening the package library.