{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gio.Interfaces.AsyncResult
(
AsyncResult(..) ,
IsAsyncResult ,
toAsyncResult ,
#if defined(ENABLE_OVERLOADING)
ResolveAsyncResultMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
AsyncResultGetSourceObjectMethodInfo ,
#endif
asyncResultGetSourceObject ,
#if defined(ENABLE_OVERLOADING)
AsyncResultGetUserDataMethodInfo ,
#endif
asyncResultGetUserData ,
#if defined(ENABLE_OVERLOADING)
AsyncResultIsTaggedMethodInfo ,
#endif
asyncResultIsTagged ,
#if defined(ENABLE_OVERLOADING)
AsyncResultLegacyPropagateErrorMethodInfo,
#endif
asyncResultLegacyPropagateError ,
) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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 Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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 qualified GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT
#if MIN_VERSION_base(4,18,0)
import qualified GI.GObject.Objects.Object as GObject.Object
#else
import qualified GI.GObject.Objects.Object as GObject.Object
#endif
newtype AsyncResult = AsyncResult (SP.ManagedPtr AsyncResult)
deriving (AsyncResult -> AsyncResult -> Bool
(AsyncResult -> AsyncResult -> Bool)
-> (AsyncResult -> AsyncResult -> Bool) -> Eq AsyncResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AsyncResult -> AsyncResult -> Bool
== :: AsyncResult -> AsyncResult -> Bool
$c/= :: AsyncResult -> AsyncResult -> Bool
/= :: AsyncResult -> AsyncResult -> Bool
Eq)
instance SP.ManagedPtrNewtype AsyncResult where
toManagedPtr :: AsyncResult -> ManagedPtr AsyncResult
toManagedPtr (AsyncResult ManagedPtr AsyncResult
p) = ManagedPtr AsyncResult
p
foreign import ccall "g_async_result_get_type"
c_g_async_result_get_type :: IO B.Types.GType
instance B.Types.TypedObject AsyncResult where
glibType :: IO GType
glibType = IO GType
c_g_async_result_get_type
instance B.Types.GObject AsyncResult
class (SP.GObject o, O.IsDescendantOf AsyncResult o) => IsAsyncResult o
instance (SP.GObject o, O.IsDescendantOf AsyncResult o) => IsAsyncResult o
instance O.HasParentTypes AsyncResult
type instance O.ParentTypes AsyncResult = '[GObject.Object.Object]
toAsyncResult :: (MIO.MonadIO m, IsAsyncResult o) => o -> m AsyncResult
toAsyncResult :: forall (m :: * -> *) o.
(MonadIO m, IsAsyncResult o) =>
o -> m AsyncResult
toAsyncResult = IO AsyncResult -> m AsyncResult
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO AsyncResult -> m AsyncResult)
-> (o -> IO AsyncResult) -> o -> m AsyncResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr AsyncResult -> AsyncResult) -> o -> IO AsyncResult
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr AsyncResult -> AsyncResult
AsyncResult
instance B.GValue.IsGValue (Maybe AsyncResult) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_g_async_result_get_type
gvalueSet_ :: Ptr GValue -> Maybe AsyncResult -> IO ()
gvalueSet_ Ptr GValue
gv Maybe AsyncResult
P.Nothing = Ptr GValue -> Ptr AsyncResult -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (Ptr AsyncResult
forall a. Ptr a
FP.nullPtr :: FP.Ptr AsyncResult)
gvalueSet_ Ptr GValue
gv (P.Just AsyncResult
obj) = AsyncResult -> (Ptr AsyncResult -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr AsyncResult
obj (Ptr GValue -> Ptr AsyncResult -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe AsyncResult)
gvalueGet_ Ptr GValue
gv = do
ptr <- Ptr GValue -> IO (Ptr AsyncResult)
forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr AsyncResult)
if ptr /= FP.nullPtr
then P.Just <$> B.ManagedPtr.newObject AsyncResult ptr
else return P.Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList AsyncResult
type instance O.AttributeList AsyncResult = AsyncResultAttributeList
type AsyncResultAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveAsyncResultMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolveAsyncResultMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveAsyncResultMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveAsyncResultMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveAsyncResultMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveAsyncResultMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveAsyncResultMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveAsyncResultMethod "isTagged" o = AsyncResultIsTaggedMethodInfo
ResolveAsyncResultMethod "legacyPropagateError" o = AsyncResultLegacyPropagateErrorMethodInfo
ResolveAsyncResultMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveAsyncResultMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveAsyncResultMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveAsyncResultMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveAsyncResultMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveAsyncResultMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveAsyncResultMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveAsyncResultMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveAsyncResultMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveAsyncResultMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveAsyncResultMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveAsyncResultMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveAsyncResultMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveAsyncResultMethod "getSourceObject" o = AsyncResultGetSourceObjectMethodInfo
ResolveAsyncResultMethod "getUserData" o = AsyncResultGetUserDataMethodInfo
ResolveAsyncResultMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveAsyncResultMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveAsyncResultMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveAsyncResultMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveAsyncResultMethod t AsyncResult, O.OverloadedMethod info AsyncResult p) => OL.IsLabel t (AsyncResult -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveAsyncResultMethod t AsyncResult, O.OverloadedMethod info AsyncResult p, R.HasField t AsyncResult p) => R.HasField t AsyncResult p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveAsyncResultMethod t AsyncResult, O.OverloadedMethodInfo info AsyncResult) => OL.IsLabel t (O.MethodProxy info AsyncResult) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif
foreign import ccall "g_async_result_get_source_object" g_async_result_get_source_object ::
Ptr AsyncResult ->
IO (Ptr GObject.Object.Object)
asyncResultGetSourceObject ::
(B.CallStack.HasCallStack, MonadIO m, IsAsyncResult a) =>
a
-> m (Maybe GObject.Object.Object)
asyncResultGetSourceObject :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsAsyncResult a) =>
a -> m (Maybe Object)
asyncResultGetSourceObject a
res = IO (Maybe Object) -> m (Maybe Object)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Object) -> m (Maybe Object))
-> IO (Maybe Object) -> m (Maybe Object)
forall a b. (a -> b) -> a -> b
$ do
res' <- a -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
res
result <- g_async_result_get_source_object res'
maybeResult <- convertIfNonNull result $ \Ptr Object
result' -> do
result'' <- ((ManagedPtr Object -> Object) -> Ptr Object -> IO Object
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Object -> Object
GObject.Object.Object) Ptr Object
result'
return result''
touchManagedPtr res
return maybeResult
#if defined(ENABLE_OVERLOADING)
data AsyncResultGetSourceObjectMethodInfo
instance (signature ~ (m (Maybe GObject.Object.Object)), MonadIO m, IsAsyncResult a) => O.OverloadedMethod AsyncResultGetSourceObjectMethodInfo a signature where
overloadedMethod = asyncResultGetSourceObject
instance O.OverloadedMethodInfo AsyncResultGetSourceObjectMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.AsyncResult.asyncResultGetSourceObject",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-AsyncResult.html#v:asyncResultGetSourceObject"
})
#endif
foreign import ccall "g_async_result_get_user_data" g_async_result_get_user_data ::
Ptr AsyncResult ->
IO (Ptr ())
asyncResultGetUserData ::
(B.CallStack.HasCallStack, MonadIO m, IsAsyncResult a) =>
a
-> m (Ptr ())
asyncResultGetUserData :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsAsyncResult a) =>
a -> m (Ptr ())
asyncResultGetUserData a
res = IO (Ptr ()) -> m (Ptr ())
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
res' <- a -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
res
result <- g_async_result_get_user_data res'
touchManagedPtr res
return result
#if defined(ENABLE_OVERLOADING)
data AsyncResultGetUserDataMethodInfo
instance (signature ~ (m (Ptr ())), MonadIO m, IsAsyncResult a) => O.OverloadedMethod AsyncResultGetUserDataMethodInfo a signature where
overloadedMethod = asyncResultGetUserData
instance O.OverloadedMethodInfo AsyncResultGetUserDataMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.AsyncResult.asyncResultGetUserData",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-AsyncResult.html#v:asyncResultGetUserData"
})
#endif
foreign import ccall "g_async_result_is_tagged" g_async_result_is_tagged ::
Ptr AsyncResult ->
Ptr () ->
IO CInt
asyncResultIsTagged ::
(B.CallStack.HasCallStack, MonadIO m, IsAsyncResult a) =>
a
-> Ptr ()
-> m Bool
asyncResultIsTagged :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsAsyncResult a) =>
a -> Ptr () -> m Bool
asyncResultIsTagged a
res Ptr ()
sourceTag = IO Bool -> m Bool
forall a. IO a -> m a
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
res' <- a -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
res
result <- g_async_result_is_tagged res' sourceTag
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
touchManagedPtr res
return result'
#if defined(ENABLE_OVERLOADING)
data AsyncResultIsTaggedMethodInfo
instance (signature ~ (Ptr () -> m Bool), MonadIO m, IsAsyncResult a) => O.OverloadedMethod AsyncResultIsTaggedMethodInfo a signature where
overloadedMethod = asyncResultIsTagged
instance O.OverloadedMethodInfo AsyncResultIsTaggedMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.AsyncResult.asyncResultIsTagged",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-AsyncResult.html#v:asyncResultIsTagged"
})
#endif
foreign import ccall "g_async_result_legacy_propagate_error" g_async_result_legacy_propagate_error ::
Ptr AsyncResult ->
Ptr (Ptr GError) ->
IO CInt
asyncResultLegacyPropagateError ::
(B.CallStack.HasCallStack, MonadIO m, IsAsyncResult a) =>
a
-> m ()
asyncResultLegacyPropagateError :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsAsyncResult a) =>
a -> m ()
asyncResultLegacyPropagateError a
res = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
res' <- a -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
res
onException (do
_ <- propagateGError $ g_async_result_legacy_propagate_error res'
touchManagedPtr res
return ()
) (do
return ()
)
#if defined(ENABLE_OVERLOADING)
data AsyncResultLegacyPropagateErrorMethodInfo
instance (signature ~ (m ()), MonadIO m, IsAsyncResult a) => O.OverloadedMethod AsyncResultLegacyPropagateErrorMethodInfo a signature where
overloadedMethod = asyncResultLegacyPropagateError
instance O.OverloadedMethodInfo AsyncResultLegacyPropagateErrorMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.AsyncResult.asyncResultLegacyPropagateError",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-AsyncResult.html#v:asyncResultLegacyPropagateError"
})
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList AsyncResult = AsyncResultSignalList
type AsyncResultSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, DK.Type)])
#endif