gi-webkit-0.2.4.12: GI/WebKit/Objects/DOMStorage.hs
{- |
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.DOMStorage
(
-- * Exported types
DOMStorage(..) ,
DOMStorageK ,
toDOMStorage ,
noDOMStorage ,
-- * Methods
-- ** dOMStorageClear
dOMStorageClear ,
-- ** dOMStorageGetItem
dOMStorageGetItem ,
-- ** dOMStorageGetLength
dOMStorageGetLength ,
-- ** dOMStorageKey
dOMStorageKey ,
-- ** dOMStorageRemoveItem
dOMStorageRemoveItem ,
-- ** dOMStorageSetItem
dOMStorageSetItem ,
-- * Properties
-- ** Length
DOMStorageLengthPropertyInfo ,
getDOMStorageLength ,
) 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 DOMStorage = DOMStorage (ForeignPtr DOMStorage)
foreign import ccall "webkit_dom_storage_get_type"
c_webkit_dom_storage_get_type :: IO GType
type instance ParentTypes DOMStorage = DOMStorageParentTypes
type DOMStorageParentTypes = '[DOMObject, GObject.Object]
instance GObject DOMStorage where
gobjectIsInitiallyUnowned _ = False
gobjectType _ = c_webkit_dom_storage_get_type
class GObject o => DOMStorageK o
instance (GObject o, IsDescendantOf DOMStorage o) => DOMStorageK o
toDOMStorage :: DOMStorageK o => o -> IO DOMStorage
toDOMStorage = unsafeCastTo DOMStorage
noDOMStorage :: Maybe DOMStorage
noDOMStorage = Nothing
-- VVV Prop "length"
-- Type: TBasicType TUInt64
-- Flags: [PropertyReadable]
getDOMStorageLength :: (MonadIO m, DOMStorageK o) => o -> m Word64
getDOMStorageLength obj = liftIO $ getObjectPropertyUInt64 obj "length"
data DOMStorageLengthPropertyInfo
instance AttrInfo DOMStorageLengthPropertyInfo where
type AttrAllowedOps DOMStorageLengthPropertyInfo = '[ 'AttrGet]
type AttrSetTypeConstraint DOMStorageLengthPropertyInfo = (~) ()
type AttrBaseTypeConstraint DOMStorageLengthPropertyInfo = DOMStorageK
type AttrGetType DOMStorageLengthPropertyInfo = Word64
type AttrLabel DOMStorageLengthPropertyInfo = "DOMStorage::length"
attrGet _ = getDOMStorageLength
attrSet _ = undefined
attrConstruct _ = undefined
type instance AttributeList DOMStorage = DOMStorageAttributeList
type DOMStorageAttributeList = ('[ '("core-object", DOMObjectCoreObjectPropertyInfo), '("length", DOMStorageLengthPropertyInfo)] :: [(Symbol, *)])
type instance SignalList DOMStorage = DOMStorageSignalList
type DOMStorageSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])
-- method DOMStorage::clear
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMStorage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMStorage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : True
-- Skip return : False
foreign import ccall "webkit_dom_storage_clear" webkit_dom_storage_clear ::
Ptr DOMStorage -> -- _obj : TInterface "WebKit" "DOMStorage"
Ptr (Ptr GError) -> -- error
IO ()
dOMStorageClear ::
(MonadIO m, DOMStorageK a) =>
a -> -- _obj
m ()
dOMStorageClear _obj = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
onException (do
propagateGError $ webkit_dom_storage_clear _obj'
touchManagedPtr _obj
return ()
) (do
return ()
)
-- method DOMStorage::get_item
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMStorage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMStorage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : True
-- Skip return : False
foreign import ccall "webkit_dom_storage_get_item" webkit_dom_storage_get_item ::
Ptr DOMStorage -> -- _obj : TInterface "WebKit" "DOMStorage"
CString -> -- key : TBasicType TUTF8
Ptr (Ptr GError) -> -- error
IO CString
dOMStorageGetItem ::
(MonadIO m, DOMStorageK a) =>
a -> -- _obj
T.Text -> -- key
m T.Text
dOMStorageGetItem _obj key = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
key' <- textToCString key
onException (do
result <- propagateGError $ webkit_dom_storage_get_item _obj' key'
checkUnexpectedReturnNULL "webkit_dom_storage_get_item" result
result' <- cstringToText result
freeMem result
touchManagedPtr _obj
freeMem key'
return result'
) (do
freeMem key'
)
-- method DOMStorage::get_length
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMStorage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMStorage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt64
-- throws : True
-- Skip return : False
foreign import ccall "webkit_dom_storage_get_length" webkit_dom_storage_get_length ::
Ptr DOMStorage -> -- _obj : TInterface "WebKit" "DOMStorage"
Ptr (Ptr GError) -> -- error
IO Word64
dOMStorageGetLength ::
(MonadIO m, DOMStorageK a) =>
a -> -- _obj
m Word64
dOMStorageGetLength _obj = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
onException (do
result <- propagateGError $ webkit_dom_storage_get_length _obj'
touchManagedPtr _obj
return result
) (do
return ()
)
-- method DOMStorage::key
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMStorage", 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" "DOMStorage", 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 TUTF8
-- throws : True
-- Skip return : False
foreign import ccall "webkit_dom_storage_key" webkit_dom_storage_key ::
Ptr DOMStorage -> -- _obj : TInterface "WebKit" "DOMStorage"
Word64 -> -- index : TBasicType TUInt64
Ptr (Ptr GError) -> -- error
IO CString
dOMStorageKey ::
(MonadIO m, DOMStorageK a) =>
a -> -- _obj
Word64 -> -- index
m T.Text
dOMStorageKey _obj index = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
onException (do
result <- propagateGError $ webkit_dom_storage_key _obj' index
checkUnexpectedReturnNULL "webkit_dom_storage_key" result
result' <- cstringToText result
freeMem result
touchManagedPtr _obj
return result'
) (do
return ()
)
-- method DOMStorage::remove_item
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMStorage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMStorage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : True
-- Skip return : False
foreign import ccall "webkit_dom_storage_remove_item" webkit_dom_storage_remove_item ::
Ptr DOMStorage -> -- _obj : TInterface "WebKit" "DOMStorage"
CString -> -- key : TBasicType TUTF8
Ptr (Ptr GError) -> -- error
IO ()
dOMStorageRemoveItem ::
(MonadIO m, DOMStorageK a) =>
a -> -- _obj
T.Text -> -- key
m ()
dOMStorageRemoveItem _obj key = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
key' <- textToCString key
onException (do
propagateGError $ webkit_dom_storage_remove_item _obj' key'
touchManagedPtr _obj
freeMem key'
return ()
) (do
freeMem key'
)
-- method DOMStorage::set_item
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMStorage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "data", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "WebKit" "DOMStorage", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "data", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : True
-- Skip return : False
foreign import ccall "webkit_dom_storage_set_item" webkit_dom_storage_set_item ::
Ptr DOMStorage -> -- _obj : TInterface "WebKit" "DOMStorage"
CString -> -- key : TBasicType TUTF8
CString -> -- data : TBasicType TUTF8
Ptr (Ptr GError) -> -- error
IO ()
dOMStorageSetItem ::
(MonadIO m, DOMStorageK a) =>
a -> -- _obj
T.Text -> -- key
T.Text -> -- data
m ()
dOMStorageSetItem _obj key data_ = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
key' <- textToCString key
data_' <- textToCString data_
onException (do
propagateGError $ webkit_dom_storage_set_item _obj' key' data_'
touchManagedPtr _obj
freeMem key'
freeMem data_'
return ()
) (do
freeMem key'
freeMem data_'
)