{- |
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(..)                          ,
    IsDOMStorage                            ,
    toDOMStorage                            ,
    noDOMStorage                            ,


 -- * Methods
-- ** clear #method:clear#
    DOMStorageClearMethodInfo               ,
    dOMStorageClear                         ,


-- ** getItem #method:getItem#
    DOMStorageGetItemMethodInfo             ,
    dOMStorageGetItem                       ,


-- ** getLength #method:getLength#
    DOMStorageGetLengthMethodInfo           ,
    dOMStorageGetLength                     ,


-- ** key #method:key#
    DOMStorageKeyMethodInfo                 ,
    dOMStorageKey                           ,


-- ** removeItem #method:removeItem#
    DOMStorageRemoveItemMethodInfo          ,
    dOMStorageRemoveItem                    ,


-- ** setItem #method:setItem#
    DOMStorageSetItemMethodInfo             ,
    dOMStorageSetItem                       ,




 -- * Properties
-- ** length #attr:length#
    DOMStorageLengthPropertyInfo            ,
    dOMStorageLength                        ,
    getDOMStorageLength                     ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.WebKit.Objects.DOMObject as WebKit.DOMObject

newtype DOMStorage = DOMStorage (ManagedPtr DOMStorage)
foreign import ccall "webkit_dom_storage_get_type"
    c_webkit_dom_storage_get_type :: IO GType

instance GObject DOMStorage where
    gobjectType _ = c_webkit_dom_storage_get_type
    

class GObject o => IsDOMStorage o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError DOMStorage a) =>
    IsDOMStorage a
#endif
instance IsDOMStorage DOMStorage
instance WebKit.DOMObject.IsDOMObject DOMStorage
instance GObject.Object.IsObject DOMStorage

toDOMStorage :: IsDOMStorage o => o -> IO DOMStorage
toDOMStorage = unsafeCastTo DOMStorage

noDOMStorage :: Maybe DOMStorage
noDOMStorage = Nothing

