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

-- * Exported types
    DOMBlob(..)                             ,
    DOMBlobK                                ,
    toDOMBlob                               ,
    noDOMBlob                               ,


 -- * Methods
-- ** dOMBlobGetSize
    dOMBlobGetSize                          ,




 -- * Properties
-- ** Size
    DOMBlobSizePropertyInfo                 ,
    getDOMBlobSize                          ,


-- ** Type
    DOMBlobTypePropertyInfo                 ,
    getDOMBlobType                          ,




    ) 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 DOMBlob = DOMBlob (ForeignPtr DOMBlob)
foreign import ccall "webkit_dom_blob_get_type"
    c_webkit_dom_blob_get_type :: IO GType

type instance ParentTypes DOMBlob = DOMBlobParentTypes
type DOMBlobParentTypes = '[DOMObject, GObject.Object]

instance GObject DOMBlob where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_webkit_dom_blob_get_type
    

class GObject o => DOMBlobK o
instance (GObject o, IsDescendantOf DOMBlob o) => DOMBlobK o

toDOMBlob :: DOMBlobK o => o -> IO DOMBlob
toDOMBlob = unsafeCastTo DOMBlob

noDOMBlob :: Maybe DOMBlob
noDOMBlob = Nothing

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

getDOMBlobSize :: (MonadIO m, DOMBlobK o) => o -> m Word64
getDOMBlobSize obj = liftIO $ getObjectPropertyUInt64 obj "size"

data DOMBlobSizePropertyInfo
instance AttrInfo DOMBlobSizePropertyInfo where
    type AttrAllowedOps DOMBlobSizePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMBlobSizePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMBlobSizePropertyInfo = DOMBlobK
    type AttrGetType DOMBlobSizePropertyInfo = Word64
    type AttrLabel DOMBlobSizePropertyInfo = "DOMBlob::size"
    attrGet _ = getDOMBlobSize
    attrSet _ = undefined
    attrConstruct _ = undefined

-- VVV Prop "type"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable]

getDOMBlobType :: (MonadIO m, DOMBlobK o) => o -> m T.Text
getDOMBlobType obj = liftIO $ getObjectPropertyString obj "type"

data DOMBlobTypePropertyInfo
instance AttrInfo DOMBlobTypePropertyInfo where
    type AttrAllowedOps DOMBlobTypePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMBlobTypePropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMBlobTypePropertyInfo = DOMBlobK
    type AttrGetType DOMBlobTypePropertyInfo = T.Text
    type AttrLabel DOMBlobTypePropertyInfo = "DOMBlob::type"
    attrGet _ = getDOMBlobType
    attrSet _ = undefined
    attrConstruct _ = undefined

type instance AttributeList DOMBlob = DOMBlobAttributeList
type DOMBlobAttributeList = ('[ '("core-object", DOMObjectCoreObjectPropertyInfo), '("size", DOMBlobSizePropertyInfo), '("type", DOMBlobTypePropertyInfo)] :: [(Symbol, *)])

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

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


dOMBlobGetSize ::
    (MonadIO m, DOMBlobK a) =>
    a ->                                    -- _obj
    m Word64
dOMBlobGetSize _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- webkit_dom_blob_get_size _obj'
    touchManagedPtr _obj
    return result