#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Gio.Interfaces.PollableOutputStream
(
PollableOutputStream(..) ,
noPollableOutputStream ,
IsPollableOutputStream ,
toPollableOutputStream ,
#if ENABLE_OVERLOADING
PollableOutputStreamCanPollMethodInfo ,
#endif
pollableOutputStreamCanPoll ,
#if ENABLE_OVERLOADING
PollableOutputStreamCreateSourceMethodInfo,
#endif
pollableOutputStreamCreateSource ,
#if ENABLE_OVERLOADING
PollableOutputStreamIsWritableMethodInfo,
#endif
pollableOutputStreamIsWritable ,
#if ENABLE_OVERLOADING
PollableOutputStreamWriteNonblockingMethodInfo,
#endif
pollableOutputStreamWriteNonblocking ,
#if ENABLE_OVERLOADING
PollableOutputStreamWritevNonblockingMethodInfo,
#endif
pollableOutputStreamWritevNonblocking ,
) 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.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.Source as GLib.Source
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Enums as Gio.Enums
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.OutputStream as Gio.OutputStream
import {-# SOURCE #-} qualified GI.Gio.Structs.OutputVector as Gio.OutputVector
newtype PollableOutputStream = PollableOutputStream (ManagedPtr PollableOutputStream)
noPollableOutputStream :: Maybe PollableOutputStream
noPollableOutputStream = Nothing
#if ENABLE_OVERLOADING
type instance O.SignalList PollableOutputStream = PollableOutputStreamSignalList
type PollableOutputStreamSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "g_pollable_output_stream_get_type"
c_g_pollable_output_stream_get_type :: IO GType
instance GObject PollableOutputStream where
gobjectType = c_g_pollable_output_stream_get_type
class (GObject o, O.IsDescendantOf PollableOutputStream o) => IsPollableOutputStream o
instance (GObject o, O.IsDescendantOf PollableOutputStream o) => IsPollableOutputStream o
instance O.HasParentTypes PollableOutputStream
type instance O.ParentTypes PollableOutputStream = '[Gio.OutputStream.OutputStream, GObject.Object.Object]
toPollableOutputStream :: (MonadIO m, IsPollableOutputStream o) => o -> m PollableOutputStream
toPollableOutputStream = liftIO . unsafeCastTo PollableOutputStream
#if ENABLE_OVERLOADING
instance O.HasAttributeList PollableOutputStream
type instance O.AttributeList PollableOutputStream = PollableOutputStreamAttributeList
type PollableOutputStreamAttributeList = ('[ ] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
#endif
#if ENABLE_OVERLOADING
type family ResolvePollableOutputStreamMethod (t :: Symbol) (o :: *) :: * where
ResolvePollableOutputStreamMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolvePollableOutputStreamMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolvePollableOutputStreamMethod "canPoll" o = PollableOutputStreamCanPollMethodInfo
ResolvePollableOutputStreamMethod "clearPending" o = Gio.OutputStream.OutputStreamClearPendingMethodInfo
ResolvePollableOutputStreamMethod "close" o = Gio.OutputStream.OutputStreamCloseMethodInfo
ResolvePollableOutputStreamMethod "closeAsync" o = Gio.OutputStream.OutputStreamCloseAsyncMethodInfo
ResolvePollableOutputStreamMethod "closeFinish" o = Gio.OutputStream.OutputStreamCloseFinishMethodInfo
ResolvePollableOutputStreamMethod "createSource" o = PollableOutputStreamCreateSourceMethodInfo
ResolvePollableOutputStreamMethod "flush" o = Gio.OutputStream.OutputStreamFlushMethodInfo
ResolvePollableOutputStreamMethod "flushAsync" o = Gio.OutputStream.OutputStreamFlushAsyncMethodInfo
ResolvePollableOutputStreamMethod "flushFinish" o = Gio.OutputStream.OutputStreamFlushFinishMethodInfo
ResolvePollableOutputStreamMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolvePollableOutputStreamMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolvePollableOutputStreamMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolvePollableOutputStreamMethod "hasPending" o = Gio.OutputStream.OutputStreamHasPendingMethodInfo
ResolvePollableOutputStreamMethod "isClosed" o = Gio.OutputStream.OutputStreamIsClosedMethodInfo
ResolvePollableOutputStreamMethod "isClosing" o = Gio.OutputStream.OutputStreamIsClosingMethodInfo
ResolvePollableOutputStreamMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolvePollableOutputStreamMethod "isWritable" o = PollableOutputStreamIsWritableMethodInfo
ResolvePollableOutputStreamMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolvePollableOutputStreamMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolvePollableOutputStreamMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolvePollableOutputStreamMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolvePollableOutputStreamMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolvePollableOutputStreamMethod "splice" o = Gio.OutputStream.OutputStreamSpliceMethodInfo
ResolvePollableOutputStreamMethod "spliceAsync" o = Gio.OutputStream.OutputStreamSpliceAsyncMethodInfo
ResolvePollableOutputStreamMethod "spliceFinish" o = Gio.OutputStream.OutputStreamSpliceFinishMethodInfo
ResolvePollableOutputStreamMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolvePollableOutputStreamMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolvePollableOutputStreamMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolvePollableOutputStreamMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolvePollableOutputStreamMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolvePollableOutputStreamMethod "write" o = Gio.OutputStream.OutputStreamWriteMethodInfo
ResolvePollableOutputStreamMethod "writeAll" o = Gio.OutputStream.OutputStreamWriteAllMethodInfo
ResolvePollableOutputStreamMethod "writeAllAsync" o = Gio.OutputStream.OutputStreamWriteAllAsyncMethodInfo
ResolvePollableOutputStreamMethod "writeAllFinish" o = Gio.OutputStream.OutputStreamWriteAllFinishMethodInfo
ResolvePollableOutputStreamMethod "writeAsync" o = Gio.OutputStream.OutputStreamWriteAsyncMethodInfo
ResolvePollableOutputStreamMethod "writeBytes" o = Gio.OutputStream.OutputStreamWriteBytesMethodInfo
ResolvePollableOutputStreamMethod "writeBytesAsync" o = Gio.OutputStream.OutputStreamWriteBytesAsyncMethodInfo
ResolvePollableOutputStreamMethod "writeBytesFinish" o = Gio.OutputStream.OutputStreamWriteBytesFinishMethodInfo
ResolvePollableOutputStreamMethod "writeFinish" o = Gio.OutputStream.OutputStreamWriteFinishMethodInfo
ResolvePollableOutputStreamMethod "writeNonblocking" o = PollableOutputStreamWriteNonblockingMethodInfo
ResolvePollableOutputStreamMethod "writev" o = Gio.OutputStream.OutputStreamWritevMethodInfo
ResolvePollableOutputStreamMethod "writevAll" o = Gio.OutputStream.OutputStreamWritevAllMethodInfo
ResolvePollableOutputStreamMethod "writevAllAsync" o = Gio.OutputStream.OutputStreamWritevAllAsyncMethodInfo
ResolvePollableOutputStreamMethod "writevAllFinish" o = Gio.OutputStream.OutputStreamWritevAllFinishMethodInfo
ResolvePollableOutputStreamMethod "writevAsync" o = Gio.OutputStream.OutputStreamWritevAsyncMethodInfo
ResolvePollableOutputStreamMethod "writevFinish" o = Gio.OutputStream.OutputStreamWritevFinishMethodInfo
ResolvePollableOutputStreamMethod "writevNonblocking" o = PollableOutputStreamWritevNonblockingMethodInfo
ResolvePollableOutputStreamMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolvePollableOutputStreamMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolvePollableOutputStreamMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolvePollableOutputStreamMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolvePollableOutputStreamMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolvePollableOutputStreamMethod "setPending" o = Gio.OutputStream.OutputStreamSetPendingMethodInfo
ResolvePollableOutputStreamMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolvePollableOutputStreamMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolvePollableOutputStreamMethod t PollableOutputStream, O.MethodInfo info PollableOutputStream p) => OL.IsLabel t (PollableOutputStream -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif
foreign import ccall "g_pollable_output_stream_can_poll" g_pollable_output_stream_can_poll ::
Ptr PollableOutputStream ->
IO CInt
pollableOutputStreamCanPoll ::
(B.CallStack.HasCallStack, MonadIO m, IsPollableOutputStream a) =>
a
-> m Bool
pollableOutputStreamCanPoll stream = liftIO $ do
stream' <- unsafeManagedPtrCastPtr stream
result <- g_pollable_output_stream_can_poll stream'
let result' = (/= 0) result
touchManagedPtr stream
return result'
#if ENABLE_OVERLOADING
data PollableOutputStreamCanPollMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsPollableOutputStream a) => O.MethodInfo PollableOutputStreamCanPollMethodInfo a signature where
overloadedMethod _ = pollableOutputStreamCanPoll
#endif
foreign import ccall "g_pollable_output_stream_create_source" g_pollable_output_stream_create_source ::
Ptr PollableOutputStream ->
Ptr Gio.Cancellable.Cancellable ->
IO (Ptr GLib.Source.Source)
pollableOutputStreamCreateSource ::
(B.CallStack.HasCallStack, MonadIO m, IsPollableOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> Maybe (b)
-> m GLib.Source.Source
pollableOutputStreamCreateSource stream cancellable = liftIO $ do
stream' <- unsafeManagedPtrCastPtr stream
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
result <- g_pollable_output_stream_create_source stream' maybeCancellable
checkUnexpectedReturnNULL "pollableOutputStreamCreateSource" result
result' <- (wrapBoxed GLib.Source.Source) result
touchManagedPtr stream
whenJust cancellable touchManagedPtr
return result'
#if ENABLE_OVERLOADING
data PollableOutputStreamCreateSourceMethodInfo
instance (signature ~ (Maybe (b) -> m GLib.Source.Source), MonadIO m, IsPollableOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo PollableOutputStreamCreateSourceMethodInfo a signature where
overloadedMethod _ = pollableOutputStreamCreateSource
#endif
foreign import ccall "g_pollable_output_stream_is_writable" g_pollable_output_stream_is_writable ::
Ptr PollableOutputStream ->
IO CInt
pollableOutputStreamIsWritable ::
(B.CallStack.HasCallStack, MonadIO m, IsPollableOutputStream a) =>
a
-> m Bool
pollableOutputStreamIsWritable stream = liftIO $ do
stream' <- unsafeManagedPtrCastPtr stream
result <- g_pollable_output_stream_is_writable stream'
let result' = (/= 0) result
touchManagedPtr stream
return result'
#if ENABLE_OVERLOADING
data PollableOutputStreamIsWritableMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsPollableOutputStream a) => O.MethodInfo PollableOutputStreamIsWritableMethodInfo a signature where
overloadedMethod _ = pollableOutputStreamIsWritable
#endif
foreign import ccall "g_pollable_output_stream_write_nonblocking" g_pollable_output_stream_write_nonblocking ::
Ptr PollableOutputStream ->
Ptr Word8 ->
Word64 ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO Int64
pollableOutputStreamWriteNonblocking ::
(B.CallStack.HasCallStack, MonadIO m, IsPollableOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> Maybe (ByteString)
-> Maybe (b)
-> m Int64
pollableOutputStreamWriteNonblocking stream buffer cancellable = liftIO $ do
let count = case buffer of
Nothing -> 0
Just jBuffer -> fromIntegral $ B.length jBuffer
stream' <- unsafeManagedPtrCastPtr stream
maybeBuffer <- case buffer of
Nothing -> return nullPtr
Just jBuffer -> do
jBuffer' <- packByteString jBuffer
return jBuffer'
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
onException (do
result <- propagateGError $ g_pollable_output_stream_write_nonblocking stream' maybeBuffer count maybeCancellable
touchManagedPtr stream
whenJust cancellable touchManagedPtr
freeMem maybeBuffer
return result
) (do
freeMem maybeBuffer
)
#if ENABLE_OVERLOADING
data PollableOutputStreamWriteNonblockingMethodInfo
instance (signature ~ (Maybe (ByteString) -> Maybe (b) -> m Int64), MonadIO m, IsPollableOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo PollableOutputStreamWriteNonblockingMethodInfo a signature where
overloadedMethod _ = pollableOutputStreamWriteNonblocking
#endif
foreign import ccall "g_pollable_output_stream_writev_nonblocking" g_pollable_output_stream_writev_nonblocking ::
Ptr PollableOutputStream ->
Ptr Gio.OutputVector.OutputVector ->
Word64 ->
Ptr Word64 ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO CInt
pollableOutputStreamWritevNonblocking ::
(B.CallStack.HasCallStack, MonadIO m, IsPollableOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> [Gio.OutputVector.OutputVector]
-> Maybe (b)
-> m ((Gio.Enums.PollableReturn, Word64))
pollableOutputStreamWritevNonblocking stream vectors cancellable = liftIO $ do
let nVectors = fromIntegral $ length vectors
stream' <- unsafeManagedPtrCastPtr stream
vectors' <- mapM unsafeManagedPtrGetPtr vectors
vectors'' <- packBlockArray 16 vectors'
bytesWritten <- allocMem :: IO (Ptr Word64)
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
onException (do
result <- propagateGError $ g_pollable_output_stream_writev_nonblocking stream' vectors'' nVectors bytesWritten maybeCancellable
let result' = (toEnum . fromIntegral) result
bytesWritten' <- peek bytesWritten
touchManagedPtr stream
mapM_ touchManagedPtr vectors
whenJust cancellable touchManagedPtr
freeMem vectors''
freeMem bytesWritten
return (result', bytesWritten')
) (do
freeMem vectors''
freeMem bytesWritten
)
#if ENABLE_OVERLOADING
data PollableOutputStreamWritevNonblockingMethodInfo
instance (signature ~ ([Gio.OutputVector.OutputVector] -> Maybe (b) -> m ((Gio.Enums.PollableReturn, Word64))), MonadIO m, IsPollableOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo PollableOutputStreamWritevNonblockingMethodInfo a signature where
overloadedMethod _ = pollableOutputStreamWritevNonblocking
#endif