{- |
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.WebKit.Objects.DOMHTMLCollection
    ( 

-- * Exported types
    DOMHTMLCollection(..)                   ,
    DOMHTMLCollectionK                      ,
    toDOMHTMLCollection                     ,
    noDOMHTMLCollection                     ,


 -- * Methods
-- ** dOMHTMLCollectionGetLength
    dOMHTMLCollectionGetLength              ,


-- ** dOMHTMLCollectionItem
    dOMHTMLCollectionItem                   ,


-- ** dOMHTMLCollectionNamedItem
    dOMHTMLCollectionNamedItem              ,




 -- * Properties
-- ** Length
    DOMHTMLCollectionLengthPropertyInfo     ,
    getDOMHTMLCollectionLength              ,




    ) 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.WebKit.Types
import GI.WebKit.Callbacks
import qualified GI.GObject as GObject

newtype DOMHTMLCollection = DOMHTMLCollection (ForeignPtr DOMHTMLCollection)
foreign import ccall "webkit_dom_html_collection_get_type"
    c_webkit_dom_html_collection_get_type :: IO GType

type instance ParentTypes DOMHTMLCollection = DOMHTMLCollectionParentTypes
type DOMHTMLCollectionParentTypes = '[DOMObject, GObject.Object]

instance GObject DOMHTMLCollection where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_dom_html_collection_get_type
    

class GObject o => DOMHTMLCollectionK o
instance (GObject o, IsDescendantOf DOMHTMLCollection o) => DOMHTMLCollectionK o

toDOMHTMLCollection :: DOMHTMLCollectionK o => o -> IO DOMHTMLCollection
toDOMHTMLCollection = unsafeCastTo DOMHTMLCollection

noDOMHTMLCollection :: Maybe DOMHTMLCollection
noDOMHTMLCollection = Nothing

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

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

data DOMHTMLCollectionLengthPropertyInfo
instance AttrInfo DOMHTMLCollectionLengthPropertyInfo where
    type AttrAllowedOps DOMHTMLCollectionLengthPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMHTMLCollectionLengthPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMHTMLCollectionLengthPropertyInfo = DOMHTMLCollectionK
    type AttrGetType DOMHTMLCollectionLengthPropertyInfo = Word64
    type AttrLabel DOMHTMLCollectionLengthPropertyInfo = "DOMHTMLCollection::length"
    attrGet _ = getDOMHTMLCollectionLength
    attrSet _ = undefined
    attrConstruct _ = undefined

type instance AttributeList DOMHTMLCollection = DOMHTMLCollectionAttributeList
type DOMHTMLCollectionAttributeList = ('[ '("core-object", DOMObjectCoreObjectPropertyInfo), '("length", DOMHTMLCollectionLengthPropertyInfo)] :: [(Symbol, *)])

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

-- method DOMHTMLCollection::get_length
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMHTMLCollection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMHTMLCollection", 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_html_collection_get_length" webkit_dom_html_collection_get_length :: 
    Ptr DOMHTMLCollection ->                -- _obj : TInterface "WebKit" "DOMHTMLCollection"
    IO Word64


dOMHTMLCollectionGetLength ::
    (MonadIO m, DOMHTMLCollectionK a) =>
    a ->                                    -- _obj
    m Word64
dOMHTMLCollectionGetLength _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_html_collection_get_length _obj'
    touchManagedPtr _obj
    return result

-- method DOMHTMLCollection::item
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMHTMLCollection", 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 "WebKit" "DOMHTMLCollection", 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 "WebKit" "DOMNode"
-- throws : False
-- Skip return : False

foreign import ccall "webkit_dom_html_collection_item" webkit_dom_html_collection_item :: 
    Ptr DOMHTMLCollection ->                -- _obj : TInterface "WebKit" "DOMHTMLCollection"
    Word64 ->                               -- index : TBasicType TUInt64
    IO (Ptr DOMNode)


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

-- method DOMHTMLCollection::named_item
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMHTMLCollection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMHTMLCollection", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "WebKit" "DOMNode"
-- throws : False
-- Skip return : False

foreign import ccall "webkit_dom_html_collection_named_item" webkit_dom_html_collection_named_item :: 
    Ptr DOMHTMLCollection ->                -- _obj : TInterface "WebKit" "DOMHTMLCollection"
    CString ->                              -- name : TBasicType TUTF8
    IO (Ptr DOMNode)


dOMHTMLCollectionNamedItem ::
    (MonadIO m, DOMHTMLCollectionK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- name
    m DOMNode
dOMHTMLCollectionNamedItem _obj name = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    name' <- textToCString name
    result <- webkit_dom_html_collection_named_item _obj' name'
    checkUnexpectedReturnNULL "webkit_dom_html_collection_named_item" result
    result' <- (newObject DOMNode) result
    touchManagedPtr _obj
    freeMem name'
    return result'