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

-- * Exported types
    DOMDocumentFragment(..)                 ,
    DOMDocumentFragmentK                    ,
    toDOMDocumentFragment                   ,
    noDOMDocumentFragment                   ,


 -- * Methods
-- ** dOMDocumentFragmentQuerySelector
    dOMDocumentFragmentQuerySelector        ,


-- ** dOMDocumentFragmentQuerySelectorAll
    dOMDocumentFragmentQuerySelectorAll     ,




    ) 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 DOMDocumentFragment = DOMDocumentFragment (ForeignPtr DOMDocumentFragment)
foreign import ccall "webkit_dom_document_fragment_get_type"
    c_webkit_dom_document_fragment_get_type :: IO GType

type instance ParentTypes DOMDocumentFragment = DOMDocumentFragmentParentTypes
type DOMDocumentFragmentParentTypes = '[DOMNode, DOMObject, GObject.Object, DOMEventTarget]

instance GObject DOMDocumentFragment where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_dom_document_fragment_get_type
    

class GObject o => DOMDocumentFragmentK o
instance (GObject o, IsDescendantOf DOMDocumentFragment o) => DOMDocumentFragmentK o

toDOMDocumentFragment :: DOMDocumentFragmentK o => o -> IO DOMDocumentFragment
toDOMDocumentFragment = unsafeCastTo DOMDocumentFragment

noDOMDocumentFragment :: Maybe DOMDocumentFragment
noDOMDocumentFragment = Nothing

type instance AttributeList DOMDocumentFragment = DOMDocumentFragmentAttributeList
type DOMDocumentFragmentAttributeList = ('[ '("base-uri", DOMNodeBaseUriPropertyInfo), '("child-nodes", DOMNodeChildNodesPropertyInfo), '("core-object", DOMObjectCoreObjectPropertyInfo), '("first-child", DOMNodeFirstChildPropertyInfo), '("last-child", DOMNodeLastChildPropertyInfo), '("local-name", DOMNodeLocalNamePropertyInfo), '("namespace-uri", DOMNodeNamespaceUriPropertyInfo), '("next-sibling", DOMNodeNextSiblingPropertyInfo), '("node-name", DOMNodeNodeNamePropertyInfo), '("node-type", DOMNodeNodeTypePropertyInfo), '("node-value", DOMNodeNodeValuePropertyInfo), '("owner-document", DOMNodeOwnerDocumentPropertyInfo), '("parent-element", DOMNodeParentElementPropertyInfo), '("parent-node", DOMNodeParentNodePropertyInfo), '("prefix", DOMNodePrefixPropertyInfo), '("previous-sibling", DOMNodePreviousSiblingPropertyInfo), '("text-content", DOMNodeTextContentPropertyInfo)] :: [(Symbol, *)])

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

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

foreign import ccall "webkit_dom_document_fragment_query_selector" webkit_dom_document_fragment_query_selector :: 
    Ptr DOMDocumentFragment ->              -- _obj : TInterface "WebKit" "DOMDocumentFragment"
    CString ->                              -- selectors : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr DOMElement)


dOMDocumentFragmentQuerySelector ::
    (MonadIO m, DOMDocumentFragmentK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- selectors
    m DOMElement
dOMDocumentFragmentQuerySelector _obj selectors = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    selectors' <- textToCString selectors
    onException (do
        result <- propagateGError $ webkit_dom_document_fragment_query_selector _obj' selectors'
        checkUnexpectedReturnNULL "webkit_dom_document_fragment_query_selector" result
        result' <- (newObject DOMElement) result
        touchManagedPtr _obj
        freeMem selectors'
        return result'
     ) (do
        freeMem selectors'
     )

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

foreign import ccall "webkit_dom_document_fragment_query_selector_all" webkit_dom_document_fragment_query_selector_all :: 
    Ptr DOMDocumentFragment ->              -- _obj : TInterface "WebKit" "DOMDocumentFragment"
    CString ->                              -- selectors : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr DOMNodeList)


dOMDocumentFragmentQuerySelectorAll ::
    (MonadIO m, DOMDocumentFragmentK a) =>
    a ->                                    -- _obj
    T.Text ->                               -- selectors
    m DOMNodeList
dOMDocumentFragmentQuerySelectorAll _obj selectors = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    selectors' <- textToCString selectors
    onException (do
        result <- propagateGError $ webkit_dom_document_fragment_query_selector_all _obj' selectors'
        checkUnexpectedReturnNULL "webkit_dom_document_fragment_query_selector_all" result
        result' <- (wrapObject DOMNodeList) result
        touchManagedPtr _obj
        freeMem selectors'
        return result'
     ) (do
        freeMem selectors'
     )