{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- /No description available in the introspection data./

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

module GI.WebKit2WebExtension.Objects.DOMNodeList
    ( 

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


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveDOMNodeListMethod                ,
#endif


-- ** getLength #method:getLength#

#if defined(ENABLE_OVERLOADING)
    DOMNodeListGetLengthMethodInfo          ,
#endif
    dOMNodeListGetLength                    ,


-- ** item #method:item#

#if defined(ENABLE_OVERLOADING)
    DOMNodeListItemMethodInfo               ,
#endif
    dOMNodeListItem                         ,




 -- * Properties
-- ** length #attr:length#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    DOMNodeListLengthPropertyInfo           ,
#endif
#if defined(ENABLE_OVERLOADING)
    dOMNodeListLength                       ,
#endif
    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.BasicTypes as B.Types
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.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
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
import {-# SOURCE #-} qualified GI.WebKit2WebExtension.Objects.DOMNode as WebKit2WebExtension.DOMNode
import {-# SOURCE #-} qualified GI.WebKit2WebExtension.Objects.DOMObject as WebKit2WebExtension.DOMObject

-- | Memory-managed wrapper type.
newtype DOMNodeList = DOMNodeList (SP.ManagedPtr DOMNodeList)
    deriving (DOMNodeList -> DOMNodeList -> Bool
(DOMNodeList -> DOMNodeList -> Bool)
-> (DOMNodeList -> DOMNodeList -> Bool) -> Eq DOMNodeList
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DOMNodeList -> DOMNodeList -> Bool
$c/= :: DOMNodeList -> DOMNodeList -> Bool
== :: DOMNodeList -> DOMNodeList -> Bool
$c== :: DOMNodeList -> DOMNodeList -> Bool
Eq)

instance SP.ManagedPtrNewtype DOMNodeList where
    toManagedPtr :: DOMNodeList -> ManagedPtr DOMNodeList
toManagedPtr (DOMNodeList ManagedPtr DOMNodeList
p) = ManagedPtr DOMNodeList
p

foreign import ccall "webkit_dom_node_list_get_type"
    c_webkit_dom_node_list_get_type :: IO B.Types.GType

instance B.Types.TypedObject DOMNodeList where
    glibType :: IO GType
glibType = IO GType
c_webkit_dom_node_list_get_type

instance B.Types.GObject DOMNodeList

-- | Convert 'DOMNodeList' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue DOMNodeList where
    toGValue :: DOMNodeList -> IO GValue
toGValue DOMNodeList
o = do
        GType
gtype <- IO GType
c_webkit_dom_node_list_get_type
        DOMNodeList -> (Ptr DOMNodeList -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr DOMNodeList
o (GType
-> (GValue -> Ptr DOMNodeList -> IO ())
-> Ptr DOMNodeList
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr DOMNodeList -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO DOMNodeList
fromGValue GValue
gv = do
        Ptr DOMNodeList
ptr <- GValue -> IO (Ptr DOMNodeList)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr DOMNodeList)
        (ManagedPtr DOMNodeList -> DOMNodeList)
-> Ptr DOMNodeList -> IO DOMNodeList
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr DOMNodeList -> DOMNodeList
DOMNodeList Ptr DOMNodeList
ptr
        
    

-- | Type class for types which can be safely cast to `DOMNodeList`, for instance with `toDOMNodeList`.
class (SP.GObject o, O.IsDescendantOf DOMNodeList o) => IsDOMNodeList o
instance (SP.GObject o, O.IsDescendantOf DOMNodeList o) => IsDOMNodeList o

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

-- | Cast to `DOMNodeList`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toDOMNodeList :: (MonadIO m, IsDOMNodeList o) => o -> m DOMNodeList
toDOMNodeList :: o -> m DOMNodeList
toDOMNodeList = IO DOMNodeList -> m DOMNodeList
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO DOMNodeList -> m DOMNodeList)
-> (o -> IO DOMNodeList) -> o -> m DOMNodeList
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr DOMNodeList -> DOMNodeList) -> o -> IO DOMNodeList
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
 ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr DOMNodeList -> DOMNodeList
DOMNodeList

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

instance (info ~ ResolveDOMNodeListMethod t DOMNodeList, O.MethodInfo info DOMNodeList p) => OL.IsLabel t (DOMNodeList -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif

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

-- | Get the value of the “@length@” property.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' dOMNodeList #length
-- @
getDOMNodeListLength :: (MonadIO m, IsDOMNodeList o) => o -> m CULong
getDOMNodeListLength :: o -> m CULong
getDOMNodeListLength o
obj = IO CULong -> m CULong
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CULong -> m CULong) -> IO CULong -> m CULong
forall a b. (a -> b) -> a -> b
$ o -> String -> IO CULong
forall a. GObject a => a -> String -> IO CULong
B.Properties.getObjectPropertyULong o
obj String
"length"

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

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

#if defined(ENABLE_OVERLOADING)
dOMNodeListLength :: AttrLabelProxy "length"
dOMNodeListLength = AttrLabelProxy

#endif

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

#endif

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

{-# DEPRECATED dOMNodeListGetLength ["(Since version 2.22)","Use JavaScriptCore API instead"] #-}
-- | /No description available in the introspection data./
dOMNodeListGetLength ::
    (B.CallStack.HasCallStack, MonadIO m, IsDOMNodeList a) =>
    a
    -- ^ /@self@/: A t'GI.WebKit2WebExtension.Objects.DOMNodeList.DOMNodeList'
    -> m CULong
    -- ^ __Returns:__ A @/gulong/@
dOMNodeListGetLength :: a -> m CULong
dOMNodeListGetLength a
self = IO CULong -> m CULong
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CULong -> m CULong) -> IO CULong -> m CULong
forall a b. (a -> b) -> a -> b
$ do
    Ptr DOMNodeList
self' <- a -> IO (Ptr DOMNodeList)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
self
    CULong
result <- Ptr DOMNodeList -> IO CULong
webkit_dom_node_list_get_length Ptr DOMNodeList
self'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
self
    CULong -> IO CULong
forall (m :: * -> *) a. Monad m => a -> m a
return CULong
result

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

#endif

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

{-# DEPRECATED dOMNodeListItem ["(Since version 2.22)","Use JavaScriptCore API instead"] #-}
-- | /No description available in the introspection data./
dOMNodeListItem ::
    (B.CallStack.HasCallStack, MonadIO m, IsDOMNodeList a) =>
    a
    -- ^ /@self@/: A t'GI.WebKit2WebExtension.Objects.DOMNodeList.DOMNodeList'
    -> CULong
    -- ^ /@index@/: A @/gulong/@
    -> m (Maybe WebKit2WebExtension.DOMNode.DOMNode)
    -- ^ __Returns:__ A t'GI.WebKit2WebExtension.Objects.DOMNode.DOMNode'
dOMNodeListItem :: a -> CULong -> m (Maybe DOMNode)
dOMNodeListItem a
self CULong
index = IO (Maybe DOMNode) -> m (Maybe DOMNode)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe DOMNode) -> m (Maybe DOMNode))
-> IO (Maybe DOMNode) -> m (Maybe DOMNode)
forall a b. (a -> b) -> a -> b
$ do
    Ptr DOMNodeList
self' <- a -> IO (Ptr DOMNodeList)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
self
    Ptr DOMNode
result <- Ptr DOMNodeList -> CULong -> IO (Ptr DOMNode)
webkit_dom_node_list_item Ptr DOMNodeList
self' CULong
index
    Maybe DOMNode
maybeResult <- Ptr DOMNode -> (Ptr DOMNode -> IO DOMNode) -> IO (Maybe DOMNode)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr DOMNode
result ((Ptr DOMNode -> IO DOMNode) -> IO (Maybe DOMNode))
-> (Ptr DOMNode -> IO DOMNode) -> IO (Maybe DOMNode)
forall a b. (a -> b) -> a -> b
$ \Ptr DOMNode
result' -> do
        DOMNode
result'' <- ((ManagedPtr DOMNode -> DOMNode) -> Ptr DOMNode -> IO DOMNode
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr DOMNode -> DOMNode
WebKit2WebExtension.DOMNode.DOMNode) Ptr DOMNode
result'
        DOMNode -> IO DOMNode
forall (m :: * -> *) a. Monad m => a -> m a
return DOMNode
result''
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
self
    Maybe DOMNode -> IO (Maybe DOMNode)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe DOMNode
maybeResult

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

#endif