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

-- * Exported types
    DOMTimeRanges(..)                       ,
    DOMTimeRangesK                          ,
    toDOMTimeRanges                         ,
    noDOMTimeRanges                         ,


 -- * Methods
-- ** dOMTimeRangesEnd
    dOMTimeRangesEnd                        ,


-- ** dOMTimeRangesGetLength
    dOMTimeRangesGetLength                  ,


-- ** dOMTimeRangesStart
    dOMTimeRangesStart                      ,




 -- * Properties
-- ** Length
    DOMTimeRangesLengthPropertyInfo         ,
    getDOMTimeRangesLength                  ,




    ) 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 DOMTimeRanges = DOMTimeRanges (ForeignPtr DOMTimeRanges)
foreign import ccall "webkit_dom_time_ranges_get_type"
    c_webkit_dom_time_ranges_get_type :: IO GType

type instance ParentTypes DOMTimeRanges = DOMTimeRangesParentTypes
type DOMTimeRangesParentTypes = '[DOMObject, GObject.Object]

instance GObject DOMTimeRanges where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_dom_time_ranges_get_type
    

class GObject o => DOMTimeRangesK o
instance (GObject o, IsDescendantOf DOMTimeRanges o) => DOMTimeRangesK o

toDOMTimeRanges :: DOMTimeRangesK o => o -> IO DOMTimeRanges
toDOMTimeRanges = unsafeCastTo DOMTimeRanges

noDOMTimeRanges :: Maybe DOMTimeRanges
noDOMTimeRanges = Nothing

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

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

data DOMTimeRangesLengthPropertyInfo
instance AttrInfo DOMTimeRangesLengthPropertyInfo where
    type AttrAllowedOps DOMTimeRangesLengthPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMTimeRangesLengthPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMTimeRangesLengthPropertyInfo = DOMTimeRangesK
    type AttrGetType DOMTimeRangesLengthPropertyInfo = Word64
    type AttrLabel DOMTimeRangesLengthPropertyInfo = "DOMTimeRanges::length"
    attrGet _ = getDOMTimeRangesLength
    attrSet _ = undefined
    attrConstruct _ = undefined

type instance AttributeList DOMTimeRanges = DOMTimeRangesAttributeList
type DOMTimeRangesAttributeList = ('[ '("core-object", DOMObjectCoreObjectPropertyInfo), '("length", DOMTimeRangesLengthPropertyInfo)] :: [(Symbol, *)])

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

-- method DOMTimeRanges::end
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMTimeRanges", 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" "DOMTimeRanges", 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 : TBasicType TDouble
-- throws : True
-- Skip return : False

foreign import ccall "webkit_dom_time_ranges_end" webkit_dom_time_ranges_end :: 
    Ptr DOMTimeRanges ->                    -- _obj : TInterface "WebKit" "DOMTimeRanges"
    Word64 ->                               -- index : TBasicType TUInt64
    Ptr (Ptr GError) ->                     -- error
    IO CDouble


dOMTimeRangesEnd ::
    (MonadIO m, DOMTimeRangesK a) =>
    a ->                                    -- _obj
    Word64 ->                               -- index
    m Double
dOMTimeRangesEnd _obj index = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    onException (do
        result <- propagateGError $ webkit_dom_time_ranges_end _obj' index
        let result' = realToFrac result
        touchManagedPtr _obj
        return result'
     ) (do
        return ()
     )

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


dOMTimeRangesGetLength ::
    (MonadIO m, DOMTimeRangesK a) =>
    a ->                                    -- _obj
    m Word64
dOMTimeRangesGetLength _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_time_ranges_get_length _obj'
    touchManagedPtr _obj
    return result

-- method DOMTimeRanges::start
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMTimeRanges", 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" "DOMTimeRanges", 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 : TBasicType TDouble
-- throws : True
-- Skip return : False

foreign import ccall "webkit_dom_time_ranges_start" webkit_dom_time_ranges_start :: 
    Ptr DOMTimeRanges ->                    -- _obj : TInterface "WebKit" "DOMTimeRanges"
    Word64 ->                               -- index : TBasicType TUInt64
    Ptr (Ptr GError) ->                     -- error
    IO CDouble


dOMTimeRangesStart ::
    (MonadIO m, DOMTimeRangesK a) =>
    a ->                                    -- _obj
    Word64 ->                               -- index
    m Double
dOMTimeRangesStart _obj index = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    onException (do
        result <- propagateGError $ webkit_dom_time_ranges_start _obj' index
        let result' = realToFrac result
        touchManagedPtr _obj
        return result'
     ) (do
        return ()
     )