lua-2.1.0: Lua, an embeddable scripting language

Copyright | © 2017-2022 Albert Krewinkel
License | MIT
Maintainer | Albert Krewinkel <tarleb+hslua@zeitkraut.de>
Stability | beta
Portability | ForeignFunctionInterface
Safe Haskell | None
Language | Haskell2010

Lua.Userdata

Description

Bindings to HsLua-specific functions used to push Haskell values as userdata.

Synopsis

- hslua_fromuserdata :: State -> StackIndex -> CString -> IO (Maybe a)
- hslua_newhsuserdata :: State -> a -> IO ()
- hslua_newudmetatable :: State -> CString -> IO LuaBool
- hslua_putuserdata :: State -> StackIndex -> CString -> a -> IO Bool

# Documentation

hslua_fromuserdata #

Arguments

:: State |
-> StackIndex | userdata index
-> CString | name
-> IO (Maybe a) |

Retrieves a Haskell object from userdata at the given index. The userdata must have the given name.

hslua_newhsuserdata :: State -> a -> IO () #

Creates a new userdata wrapping the given Haskell object.

hslua_newudmetatable #

Arguments

:: State | Lua state
-> CString | Userdata name (__name)
-> IO LuaBool | True iff new metatable was created.

Creates and registers a new metatable for a userdata-wrapped Haskell value; checks whether a metatable of that name has been registered yet and uses the registered table if possible.

hslua_putuserdata #

Arguments

:: State |
-> StackIndex | index
-> CString | name
-> a | new Haskell value
-> IO Bool |

Replaces the Haskell value contained in the userdata value at `index`. Checks that the userdata is of type `name` and returns `True` on success, or `False` otherwise.