type family ResolveDOMStorageMethod (t :: Symbol) (o :: *) :: * where
    ResolveDOMStorageMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveDOMStorageMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveDOMStorageMethod "clear" o = DOMStorageClearMethodInfo
    ResolveDOMStorageMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveDOMStorageMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveDOMStorageMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveDOMStorageMethod "key" o = DOMStorageKeyMethodInfo
    ResolveDOMStorageMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveDOMStorageMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveDOMStorageMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveDOMStorageMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveDOMStorageMethod "removeItem" o = DOMStorageRemoveItemMethodInfo
    ResolveDOMStorageMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveDOMStorageMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveDOMStorageMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveDOMStorageMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveDOMStorageMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveDOMStorageMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveDOMStorageMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveDOMStorageMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveDOMStorageMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveDOMStorageMethod "getItem" o = DOMStorageGetItemMethodInfo
    ResolveDOMStorageMethod "getLength" o = DOMStorageGetLengthMethodInfo
    ResolveDOMStorageMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveDOMStorageMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveDOMStorageMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveDOMStorageMethod "setItem" o = DOMStorageSetItemMethodInfo
    ResolveDOMStorageMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveDOMStorageMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveDOMStorageMethod t DOMStorage, O.MethodInfo info DOMStorage p) => O.IsLabelProxy t (DOMStorage -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveDOMStorageMethod t DOMStorage, O.MethodInfo info DOMStorage p) => O.IsLabel t (DOMStorage -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- VVV Prop "length"
   -- Type: TBasicType TULong
   -- Flags: [PropertyReadable]
   -- Nullable: (Nothing,Nothing)

getDOMStorageLength :: (MonadIO m, IsDOMStorage o) => o -> m CULong
getDOMStorageLength obj = liftIO $ getObjectPropertyULong obj "length"

data DOMStorageLengthPropertyInfo
instance AttrInfo DOMStorageLengthPropertyInfo where
    type AttrAllowedOps DOMStorageLengthPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint DOMStorageLengthPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DOMStorageLengthPropertyInfo = IsDOMStorage
    type AttrGetType DOMStorageLengthPropertyInfo = CULong
    type AttrLabel DOMStorageLengthPropertyInfo = "length"
    type AttrOrigin DOMStorageLengthPropertyInfo = DOMStorage
    attrGet _ = getDOMStorageLength
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined

instance O.HasAttributeList DOMStorage
type instance O.AttributeList DOMStorage = DOMStorageAttributeList
type DOMStorageAttributeList = ('[ '("coreObject", WebKit.DOMObject.DOMObjectCoreObjectPropertyInfo), '("length", DOMStorageLengthPropertyInfo)] :: [(Symbol, *)])

dOMStorageLength :: AttrLabelProxy "length"
dOMStorageLength = AttrLabelProxy

type instance O.SignalList DOMStorage = DOMStorageSignalList
type DOMStorageSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method DOMStorage::clear
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "WebKit", name = "DOMStorage"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitDOMStorage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : True
-- Skip return : False

foreign import ccall "webkit_dom_storage_clear" webkit_dom_storage_clear :: 
    Ptr DOMStorage ->                       -- self : TInterface (Name {namespace = "WebKit", name = "DOMStorage"})
    Ptr (Ptr GError) ->                     -- error
    IO ()

{- |
/No description available in the introspection data./
-}
dOMStorageClear ::
    (B.CallStack.HasCallStack, MonadIO m, IsDOMStorage a) =>
    a
    {- ^ /@self@/: A 'GI.WebKit.Objects.DOMStorage.DOMStorage' -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
dOMStorageClear self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    onException (do
        propagateGError $ webkit_dom_storage_clear self'
        touchManagedPtr self
        return ()
     ) (do
        return ()
     )

data DOMStorageClearMethodInfo
instance (signature ~ (m ()), MonadIO m, IsDOMStorage a) => O.MethodInfo DOMStorageClearMethodInfo a signature where
    overloadedMethod _ = dOMStorageClear

-- method DOMStorage::get_item
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "WebKit", name = "DOMStorage"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitDOMStorage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #gchar", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "webkit_dom_storage_get_item" webkit_dom_storage_get_item :: 
    Ptr DOMStorage ->                       -- self : TInterface (Name {namespace = "WebKit", name = "DOMStorage"})
    CString ->                              -- key : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CString

{- |
/No description available in the introspection data./
-}
dOMStorageGetItem ::
    (B.CallStack.HasCallStack, MonadIO m, IsDOMStorage a) =>
    a
    {- ^ /@self@/: A 'GI.WebKit.Objects.DOMStorage.DOMStorage' -}
    -> T.Text
    {- ^ /@key@/: A @/gchar/@ -}
    -> m T.Text
    {- ^ __Returns:__ A @/gchar/@ /(Can throw 'Data.GI.Base.GError.GError')/ -}
dOMStorageGetItem self key = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    key' <- textToCString key
    onException (do
        result <- propagateGError $ webkit_dom_storage_get_item self' key'
        checkUnexpectedReturnNULL "dOMStorageGetItem" result
        result' <- cstringToText result
        freeMem result
        touchManagedPtr self
        freeMem key'
        return result'
     ) (do
        freeMem key'
     )

data DOMStorageGetItemMethodInfo
instance (signature ~ (T.Text -> m T.Text), MonadIO m, IsDOMStorage a) => O.MethodInfo DOMStorageGetItemMethodInfo a signature where
    overloadedMethod _ = dOMStorageGetItem

-- method DOMStorage::get_length
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "WebKit", name = "DOMStorage"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitDOMStorage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TULong)
-- throws : True
-- Skip return : False

foreign import ccall "webkit_dom_storage_get_length" webkit_dom_storage_get_length :: 
    Ptr DOMStorage ->                       -- self : TInterface (Name {namespace = "WebKit", name = "DOMStorage"})
    Ptr (Ptr GError) ->                     -- error
    IO CULong

{- |
/No description available in the introspection data./
-}
dOMStorageGetLength ::
    (B.CallStack.HasCallStack, MonadIO m, IsDOMStorage a) =>
    a
    {- ^ /@self@/: A 'GI.WebKit.Objects.DOMStorage.DOMStorage' -}
    -> m CULong
    {- ^ __Returns:__ A @/gulong/@ /(Can throw 'Data.GI.Base.GError.GError')/ -}
dOMStorageGetLength self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    onException (do
        result <- propagateGError $ webkit_dom_storage_get_length self'
        touchManagedPtr self
        return result
     ) (do
        return ()
     )

data DOMStorageGetLengthMethodInfo
instance (signature ~ (m CULong), MonadIO m, IsDOMStorage a) => O.MethodInfo DOMStorageGetLengthMethodInfo a signature where
    overloadedMethod _ = dOMStorageGetLength

-- method DOMStorage::key
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "WebKit", name = "DOMStorage"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitDOMStorage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "index", argType = TBasicType TULong, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #gulong", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "webkit_dom_storage_key" webkit_dom_storage_key :: 
    Ptr DOMStorage ->                       -- self : TInterface (Name {namespace = "WebKit", name = "DOMStorage"})
    CULong ->                               -- index : TBasicType TULong
    Ptr (Ptr GError) ->                     -- error
    IO CString

{- |
/No description available in the introspection data./
-}
dOMStorageKey ::
    (B.CallStack.HasCallStack, MonadIO m, IsDOMStorage a) =>
    a
    {- ^ /@self@/: A 'GI.WebKit.Objects.DOMStorage.DOMStorage' -}
    -> CULong
    {- ^ /@index@/: A @/gulong/@ -}
    -> m T.Text
    {- ^ __Returns:__ A @/gchar/@ /(Can throw 'Data.GI.Base.GError.GError')/ -}
dOMStorageKey self index = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    onException (do
        result <- propagateGError $ webkit_dom_storage_key self' index
        checkUnexpectedReturnNULL "dOMStorageKey" result
        result' <- cstringToText result
        freeMem result
        touchManagedPtr self
        return result'
     ) (do
        return ()
     )

data DOMStorageKeyMethodInfo
instance (signature ~ (CULong -> m T.Text), MonadIO m, IsDOMStorage a) => O.MethodInfo DOMStorageKeyMethodInfo a signature where
    overloadedMethod _ = dOMStorageKey

-- method DOMStorage::remove_item
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "WebKit", name = "DOMStorage"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitDOMStorage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #gchar", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : True
-- Skip return : False

foreign import ccall "webkit_dom_storage_remove_item" webkit_dom_storage_remove_item :: 
    Ptr DOMStorage ->                       -- self : TInterface (Name {namespace = "WebKit", name = "DOMStorage"})
    CString ->                              -- key : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO ()

{- |
/No description available in the introspection data./
-}
dOMStorageRemoveItem ::
    (B.CallStack.HasCallStack, MonadIO m, IsDOMStorage a) =>
    a
    {- ^ /@self@/: A 'GI.WebKit.Objects.DOMStorage.DOMStorage' -}
    -> T.Text
    {- ^ /@key@/: A @/gchar/@ -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
dOMStorageRemoveItem self key = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    key' <- textToCString key
    onException (do
        propagateGError $ webkit_dom_storage_remove_item self' key'
        touchManagedPtr self
        freeMem key'
        return ()
     ) (do
        freeMem key'
     )

data DOMStorageRemoveItemMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsDOMStorage a) => O.MethodInfo DOMStorageRemoveItemMethodInfo a signature where
    overloadedMethod _ = dOMStorageRemoveItem

-- method DOMStorage::set_item
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "WebKit", name = "DOMStorage"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #WebKitDOMStorage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "key", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #gchar", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #gchar", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : True
-- Skip return : False

foreign import ccall "webkit_dom_storage_set_item" webkit_dom_storage_set_item :: 
    Ptr DOMStorage ->                       -- self : TInterface (Name {namespace = "WebKit", name = "DOMStorage"})
    CString ->                              -- key : TBasicType TUTF8
    CString ->                              -- data : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO ()

{- |
/No description available in the introspection data./
-}
dOMStorageSetItem ::
    (B.CallStack.HasCallStack, MonadIO m, IsDOMStorage a) =>
    a
    {- ^ /@self@/: A 'GI.WebKit.Objects.DOMStorage.DOMStorage' -}
    -> T.Text
    {- ^ /@key@/: A @/gchar/@ -}
    -> T.Text
    {- ^ /@data@/: A @/gchar/@ -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
dOMStorageSetItem self key data_ = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    key' <- textToCString key
    data_' <- textToCString data_
    onException (do
        propagateGError $ webkit_dom_storage_set_item self' key' data_'
        touchManagedPtr self
        freeMem key'
        freeMem data_'
        return ()
     ) (do
        freeMem key'
        freeMem data_'
     )

data DOMStorageSetItemMethodInfo
instance (signature ~ (T.Text -> T.Text -> m ()), MonadIO m, IsDOMStorage a) => O.MethodInfo DOMStorageSetItemMethodInfo a signature where
    overloadedMethod _ = dOMStorageSetItem