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

-- * Exported types
    DOMPerformance(..)                      ,
    DOMPerformanceK                         ,
    toDOMPerformance                        ,
    noDOMPerformance                        ,


 -- * Methods
-- ** dOMPerformanceGetMemory
    dOMPerformanceGetMemory                 ,


-- ** dOMPerformanceGetNavigation
    dOMPerformanceGetNavigation             ,


-- ** dOMPerformanceGetTiming
    dOMPerformanceGetTiming                 ,


-- ** dOMPerformanceNow
    dOMPerformanceNow                       ,




 -- * Properties
-- ** Navigation
    DOMPerformanceNavigationPropertyInfo    ,
    getDOMPerformanceNavigation             ,


-- ** Timing
    DOMPerformanceTimingPropertyInfo        ,
    getDOMPerformanceTiming                 ,




    ) 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 DOMPerformance = DOMPerformance (ForeignPtr DOMPerformance)
foreign import ccall "webkit_dom_performance_get_type"
    c_webkit_dom_performance_get_type :: IO GType

type instance ParentTypes DOMPerformance = DOMPerformanceParentTypes
type DOMPerformanceParentTypes = '[DOMObject, GObject.Object, DOMEventTarget]

instance GObject DOMPerformance where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_dom_performance_get_type
    

class GObject o => DOMPerformanceK o
instance (GObject o, IsDescendantOf DOMPerformance o) => DOMPerformanceK o

toDOMPerformance :: DOMPerformanceK o => o -> IO DOMPerformance
toDOMPerformance = unsafeCastTo DOMPerformance

noDOMPerformance :: Maybe DOMPerformance
noDOMPerformance = Nothing

-- VVV Prop "navigation"
   -- Type: TInterface "WebKit" "DOMPerformanceNavigation"
   -- Flags: [PropertyReadable]

getDOMPerformanceNavigation :: (MonadIO m, DOMPerformanceK o) => o -> m DOMPerformanceNavigation
getDOMPerformanceNavigation obj = liftIO $ getObjectPropertyObject obj "navigation" DOMPerformanceNavigation

data DOMPerformanceNavigationPropertyInfo
instance AttrInfo DOMPerformanceNavigationPropertyInfo where
    type AttrAllowedOps DOMPerformanceNavigationPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMPerformanceNavigationPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMPerformanceNavigationPropertyInfo = DOMPerformanceK
    type AttrGetType DOMPerformanceNavigationPropertyInfo = DOMPerformanceNavigation
    type AttrLabel DOMPerformanceNavigationPropertyInfo = "DOMPerformance::navigation"
    attrGet _ = getDOMPerformanceNavigation
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "timing"
   -- Type: TInterface "WebKit" "DOMPerformanceTiming"
   -- Flags: [PropertyReadable]

getDOMPerformanceTiming :: (MonadIO m, DOMPerformanceK o) => o -> m DOMPerformanceTiming
getDOMPerformanceTiming obj = liftIO $ getObjectPropertyObject obj "timing" DOMPerformanceTiming

data DOMPerformanceTimingPropertyInfo
instance AttrInfo DOMPerformanceTimingPropertyInfo where
    type AttrAllowedOps DOMPerformanceTimingPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMPerformanceTimingPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMPerformanceTimingPropertyInfo = DOMPerformanceK
    type AttrGetType DOMPerformanceTimingPropertyInfo = DOMPerformanceTiming
    type AttrLabel DOMPerformanceTimingPropertyInfo = "DOMPerformance::timing"
    attrGet _ = getDOMPerformanceTiming
    attrSet _ = undefined
    attrConstruct _ = undefined

type instance AttributeList DOMPerformance = DOMPerformanceAttributeList
type DOMPerformanceAttributeList = ('[ '("core-object", DOMObjectCoreObjectPropertyInfo), '("navigation", DOMPerformanceNavigationPropertyInfo), '("timing", DOMPerformanceTimingPropertyInfo)] :: [(Symbol, *)])

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

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

foreign import ccall "webkit_dom_performance_get_memory" webkit_dom_performance_get_memory :: 
    Ptr DOMPerformance ->                   -- _obj : TInterface "WebKit" "DOMPerformance"
    IO ()

{-# DEPRECATED dOMPerformanceGetMemory ["(Since version 2.2)"]#-}
dOMPerformanceGetMemory ::
    (MonadIO m, DOMPerformanceK a) =>
    a ->                                    -- _obj
    m ()
dOMPerformanceGetMemory _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    webkit_dom_performance_get_memory _obj'
    touchManagedPtr _obj
    return ()

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

foreign import ccall "webkit_dom_performance_get_navigation" webkit_dom_performance_get_navigation :: 
    Ptr DOMPerformance ->                   -- _obj : TInterface "WebKit" "DOMPerformance"
    IO (Ptr DOMPerformanceNavigation)


dOMPerformanceGetNavigation ::
    (MonadIO m, DOMPerformanceK a) =>
    a ->                                    -- _obj
    m DOMPerformanceNavigation
dOMPerformanceGetNavigation _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_performance_get_navigation _obj'
    checkUnexpectedReturnNULL "webkit_dom_performance_get_navigation" result
    result' <- (wrapObject DOMPerformanceNavigation) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_dom_performance_get_timing" webkit_dom_performance_get_timing :: 
    Ptr DOMPerformance ->                   -- _obj : TInterface "WebKit" "DOMPerformance"
    IO (Ptr DOMPerformanceTiming)


dOMPerformanceGetTiming ::
    (MonadIO m, DOMPerformanceK a) =>
    a ->                                    -- _obj
    m DOMPerformanceTiming
dOMPerformanceGetTiming _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_performance_get_timing _obj'
    checkUnexpectedReturnNULL "webkit_dom_performance_get_timing" result
    result' <- (wrapObject DOMPerformanceTiming) result
    touchManagedPtr _obj
    return result'

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

foreign import ccall "webkit_dom_performance_now" webkit_dom_performance_now :: 
    Ptr DOMPerformance ->                   -- _obj : TInterface "WebKit" "DOMPerformance"
    IO CDouble


dOMPerformanceNow ::
    (MonadIO m, DOMPerformanceK a) =>
    a ->                                    -- _obj
    m Double
dOMPerformanceNow _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_performance_now _obj'
    let result' = realToFrac result
    touchManagedPtr _obj
    return result'