hslua-core-2.0.0.2: Bindings to 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
Portabilitynon-portable (depends on GHC)
Safe HaskellNone
LanguageHaskell2010

HsLua.Core.Userdata

Description

Convenience functions to convert Haskell values into Lua userdata.

Synopsis

Documentation

newhsuserdata :: forall a e. a -> 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.

fromuserdata Source #

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.

putuserdata Source #

Arguments

:: forall a e. StackIndex

index

-> Name

name

-> a

new value

-> LuaE e 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.