| Copyright | © 2007–2012 Gracjan Polak; © 2012–2016 Ömer Sinan Ağacan; © 2017-2023 Albert Krewinkel |
|---|---|
| License | MIT |
| Maintainer | Albert Krewinkel <tarleb@hslua.org> |
| Stability | beta |
| Portability | non-portable (depends on GHC) |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
HsLua.Core.Userdata
Description
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
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.
Returns True if a new metatable was created, and False otherwise.
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.
Arguments
| :: 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.
Arguments
| :: forall a e. StackIndex | index |
| -> Name | name |
| -> a | new value |
| -> LuaE e Bool |