module HsLua.Packaging.UDType
( DocumentedType
, DocumentedTypeWithList
, deftype
, deftype'
, method
, property
, possibleProperty
, readonly
, alias
, operation
, peekUD
, pushUD
, udparam
, udresult
, Member
, Operation (..)
, Property
, Possible (..)
) where
import Data.Text (Text)
import HsLua.Core
import HsLua.ObjectOrientation
import HsLua.ObjectOrientation.Operation (metamethodName)
import HsLua.Packaging.Function
import qualified HsLua.Core.Utf8 as Utf8
type DocumentedType e a = UDType e (DocumentedFunction e) a
type DocumentedTypeWithList e a itemtype =
UDTypeWithList e (DocumentedFunction e) a itemtype
deftype :: LuaError e
=> Name
-> [(Operation, DocumentedFunction e)]
-> [Member e (DocumentedFunction e) a]
-> DocumentedType e a
deftype :: Name
-> [(Operation, DocumentedFunction e)]
-> [Member e (DocumentedFunction e) a]
-> DocumentedType e a
deftype = Pusher e (DocumentedFunction e)
-> Name
-> [(Operation, DocumentedFunction e)]
-> [Member e (DocumentedFunction e) a]
-> DocumentedType e a
forall e fn a.
Pusher e fn
-> Name -> [(Operation, fn)] -> [Member e fn a] -> UDType e fn a
deftypeGeneric Pusher e (DocumentedFunction e)
forall e. LuaError e => DocumentedFunction e -> LuaE e ()
pushDocumentedFunction
deftype' :: LuaError e
=> Name
-> [(Operation, DocumentedFunction e)]
-> [Member e (DocumentedFunction e) a]
-> Maybe (ListSpec e a itemtype)
-> DocumentedTypeWithList e a itemtype
deftype' :: Name
-> [(Operation, DocumentedFunction e)]
-> [Member e (DocumentedFunction e) a]
-> Maybe (ListSpec e a itemtype)
-> DocumentedTypeWithList e a itemtype
deftype' = Pusher e (DocumentedFunction e)
-> Name
-> [(Operation, DocumentedFunction e)]
-> [Member e (DocumentedFunction e) a]
-> Maybe (ListSpec e a itemtype)
-> DocumentedTypeWithList e a itemtype
forall e fn a itemtype.
Pusher e fn
-> Name
-> [(Operation, fn)]
-> [Member e fn a]
-> Maybe (ListSpec e a itemtype)
-> UDTypeWithList e fn a itemtype
deftypeGeneric' Pusher e (DocumentedFunction e)
forall e. LuaError e => DocumentedFunction e -> LuaE e ()
pushDocumentedFunction
method :: DocumentedFunction e
-> Member e (DocumentedFunction e) a
method :: DocumentedFunction e -> Member e (DocumentedFunction e) a
method DocumentedFunction e
f = Name -> DocumentedFunction e -> Member e (DocumentedFunction e) a
forall fn e a. Name -> fn -> Member e fn a
methodGeneric (DocumentedFunction e -> Name
forall e. DocumentedFunction e -> Name
functionName DocumentedFunction e
f) DocumentedFunction e
f
operation :: Operation
-> DocumentedFunction e
-> (Operation, DocumentedFunction e)
operation :: Operation
-> DocumentedFunction e -> (Operation, DocumentedFunction e)
operation Operation
op DocumentedFunction e
f = (,) Operation
op (DocumentedFunction e -> (Operation, DocumentedFunction e))
-> DocumentedFunction e -> (Operation, DocumentedFunction e)
forall a b. (a -> b) -> a -> b
$ Name -> DocumentedFunction e -> DocumentedFunction e
forall e. Name -> DocumentedFunction e -> DocumentedFunction e
setName (Operation -> Name
metamethodName Operation
op) DocumentedFunction e
f
udparam :: LuaError e
=> DocumentedTypeWithList e a itemtype
-> Text
-> Text
-> Parameter e a
udparam :: DocumentedTypeWithList e a itemtype
-> Text -> Text -> Parameter e a
udparam DocumentedTypeWithList e a itemtype
ty = Peeker e a -> Text -> Text -> Text -> Parameter e a
forall e a. Peeker e a -> Text -> Text -> Text -> Parameter e a
parameter (DocumentedTypeWithList e a itemtype -> Peeker e a
forall e fn a itemtype.
LuaError e =>
UDTypeWithList e fn a itemtype -> Peeker e a
peekUD DocumentedTypeWithList e a itemtype
ty) (ByteString -> Text
Utf8.toText (ByteString -> Text) -> (Name -> ByteString) -> Name -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> ByteString
fromName (Name -> Text) -> Name -> Text
forall a b. (a -> b) -> a -> b
$ DocumentedTypeWithList e a itemtype -> Name
forall e fn a itemtype. UDTypeWithList e fn a itemtype -> Name
udName DocumentedTypeWithList e a itemtype
ty)
udresult :: LuaError e
=> DocumentedTypeWithList e a itemtype
-> Text
-> FunctionResults e a
udresult :: DocumentedTypeWithList e a itemtype -> Text -> FunctionResults e a
udresult DocumentedTypeWithList e a itemtype
ty = Pusher e a -> Text -> Text -> FunctionResults e a
forall e a. Pusher e a -> Text -> Text -> FunctionResults e a
functionResult (DocumentedTypeWithList e a itemtype -> Pusher e a
forall e fn a itemtype.
LuaError e =>
UDTypeWithList e fn a itemtype -> a -> LuaE e ()
pushUD DocumentedTypeWithList e a itemtype
ty) (ByteString -> Text
Utf8.toText (ByteString -> Text) -> (Name -> ByteString) -> Name -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> ByteString
fromName (Name -> Text) -> Name -> Text
forall a b. (a -> b) -> a -> b
$ DocumentedTypeWithList e a itemtype -> Name
forall e fn a itemtype. UDTypeWithList e fn a itemtype -> Name
udName DocumentedTypeWithList e a itemtype
ty)