{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gst.Structs.Promise
(
Promise(..) ,
newZeroPromise ,
noPromise ,
#if defined(ENABLE_OVERLOADING)
ResolvePromiseMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
PromiseExpireMethodInfo ,
#endif
promiseExpire ,
#if defined(ENABLE_OVERLOADING)
PromiseGetReplyMethodInfo ,
#endif
promiseGetReply ,
#if defined(ENABLE_OVERLOADING)
PromiseInterruptMethodInfo ,
#endif
promiseInterrupt ,
promiseNew ,
promiseNewWithChangeFunc ,
#if defined(ENABLE_OVERLOADING)
PromiseReplyMethodInfo ,
#endif
promiseReply ,
#if defined(ENABLE_OVERLOADING)
PromiseWaitMethodInfo ,
#endif
promiseWait ,
getPromiseParent ,
#if defined(ENABLE_OVERLOADING)
promise_parent ,
#endif
) 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 qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.Gst.Callbacks as Gst.Callbacks
import {-# SOURCE #-} qualified GI.Gst.Enums as Gst.Enums
import {-# SOURCE #-} qualified GI.Gst.Structs.MiniObject as Gst.MiniObject
import {-# SOURCE #-} qualified GI.Gst.Structs.Structure as Gst.Structure
newtype Promise = Promise (ManagedPtr Promise)
deriving (Promise -> Promise -> Bool
(Promise -> Promise -> Bool)
-> (Promise -> Promise -> Bool) -> Eq Promise
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Promise -> Promise -> Bool
$c/= :: Promise -> Promise -> Bool
== :: Promise -> Promise -> Bool
$c== :: Promise -> Promise -> Bool
Eq)
foreign import ccall "gst_promise_get_type" c_gst_promise_get_type ::
IO GType
instance BoxedObject Promise where
boxedType :: Promise -> IO GType
boxedType _ = IO GType
c_gst_promise_get_type
instance B.GValue.IsGValue Promise where
toGValue :: Promise -> IO GValue
toGValue o :: Promise
o = do
GType
gtype <- IO GType
c_gst_promise_get_type
Promise -> (Ptr Promise -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Promise
o (GType
-> (GValue -> Ptr Promise -> IO ()) -> Ptr Promise -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Promise -> IO ()
forall a. GValue -> Ptr a -> IO ()
B.GValue.set_boxed)
fromGValue :: GValue -> IO Promise
fromGValue gv :: GValue
gv = do
Ptr Promise
ptr <- GValue -> IO (Ptr Promise)
forall b. GValue -> IO (Ptr b)
B.GValue.get_boxed GValue
gv :: IO (Ptr Promise)
(ManagedPtr Promise -> Promise) -> Ptr Promise -> IO Promise
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr Promise -> Promise
Promise Ptr Promise
ptr
newZeroPromise :: MonadIO m => m Promise
newZeroPromise :: m Promise
newZeroPromise = IO Promise -> m Promise
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Promise -> m Promise) -> IO Promise -> m Promise
forall a b. (a -> b) -> a -> b
$ Int -> IO (Ptr Promise)
forall a. BoxedObject a => Int -> IO (Ptr a)
callocBoxedBytes 64 IO (Ptr Promise) -> (Ptr Promise -> IO Promise) -> IO Promise
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr Promise -> Promise) -> Ptr Promise -> IO Promise
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Promise -> Promise
Promise
instance tag ~ 'AttrSet => Constructible Promise tag where
new :: (ManagedPtr Promise -> Promise)
-> [AttrOp Promise tag] -> m Promise
new _ attrs :: [AttrOp Promise tag]
attrs = do
Promise
o <- m Promise
forall (m :: * -> *). MonadIO m => m Promise
newZeroPromise
Promise -> [AttrOp Promise 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set Promise
o [AttrOp Promise tag]
[AttrOp Promise 'AttrSet]
attrs
Promise -> m Promise
forall (m :: * -> *) a. Monad m => a -> m a
return Promise
o
noPromise :: Maybe Promise
noPromise :: Maybe Promise
noPromise = Maybe Promise
forall a. Maybe a
Nothing
getPromiseParent :: MonadIO m => Promise -> m Gst.MiniObject.MiniObject
getPromiseParent :: Promise -> m MiniObject
getPromiseParent s :: Promise
s = IO MiniObject -> m MiniObject
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO MiniObject -> m MiniObject) -> IO MiniObject -> m MiniObject
forall a b. (a -> b) -> a -> b
$ Promise -> (Ptr Promise -> IO MiniObject) -> IO MiniObject
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Promise
s ((Ptr Promise -> IO MiniObject) -> IO MiniObject)
-> (Ptr Promise -> IO MiniObject) -> IO MiniObject
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr Promise
ptr -> do
let val :: Ptr MiniObject
val = Ptr Promise
ptr Ptr Promise -> Int -> Ptr MiniObject
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: (Ptr Gst.MiniObject.MiniObject)
MiniObject
val' <- ((ManagedPtr MiniObject -> MiniObject)
-> Ptr MiniObject -> IO MiniObject
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr MiniObject -> MiniObject
Gst.MiniObject.MiniObject) Ptr MiniObject
val
MiniObject -> IO MiniObject
forall (m :: * -> *) a. Monad m => a -> m a
return MiniObject
val'
#if defined(ENABLE_OVERLOADING)
data PromiseParentFieldInfo
instance AttrInfo PromiseParentFieldInfo where
type AttrBaseTypeConstraint PromiseParentFieldInfo = (~) Promise
type AttrAllowedOps PromiseParentFieldInfo = '[ 'AttrGet]
type AttrSetTypeConstraint PromiseParentFieldInfo = (~) (Ptr Gst.MiniObject.MiniObject)
type AttrTransferTypeConstraint PromiseParentFieldInfo = (~)(Ptr Gst.MiniObject.MiniObject)
type AttrTransferType PromiseParentFieldInfo = (Ptr Gst.MiniObject.MiniObject)
type AttrGetType PromiseParentFieldInfo = Gst.MiniObject.MiniObject
type AttrLabel PromiseParentFieldInfo = "parent"
type AttrOrigin PromiseParentFieldInfo = Promise
attrGet = getPromiseParent
attrSet = undefined
attrConstruct = undefined
attrClear = undefined
attrTransfer = undefined
promise_parent :: AttrLabelProxy "parent"
promise_parent = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Promise
type instance O.AttributeList Promise = PromiseAttributeList
type PromiseAttributeList = ('[ '("parent", PromiseParentFieldInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "gst_promise_new" gst_promise_new ::
IO (Ptr Promise)
promiseNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
m Promise
promiseNew :: m Promise
promiseNew = IO Promise -> m Promise
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Promise -> m Promise) -> IO Promise -> m Promise
forall a b. (a -> b) -> a -> b
$ do
Ptr Promise
result <- IO (Ptr Promise)
gst_promise_new
Text -> Ptr Promise -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "promiseNew" Ptr Promise
result
Promise
result' <- ((ManagedPtr Promise -> Promise) -> Ptr Promise -> IO Promise
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Promise -> Promise
Promise) Ptr Promise
result
Promise -> IO Promise
forall (m :: * -> *) a. Monad m => a -> m a
return Promise
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "gst_promise_new_with_change_func" gst_promise_new_with_change_func ::
FunPtr Gst.Callbacks.C_PromiseChangeFunc ->
Ptr () ->
FunPtr GLib.Callbacks.C_DestroyNotify ->
IO (Ptr Promise)
promiseNewWithChangeFunc ::
(B.CallStack.HasCallStack, MonadIO m) =>
Gst.Callbacks.PromiseChangeFunc
-> m Promise
promiseNewWithChangeFunc :: PromiseChangeFunc -> m Promise
promiseNewWithChangeFunc func :: PromiseChangeFunc
func = IO Promise -> m Promise
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Promise -> m Promise) -> IO Promise -> m Promise
forall a b. (a -> b) -> a -> b
$ do
FunPtr C_PromiseChangeFunc
func' <- C_PromiseChangeFunc -> IO (FunPtr C_PromiseChangeFunc)
Gst.Callbacks.mk_PromiseChangeFunc (Maybe (Ptr (FunPtr C_PromiseChangeFunc))
-> PromiseChangeFunc_WithClosures -> C_PromiseChangeFunc
Gst.Callbacks.wrap_PromiseChangeFunc Maybe (Ptr (FunPtr C_PromiseChangeFunc))
forall a. Maybe a
Nothing (PromiseChangeFunc -> PromiseChangeFunc_WithClosures
Gst.Callbacks.drop_closures_PromiseChangeFunc PromiseChangeFunc
func))
let userData :: Ptr ()
userData = FunPtr C_PromiseChangeFunc -> Ptr ()
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_PromiseChangeFunc
func'
let notify :: FunPtr (Ptr a -> IO ())
notify = FunPtr (Ptr a -> IO ())
forall a. FunPtr (Ptr a -> IO ())
safeFreeFunPtrPtr
Ptr Promise
result <- FunPtr C_PromiseChangeFunc
-> Ptr () -> FunPtr C_DestroyNotify -> IO (Ptr Promise)
gst_promise_new_with_change_func FunPtr C_PromiseChangeFunc
func' Ptr ()
userData FunPtr C_DestroyNotify
forall a. FunPtr (Ptr a -> IO ())
notify
Text -> Ptr Promise -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "promiseNewWithChangeFunc" Ptr Promise
result
Promise
result' <- ((ManagedPtr Promise -> Promise) -> Ptr Promise -> IO Promise
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Promise -> Promise
Promise) Ptr Promise
result
Promise -> IO Promise
forall (m :: * -> *) a. Monad m => a -> m a
return Promise
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "gst_promise_expire" gst_promise_expire ::
Ptr Promise ->
IO ()
promiseExpire ::
(B.CallStack.HasCallStack, MonadIO m) =>
Promise
-> m ()
promiseExpire :: Promise -> m ()
promiseExpire promise :: Promise
promise = 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 Promise
promise' <- Promise -> IO (Ptr Promise)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Promise
promise
Ptr Promise -> IO ()
gst_promise_expire Ptr Promise
promise'
PromiseChangeFunc
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Promise
promise
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data PromiseExpireMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo PromiseExpireMethodInfo Promise signature where
overloadedMethod = promiseExpire
#endif
foreign import ccall "gst_promise_get_reply" gst_promise_get_reply ::
Ptr Promise ->
IO (Ptr Gst.Structure.Structure)
promiseGetReply ::
(B.CallStack.HasCallStack, MonadIO m) =>
Promise
-> m Gst.Structure.Structure
promiseGetReply :: Promise -> m Structure
promiseGetReply promise :: Promise
promise = IO Structure -> m Structure
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Structure -> m Structure) -> IO Structure -> m Structure
forall a b. (a -> b) -> a -> b
$ do
Ptr Promise
promise' <- Promise -> IO (Ptr Promise)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Promise
promise
Ptr Structure
result <- Ptr Promise -> IO (Ptr Structure)
gst_promise_get_reply Ptr Promise
promise'
Text -> Ptr Structure -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "promiseGetReply" Ptr Structure
result
Structure
result' <- ((ManagedPtr Structure -> Structure)
-> Ptr Structure -> IO Structure
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr Structure -> Structure
Gst.Structure.Structure) Ptr Structure
result
PromiseChangeFunc
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Promise
promise
Structure -> IO Structure
forall (m :: * -> *) a. Monad m => a -> m a
return Structure
result'
#if defined(ENABLE_OVERLOADING)
data PromiseGetReplyMethodInfo
instance (signature ~ (m Gst.Structure.Structure), MonadIO m) => O.MethodInfo PromiseGetReplyMethodInfo Promise signature where
overloadedMethod = promiseGetReply
#endif
foreign import ccall "gst_promise_interrupt" gst_promise_interrupt ::
Ptr Promise ->
IO ()
promiseInterrupt ::
(B.CallStack.HasCallStack, MonadIO m) =>
Promise
-> m ()
promiseInterrupt :: Promise -> m ()
promiseInterrupt promise :: Promise
promise = 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 Promise
promise' <- Promise -> IO (Ptr Promise)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Promise
promise
Ptr Promise -> IO ()
gst_promise_interrupt Ptr Promise
promise'
PromiseChangeFunc
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Promise
promise
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data PromiseInterruptMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo PromiseInterruptMethodInfo Promise signature where
overloadedMethod = promiseInterrupt
#endif
foreign import ccall "gst_promise_reply" gst_promise_reply ::
Ptr Promise ->
Ptr Gst.Structure.Structure ->
IO ()
promiseReply ::
(B.CallStack.HasCallStack, MonadIO m) =>
Promise
-> Gst.Structure.Structure
-> m ()
promiseReply :: Promise -> Structure -> m ()
promiseReply promise :: Promise
promise s :: Structure
s = 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 Promise
promise' <- Promise -> IO (Ptr Promise)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Promise
promise
Ptr Structure
s' <- Structure -> IO (Ptr Structure)
forall a. (HasCallStack, BoxedObject a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed Structure
s
Ptr Promise -> Ptr Structure -> IO ()
gst_promise_reply Ptr Promise
promise' Ptr Structure
s'
PromiseChangeFunc
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Promise
promise
Structure -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Structure
s
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data PromiseReplyMethodInfo
instance (signature ~ (Gst.Structure.Structure -> m ()), MonadIO m) => O.MethodInfo PromiseReplyMethodInfo Promise signature where
overloadedMethod = promiseReply
#endif
foreign import ccall "gst_promise_wait" gst_promise_wait ::
Ptr Promise ->
IO CUInt
promiseWait ::
(B.CallStack.HasCallStack, MonadIO m) =>
Promise
-> m Gst.Enums.PromiseResult
promiseWait :: Promise -> m PromiseResult
promiseWait promise :: Promise
promise = IO PromiseResult -> m PromiseResult
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO PromiseResult -> m PromiseResult)
-> IO PromiseResult -> m PromiseResult
forall a b. (a -> b) -> a -> b
$ do
Ptr Promise
promise' <- Promise -> IO (Ptr Promise)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Promise
promise
CUInt
result <- Ptr Promise -> IO CUInt
gst_promise_wait Ptr Promise
promise'
let result' :: PromiseResult
result' = (Int -> PromiseResult
forall a. Enum a => Int -> a
toEnum (Int -> PromiseResult) -> (CUInt -> Int) -> CUInt -> PromiseResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
PromiseChangeFunc
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Promise
promise
PromiseResult -> IO PromiseResult
forall (m :: * -> *) a. Monad m => a -> m a
return PromiseResult
result'
#if defined(ENABLE_OVERLOADING)
data PromiseWaitMethodInfo
instance (signature ~ (m Gst.Enums.PromiseResult), MonadIO m) => O.MethodInfo PromiseWaitMethodInfo Promise signature where
overloadedMethod = promiseWait
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolvePromiseMethod (t :: Symbol) (o :: *) :: * where
ResolvePromiseMethod "expire" o = PromiseExpireMethodInfo
ResolvePromiseMethod "interrupt" o = PromiseInterruptMethodInfo
ResolvePromiseMethod "reply" o = PromiseReplyMethodInfo
ResolvePromiseMethod "wait" o = PromiseWaitMethodInfo
ResolvePromiseMethod "getReply" o = PromiseGetReplyMethodInfo
ResolvePromiseMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolvePromiseMethod t Promise, O.MethodInfo info Promise p) => OL.IsLabel t (Promise -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif