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

/No description available in the introspection data./
-}

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

module GI.WebKit2WebExtension.Objects.DOMObject
    (

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


 -- * Properties
-- ** coreObject #attr:coreObject#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    DOMObjectCoreObjectPropertyInfo         ,
#endif
    constructDOMObjectCoreObject            ,
#if ENABLE_OVERLOADING
    dOMObjectCoreObject                     ,
#endif




    ) 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.GClosure as B.GClosure
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.GI.Base.Properties as B.Properties
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 GHC.OverloadedLabels as OL

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

-- | Memory-managed wrapper type.
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


-- | Type class for types which can be safely cast to `DOMObject`, for instance with `toDOMObject`.
class (GObject o, O.IsDescendantOf DOMObject o) => IsDOMObject o
instance (GObject o, O.IsDescendantOf DOMObject o) => IsDOMObject o

instance O.HasParentTypes DOMObject
type instance O.ParentTypes DOMObject = '[GObject.Object.Object]

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

-- | A convenience alias for `Nothing` :: `Maybe` `DOMObject`.
noDOMObject :: Maybe DOMObject
noDOMObject = Nothing

#if ENABLE_OVERLOADING
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 "getv" o = GObject.Object.ObjectGetvMethodInfo
    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 "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 "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveDOMObjectMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveDOMObjectMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveDOMObjectMethod t DOMObject, O.MethodInfo info DOMObject p) => OL.IsLabel t (DOMObject -> 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

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

{- |
Construct a `GValueConstruct` with valid value for the “@core-object@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructDOMObjectCoreObject :: (IsDOMObject o) => Ptr () -> IO (GValueConstruct o)
constructDOMObjectCoreObject val = B.Properties.constructObjectPropertyPtr "core-object" val

#if ENABLE_OVERLOADING
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
#endif

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

#if ENABLE_OVERLOADING
dOMObjectCoreObject :: AttrLabelProxy "coreObject"
dOMObjectCoreObject = AttrLabelProxy

#endif

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

#endif