{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gio.Objects.OutputStream
(
OutputStream(..) ,
IsOutputStream ,
toOutputStream ,
noOutputStream ,
#if defined(ENABLE_OVERLOADING)
ResolveOutputStreamMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
OutputStreamClearPendingMethodInfo ,
#endif
outputStreamClearPending ,
#if defined(ENABLE_OVERLOADING)
OutputStreamCloseMethodInfo ,
#endif
outputStreamClose ,
#if defined(ENABLE_OVERLOADING)
OutputStreamCloseAsyncMethodInfo ,
#endif
outputStreamCloseAsync ,
#if defined(ENABLE_OVERLOADING)
OutputStreamCloseFinishMethodInfo ,
#endif
outputStreamCloseFinish ,
#if defined(ENABLE_OVERLOADING)
OutputStreamFlushMethodInfo ,
#endif
outputStreamFlush ,
#if defined(ENABLE_OVERLOADING)
OutputStreamFlushAsyncMethodInfo ,
#endif
outputStreamFlushAsync ,
#if defined(ENABLE_OVERLOADING)
OutputStreamFlushFinishMethodInfo ,
#endif
outputStreamFlushFinish ,
#if defined(ENABLE_OVERLOADING)
OutputStreamHasPendingMethodInfo ,
#endif
outputStreamHasPending ,
#if defined(ENABLE_OVERLOADING)
OutputStreamIsClosedMethodInfo ,
#endif
outputStreamIsClosed ,
#if defined(ENABLE_OVERLOADING)
OutputStreamIsClosingMethodInfo ,
#endif
outputStreamIsClosing ,
#if defined(ENABLE_OVERLOADING)
OutputStreamSetPendingMethodInfo ,
#endif
outputStreamSetPending ,
#if defined(ENABLE_OVERLOADING)
OutputStreamSpliceMethodInfo ,
#endif
outputStreamSplice ,
#if defined(ENABLE_OVERLOADING)
OutputStreamSpliceAsyncMethodInfo ,
#endif
outputStreamSpliceAsync ,
#if defined(ENABLE_OVERLOADING)
OutputStreamSpliceFinishMethodInfo ,
#endif
outputStreamSpliceFinish ,
#if defined(ENABLE_OVERLOADING)
OutputStreamWriteMethodInfo ,
#endif
outputStreamWrite ,
#if defined(ENABLE_OVERLOADING)
OutputStreamWriteAllMethodInfo ,
#endif
outputStreamWriteAll ,
#if defined(ENABLE_OVERLOADING)
OutputStreamWriteAllAsyncMethodInfo ,
#endif
outputStreamWriteAllAsync ,
#if defined(ENABLE_OVERLOADING)
OutputStreamWriteAllFinishMethodInfo ,
#endif
outputStreamWriteAllFinish ,
#if defined(ENABLE_OVERLOADING)
OutputStreamWriteAsyncMethodInfo ,
#endif
outputStreamWriteAsync ,
#if defined(ENABLE_OVERLOADING)
OutputStreamWriteBytesMethodInfo ,
#endif
outputStreamWriteBytes ,
#if defined(ENABLE_OVERLOADING)
OutputStreamWriteBytesAsyncMethodInfo ,
#endif
outputStreamWriteBytesAsync ,
#if defined(ENABLE_OVERLOADING)
OutputStreamWriteBytesFinishMethodInfo ,
#endif
outputStreamWriteBytesFinish ,
#if defined(ENABLE_OVERLOADING)
OutputStreamWriteFinishMethodInfo ,
#endif
outputStreamWriteFinish ,
#if defined(ENABLE_OVERLOADING)
OutputStreamWritevMethodInfo ,
#endif
outputStreamWritev ,
#if defined(ENABLE_OVERLOADING)
OutputStreamWritevAllMethodInfo ,
#endif
outputStreamWritevAll ,
#if defined(ENABLE_OVERLOADING)
OutputStreamWritevAllAsyncMethodInfo ,
#endif
outputStreamWritevAllAsync ,
#if defined(ENABLE_OVERLOADING)
OutputStreamWritevAllFinishMethodInfo ,
#endif
outputStreamWritevAllFinish ,
#if defined(ENABLE_OVERLOADING)
OutputStreamWritevAsyncMethodInfo ,
#endif
outputStreamWritevAsync ,
#if defined(ENABLE_OVERLOADING)
OutputStreamWritevFinishMethodInfo ,
#endif
outputStreamWritevFinish ,
) 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.Structs.Bytes as GLib.Bytes
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Flags as Gio.Flags
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.InputStream as Gio.InputStream
import {-# SOURCE #-} qualified GI.Gio.Structs.OutputVector as Gio.OutputVector
newtype OutputStream = OutputStream (ManagedPtr OutputStream)
deriving (OutputStream -> OutputStream -> Bool
(OutputStream -> OutputStream -> Bool)
-> (OutputStream -> OutputStream -> Bool) -> Eq OutputStream
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OutputStream -> OutputStream -> Bool
$c/= :: OutputStream -> OutputStream -> Bool
== :: OutputStream -> OutputStream -> Bool
$c== :: OutputStream -> OutputStream -> Bool
Eq)
foreign import ccall "g_output_stream_get_type"
c_g_output_stream_get_type :: IO GType
instance GObject OutputStream where
gobjectType :: IO GType
gobjectType = IO GType
c_g_output_stream_get_type
instance B.GValue.IsGValue OutputStream where
toGValue :: OutputStream -> IO GValue
toGValue o :: OutputStream
o = do
GType
gtype <- IO GType
c_g_output_stream_get_type
OutputStream -> (Ptr OutputStream -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr OutputStream
o (GType
-> (GValue -> Ptr OutputStream -> IO ())
-> Ptr OutputStream
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr OutputStream -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
fromGValue :: GValue -> IO OutputStream
fromGValue gv :: GValue
gv = do
Ptr OutputStream
ptr <- GValue -> IO (Ptr OutputStream)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr OutputStream)
(ManagedPtr OutputStream -> OutputStream)
-> Ptr OutputStream -> IO OutputStream
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr OutputStream -> OutputStream
OutputStream Ptr OutputStream
ptr
class (GObject o, O.IsDescendantOf OutputStream o) => IsOutputStream o
instance (GObject o, O.IsDescendantOf OutputStream o) => IsOutputStream o
instance O.HasParentTypes OutputStream
type instance O.ParentTypes OutputStream = '[GObject.Object.Object]
toOutputStream :: (MonadIO m, IsOutputStream o) => o -> m OutputStream
toOutputStream :: o -> m OutputStream
toOutputStream = IO OutputStream -> m OutputStream
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO OutputStream -> m OutputStream)
-> (o -> IO OutputStream) -> o -> m OutputStream
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr OutputStream -> OutputStream) -> o -> IO OutputStream
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr OutputStream -> OutputStream
OutputStream
noOutputStream :: Maybe OutputStream
noOutputStream :: Maybe OutputStream
noOutputStream = Maybe OutputStream
forall a. Maybe a
Nothing
#if defined(ENABLE_OVERLOADING)
type family ResolveOutputStreamMethod (t :: Symbol) (o :: *) :: * where
ResolveOutputStreamMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveOutputStreamMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveOutputStreamMethod "clearPending" o = OutputStreamClearPendingMethodInfo
ResolveOutputStreamMethod "close" o = OutputStreamCloseMethodInfo
ResolveOutputStreamMethod "closeAsync" o = OutputStreamCloseAsyncMethodInfo
ResolveOutputStreamMethod "closeFinish" o = OutputStreamCloseFinishMethodInfo
ResolveOutputStreamMethod "flush" o = OutputStreamFlushMethodInfo
ResolveOutputStreamMethod "flushAsync" o = OutputStreamFlushAsyncMethodInfo
ResolveOutputStreamMethod "flushFinish" o = OutputStreamFlushFinishMethodInfo
ResolveOutputStreamMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveOutputStreamMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveOutputStreamMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveOutputStreamMethod "hasPending" o = OutputStreamHasPendingMethodInfo
ResolveOutputStreamMethod "isClosed" o = OutputStreamIsClosedMethodInfo
ResolveOutputStreamMethod "isClosing" o = OutputStreamIsClosingMethodInfo
ResolveOutputStreamMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveOutputStreamMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveOutputStreamMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveOutputStreamMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveOutputStreamMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveOutputStreamMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveOutputStreamMethod "splice" o = OutputStreamSpliceMethodInfo
ResolveOutputStreamMethod "spliceAsync" o = OutputStreamSpliceAsyncMethodInfo
ResolveOutputStreamMethod "spliceFinish" o = OutputStreamSpliceFinishMethodInfo
ResolveOutputStreamMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveOutputStreamMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveOutputStreamMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveOutputStreamMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveOutputStreamMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveOutputStreamMethod "write" o = OutputStreamWriteMethodInfo
ResolveOutputStreamMethod "writeAll" o = OutputStreamWriteAllMethodInfo
ResolveOutputStreamMethod "writeAllAsync" o = OutputStreamWriteAllAsyncMethodInfo
ResolveOutputStreamMethod "writeAllFinish" o = OutputStreamWriteAllFinishMethodInfo
ResolveOutputStreamMethod "writeAsync" o = OutputStreamWriteAsyncMethodInfo
ResolveOutputStreamMethod "writeBytes" o = OutputStreamWriteBytesMethodInfo
ResolveOutputStreamMethod "writeBytesAsync" o = OutputStreamWriteBytesAsyncMethodInfo
ResolveOutputStreamMethod "writeBytesFinish" o = OutputStreamWriteBytesFinishMethodInfo
ResolveOutputStreamMethod "writeFinish" o = OutputStreamWriteFinishMethodInfo
ResolveOutputStreamMethod "writev" o = OutputStreamWritevMethodInfo
ResolveOutputStreamMethod "writevAll" o = OutputStreamWritevAllMethodInfo
ResolveOutputStreamMethod "writevAllAsync" o = OutputStreamWritevAllAsyncMethodInfo
ResolveOutputStreamMethod "writevAllFinish" o = OutputStreamWritevAllFinishMethodInfo
ResolveOutputStreamMethod "writevAsync" o = OutputStreamWritevAsyncMethodInfo
ResolveOutputStreamMethod "writevFinish" o = OutputStreamWritevFinishMethodInfo
ResolveOutputStreamMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveOutputStreamMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveOutputStreamMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveOutputStreamMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveOutputStreamMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveOutputStreamMethod "setPending" o = OutputStreamSetPendingMethodInfo
ResolveOutputStreamMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveOutputStreamMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveOutputStreamMethod t OutputStream, O.MethodInfo info OutputStream p) => OL.IsLabel t (OutputStream -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList OutputStream
type instance O.AttributeList OutputStream = OutputStreamAttributeList
type OutputStreamAttributeList = ('[ ] :: [(Symbol, *)])
#endif
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList OutputStream = OutputStreamSignalList
type OutputStreamSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "g_output_stream_clear_pending" g_output_stream_clear_pending ::
Ptr OutputStream ->
IO ()
outputStreamClearPending ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a) =>
a
-> m ()
outputStreamClearPending :: a -> m ()
outputStreamClearPending stream :: a
stream = 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 OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr OutputStream -> IO ()
g_output_stream_clear_pending Ptr OutputStream
stream'
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OutputStreamClearPendingMethodInfo
instance (signature ~ (m ()), MonadIO m, IsOutputStream a) => O.MethodInfo OutputStreamClearPendingMethodInfo a signature where
overloadedMethod = outputStreamClearPending
#endif
foreign import ccall "g_output_stream_close" g_output_stream_close ::
Ptr OutputStream ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO CInt
outputStreamClose ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> Maybe (b)
-> m ()
outputStreamClose :: a -> Maybe b -> m ()
outputStreamClose stream :: a
stream cancellable :: Maybe b
cancellable = 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 OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
Just jCancellable :: b
jCancellable -> do
Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr OutputStream -> Ptr Cancellable -> Ptr (Ptr GError) -> IO CInt
g_output_stream_close Ptr OutputStream
stream' Ptr Cancellable
maybeCancellable
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
) (do
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data OutputStreamCloseMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo OutputStreamCloseMethodInfo a signature where
overloadedMethod = outputStreamClose
#endif
foreign import ccall "g_output_stream_close_async" g_output_stream_close_async ::
Ptr OutputStream ->
Int32 ->
Ptr Gio.Cancellable.Cancellable ->
FunPtr Gio.Callbacks.C_AsyncReadyCallback ->
Ptr () ->
IO ()
outputStreamCloseAsync ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> Int32
-> Maybe (b)
-> Maybe (Gio.Callbacks.AsyncReadyCallback)
-> m ()
outputStreamCloseAsync :: a -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
outputStreamCloseAsync stream :: a
stream ioPriority :: Int32
ioPriority cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = 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 OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
Just jCancellable :: b
jCancellable -> do
Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
Just jCallback :: AsyncReadyCallback
jCallback -> do
Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
Ptr OutputStream
-> Int32
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_output_stream_close_async Ptr OutputStream
stream' Int32
ioPriority Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OutputStreamCloseAsyncMethodInfo
instance (signature ~ (Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo OutputStreamCloseAsyncMethodInfo a signature where
overloadedMethod = outputStreamCloseAsync
#endif
foreign import ccall "g_output_stream_close_finish" g_output_stream_close_finish ::
Ptr OutputStream ->
Ptr Gio.AsyncResult.AsyncResult ->
Ptr (Ptr GError) ->
IO CInt
outputStreamCloseFinish ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.AsyncResult.IsAsyncResult b) =>
a
-> b
-> m ()
outputStreamCloseFinish :: a -> b -> m ()
outputStreamCloseFinish stream :: a
stream result_ :: b
result_ = 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 OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr OutputStream -> Ptr AsyncResult -> Ptr (Ptr GError) -> IO CInt
g_output_stream_close_finish Ptr OutputStream
stream' Ptr AsyncResult
result_'
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
) (do
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data OutputStreamCloseFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsOutputStream a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo OutputStreamCloseFinishMethodInfo a signature where
overloadedMethod = outputStreamCloseFinish
#endif
foreign import ccall "g_output_stream_flush" g_output_stream_flush ::
Ptr OutputStream ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO CInt
outputStreamFlush ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> Maybe (b)
-> m ()
outputStreamFlush :: a -> Maybe b -> m ()
outputStreamFlush stream :: a
stream cancellable :: Maybe b
cancellable = 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 OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
Just jCancellable :: b
jCancellable -> do
Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr OutputStream -> Ptr Cancellable -> Ptr (Ptr GError) -> IO CInt
g_output_stream_flush Ptr OutputStream
stream' Ptr Cancellable
maybeCancellable
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
) (do
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data OutputStreamFlushMethodInfo
instance (signature ~ (Maybe (b) -> m ()), MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo OutputStreamFlushMethodInfo a signature where
overloadedMethod = outputStreamFlush
#endif
foreign import ccall "g_output_stream_flush_async" g_output_stream_flush_async ::
Ptr OutputStream ->
Int32 ->
Ptr Gio.Cancellable.Cancellable ->
FunPtr Gio.Callbacks.C_AsyncReadyCallback ->
Ptr () ->
IO ()
outputStreamFlushAsync ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> Int32
-> Maybe (b)
-> Maybe (Gio.Callbacks.AsyncReadyCallback)
-> m ()
outputStreamFlushAsync :: a -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
outputStreamFlushAsync stream :: a
stream ioPriority :: Int32
ioPriority cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = 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 OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
Just jCancellable :: b
jCancellable -> do
Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
Just jCallback :: AsyncReadyCallback
jCallback -> do
Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
Ptr OutputStream
-> Int32
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_output_stream_flush_async Ptr OutputStream
stream' Int32
ioPriority Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OutputStreamFlushAsyncMethodInfo
instance (signature ~ (Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo OutputStreamFlushAsyncMethodInfo a signature where
overloadedMethod = outputStreamFlushAsync
#endif
foreign import ccall "g_output_stream_flush_finish" g_output_stream_flush_finish ::
Ptr OutputStream ->
Ptr Gio.AsyncResult.AsyncResult ->
Ptr (Ptr GError) ->
IO CInt
outputStreamFlushFinish ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.AsyncResult.IsAsyncResult b) =>
a
-> b
-> m ()
outputStreamFlushFinish :: a -> b -> m ()
outputStreamFlushFinish stream :: a
stream result_ :: b
result_ = 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 OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr OutputStream -> Ptr AsyncResult -> Ptr (Ptr GError) -> IO CInt
g_output_stream_flush_finish Ptr OutputStream
stream' Ptr AsyncResult
result_'
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
) (do
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data OutputStreamFlushFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsOutputStream a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo OutputStreamFlushFinishMethodInfo a signature where
overloadedMethod = outputStreamFlushFinish
#endif
foreign import ccall "g_output_stream_has_pending" g_output_stream_has_pending ::
Ptr OutputStream ->
IO CInt
outputStreamHasPending ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a) =>
a
-> m Bool
outputStreamHasPending :: a -> m Bool
outputStreamHasPending stream :: a
stream = 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 OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
CInt
result <- Ptr OutputStream -> IO CInt
g_output_stream_has_pending Ptr OutputStream
stream'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data OutputStreamHasPendingMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsOutputStream a) => O.MethodInfo OutputStreamHasPendingMethodInfo a signature where
overloadedMethod = outputStreamHasPending
#endif
foreign import ccall "g_output_stream_is_closed" g_output_stream_is_closed ::
Ptr OutputStream ->
IO CInt
outputStreamIsClosed ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a) =>
a
-> m Bool
outputStreamIsClosed :: a -> m Bool
outputStreamIsClosed stream :: a
stream = 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 OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
CInt
result <- Ptr OutputStream -> IO CInt
g_output_stream_is_closed Ptr OutputStream
stream'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data OutputStreamIsClosedMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsOutputStream a) => O.MethodInfo OutputStreamIsClosedMethodInfo a signature where
overloadedMethod = outputStreamIsClosed
#endif
foreign import ccall "g_output_stream_is_closing" g_output_stream_is_closing ::
Ptr OutputStream ->
IO CInt
outputStreamIsClosing ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a) =>
a
-> m Bool
outputStreamIsClosing :: a -> m Bool
outputStreamIsClosing stream :: a
stream = 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 OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
CInt
result <- Ptr OutputStream -> IO CInt
g_output_stream_is_closing Ptr OutputStream
stream'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data OutputStreamIsClosingMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsOutputStream a) => O.MethodInfo OutputStreamIsClosingMethodInfo a signature where
overloadedMethod = outputStreamIsClosing
#endif
foreign import ccall "g_output_stream_set_pending" g_output_stream_set_pending ::
Ptr OutputStream ->
Ptr (Ptr GError) ->
IO CInt
outputStreamSetPending ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a) =>
a
-> m ()
outputStreamSetPending :: a -> m ()
outputStreamSetPending stream :: a
stream = 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 OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr OutputStream -> Ptr (Ptr GError) -> IO CInt
g_output_stream_set_pending Ptr OutputStream
stream'
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
) (do
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data OutputStreamSetPendingMethodInfo
instance (signature ~ (m ()), MonadIO m, IsOutputStream a) => O.MethodInfo OutputStreamSetPendingMethodInfo a signature where
overloadedMethod = outputStreamSetPending
#endif
foreign import ccall "g_output_stream_splice" g_output_stream_splice ::
Ptr OutputStream ->
Ptr Gio.InputStream.InputStream ->
CUInt ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO Int64
outputStreamSplice ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.InputStream.IsInputStream b, Gio.Cancellable.IsCancellable c) =>
a
-> b
-> [Gio.Flags.OutputStreamSpliceFlags]
-> Maybe (c)
-> m Int64
outputStreamSplice :: a -> b -> [OutputStreamSpliceFlags] -> Maybe c -> m Int64
outputStreamSplice stream :: a
stream source :: b
source flags :: [OutputStreamSpliceFlags]
flags cancellable :: Maybe c
cancellable = IO Int64 -> m Int64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
Ptr OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr InputStream
source' <- b -> IO (Ptr InputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
source
let flags' :: CUInt
flags' = [OutputStreamSpliceFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [OutputStreamSpliceFlags]
flags
Ptr Cancellable
maybeCancellable <- case Maybe c
cancellable of
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
Just jCancellable :: c
jCancellable -> do
Ptr Cancellable
jCancellable' <- c -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr c
jCancellable
Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
IO Int64 -> IO () -> IO Int64
forall a b. IO a -> IO b -> IO a
onException (do
Int64
result <- (Ptr (Ptr GError) -> IO Int64) -> IO Int64
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO Int64) -> IO Int64)
-> (Ptr (Ptr GError) -> IO Int64) -> IO Int64
forall a b. (a -> b) -> a -> b
$ Ptr OutputStream
-> Ptr InputStream
-> CUInt
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO Int64
g_output_stream_splice Ptr OutputStream
stream' Ptr InputStream
source' CUInt
flags' Ptr Cancellable
maybeCancellable
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
source
Maybe c -> (c -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe c
cancellable c -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
Int64 -> IO Int64
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
result
) (do
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data OutputStreamSpliceMethodInfo
instance (signature ~ (b -> [Gio.Flags.OutputStreamSpliceFlags] -> Maybe (c) -> m Int64), MonadIO m, IsOutputStream a, Gio.InputStream.IsInputStream b, Gio.Cancellable.IsCancellable c) => O.MethodInfo OutputStreamSpliceMethodInfo a signature where
overloadedMethod = outputStreamSplice
#endif
foreign import ccall "g_output_stream_splice_async" g_output_stream_splice_async ::
Ptr OutputStream ->
Ptr Gio.InputStream.InputStream ->
CUInt ->
Int32 ->
Ptr Gio.Cancellable.Cancellable ->
FunPtr Gio.Callbacks.C_AsyncReadyCallback ->
Ptr () ->
IO ()
outputStreamSpliceAsync ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.InputStream.IsInputStream b, Gio.Cancellable.IsCancellable c) =>
a
-> b
-> [Gio.Flags.OutputStreamSpliceFlags]
-> Int32
-> Maybe (c)
-> Maybe (Gio.Callbacks.AsyncReadyCallback)
-> m ()
outputStreamSpliceAsync :: a
-> b
-> [OutputStreamSpliceFlags]
-> Int32
-> Maybe c
-> Maybe AsyncReadyCallback
-> m ()
outputStreamSpliceAsync stream :: a
stream source :: b
source flags :: [OutputStreamSpliceFlags]
flags ioPriority :: Int32
ioPriority cancellable :: Maybe c
cancellable callback :: Maybe AsyncReadyCallback
callback = 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 OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr InputStream
source' <- b -> IO (Ptr InputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
source
let flags' :: CUInt
flags' = [OutputStreamSpliceFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [OutputStreamSpliceFlags]
flags
Ptr Cancellable
maybeCancellable <- case Maybe c
cancellable of
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
Just jCancellable :: c
jCancellable -> do
Ptr Cancellable
jCancellable' <- c -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr c
jCancellable
Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
Just jCallback :: AsyncReadyCallback
jCallback -> do
Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
Ptr OutputStream
-> Ptr InputStream
-> CUInt
-> Int32
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_output_stream_splice_async Ptr OutputStream
stream' Ptr InputStream
source' CUInt
flags' Int32
ioPriority Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
source
Maybe c -> (c -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe c
cancellable c -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OutputStreamSpliceAsyncMethodInfo
instance (signature ~ (b -> [Gio.Flags.OutputStreamSpliceFlags] -> Int32 -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsOutputStream a, Gio.InputStream.IsInputStream b, Gio.Cancellable.IsCancellable c) => O.MethodInfo OutputStreamSpliceAsyncMethodInfo a signature where
overloadedMethod = outputStreamSpliceAsync
#endif
foreign import ccall "g_output_stream_splice_finish" g_output_stream_splice_finish ::
Ptr OutputStream ->
Ptr Gio.AsyncResult.AsyncResult ->
Ptr (Ptr GError) ->
IO Int64
outputStreamSpliceFinish ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.AsyncResult.IsAsyncResult b) =>
a
-> b
-> m Int64
outputStreamSpliceFinish :: a -> b -> m Int64
outputStreamSpliceFinish stream :: a
stream result_ :: b
result_ = IO Int64 -> m Int64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
Ptr OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
IO Int64 -> IO () -> IO Int64
forall a b. IO a -> IO b -> IO a
onException (do
Int64
result <- (Ptr (Ptr GError) -> IO Int64) -> IO Int64
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO Int64) -> IO Int64)
-> (Ptr (Ptr GError) -> IO Int64) -> IO Int64
forall a b. (a -> b) -> a -> b
$ Ptr OutputStream -> Ptr AsyncResult -> Ptr (Ptr GError) -> IO Int64
g_output_stream_splice_finish Ptr OutputStream
stream' Ptr AsyncResult
result_'
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
Int64 -> IO Int64
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
result
) (do
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data OutputStreamSpliceFinishMethodInfo
instance (signature ~ (b -> m Int64), MonadIO m, IsOutputStream a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo OutputStreamSpliceFinishMethodInfo a signature where
overloadedMethod = outputStreamSpliceFinish
#endif
foreign import ccall "g_output_stream_write" g_output_stream_write ::
Ptr OutputStream ->
Ptr Word8 ->
Word64 ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO Int64
outputStreamWrite ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> ByteString
-> Maybe (b)
-> m Int64
outputStreamWrite :: a -> ByteString -> Maybe b -> m Int64
outputStreamWrite stream :: a
stream buffer :: ByteString
buffer cancellable :: Maybe b
cancellable = IO Int64 -> m Int64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
let count :: Word64
count = Int -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word64) -> Int -> Word64
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
buffer
Ptr OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr Word8
buffer' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
buffer
Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
Just jCancellable :: b
jCancellable -> do
Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
IO Int64 -> IO () -> IO Int64
forall a b. IO a -> IO b -> IO a
onException (do
Int64
result <- (Ptr (Ptr GError) -> IO Int64) -> IO Int64
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO Int64) -> IO Int64)
-> (Ptr (Ptr GError) -> IO Int64) -> IO Int64
forall a b. (a -> b) -> a -> b
$ Ptr OutputStream
-> Ptr Word8
-> Word64
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO Int64
g_output_stream_write Ptr OutputStream
stream' Ptr Word8
buffer' Word64
count Ptr Cancellable
maybeCancellable
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
buffer'
Int64 -> IO Int64
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
result
) (do
Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
buffer'
)
#if defined(ENABLE_OVERLOADING)
data OutputStreamWriteMethodInfo
instance (signature ~ (ByteString -> Maybe (b) -> m Int64), MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo OutputStreamWriteMethodInfo a signature where
overloadedMethod = outputStreamWrite
#endif
foreign import ccall "g_output_stream_write_all" g_output_stream_write_all ::
Ptr OutputStream ->
Ptr Word8 ->
Word64 ->
Ptr Word64 ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO CInt
outputStreamWriteAll ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> ByteString
-> Maybe (b)
-> m (Word64)
outputStreamWriteAll :: a -> ByteString -> Maybe b -> m Word64
outputStreamWriteAll stream :: a
stream buffer :: ByteString
buffer cancellable :: Maybe b
cancellable = IO Word64 -> m Word64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word64 -> m Word64) -> IO Word64 -> m Word64
forall a b. (a -> b) -> a -> b
$ do
let count :: Word64
count = Int -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word64) -> Int -> Word64
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
buffer
Ptr OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr Word8
buffer' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
buffer
Ptr Word64
bytesWritten <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
Just jCancellable :: b
jCancellable -> do
Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
IO Word64 -> IO () -> IO Word64
forall a b. IO a -> IO b -> IO a
onException (do
CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr OutputStream
-> Ptr Word8
-> Word64
-> Ptr Word64
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO CInt
g_output_stream_write_all Ptr OutputStream
stream' Ptr Word8
buffer' Word64
count Ptr Word64
bytesWritten Ptr Cancellable
maybeCancellable
Word64
bytesWritten' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
bytesWritten
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
buffer'
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
bytesWritten
Word64 -> IO Word64
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
bytesWritten'
) (do
Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
buffer'
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
bytesWritten
)
#if defined(ENABLE_OVERLOADING)
data OutputStreamWriteAllMethodInfo
instance (signature ~ (ByteString -> Maybe (b) -> m (Word64)), MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo OutputStreamWriteAllMethodInfo a signature where
overloadedMethod = outputStreamWriteAll
#endif
foreign import ccall "g_output_stream_write_all_async" g_output_stream_write_all_async ::
Ptr OutputStream ->
Ptr Word8 ->
Word64 ->
Int32 ->
Ptr Gio.Cancellable.Cancellable ->
FunPtr Gio.Callbacks.C_AsyncReadyCallback ->
Ptr () ->
IO ()
outputStreamWriteAllAsync ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> ByteString
-> Int32
-> Maybe (b)
-> Maybe (Gio.Callbacks.AsyncReadyCallback)
-> m ()
outputStreamWriteAllAsync :: a
-> ByteString
-> Int32
-> Maybe b
-> Maybe AsyncReadyCallback
-> m ()
outputStreamWriteAllAsync stream :: a
stream buffer :: ByteString
buffer ioPriority :: Int32
ioPriority cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
let count :: Word64
count = Int -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word64) -> Int -> Word64
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
buffer
Ptr OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr Word8
buffer' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
buffer
Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
Just jCancellable :: b
jCancellable -> do
Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
Just jCallback :: AsyncReadyCallback
jCallback -> do
Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
Ptr OutputStream
-> Ptr Word8
-> Word64
-> Int32
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_output_stream_write_all_async Ptr OutputStream
stream' Ptr Word8
buffer' Word64
count Int32
ioPriority Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
buffer'
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OutputStreamWriteAllAsyncMethodInfo
instance (signature ~ (ByteString -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo OutputStreamWriteAllAsyncMethodInfo a signature where
overloadedMethod = outputStreamWriteAllAsync
#endif
foreign import ccall "g_output_stream_write_all_finish" g_output_stream_write_all_finish ::
Ptr OutputStream ->
Ptr Gio.AsyncResult.AsyncResult ->
Ptr Word64 ->
Ptr (Ptr GError) ->
IO CInt
outputStreamWriteAllFinish ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.AsyncResult.IsAsyncResult b) =>
a
-> b
-> m (Word64)
outputStreamWriteAllFinish :: a -> b -> m Word64
outputStreamWriteAllFinish stream :: a
stream result_ :: b
result_ = IO Word64 -> m Word64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word64 -> m Word64) -> IO Word64 -> m Word64
forall a b. (a -> b) -> a -> b
$ do
Ptr OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
Ptr Word64
bytesWritten <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
IO Word64 -> IO () -> IO Word64
forall a b. IO a -> IO b -> IO a
onException (do
CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr OutputStream
-> Ptr AsyncResult -> Ptr Word64 -> Ptr (Ptr GError) -> IO CInt
g_output_stream_write_all_finish Ptr OutputStream
stream' Ptr AsyncResult
result_' Ptr Word64
bytesWritten
Word64
bytesWritten' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
bytesWritten
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
bytesWritten
Word64 -> IO Word64
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
bytesWritten'
) (do
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
bytesWritten
)
#if defined(ENABLE_OVERLOADING)
data OutputStreamWriteAllFinishMethodInfo
instance (signature ~ (b -> m (Word64)), MonadIO m, IsOutputStream a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo OutputStreamWriteAllFinishMethodInfo a signature where
overloadedMethod = outputStreamWriteAllFinish
#endif
foreign import ccall "g_output_stream_write_async" g_output_stream_write_async ::
Ptr OutputStream ->
Ptr Word8 ->
Word64 ->
Int32 ->
Ptr Gio.Cancellable.Cancellable ->
FunPtr Gio.Callbacks.C_AsyncReadyCallback ->
Ptr () ->
IO ()
outputStreamWriteAsync ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> Maybe (ByteString)
-> Int32
-> Maybe (b)
-> Maybe (Gio.Callbacks.AsyncReadyCallback)
-> m ()
outputStreamWriteAsync :: a
-> Maybe ByteString
-> Int32
-> Maybe b
-> Maybe AsyncReadyCallback
-> m ()
outputStreamWriteAsync stream :: a
stream buffer :: Maybe ByteString
buffer ioPriority :: Int32
ioPriority cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
let count :: Word64
count = case Maybe ByteString
buffer of
Nothing -> 0
Just jBuffer :: ByteString
jBuffer -> Int -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word64) -> Int -> Word64
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
jBuffer
Ptr OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr Word8
maybeBuffer <- case Maybe ByteString
buffer of
Nothing -> Ptr Word8 -> IO (Ptr Word8)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Word8
forall a. Ptr a
nullPtr
Just jBuffer :: ByteString
jBuffer -> do
Ptr Word8
jBuffer' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
jBuffer
Ptr Word8 -> IO (Ptr Word8)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Word8
jBuffer'
Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
Just jCancellable :: b
jCancellable -> do
Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
Just jCallback :: AsyncReadyCallback
jCallback -> do
Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
Ptr OutputStream
-> Ptr Word8
-> Word64
-> Int32
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_output_stream_write_async Ptr OutputStream
stream' Ptr Word8
maybeBuffer Word64
count Int32
ioPriority Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
maybeBuffer
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OutputStreamWriteAsyncMethodInfo
instance (signature ~ (Maybe (ByteString) -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo OutputStreamWriteAsyncMethodInfo a signature where
overloadedMethod = outputStreamWriteAsync
#endif
foreign import ccall "g_output_stream_write_bytes" g_output_stream_write_bytes ::
Ptr OutputStream ->
Ptr GLib.Bytes.Bytes ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO Int64
outputStreamWriteBytes ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> GLib.Bytes.Bytes
-> Maybe (b)
-> m Int64
outputStreamWriteBytes :: a -> Bytes -> Maybe b -> m Int64
outputStreamWriteBytes stream :: a
stream bytes :: Bytes
bytes cancellable :: Maybe b
cancellable = IO Int64 -> m Int64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
Ptr OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr Bytes
bytes' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Bytes
bytes
Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
Just jCancellable :: b
jCancellable -> do
Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
IO Int64 -> IO () -> IO Int64
forall a b. IO a -> IO b -> IO a
onException (do
Int64
result <- (Ptr (Ptr GError) -> IO Int64) -> IO Int64
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO Int64) -> IO Int64)
-> (Ptr (Ptr GError) -> IO Int64) -> IO Int64
forall a b. (a -> b) -> a -> b
$ Ptr OutputStream
-> Ptr Bytes -> Ptr Cancellable -> Ptr (Ptr GError) -> IO Int64
g_output_stream_write_bytes Ptr OutputStream
stream' Ptr Bytes
bytes' Ptr Cancellable
maybeCancellable
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
bytes
Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
Int64 -> IO Int64
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
result
) (do
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data OutputStreamWriteBytesMethodInfo
instance (signature ~ (GLib.Bytes.Bytes -> Maybe (b) -> m Int64), MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo OutputStreamWriteBytesMethodInfo a signature where
overloadedMethod = outputStreamWriteBytes
#endif
foreign import ccall "g_output_stream_write_bytes_async" g_output_stream_write_bytes_async ::
Ptr OutputStream ->
Ptr GLib.Bytes.Bytes ->
Int32 ->
Ptr Gio.Cancellable.Cancellable ->
FunPtr Gio.Callbacks.C_AsyncReadyCallback ->
Ptr () ->
IO ()
outputStreamWriteBytesAsync ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> GLib.Bytes.Bytes
-> Int32
-> Maybe (b)
-> Maybe (Gio.Callbacks.AsyncReadyCallback)
-> m ()
outputStreamWriteBytesAsync :: a -> Bytes -> Int32 -> Maybe b -> Maybe AsyncReadyCallback -> m ()
outputStreamWriteBytesAsync stream :: a
stream bytes :: Bytes
bytes ioPriority :: Int32
ioPriority cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = 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 OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr Bytes
bytes' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Bytes
bytes
Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
Just jCancellable :: b
jCancellable -> do
Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
Just jCallback :: AsyncReadyCallback
jCallback -> do
Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
Ptr OutputStream
-> Ptr Bytes
-> Int32
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_output_stream_write_bytes_async Ptr OutputStream
stream' Ptr Bytes
bytes' Int32
ioPriority Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
bytes
Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OutputStreamWriteBytesAsyncMethodInfo
instance (signature ~ (GLib.Bytes.Bytes -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo OutputStreamWriteBytesAsyncMethodInfo a signature where
overloadedMethod = outputStreamWriteBytesAsync
#endif
foreign import ccall "g_output_stream_write_bytes_finish" g_output_stream_write_bytes_finish ::
Ptr OutputStream ->
Ptr Gio.AsyncResult.AsyncResult ->
Ptr (Ptr GError) ->
IO Int64
outputStreamWriteBytesFinish ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.AsyncResult.IsAsyncResult b) =>
a
-> b
-> m Int64
outputStreamWriteBytesFinish :: a -> b -> m Int64
outputStreamWriteBytesFinish stream :: a
stream result_ :: b
result_ = IO Int64 -> m Int64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
Ptr OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
IO Int64 -> IO () -> IO Int64
forall a b. IO a -> IO b -> IO a
onException (do
Int64
result <- (Ptr (Ptr GError) -> IO Int64) -> IO Int64
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO Int64) -> IO Int64)
-> (Ptr (Ptr GError) -> IO Int64) -> IO Int64
forall a b. (a -> b) -> a -> b
$ Ptr OutputStream -> Ptr AsyncResult -> Ptr (Ptr GError) -> IO Int64
g_output_stream_write_bytes_finish Ptr OutputStream
stream' Ptr AsyncResult
result_'
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
Int64 -> IO Int64
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
result
) (do
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data OutputStreamWriteBytesFinishMethodInfo
instance (signature ~ (b -> m Int64), MonadIO m, IsOutputStream a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo OutputStreamWriteBytesFinishMethodInfo a signature where
overloadedMethod = outputStreamWriteBytesFinish
#endif
foreign import ccall "g_output_stream_write_finish" g_output_stream_write_finish ::
Ptr OutputStream ->
Ptr Gio.AsyncResult.AsyncResult ->
Ptr (Ptr GError) ->
IO Int64
outputStreamWriteFinish ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.AsyncResult.IsAsyncResult b) =>
a
-> b
-> m Int64
outputStreamWriteFinish :: a -> b -> m Int64
outputStreamWriteFinish stream :: a
stream result_ :: b
result_ = IO Int64 -> m Int64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
Ptr OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
IO Int64 -> IO () -> IO Int64
forall a b. IO a -> IO b -> IO a
onException (do
Int64
result <- (Ptr (Ptr GError) -> IO Int64) -> IO Int64
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO Int64) -> IO Int64)
-> (Ptr (Ptr GError) -> IO Int64) -> IO Int64
forall a b. (a -> b) -> a -> b
$ Ptr OutputStream -> Ptr AsyncResult -> Ptr (Ptr GError) -> IO Int64
g_output_stream_write_finish Ptr OutputStream
stream' Ptr AsyncResult
result_'
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
Int64 -> IO Int64
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
result
) (do
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
)
#if defined(ENABLE_OVERLOADING)
data OutputStreamWriteFinishMethodInfo
instance (signature ~ (b -> m Int64), MonadIO m, IsOutputStream a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo OutputStreamWriteFinishMethodInfo a signature where
overloadedMethod = outputStreamWriteFinish
#endif
foreign import ccall "g_output_stream_writev" g_output_stream_writev ::
Ptr OutputStream ->
Ptr Gio.OutputVector.OutputVector ->
Word64 ->
Ptr Word64 ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO CInt
outputStreamWritev ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> [Gio.OutputVector.OutputVector]
-> Maybe (b)
-> m (Word64)
outputStreamWritev :: a -> [OutputVector] -> Maybe b -> m Word64
outputStreamWritev stream :: a
stream vectors :: [OutputVector]
vectors cancellable :: Maybe b
cancellable = IO Word64 -> m Word64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word64 -> m Word64) -> IO Word64 -> m Word64
forall a b. (a -> b) -> a -> b
$ do
let nVectors :: Word64
nVectors = Int -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word64) -> Int -> Word64
forall a b. (a -> b) -> a -> b
$ [OutputVector] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [OutputVector]
vectors
Ptr OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
[Ptr OutputVector]
vectors' <- (OutputVector -> IO (Ptr OutputVector))
-> [OutputVector] -> IO [Ptr OutputVector]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM OutputVector -> IO (Ptr OutputVector)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [OutputVector]
vectors
Ptr OutputVector
vectors'' <- Int -> [Ptr OutputVector] -> IO (Ptr OutputVector)
forall a. Int -> [Ptr a] -> IO (Ptr a)
packBlockArray 16 [Ptr OutputVector]
vectors'
Ptr Word64
bytesWritten <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
Just jCancellable :: b
jCancellable -> do
Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
IO Word64 -> IO () -> IO Word64
forall a b. IO a -> IO b -> IO a
onException (do
CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr OutputStream
-> Ptr OutputVector
-> Word64
-> Ptr Word64
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO CInt
g_output_stream_writev Ptr OutputStream
stream' Ptr OutputVector
vectors'' Word64
nVectors Ptr Word64
bytesWritten Ptr Cancellable
maybeCancellable
Word64
bytesWritten' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
bytesWritten
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
(OutputVector -> IO ()) -> [OutputVector] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ OutputVector -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [OutputVector]
vectors
Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
Ptr OutputVector -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr OutputVector
vectors''
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
bytesWritten
Word64 -> IO Word64
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
bytesWritten'
) (do
Ptr OutputVector -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr OutputVector
vectors''
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
bytesWritten
)
#if defined(ENABLE_OVERLOADING)
data OutputStreamWritevMethodInfo
instance (signature ~ ([Gio.OutputVector.OutputVector] -> Maybe (b) -> m (Word64)), MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo OutputStreamWritevMethodInfo a signature where
overloadedMethod = outputStreamWritev
#endif
foreign import ccall "g_output_stream_writev_all" g_output_stream_writev_all ::
Ptr OutputStream ->
Ptr Gio.OutputVector.OutputVector ->
Word64 ->
Ptr Word64 ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO CInt
outputStreamWritevAll ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> [Gio.OutputVector.OutputVector]
-> Maybe (b)
-> m (Word64)
outputStreamWritevAll :: a -> [OutputVector] -> Maybe b -> m Word64
outputStreamWritevAll stream :: a
stream vectors :: [OutputVector]
vectors cancellable :: Maybe b
cancellable = IO Word64 -> m Word64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word64 -> m Word64) -> IO Word64 -> m Word64
forall a b. (a -> b) -> a -> b
$ do
let nVectors :: Word64
nVectors = Int -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word64) -> Int -> Word64
forall a b. (a -> b) -> a -> b
$ [OutputVector] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [OutputVector]
vectors
Ptr OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
[Ptr OutputVector]
vectors' <- (OutputVector -> IO (Ptr OutputVector))
-> [OutputVector] -> IO [Ptr OutputVector]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM OutputVector -> IO (Ptr OutputVector)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [OutputVector]
vectors
Ptr OutputVector
vectors'' <- Int -> [Ptr OutputVector] -> IO (Ptr OutputVector)
forall a. Int -> [Ptr a] -> IO (Ptr a)
packBlockArray 16 [Ptr OutputVector]
vectors'
Ptr Word64
bytesWritten <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
Just jCancellable :: b
jCancellable -> do
Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
IO Word64 -> IO () -> IO Word64
forall a b. IO a -> IO b -> IO a
onException (do
CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr OutputStream
-> Ptr OutputVector
-> Word64
-> Ptr Word64
-> Ptr Cancellable
-> Ptr (Ptr GError)
-> IO CInt
g_output_stream_writev_all Ptr OutputStream
stream' Ptr OutputVector
vectors'' Word64
nVectors Ptr Word64
bytesWritten Ptr Cancellable
maybeCancellable
Word64
bytesWritten' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
bytesWritten
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
(OutputVector -> IO ()) -> [OutputVector] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ OutputVector -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [OutputVector]
vectors
Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
Ptr OutputVector -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr OutputVector
vectors''
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
bytesWritten
Word64 -> IO Word64
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
bytesWritten'
) (do
Ptr OutputVector -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr OutputVector
vectors''
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
bytesWritten
)
#if defined(ENABLE_OVERLOADING)
data OutputStreamWritevAllMethodInfo
instance (signature ~ ([Gio.OutputVector.OutputVector] -> Maybe (b) -> m (Word64)), MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo OutputStreamWritevAllMethodInfo a signature where
overloadedMethod = outputStreamWritevAll
#endif
foreign import ccall "g_output_stream_writev_all_async" g_output_stream_writev_all_async ::
Ptr OutputStream ->
Ptr Gio.OutputVector.OutputVector ->
Word64 ->
Int32 ->
Ptr Gio.Cancellable.Cancellable ->
FunPtr Gio.Callbacks.C_AsyncReadyCallback ->
Ptr () ->
IO ()
outputStreamWritevAllAsync ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> [Gio.OutputVector.OutputVector]
-> Int32
-> Maybe (b)
-> Maybe (Gio.Callbacks.AsyncReadyCallback)
-> m ()
outputStreamWritevAllAsync :: a
-> [OutputVector]
-> Int32
-> Maybe b
-> Maybe AsyncReadyCallback
-> m ()
outputStreamWritevAllAsync stream :: a
stream vectors :: [OutputVector]
vectors ioPriority :: Int32
ioPriority cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
let nVectors :: Word64
nVectors = Int -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word64) -> Int -> Word64
forall a b. (a -> b) -> a -> b
$ [OutputVector] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [OutputVector]
vectors
Ptr OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
[Ptr OutputVector]
vectors' <- (OutputVector -> IO (Ptr OutputVector))
-> [OutputVector] -> IO [Ptr OutputVector]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM OutputVector -> IO (Ptr OutputVector)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [OutputVector]
vectors
Ptr OutputVector
vectors'' <- Int -> [Ptr OutputVector] -> IO (Ptr OutputVector)
forall a. Int -> [Ptr a] -> IO (Ptr a)
packBlockArray 16 [Ptr OutputVector]
vectors'
Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
Just jCancellable :: b
jCancellable -> do
Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
Just jCallback :: AsyncReadyCallback
jCallback -> do
Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
Ptr OutputStream
-> Ptr OutputVector
-> Word64
-> Int32
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_output_stream_writev_all_async Ptr OutputStream
stream' Ptr OutputVector
vectors'' Word64
nVectors Int32
ioPriority Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
(OutputVector -> IO ()) -> [OutputVector] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ OutputVector -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [OutputVector]
vectors
Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
Ptr OutputVector -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr OutputVector
vectors''
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OutputStreamWritevAllAsyncMethodInfo
instance (signature ~ ([Gio.OutputVector.OutputVector] -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo OutputStreamWritevAllAsyncMethodInfo a signature where
overloadedMethod = outputStreamWritevAllAsync
#endif
foreign import ccall "g_output_stream_writev_all_finish" g_output_stream_writev_all_finish ::
Ptr OutputStream ->
Ptr Gio.AsyncResult.AsyncResult ->
Ptr Word64 ->
Ptr (Ptr GError) ->
IO CInt
outputStreamWritevAllFinish ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.AsyncResult.IsAsyncResult b) =>
a
-> b
-> m (Word64)
outputStreamWritevAllFinish :: a -> b -> m Word64
outputStreamWritevAllFinish stream :: a
stream result_ :: b
result_ = IO Word64 -> m Word64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word64 -> m Word64) -> IO Word64 -> m Word64
forall a b. (a -> b) -> a -> b
$ do
Ptr OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
Ptr Word64
bytesWritten <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
IO Word64 -> IO () -> IO Word64
forall a b. IO a -> IO b -> IO a
onException (do
CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr OutputStream
-> Ptr AsyncResult -> Ptr Word64 -> Ptr (Ptr GError) -> IO CInt
g_output_stream_writev_all_finish Ptr OutputStream
stream' Ptr AsyncResult
result_' Ptr Word64
bytesWritten
Word64
bytesWritten' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
bytesWritten
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
bytesWritten
Word64 -> IO Word64
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
bytesWritten'
) (do
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
bytesWritten
)
#if defined(ENABLE_OVERLOADING)
data OutputStreamWritevAllFinishMethodInfo
instance (signature ~ (b -> m (Word64)), MonadIO m, IsOutputStream a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo OutputStreamWritevAllFinishMethodInfo a signature where
overloadedMethod = outputStreamWritevAllFinish
#endif
foreign import ccall "g_output_stream_writev_async" g_output_stream_writev_async ::
Ptr OutputStream ->
Ptr Gio.OutputVector.OutputVector ->
Word64 ->
Int32 ->
Ptr Gio.Cancellable.Cancellable ->
FunPtr Gio.Callbacks.C_AsyncReadyCallback ->
Ptr () ->
IO ()
outputStreamWritevAsync ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> [Gio.OutputVector.OutputVector]
-> Int32
-> Maybe (b)
-> Maybe (Gio.Callbacks.AsyncReadyCallback)
-> m ()
outputStreamWritevAsync :: a
-> [OutputVector]
-> Int32
-> Maybe b
-> Maybe AsyncReadyCallback
-> m ()
outputStreamWritevAsync stream :: a
stream vectors :: [OutputVector]
vectors ioPriority :: Int32
ioPriority cancellable :: Maybe b
cancellable callback :: Maybe AsyncReadyCallback
callback = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
let nVectors :: Word64
nVectors = Int -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word64) -> Int -> Word64
forall a b. (a -> b) -> a -> b
$ [OutputVector] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [OutputVector]
vectors
Ptr OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
[Ptr OutputVector]
vectors' <- (OutputVector -> IO (Ptr OutputVector))
-> [OutputVector] -> IO [Ptr OutputVector]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM OutputVector -> IO (Ptr OutputVector)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [OutputVector]
vectors
Ptr OutputVector
vectors'' <- Int -> [Ptr OutputVector] -> IO (Ptr OutputVector)
forall a. Int -> [Ptr a] -> IO (Ptr a)
packBlockArray 16 [Ptr OutputVector]
vectors'
Ptr Cancellable
maybeCancellable <- case Maybe b
cancellable of
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
nullPtr
Just jCancellable :: b
jCancellable -> do
Ptr Cancellable
jCancellable' <- b -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jCancellable
Ptr Cancellable -> IO (Ptr Cancellable)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
jCancellable'
FunPtr C_AsyncReadyCallback
maybeCallback <- case Maybe AsyncReadyCallback
callback of
Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr C_AsyncReadyCallback
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
Just jCallback :: AsyncReadyCallback
jCallback -> do
Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
FunPtr C_AsyncReadyCallback
jCallback' <- C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
Gio.Callbacks.mk_AsyncReadyCallback (Maybe (Ptr (FunPtr C_AsyncReadyCallback))
-> AsyncReadyCallback_WithClosures -> C_AsyncReadyCallback
Gio.Callbacks.wrap_AsyncReadyCallback (Ptr (FunPtr C_AsyncReadyCallback)
-> Maybe (Ptr (FunPtr C_AsyncReadyCallback))
forall a. a -> Maybe a
Just Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback) (AsyncReadyCallback -> AsyncReadyCallback_WithClosures
Gio.Callbacks.drop_closures_AsyncReadyCallback AsyncReadyCallback
jCallback))
Ptr (FunPtr C_AsyncReadyCallback)
-> FunPtr C_AsyncReadyCallback -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr C_AsyncReadyCallback)
ptrcallback FunPtr C_AsyncReadyCallback
jCallback'
FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
jCallback'
let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
Ptr OutputStream
-> Ptr OutputVector
-> Word64
-> Int32
-> Ptr Cancellable
-> FunPtr C_AsyncReadyCallback
-> Ptr ()
-> IO ()
g_output_stream_writev_async Ptr OutputStream
stream' Ptr OutputVector
vectors'' Word64
nVectors Int32
ioPriority Ptr Cancellable
maybeCancellable FunPtr C_AsyncReadyCallback
maybeCallback Ptr ()
forall a. Ptr a
userData
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
(OutputVector -> IO ()) -> [OutputVector] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ OutputVector -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [OutputVector]
vectors
Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
cancellable b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
Ptr OutputVector -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr OutputVector
vectors''
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data OutputStreamWritevAsyncMethodInfo
instance (signature ~ ([Gio.OutputVector.OutputVector] -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo OutputStreamWritevAsyncMethodInfo a signature where
overloadedMethod = outputStreamWritevAsync
#endif
foreign import ccall "g_output_stream_writev_finish" g_output_stream_writev_finish ::
Ptr OutputStream ->
Ptr Gio.AsyncResult.AsyncResult ->
Ptr Word64 ->
Ptr (Ptr GError) ->
IO CInt
outputStreamWritevFinish ::
(B.CallStack.HasCallStack, MonadIO m, IsOutputStream a, Gio.AsyncResult.IsAsyncResult b) =>
a
-> b
-> m (Word64)
outputStreamWritevFinish :: a -> b -> m Word64
outputStreamWritevFinish stream :: a
stream result_ :: b
result_ = IO Word64 -> m Word64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word64 -> m Word64) -> IO Word64 -> m Word64
forall a b. (a -> b) -> a -> b
$ do
Ptr OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
Ptr AsyncResult
result_' <- b -> IO (Ptr AsyncResult)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
result_
Ptr Word64
bytesWritten <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
IO Word64 -> IO () -> IO Word64
forall a b. IO a -> IO b -> IO a
onException (do
CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr OutputStream
-> Ptr AsyncResult -> Ptr Word64 -> Ptr (Ptr GError) -> IO CInt
g_output_stream_writev_finish Ptr OutputStream
stream' Ptr AsyncResult
result_' Ptr Word64
bytesWritten
Word64
bytesWritten' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
bytesWritten
a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr b
result_
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
bytesWritten
Word64 -> IO Word64
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
bytesWritten'
) (do
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
bytesWritten
)
#if defined(ENABLE_OVERLOADING)
data OutputStreamWritevFinishMethodInfo
instance (signature ~ (b -> m (Word64)), MonadIO m, IsOutputStream a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo OutputStreamWritevFinishMethodInfo a signature where
overloadedMethod = outputStreamWritevFinish
#endif