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

module GI.WebKit2WebExtension.Objects.DOMObject
    ( 

-- * Exported types
    DOMObject(..)                           ,
    IsDOMObject                             ,
    toDOMObject                             ,
    noDOMObject                             ,


 -- * Properties
-- ** coreObject #attr:coreObject#
    DOMObjectCoreObjectPropertyInfo         ,
    constructDOMObjectCoreObject            ,
    dOMObjectCoreObject                     ,




    ) 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.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

newtype DOMObject = DOMObject (ManagedPtr DOMObject)
foreign import ccall "webkit_dom_object_get_type"
    c_webkit_dom_object_get_type :: IO GType

instance GObject DOMObject where
    gobjectType _ = c_webkit_dom_object_get_type
    

class GObject o => IsDOMObject o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError DOMObject a) =>
    IsDOMObject a
#endif
instance IsDOMObject DOMObject
instance GObject.Object.IsObject DOMObject

toDOMObject :: IsDOMObject o => o -> IO DOMObject
toDOMObject = unsafeCastTo DOMObject

noDOMObject :: Maybe DOMObject
noDOMObject = Nothing

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

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

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

-- VVV Prop "core-object"
   -- Type: TBasicType TPtr
   -- Flags: [PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

constructDOMObjectCoreObject :: (IsDOMObject o) => Ptr () -> IO (GValueConstruct o)
constructDOMObjectCoreObject val = constructObjectPropertyPtr "core-object" val

data DOMObjectCoreObjectPropertyInfo
instance AttrInfo DOMObjectCoreObjectPropertyInfo where
    type AttrAllowedOps DOMObjectCoreObjectPropertyInfo = '[ 'AttrConstruct]
    type AttrSetTypeConstraint DOMObjectCoreObjectPropertyInfo = (~) (Ptr ())
    type AttrBaseTypeConstraint DOMObjectCoreObjectPropertyInfo = IsDOMObject
    type AttrGetType DOMObjectCoreObjectPropertyInfo = ()
    type AttrLabel DOMObjectCoreObjectPropertyInfo = "core-object"
    type AttrOrigin DOMObjectCoreObjectPropertyInfo = DOMObject
    attrGet _ = undefined
    attrSet _ = undefined
    attrConstruct _ = constructDOMObjectCoreObject
    attrClear _ = undefined

instance O.HasAttributeList DOMObject
type instance O.AttributeList DOMObject = DOMObjectAttributeList
type DOMObjectAttributeList = ('[ '("coreObject", DOMObjectCoreObjectPropertyInfo)] :: [(Symbol, *)])

dOMObjectCoreObject :: AttrLabelProxy "coreObject"
dOMObjectCoreObject = AttrLabelProxy

type instance O.SignalList DOMObject = DOMObjectSignalList
type DOMObjectSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])