{- |
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(..)                         ,
    DOMNodeListK                            ,
    toDOMNodeList                           ,
    noDOMNodeList                           ,


 -- * Methods
-- ** dOMNodeListGetLength
    dOMNodeListGetLength                    ,


-- ** dOMNodeListItem
    dOMNodeListItem                         ,




 -- * Properties
-- ** Length
    DOMNodeListLengthPropertyInfo           ,
    getDOMNodeListLength                    ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.WebKit2WebExtension.Types
import GI.WebKit2WebExtension.Callbacks
import qualified GI.GObject as GObject

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

type instance ParentTypes DOMNodeList = DOMNodeListParentTypes
type DOMNodeListParentTypes = '[DOMObject, GObject.Object]

instance GObject DOMNodeList where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_dom_node_list_get_type
    

class GObject o => DOMNodeListK o
instance (GObject o, IsDescendantOf DOMNodeList o) => DOMNodeListK o

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

noDOMNodeList :: Maybe DOMNodeList
noDOMNodeList = Nothing

-- VVV Prop "length"
   -- Type: TBasicType TUInt64
   -- Flags: [PropertyReadable]

getDOMNodeListLength :: (MonadIO m, DOMNodeListK o) => o -> m Word64
getDOMNodeListLength obj = liftIO $ getObjectPropertyUInt64 obj "length"

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

type instance AttributeList DOMNodeList = DOMNodeListAttributeList
type DOMNodeListAttributeList = ('[ '("core-object", DOMObjectCoreObjectPropertyInfo), '("length", DOMNodeListLengthPropertyInfo)] :: [(Symbol, *)])

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

-- method DOMNodeList::get_length
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2WebExtension" "DOMNodeList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2WebExtension" "DOMNodeList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt64
-- throws : False
-- Skip return : False

foreign import ccall "webkit_dom_node_list_get_length" webkit_dom_node_list_get_length :: 
    Ptr DOMNodeList ->                      -- _obj : TInterface "WebKit2WebExtension" "DOMNodeList"
    IO Word64


dOMNodeListGetLength ::
    (MonadIO m, DOMNodeListK a) =>
    a ->                                    -- _obj
    m Word64
dOMNodeListGetLength _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_node_list_get_length _obj'
    touchManagedPtr _obj
    return result

-- method DOMNodeList::item
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2WebExtension" "DOMNodeList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "index", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2WebExtension" "DOMNodeList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "index", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "WebKit2WebExtension" "DOMNode"
-- throws : False
-- Skip return : False

foreign import ccall "webkit_dom_node_list_item" webkit_dom_node_list_item :: 
    Ptr DOMNodeList ->                      -- _obj : TInterface "WebKit2WebExtension" "DOMNodeList"
    Word64 ->                               -- index : TBasicType TUInt64
    IO (Ptr DOMNode)


dOMNodeListItem ::
    (MonadIO m, DOMNodeListK a) =>
    a ->                                    -- _obj
    Word64 ->                               -- index
    m DOMNode
dOMNodeListItem _obj index = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_node_list_item _obj' index
    checkUnexpectedReturnNULL "webkit_dom_node_list_item" result
    result' <- (newObject DOMNode) result
    touchManagedPtr _obj
    return result'