hslua-packaging-2.3.1: Utilities to build Lua modules.
Copyright© 2020-2024 Albert Krewinkel
LicenseMIT
MaintainerAlbert Krewinkel <tarleb@hslua.org>
Safe HaskellNone
LanguageHaskell2010

HsLua.Packaging.UDType

Description

This module provides types and functions to use Haskell values as userdata objects in Lua. These objects wrap a Haskell value and provide methods and properties to interact with the Haskell value.

The terminology in this module refers to the userdata values as /UD objects, and to their type as UD type/.

Synopsis

Documentation

type DocumentedType e a = UDType e (DocumentedFunction e) a Source #

Type definitions containing documented functions.

type DocumentedTypeWithList e a itemtype = UDTypeWithList e (DocumentedFunction e) a itemtype Source #

A userdata type, capturing the behavior of Lua objects that wrap Haskell values. The type name must be unique; once the type has been used to push or retrieve a value, the behavior can no longer be modified through this type.

deftype Source #

Arguments

:: LuaError e 
=> Name

type name

-> [(Operation, DocumentedFunction e)]

operations

-> [Member e (DocumentedFunction e) a]

methods

-> DocumentedType e a 

Defines a new type, defining the behavior of objects in Lua. Note that the type name must be unique.

deftype' Source #

Arguments

:: LuaError e 
=> Name

type name

-> [(Operation, DocumentedFunction e)]

operations

-> [Member e (DocumentedFunction e) a]

methods

-> Maybe (ListSpec e a itemtype)

list access

-> DocumentedTypeWithList e a itemtype 

Defines a new type that could also be treated as a list; defines the behavior of objects in Lua. Note that the type name must be unique.

method :: DocumentedFunction e -> Member e (DocumentedFunction e) a Source #

Use a documented function as an object method.

property :: LuaError e => Name -> Text -> (Pusher e b, a -> b) -> (Peeker e b, a -> b -> a) -> Member e fn a #

property' :: LuaError e => Name -> TypeSpec -> Text -> (Pusher e b, a -> b) -> (Peeker e b, a -> b -> a) -> Member e fn a #

possibleProperty :: LuaError e => Name -> Text -> (Pusher e b, a -> Possible b) -> (Peeker e b, a -> b -> Possible a) -> Member e fn a #

possibleProperty' :: LuaError e => Name -> TypeSpec -> Text -> (Pusher e b, a -> Possible b) -> (Peeker e b, a -> b -> Possible a) -> Member e fn a #

readonly :: Name -> Text -> (Pusher e b, a -> b) -> Member e fn a #

readonly' :: Name -> TypeSpec -> Text -> (Pusher e b, a -> b) -> Member e fn a #

alias :: AliasIndex -> Text -> [AliasIndex] -> Member e fn a #

operation Source #

Arguments

:: Operation

the kind of operation

-> DocumentedFunction e

function used to perform the operation

-> (Operation, DocumentedFunction e) 

Declares a new object operation from a documented function.

peekUD :: LuaError e => DocumentedTypeWithList e a itemtype -> Peeker e a Source #

Retrieves a userdata value of the given type.

pushUD :: LuaError e => DocumentedTypeWithList e a itemtype -> a -> LuaE e () Source #

Pushes a userdata value of the given type.

initType :: LuaError e => DocumentedTypeWithList e a itemtype -> LuaE e Name Source #

Ensures that the type has been fully initialized, i.e., that all metatables have been created and stored in the registry. Returns the name of the initialized type.

udparam Source #

Arguments

:: LuaError e 
=> DocumentedTypeWithList e a itemtype

expected type

-> Text

parameter name

-> Text

parameter description

-> Parameter e a 

Defines a function parameter that takes the given type.

udresult Source #

Arguments

:: LuaError e 
=> DocumentedTypeWithList e a itemtype

result type

-> Text

result description

-> FunctionResults e a 

Defines a function result of the given type.

udDocs :: UDTypeWithList e fn a itemtype -> TypeDocs #

udTypeSpec :: UDTypeWithList e fn a itemtype -> TypeSpec #

Helper types for building

data Member e fn a #

data Operation #

Instances

Instances details
Show Operation 
Instance details

Defined in HsLua.ObjectOrientation.Operation

Methods

showsPrec :: Int -> Operation -> ShowS

show :: Operation -> String

showList :: [Operation] -> ShowS

Eq Operation 
Instance details

Defined in HsLua.ObjectOrientation.Operation

Methods

(==) :: Operation -> Operation -> Bool

(/=) :: Operation -> Operation -> Bool

Ord Operation 
Instance details

Defined in HsLua.ObjectOrientation.Operation

Methods

compare :: Operation -> Operation -> Ordering

(<) :: Operation -> Operation -> Bool

(<=) :: Operation -> Operation -> Bool

(>) :: Operation -> Operation -> Bool

(>=) :: Operation -> Operation -> Bool

max :: Operation -> Operation -> Operation

min :: Operation -> Operation -> Operation

data Property e a #

data Possible a #

Constructors

Actual a 
Absent