Copyright | © 2007–2012 Gracjan Polak; © 2012–2016 Ömer Sinan Ağacan; © 2017-2022 Albert Krewinkel |
---|---|
License | MIT |
Maintainer | Albert Krewinkel <tarleb+hslua@zeitkraut.de> |
Stability | beta |
Portability | non-portable (depends on GHC) |
Safe Haskell | None |
Language | Haskell2010 |
Convenience functions to convert Haskell values into Lua userdata.
Synopsis
- newhsuserdatauv :: forall a e. a -> Int -> LuaE e ()
- newudmetatable :: Name -> LuaE e Bool
- fromuserdata :: forall a e. StackIndex -> Name -> LuaE e (Maybe a)
- putuserdata :: forall a e. StackIndex -> Name -> a -> LuaE e Bool
Documentation
newhsuserdatauv :: forall a e. a -> Int -> LuaE e () Source #
Creates a new userdata wrapping the given Haskell object. The userdata is pushed to the top of the stack.
newudmetatable :: Name -> LuaE e Bool Source #
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.
Using a metatable created by this functions ensures that the pointer to the Haskell value will be freed when the userdata object is garbage collected in Lua.
The name may not contain a nul character.
:: forall a e. StackIndex | stack index of userdata |
-> Name | expected name of userdata object |
-> LuaE e (Maybe a) |
Retrieves a Haskell object from userdata at the given index. The userdata must have the given name.
:: forall a e. StackIndex | index |
-> Name | name |
-> a | new value |
-> LuaE e Bool |