{- |
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.DOMNodeList
    ( 

-- * Exported types
    DOMNodeList(..)                         ,
    IsDOMNodeList                           ,
    toDOMNodeList                           ,
    noDOMNodeList                           ,


 -- * Methods
-- ** getLength #method:getLength#
    DOMNodeListGetLengthMethodInfo          ,
    dOMNodeListGetLength                    ,


-- ** item #method:item#
    DOMNodeListItemMethodInfo               ,
    dOMNodeListItem                         ,




 -- * Properties
-- ** length #attr:length#
    DOMNodeListLengthPropertyInfo           ,
    dOMNodeListLength                       ,
    getDOMNodeListLength                    ,




    ) 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
import {-# SOURCE #-} qualified GI.WebKit2WebExtension.Objects.DOMNode as WebKit2WebExtension.DOMNode
import {-# SOURCE #-} qualified GI.WebKit2WebExtension.Objects.DOMObject as WebKit2WebExtension.DOMObject

newtype DOMNodeList = DOMNodeList (ManagedPtr DOMNodeList)
foreign import ccall "webkit_dom_node_list_get_type"
    c_webkit_dom_node_list_get_type :: IO GType

instance GObject DOMNodeList where
    gobjectType _ = c_webkit_dom_node_list_get_type
    

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

toDOMNodeList :: IsDOMNodeList o => o -> IO DOMNodeList
toDOMNodeList = unsafeCastTo DOMNodeList

noDOMNodeList :: Maybe DOMNodeList
noDOMNodeList = Nothing

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

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

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

-- VVV Prop "length"
   -- Type: TBasicType TULong
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

getDOMNodeListLength :: (MonadIO m, IsDOMNodeList o) => o -> m CULong
getDOMNodeListLength obj = liftIO $ getObjectPropertyULong obj "length"

data DOMNodeListLengthPropertyInfo
instance AttrInfo DOMNodeListLengthPropertyInfo where
    type AttrAllowedOps DOMNodeListLengthPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMNodeListLengthPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMNodeListLengthPropertyInfo = IsDOMNodeList
    type AttrGetType DOMNodeListLengthPropertyInfo = CULong
    type AttrLabel DOMNodeListLengthPropertyInfo = "length"
    type AttrOrigin DOMNodeListLengthPropertyInfo = DOMNodeList
    attrGet _ = getDOMNodeListLength
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined

instance O.HasAttributeList DOMNodeList
type instance O.AttributeList DOMNodeList = DOMNodeListAttributeList
type DOMNodeListAttributeList = ('[ '("coreObject", WebKit2WebExtension.DOMObject.DOMObjectCoreObjectPropertyInfo), '("length", DOMNodeListLengthPropertyInfo)] :: [(Symbol, *)])

dOMNodeListLength :: AttrLabelProxy "length"
dOMNodeListLength = AttrLabelProxy

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

-- method DOMNodeList::get_length
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "WebKit2WebExtension", name = "DOMNodeList"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitDOMNodeList", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TULong)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_dom_node_list_get_length" webkit_dom_node_list_get_length :: 
    Ptr DOMNodeList ->                      -- self : TInterface (Name {namespace = "WebKit2WebExtension", name = "DOMNodeList"})
    IO CULong

{- |
/No description available in the introspection data./
-}
dOMNodeListGetLength ::
    (B.CallStack.HasCallStack, MonadIO m, IsDOMNodeList a) =>
    a
    {- ^ /@self@/: A 'GI.WebKit2WebExtension.Objects.DOMNodeList.DOMNodeList' -}
    -> m CULong
    {- ^ __Returns:__ A @/gulong/@ -}
dOMNodeListGetLength self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- webkit_dom_node_list_get_length self'
    touchManagedPtr self
    return result

data DOMNodeListGetLengthMethodInfo
instance (signature ~ (m CULong), MonadIO m, IsDOMNodeList a) => O.MethodInfo DOMNodeListGetLengthMethodInfo a signature where
    overloadedMethod _ = dOMNodeListGetLength

-- method DOMNodeList::item
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "WebKit2WebExtension", name = "DOMNodeList"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitDOMNodeList", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "index", argType = TBasicType TULong, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #gulong", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "WebKit2WebExtension", name = "DOMNode"}))
-- throws : False
-- Skip return : False

foreign import ccall "webkit_dom_node_list_item" webkit_dom_node_list_item :: 
    Ptr DOMNodeList ->                      -- self : TInterface (Name {namespace = "WebKit2WebExtension", name = "DOMNodeList"})
    CULong ->                               -- index : TBasicType TULong
    IO (Ptr WebKit2WebExtension.DOMNode.DOMNode)

{- |
/No description available in the introspection data./
-}
dOMNodeListItem ::
    (B.CallStack.HasCallStack, MonadIO m, IsDOMNodeList a) =>
    a
    {- ^ /@self@/: A 'GI.WebKit2WebExtension.Objects.DOMNodeList.DOMNodeList' -}
    -> CULong
    {- ^ /@index@/: A @/gulong/@ -}
    -> m WebKit2WebExtension.DOMNode.DOMNode
    {- ^ __Returns:__ A 'GI.WebKit2WebExtension.Objects.DOMNode.DOMNode' -}
dOMNodeListItem self index = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- webkit_dom_node_list_item self' index
    checkUnexpectedReturnNULL "dOMNodeListItem" result
    result' <- (newObject WebKit2WebExtension.DOMNode.DOMNode) result
    touchManagedPtr self
    return result'

data DOMNodeListItemMethodInfo
instance (signature ~ (CULong -> m WebKit2WebExtension.DOMNode.DOMNode), MonadIO m, IsDOMNodeList a) => O.MethodInfo DOMNodeListItemMethodInfo a signature where
    overloadedMethod _ = dOMNodeListItem