{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GLib.Structs.VariantDict
(
VariantDict(..) ,
noVariantDict ,
#if defined(ENABLE_OVERLOADING)
ResolveVariantDictMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
VariantDictClearMethodInfo ,
#endif
variantDictClear ,
#if defined(ENABLE_OVERLOADING)
VariantDictContainsMethodInfo ,
#endif
variantDictContains ,
#if defined(ENABLE_OVERLOADING)
VariantDictEndMethodInfo ,
#endif
variantDictEnd ,
#if defined(ENABLE_OVERLOADING)
VariantDictInsertValueMethodInfo ,
#endif
variantDictInsertValue ,
#if defined(ENABLE_OVERLOADING)
VariantDictLookupValueMethodInfo ,
#endif
variantDictLookupValue ,
variantDictNew ,
#if defined(ENABLE_OVERLOADING)
VariantDictRefMethodInfo ,
#endif
variantDictRef ,
#if defined(ENABLE_OVERLOADING)
VariantDictRemoveMethodInfo ,
#endif
variantDictRemove ,
#if defined(ENABLE_OVERLOADING)
VariantDictUnrefMethodInfo ,
#endif
variantDictUnref ,
) 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.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
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 GHC.OverloadedLabels as OL
import {-# SOURCE #-} qualified GI.GLib.Structs.VariantType as GLib.VariantType
newtype VariantDict = VariantDict (ManagedPtr VariantDict)
deriving (VariantDict -> VariantDict -> Bool
(VariantDict -> VariantDict -> Bool)
-> (VariantDict -> VariantDict -> Bool) -> Eq VariantDict
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VariantDict -> VariantDict -> Bool
$c/= :: VariantDict -> VariantDict -> Bool
== :: VariantDict -> VariantDict -> Bool
$c== :: VariantDict -> VariantDict -> Bool
Eq)
foreign import ccall "g_variant_dict_get_type" c_g_variant_dict_get_type ::
IO GType
instance BoxedObject VariantDict where
boxedType :: VariantDict -> IO GType
boxedType _ = IO GType
c_g_variant_dict_get_type
instance B.GValue.IsGValue VariantDict where
toGValue :: VariantDict -> IO GValue
toGValue o :: VariantDict
o = do
GType
gtype <- IO GType
c_g_variant_dict_get_type
VariantDict -> (Ptr VariantDict -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr VariantDict
o (GType
-> (GValue -> Ptr VariantDict -> IO ())
-> Ptr VariantDict
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr VariantDict -> IO ()
forall a. GValue -> Ptr a -> IO ()
B.GValue.set_boxed)
fromGValue :: GValue -> IO VariantDict
fromGValue gv :: GValue
gv = do
Ptr VariantDict
ptr <- GValue -> IO (Ptr VariantDict)
forall b. GValue -> IO (Ptr b)
B.GValue.get_boxed GValue
gv :: IO (Ptr VariantDict)
(ManagedPtr VariantDict -> VariantDict)
-> Ptr VariantDict -> IO VariantDict
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr VariantDict -> VariantDict
VariantDict Ptr VariantDict
ptr
noVariantDict :: Maybe VariantDict
noVariantDict :: Maybe VariantDict
noVariantDict = Maybe VariantDict
forall a. Maybe a
Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList VariantDict
type instance O.AttributeList VariantDict = VariantDictAttributeList
type VariantDictAttributeList = ('[ ] :: [(Symbol, *)])
#endif
foreign import ccall "g_variant_dict_new" g_variant_dict_new ::
Ptr GVariant ->
IO (Ptr VariantDict)
variantDictNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
Maybe (GVariant)
-> m VariantDict
variantDictNew :: Maybe GVariant -> m VariantDict
variantDictNew fromAsv :: Maybe GVariant
fromAsv = IO VariantDict -> m VariantDict
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO VariantDict -> m VariantDict)
-> IO VariantDict -> m VariantDict
forall a b. (a -> b) -> a -> b
$ do
Ptr GVariant
maybeFromAsv <- case Maybe GVariant
fromAsv of
Nothing -> Ptr GVariant -> IO (Ptr GVariant)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr GVariant
forall a. Ptr a
nullPtr
Just jFromAsv :: GVariant
jFromAsv -> do
Ptr GVariant
jFromAsv' <- GVariant -> IO (Ptr GVariant)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GVariant
jFromAsv
Ptr GVariant -> IO (Ptr GVariant)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr GVariant
jFromAsv'
Ptr VariantDict
result <- Ptr GVariant -> IO (Ptr VariantDict)
g_variant_dict_new Ptr GVariant
maybeFromAsv
Text -> Ptr VariantDict -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "variantDictNew" Ptr VariantDict
result
VariantDict
result' <- ((ManagedPtr VariantDict -> VariantDict)
-> Ptr VariantDict -> IO VariantDict
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr VariantDict -> VariantDict
VariantDict) Ptr VariantDict
result
Maybe GVariant -> (GVariant -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe GVariant
fromAsv GVariant -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
VariantDict -> IO VariantDict
forall (m :: * -> *) a. Monad m => a -> m a
return VariantDict
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_variant_dict_clear" g_variant_dict_clear ::
Ptr VariantDict ->
IO ()
variantDictClear ::
(B.CallStack.HasCallStack, MonadIO m) =>
VariantDict
-> m ()
variantDictClear :: VariantDict -> m ()
variantDictClear dict :: VariantDict
dict = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr VariantDict
dict' <- VariantDict -> IO (Ptr VariantDict)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr VariantDict
dict
Ptr VariantDict -> IO ()
g_variant_dict_clear Ptr VariantDict
dict'
VariantDict -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr VariantDict
dict
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data VariantDictClearMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo VariantDictClearMethodInfo VariantDict signature where
overloadedMethod = variantDictClear
#endif
foreign import ccall "g_variant_dict_contains" g_variant_dict_contains ::
Ptr VariantDict ->
CString ->
IO CInt
variantDictContains ::
(B.CallStack.HasCallStack, MonadIO m) =>
VariantDict
-> T.Text
-> m Bool
variantDictContains :: VariantDict -> Text -> m Bool
variantDictContains dict :: VariantDict
dict key :: Text
key = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
Ptr VariantDict
dict' <- VariantDict -> IO (Ptr VariantDict)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr VariantDict
dict
CString
key' <- Text -> IO CString
textToCString Text
key
CInt
result <- Ptr VariantDict -> CString -> IO CInt
g_variant_dict_contains Ptr VariantDict
dict' CString
key'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
VariantDict -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr VariantDict
dict
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
key'
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data VariantDictContainsMethodInfo
instance (signature ~ (T.Text -> m Bool), MonadIO m) => O.MethodInfo VariantDictContainsMethodInfo VariantDict signature where
overloadedMethod = variantDictContains
#endif
foreign import ccall "g_variant_dict_end" g_variant_dict_end ::
Ptr VariantDict ->
IO (Ptr GVariant)
variantDictEnd ::
(B.CallStack.HasCallStack, MonadIO m) =>
VariantDict
-> m GVariant
variantDictEnd :: VariantDict -> m GVariant
variantDictEnd dict :: VariantDict
dict = IO GVariant -> m GVariant
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GVariant -> m GVariant) -> IO GVariant -> m GVariant
forall a b. (a -> b) -> a -> b
$ do
Ptr VariantDict
dict' <- VariantDict -> IO (Ptr VariantDict)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr VariantDict
dict
Ptr GVariant
result <- Ptr VariantDict -> IO (Ptr GVariant)
g_variant_dict_end Ptr VariantDict
dict'
Text -> Ptr GVariant -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "variantDictEnd" Ptr GVariant
result
GVariant
result' <- Ptr GVariant -> IO GVariant
B.GVariant.newGVariantFromPtr Ptr GVariant
result
VariantDict -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr VariantDict
dict
GVariant -> IO GVariant
forall (m :: * -> *) a. Monad m => a -> m a
return GVariant
result'
#if defined(ENABLE_OVERLOADING)
data VariantDictEndMethodInfo
instance (signature ~ (m GVariant), MonadIO m) => O.MethodInfo VariantDictEndMethodInfo VariantDict signature where
overloadedMethod = variantDictEnd
#endif
foreign import ccall "g_variant_dict_insert_value" g_variant_dict_insert_value ::
Ptr VariantDict ->
CString ->
Ptr GVariant ->
IO ()
variantDictInsertValue ::
(B.CallStack.HasCallStack, MonadIO m) =>
VariantDict
-> T.Text
-> GVariant
-> m ()
variantDictInsertValue :: VariantDict -> Text -> GVariant -> m ()
variantDictInsertValue dict :: VariantDict
dict key :: Text
key value :: GVariant
value = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr VariantDict
dict' <- VariantDict -> IO (Ptr VariantDict)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr VariantDict
dict
CString
key' <- Text -> IO CString
textToCString Text
key
Ptr GVariant
value' <- GVariant -> IO (Ptr GVariant)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GVariant
value
Ptr VariantDict -> CString -> Ptr GVariant -> IO ()
g_variant_dict_insert_value Ptr VariantDict
dict' CString
key' Ptr GVariant
value'
VariantDict -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr VariantDict
dict
GVariant -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GVariant
value
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
key'
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data VariantDictInsertValueMethodInfo
instance (signature ~ (T.Text -> GVariant -> m ()), MonadIO m) => O.MethodInfo VariantDictInsertValueMethodInfo VariantDict signature where
overloadedMethod = variantDictInsertValue
#endif
foreign import ccall "g_variant_dict_lookup_value" g_variant_dict_lookup_value ::
Ptr VariantDict ->
CString ->
Ptr GLib.VariantType.VariantType ->
IO (Ptr GVariant)
variantDictLookupValue ::
(B.CallStack.HasCallStack, MonadIO m) =>
VariantDict
-> T.Text
-> Maybe (GLib.VariantType.VariantType)
-> m GVariant
variantDictLookupValue :: VariantDict -> Text -> Maybe VariantType -> m GVariant
variantDictLookupValue dict :: VariantDict
dict key :: Text
key expectedType :: Maybe VariantType
expectedType = IO GVariant -> m GVariant
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GVariant -> m GVariant) -> IO GVariant -> m GVariant
forall a b. (a -> b) -> a -> b
$ do
Ptr VariantDict
dict' <- VariantDict -> IO (Ptr VariantDict)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr VariantDict
dict
CString
key' <- Text -> IO CString
textToCString Text
key
Ptr VariantType
maybeExpectedType <- case Maybe VariantType
expectedType of
Nothing -> Ptr VariantType -> IO (Ptr VariantType)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr VariantType
forall a. Ptr a
nullPtr
Just jExpectedType :: VariantType
jExpectedType -> do
Ptr VariantType
jExpectedType' <- VariantType -> IO (Ptr VariantType)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr VariantType
jExpectedType
Ptr VariantType -> IO (Ptr VariantType)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr VariantType
jExpectedType'
Ptr GVariant
result <- Ptr VariantDict -> CString -> Ptr VariantType -> IO (Ptr GVariant)
g_variant_dict_lookup_value Ptr VariantDict
dict' CString
key' Ptr VariantType
maybeExpectedType
Text -> Ptr GVariant -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "variantDictLookupValue" Ptr GVariant
result
GVariant
result' <- Ptr GVariant -> IO GVariant
B.GVariant.wrapGVariantPtr Ptr GVariant
result
VariantDict -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr VariantDict
dict
Maybe VariantType -> (VariantType -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe VariantType
expectedType VariantType -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
key'
GVariant -> IO GVariant
forall (m :: * -> *) a. Monad m => a -> m a
return GVariant
result'
#if defined(ENABLE_OVERLOADING)
data VariantDictLookupValueMethodInfo
instance (signature ~ (T.Text -> Maybe (GLib.VariantType.VariantType) -> m GVariant), MonadIO m) => O.MethodInfo VariantDictLookupValueMethodInfo VariantDict signature where
overloadedMethod = variantDictLookupValue
#endif
foreign import ccall "g_variant_dict_ref" g_variant_dict_ref ::
Ptr VariantDict ->
IO (Ptr VariantDict)
variantDictRef ::
(B.CallStack.HasCallStack, MonadIO m) =>
VariantDict
-> m VariantDict
variantDictRef :: VariantDict -> m VariantDict
variantDictRef dict :: VariantDict
dict = IO VariantDict -> m VariantDict
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO VariantDict -> m VariantDict)
-> IO VariantDict -> m VariantDict
forall a b. (a -> b) -> a -> b
$ do
Ptr VariantDict
dict' <- VariantDict -> IO (Ptr VariantDict)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr VariantDict
dict
Ptr VariantDict
result <- Ptr VariantDict -> IO (Ptr VariantDict)
g_variant_dict_ref Ptr VariantDict
dict'
Text -> Ptr VariantDict -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "variantDictRef" Ptr VariantDict
result
VariantDict
result' <- ((ManagedPtr VariantDict -> VariantDict)
-> Ptr VariantDict -> IO VariantDict
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr VariantDict -> VariantDict
VariantDict) Ptr VariantDict
result
VariantDict -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr VariantDict
dict
VariantDict -> IO VariantDict
forall (m :: * -> *) a. Monad m => a -> m a
return VariantDict
result'
#if defined(ENABLE_OVERLOADING)
data VariantDictRefMethodInfo
instance (signature ~ (m VariantDict), MonadIO m) => O.MethodInfo VariantDictRefMethodInfo VariantDict signature where
overloadedMethod = variantDictRef
#endif
foreign import ccall "g_variant_dict_remove" g_variant_dict_remove ::
Ptr VariantDict ->
CString ->
IO CInt
variantDictRemove ::
(B.CallStack.HasCallStack, MonadIO m) =>
VariantDict
-> T.Text
-> m Bool
variantDictRemove :: VariantDict -> Text -> m Bool
variantDictRemove dict :: VariantDict
dict key :: Text
key = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
Ptr VariantDict
dict' <- VariantDict -> IO (Ptr VariantDict)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr VariantDict
dict
CString
key' <- Text -> IO CString
textToCString Text
key
CInt
result <- Ptr VariantDict -> CString -> IO CInt
g_variant_dict_remove Ptr VariantDict
dict' CString
key'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
VariantDict -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr VariantDict
dict
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
key'
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data VariantDictRemoveMethodInfo
instance (signature ~ (T.Text -> m Bool), MonadIO m) => O.MethodInfo VariantDictRemoveMethodInfo VariantDict signature where
overloadedMethod = variantDictRemove
#endif
foreign import ccall "g_variant_dict_unref" g_variant_dict_unref ::
Ptr VariantDict ->
IO ()
variantDictUnref ::
(B.CallStack.HasCallStack, MonadIO m) =>
VariantDict
-> m ()
variantDictUnref :: VariantDict -> m ()
variantDictUnref dict :: VariantDict
dict = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr VariantDict
dict' <- VariantDict -> IO (Ptr VariantDict)
forall a. (HasCallStack, BoxedObject a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed VariantDict
dict
Ptr VariantDict -> IO ()
g_variant_dict_unref Ptr VariantDict
dict'
VariantDict -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr VariantDict
dict
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data VariantDictUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo VariantDictUnrefMethodInfo VariantDict signature where
overloadedMethod = variantDictUnref
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveVariantDictMethod (t :: Symbol) (o :: *) :: * where
ResolveVariantDictMethod "clear" o = VariantDictClearMethodInfo
ResolveVariantDictMethod "contains" o = VariantDictContainsMethodInfo
ResolveVariantDictMethod "end" o = VariantDictEndMethodInfo
ResolveVariantDictMethod "insertValue" o = VariantDictInsertValueMethodInfo
ResolveVariantDictMethod "lookupValue" o = VariantDictLookupValueMethodInfo
ResolveVariantDictMethod "ref" o = VariantDictRefMethodInfo
ResolveVariantDictMethod "remove" o = VariantDictRemoveMethodInfo
ResolveVariantDictMethod "unref" o = VariantDictUnrefMethodInfo
ResolveVariantDictMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveVariantDictMethod t VariantDict, O.MethodInfo info VariantDict p) => OL.IsLabel t (VariantDict -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif