| Safe Haskell | None |
|---|
Graphics.QML.Objects
Description
Facilities for defining new object types which can be marshalled between Haskell and QML.
- class Typeable tt => Object tt where
- data ClassDef tt
- data Member tt
- defClass :: forall tt. Object tt => [Member tt] -> ClassDef tt
- defMethod :: forall tt ms. (MarshalThis tt, MethodSuffix ms) => String -> (tt -> ms) -> Member (ThisObj tt)
- class MethodSuffix a
- defPropertyRO :: forall tt tr. (MarshalThis tt, MarshalOut tr) => String -> (tt -> IO tr) -> Member (ThisObj tt)
- defPropertyRW :: forall tt tr. (MarshalThis tt, MarshalOut tr) => String -> (tt -> IO tr) -> (tt -> tr -> IO ()) -> Member (ThisObj tt)
- data ObjRef tt
- newObject :: forall tt. Object tt => tt -> IO (ObjRef tt)
- fromObjRef :: ObjRef tt -> tt
- objectInMarshaller :: Object tt => InMarshaller tt
- class Object (ThisObj tt) => MarshalThis tt where
- objectThisMarshaller :: (Object tt, ThisObj tt ~ tt) => ThisMarshaller tt
Class Definition
class Typeable tt => Object tt whereSource
The class Object allows Haskell types to expose an object-oriented
interface to QML.
Methods
defMethod :: forall tt ms. (MarshalThis tt, MethodSuffix ms) => String -> (tt -> ms) -> Member (ThisObj tt)Source
Defines a named method using a function f in the IO monad.
The first argument to f receives the "this" object and hence must match
the type of the class on which the method is being defined. Subsequently,
there may be zero or more parameter arguments followed by an optional return
argument in the IO monad. These argument types must be members of the
MarshalThis, MarshalIn, and MarshalOut typeclasses respectively.
class MethodSuffix a Source
Supports marshalling Haskell functions with an arbitrary number of arguments.
Instances
| MarshalOut a => MethodSuffix (IO a) | |
| (MarshalIn a, MethodSuffix b) => MethodSuffix (a -> b) |
Properties
defPropertyRO :: forall tt tr. (MarshalThis tt, MarshalOut tr) => String -> (tt -> IO tr) -> Member (ThisObj tt)Source
Defines a named read-only property using an accessor function in the IO monad.
defPropertyRW :: forall tt tr. (MarshalThis tt, MarshalOut tr) => String -> (tt -> IO tr) -> (tt -> tr -> IO ()) -> Member (ThisObj tt)Source
Defines a named read-write property using a pair of accessor and mutator functions in the IO monad.
Object References
Represents an instance of the QML class which wraps the type tt.
newObject :: forall tt. Object tt => tt -> IO (ObjRef tt)Source
Creates an instance of a QML class given a value of the underlying Haskell
type tt.
fromObjRef :: ObjRef tt -> ttSource
Returns the associated value of the underlying Haskell type tt from an
instance of the QML class which wraps it.
Marshalling Type-classes
objectInMarshaller :: Object tt => InMarshaller ttSource
Provides an InMarshaller which allows you to define instances of
MarshalIn for custom object types. For example:
instance MarshalIn MyObjectType where
mIn = objectInMarshaller
This instance would allow MyObjectType to be used as a parameter type
in callbacks. An instance is provided for by
default.
ObjRef MyObjectType
class Object (ThisObj tt) => MarshalThis tt whereSource
The class MarshalThis allows objects to be marshalled back into
Haskell as the "this" value for callbacks.
objectThisMarshaller :: (Object tt, ThisObj tt ~ tt) => ThisMarshaller ttSource
Provides an ThisMarshaller which allows you to define instances of
MarshalThis for custom object types. For example:
instance MarshalThis MyObjectType where
type (ThisObj MyObjectType) = MyObjectType
mIn = objectInMarshaller
This instance would allow MyObjectType to be used as the "this" type
for callbacks. An instance is provided for by
default.
ObjRef MyObjectType