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

-- * Exported types
    DOMXPathExpression(..)                  ,
    DOMXPathExpressionK                     ,
    toDOMXPathExpression                    ,
    noDOMXPathExpression                    ,


 -- * Methods
-- ** dOMXPathExpressionEvaluate
    dOMXPathExpressionEvaluate              ,




    ) 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 DOMXPathExpression = DOMXPathExpression (ForeignPtr DOMXPathExpression)
foreign import ccall "webkit_dom_xpath_expression_get_type"
    c_webkit_dom_xpath_expression_get_type :: IO GType

type instance ParentTypes DOMXPathExpression = DOMXPathExpressionParentTypes
type DOMXPathExpressionParentTypes = '[DOMObject, GObject.Object]

instance GObject DOMXPathExpression where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_dom_xpath_expression_get_type
    

class GObject o => DOMXPathExpressionK o
instance (GObject o, IsDescendantOf DOMXPathExpression o) => DOMXPathExpressionK o

toDOMXPathExpression :: DOMXPathExpressionK o => o -> IO DOMXPathExpression
toDOMXPathExpression = unsafeCastTo DOMXPathExpression

noDOMXPathExpression :: Maybe DOMXPathExpression
noDOMXPathExpression = Nothing

type instance AttributeList DOMXPathExpression = DOMXPathExpressionAttributeList
type DOMXPathExpressionAttributeList = ('[ '("core-object", DOMObjectCoreObjectPropertyInfo)] :: [(Symbol, *)])

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

-- method DOMXPathExpression::evaluate
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit2WebExtension" "DOMXPathExpression", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "contextNode", argType = TInterface "WebKit2WebExtension" "DOMNode", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "inResult", argType = TInterface "WebKit2WebExtension" "DOMXPathResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit2WebExtension" "DOMXPathExpression", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "contextNode", argType = TInterface "WebKit2WebExtension" "DOMNode", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "inResult", argType = TInterface "WebKit2WebExtension" "DOMXPathResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "WebKit2WebExtension" "DOMXPathResult"
-- throws : True
-- Skip return : False

foreign import ccall "webkit_dom_xpath_expression_evaluate" webkit_dom_xpath_expression_evaluate :: 
    Ptr DOMXPathExpression ->               -- _obj : TInterface "WebKit2WebExtension" "DOMXPathExpression"
    Ptr DOMNode ->                          -- contextNode : TInterface "WebKit2WebExtension" "DOMNode"
    Word16 ->                               -- type : TBasicType TUInt16
    Ptr DOMXPathResult ->                   -- inResult : TInterface "WebKit2WebExtension" "DOMXPathResult"
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr DOMXPathResult)


dOMXPathExpressionEvaluate ::
    (MonadIO m, DOMXPathExpressionK a, DOMNodeK b, DOMXPathResultK c) =>
    a ->                                    -- _obj
    b ->                                    -- contextNode
    Word16 ->                               -- type
    c ->                                    -- inResult
    m DOMXPathResult
dOMXPathExpressionEvaluate _obj contextNode type_ inResult = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    let contextNode' = unsafeManagedPtrCastPtr contextNode
    let inResult' = unsafeManagedPtrCastPtr inResult
    onException (do
        result <- propagateGError $ webkit_dom_xpath_expression_evaluate _obj' contextNode' type_ inResult'
        checkUnexpectedReturnNULL "webkit_dom_xpath_expression_evaluate" result
        result' <- (wrapObject DOMXPathResult) result
        touchManagedPtr _obj
        touchManagedPtr contextNode
        touchManagedPtr inResult
        return result'
     ) (do
        return ()
     )