{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

'GI.Pango.Objects.Engine.Engine' is the base class for all types of language and
script specific engines. It has no functionality by itself.
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.Pango.Objects.Engine
    (

-- * Exported types
    Engine(..)                              ,
    IsEngine                                ,
    toEngine                                ,
    noEngine                                ,


    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object

-- | Memory-managed wrapper type.
newtype Engine = Engine (ManagedPtr Engine)
foreign import ccall "pango_engine_get_type"
    c_pango_engine_get_type :: IO GType

instance GObject Engine where
    gobjectType _ = c_pango_engine_get_type


-- | Type class for types which can be safely cast to `Engine`, for instance with `toEngine`.
class GObject o => IsEngine o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Engine a) =>
    IsEngine a
#endif
instance IsEngine Engine
instance GObject.Object.IsObject Engine

-- | Cast to `Engine`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toEngine :: (MonadIO m, IsEngine o) => o -> m Engine
toEngine = liftIO . unsafeCastTo Engine

-- | A convenience alias for `Nothing` :: `Maybe` `Engine`.
noEngine :: Maybe Engine
noEngine = Nothing

#if ENABLE_OVERLOADING
type family ResolveEngineMethod (t :: Symbol) (o :: *) :: * where
    ResolveEngineMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveEngineMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveEngineMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveEngineMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveEngineMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveEngineMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveEngineMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveEngineMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveEngineMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveEngineMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveEngineMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveEngineMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveEngineMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveEngineMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveEngineMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveEngineMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveEngineMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveEngineMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveEngineMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveEngineMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveEngineMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveEngineMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveEngineMethod t Engine, O.MethodInfo info Engine p) => O.IsLabelProxy t (Engine -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveEngineMethod t Engine, O.MethodInfo info Engine p) => O.IsLabel t (Engine -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif

#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList Engine
type instance O.AttributeList Engine = EngineAttributeList
type EngineAttributeList = ('[ ] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
#endif

#if ENABLE_OVERLOADING
type instance O.SignalList Engine = EngineSignalList
type EngineSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif