lua-1.0.0: Lua, an embeddable scripting language
Copyright© 2007–2012 Gracjan Polak;
© 2012–2016 Ömer Sinan Ağacan;
© 2017-2021 Albert Krewinkel
LicenseMIT
MaintainerAlbert Krewinkel <tarleb+hslua@zeitkraut.de>
Stabilitybeta
PortabilityForeignFunctionInterface, CPP
Safe HaskellNone
LanguageHaskell2010

Foreign.Lua.Raw.Functions

Description

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

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_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.

Access functions (stack -> Haskell)

hslua_compare :: State -> StackIndex -> StackIndex -> CInt -> Ptr StatusCode -> IO LuaBool Source #

Wrapper around -- @lua_compare@ which catches any Lua errors.

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_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.

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.

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.

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_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

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.