#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Gio.Interfaces.PollableInputStream
(
PollableInputStream(..) ,
noPollableInputStream ,
IsPollableInputStream ,
toPollableInputStream ,
#if ENABLE_OVERLOADING
PollableInputStreamCanPollMethodInfo ,
#endif
pollableInputStreamCanPoll ,
#if ENABLE_OVERLOADING
PollableInputStreamCreateSourceMethodInfo,
#endif
pollableInputStreamCreateSource ,
#if ENABLE_OVERLOADING
PollableInputStreamIsReadableMethodInfo ,
#endif
pollableInputStreamIsReadable ,
#if ENABLE_OVERLOADING
PollableInputStreamReadNonblockingMethodInfo,
#endif
pollableInputStreamReadNonblocking ,
) 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.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.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GI.GLib.Structs.Source as GLib.Source
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.InputStream as Gio.InputStream
newtype PollableInputStream = PollableInputStream (ManagedPtr PollableInputStream)
noPollableInputStream :: Maybe PollableInputStream
noPollableInputStream = Nothing
#if ENABLE_OVERLOADING
type instance O.SignalList PollableInputStream = PollableInputStreamSignalList
type PollableInputStreamSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "g_pollable_input_stream_get_type"
c_g_pollable_input_stream_get_type :: IO GType
instance GObject PollableInputStream where
gobjectType _ = c_g_pollable_input_stream_get_type
class GObject o => IsPollableInputStream o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError PollableInputStream a) =>
IsPollableInputStream a
#endif
instance IsPollableInputStream PollableInputStream
instance Gio.InputStream.IsInputStream PollableInputStream
instance GObject.Object.IsObject PollableInputStream
toPollableInputStream :: (MonadIO m, IsPollableInputStream o) => o -> m PollableInputStream
toPollableInputStream = liftIO . unsafeCastTo PollableInputStream
#if ENABLE_OVERLOADING
instance O.HasAttributeList PollableInputStream
type instance O.AttributeList PollableInputStream = PollableInputStreamAttributeList
type PollableInputStreamAttributeList = ('[ ] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
#endif
#if ENABLE_OVERLOADING
type family ResolvePollableInputStreamMethod (t :: Symbol) (o :: *) :: * where
ResolvePollableInputStreamMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolvePollableInputStreamMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolvePollableInputStreamMethod "canPoll" o = PollableInputStreamCanPollMethodInfo
ResolvePollableInputStreamMethod "clearPending" o = Gio.InputStream.InputStreamClearPendingMethodInfo
ResolvePollableInputStreamMethod "close" o = Gio.InputStream.InputStreamCloseMethodInfo
ResolvePollableInputStreamMethod "closeAsync" o = Gio.InputStream.InputStreamCloseAsyncMethodInfo
ResolvePollableInputStreamMethod "closeFinish" o = Gio.InputStream.InputStreamCloseFinishMethodInfo
ResolvePollableInputStreamMethod "createSource" o = PollableInputStreamCreateSourceMethodInfo
ResolvePollableInputStreamMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolvePollableInputStreamMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolvePollableInputStreamMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolvePollableInputStreamMethod "hasPending" o = Gio.InputStream.InputStreamHasPendingMethodInfo
ResolvePollableInputStreamMethod "isClosed" o = Gio.InputStream.InputStreamIsClosedMethodInfo
ResolvePollableInputStreamMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolvePollableInputStreamMethod "isReadable" o = PollableInputStreamIsReadableMethodInfo
ResolvePollableInputStreamMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolvePollableInputStreamMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolvePollableInputStreamMethod "read" o = Gio.InputStream.InputStreamReadMethodInfo
ResolvePollableInputStreamMethod "readAll" o = Gio.InputStream.InputStreamReadAllMethodInfo
ResolvePollableInputStreamMethod "readAllAsync" o = Gio.InputStream.InputStreamReadAllAsyncMethodInfo
ResolvePollableInputStreamMethod "readAllFinish" o = Gio.InputStream.InputStreamReadAllFinishMethodInfo
ResolvePollableInputStreamMethod "readAsync" o = Gio.InputStream.InputStreamReadAsyncMethodInfo
ResolvePollableInputStreamMethod "readBytes" o = Gio.InputStream.InputStreamReadBytesMethodInfo
ResolvePollableInputStreamMethod "readBytesAsync" o = Gio.InputStream.InputStreamReadBytesAsyncMethodInfo
ResolvePollableInputStreamMethod "readBytesFinish" o = Gio.InputStream.InputStreamReadBytesFinishMethodInfo
ResolvePollableInputStreamMethod "readFinish" o = Gio.InputStream.InputStreamReadFinishMethodInfo
ResolvePollableInputStreamMethod "readNonblocking" o = PollableInputStreamReadNonblockingMethodInfo
ResolvePollableInputStreamMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolvePollableInputStreamMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolvePollableInputStreamMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolvePollableInputStreamMethod "skip" o = Gio.InputStream.InputStreamSkipMethodInfo
ResolvePollableInputStreamMethod "skipAsync" o = Gio.InputStream.InputStreamSkipAsyncMethodInfo
ResolvePollableInputStreamMethod "skipFinish" o = Gio.InputStream.InputStreamSkipFinishMethodInfo
ResolvePollableInputStreamMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolvePollableInputStreamMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolvePollableInputStreamMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolvePollableInputStreamMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolvePollableInputStreamMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolvePollableInputStreamMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolvePollableInputStreamMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolvePollableInputStreamMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolvePollableInputStreamMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolvePollableInputStreamMethod "setPending" o = Gio.InputStream.InputStreamSetPendingMethodInfo
ResolvePollableInputStreamMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolvePollableInputStreamMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolvePollableInputStreamMethod t PollableInputStream, O.MethodInfo info PollableInputStream p) => O.IsLabelProxy t (PollableInputStream -> p) where
fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolvePollableInputStreamMethod t PollableInputStream, O.MethodInfo info PollableInputStream p) => O.IsLabel t (PollableInputStream -> 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
#endif
foreign import ccall "g_pollable_input_stream_can_poll" g_pollable_input_stream_can_poll ::
Ptr PollableInputStream ->
IO CInt
pollableInputStreamCanPoll ::
(B.CallStack.HasCallStack, MonadIO m, IsPollableInputStream a) =>
a
-> m Bool
pollableInputStreamCanPoll stream = liftIO $ do
stream' <- unsafeManagedPtrCastPtr stream
result <- g_pollable_input_stream_can_poll stream'
let result' = (/= 0) result
touchManagedPtr stream
return result'
#if ENABLE_OVERLOADING
data PollableInputStreamCanPollMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsPollableInputStream a) => O.MethodInfo PollableInputStreamCanPollMethodInfo a signature where
overloadedMethod _ = pollableInputStreamCanPoll
#endif
foreign import ccall "g_pollable_input_stream_create_source" g_pollable_input_stream_create_source ::
Ptr PollableInputStream ->
Ptr Gio.Cancellable.Cancellable ->
IO (Ptr GLib.Source.Source)
pollableInputStreamCreateSource ::
(B.CallStack.HasCallStack, MonadIO m, IsPollableInputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> Maybe (b)
-> m GLib.Source.Source
pollableInputStreamCreateSource 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_input_stream_create_source stream' maybeCancellable
checkUnexpectedReturnNULL "pollableInputStreamCreateSource" result
result' <- (wrapBoxed GLib.Source.Source) result
touchManagedPtr stream
whenJust cancellable touchManagedPtr
return result'
#if ENABLE_OVERLOADING
data PollableInputStreamCreateSourceMethodInfo
instance (signature ~ (Maybe (b) -> m GLib.Source.Source), MonadIO m, IsPollableInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo PollableInputStreamCreateSourceMethodInfo a signature where
overloadedMethod _ = pollableInputStreamCreateSource
#endif
foreign import ccall "g_pollable_input_stream_is_readable" g_pollable_input_stream_is_readable ::
Ptr PollableInputStream ->
IO CInt
pollableInputStreamIsReadable ::
(B.CallStack.HasCallStack, MonadIO m, IsPollableInputStream a) =>
a
-> m Bool
pollableInputStreamIsReadable stream = liftIO $ do
stream' <- unsafeManagedPtrCastPtr stream
result <- g_pollable_input_stream_is_readable stream'
let result' = (/= 0) result
touchManagedPtr stream
return result'
#if ENABLE_OVERLOADING
data PollableInputStreamIsReadableMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsPollableInputStream a) => O.MethodInfo PollableInputStreamIsReadableMethodInfo a signature where
overloadedMethod _ = pollableInputStreamIsReadable
#endif
foreign import ccall "g_pollable_input_stream_read_nonblocking" g_pollable_input_stream_read_nonblocking ::
Ptr PollableInputStream ->
Ptr Word8 ->
Word64 ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO Int64
pollableInputStreamReadNonblocking ::
(B.CallStack.HasCallStack, MonadIO m, IsPollableInputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> Maybe (ByteString)
-> Maybe (b)
-> m Int64
pollableInputStreamReadNonblocking 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_input_stream_read_nonblocking stream' maybeBuffer count maybeCancellable
touchManagedPtr stream
whenJust cancellable touchManagedPtr
freeMem maybeBuffer
return result
) (do
freeMem maybeBuffer
)
#if ENABLE_OVERLOADING
data PollableInputStreamReadNonblockingMethodInfo
instance (signature ~ (Maybe (ByteString) -> Maybe (b) -> m Int64), MonadIO m, IsPollableInputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo PollableInputStreamReadNonblockingMethodInfo a signature where
overloadedMethod _ = pollableInputStreamReadNonblocking
#endif