#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Gio.Objects.MemoryInputStream
(
MemoryInputStream(..) ,
IsMemoryInputStream ,
toMemoryInputStream ,
noMemoryInputStream ,
#if ENABLE_OVERLOADING
MemoryInputStreamAddBytesMethodInfo ,
#endif
memoryInputStreamAddBytes ,
#if ENABLE_OVERLOADING
MemoryInputStreamAddDataMethodInfo ,
#endif
memoryInputStreamAddData ,
memoryInputStreamNew ,
memoryInputStreamNewFromBytes ,
memoryInputStreamNewFromData ,
) 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.Callbacks as GLib.Callbacks
import qualified GI.GLib.Structs.Bytes as GLib.Bytes
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Interfaces.PollableInputStream as Gio.PollableInputStream
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Seekable as Gio.Seekable
import {-# SOURCE #-} qualified GI.Gio.Objects.InputStream as Gio.InputStream
newtype MemoryInputStream = MemoryInputStream (ManagedPtr MemoryInputStream)
foreign import ccall "g_memory_input_stream_get_type"
c_g_memory_input_stream_get_type :: IO GType
instance GObject MemoryInputStream where
gobjectType = c_g_memory_input_stream_get_type
class (GObject o, O.IsDescendantOf MemoryInputStream o) => IsMemoryInputStream o
instance (GObject o, O.IsDescendantOf MemoryInputStream o) => IsMemoryInputStream o
instance O.HasParentTypes MemoryInputStream
type instance O.ParentTypes MemoryInputStream = '[Gio.InputStream.InputStream, GObject.Object.Object, Gio.PollableInputStream.PollableInputStream, Gio.Seekable.Seekable]
toMemoryInputStream :: (MonadIO m, IsMemoryInputStream o) => o -> m MemoryInputStream
toMemoryInputStream = liftIO . unsafeCastTo MemoryInputStream
noMemoryInputStream :: Maybe MemoryInputStream
noMemoryInputStream = Nothing
#if ENABLE_OVERLOADING
type family ResolveMemoryInputStreamMethod (t :: Symbol) (o :: *) :: * where
ResolveMemoryInputStreamMethod "addBytes" o = MemoryInputStreamAddBytesMethodInfo
ResolveMemoryInputStreamMethod "addData" o = MemoryInputStreamAddDataMethodInfo
ResolveMemoryInputStreamMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveMemoryInputStreamMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveMemoryInputStreamMethod "canPoll" o = Gio.PollableInputStream.PollableInputStreamCanPollMethodInfo
ResolveMemoryInputStreamMethod "canSeek" o = Gio.Seekable.SeekableCanSeekMethodInfo
ResolveMemoryInputStreamMethod "canTruncate" o = Gio.Seekable.SeekableCanTruncateMethodInfo
ResolveMemoryInputStreamMethod "clearPending" o = Gio.InputStream.InputStreamClearPendingMethodInfo
ResolveMemoryInputStreamMethod "close" o = Gio.InputStream.InputStreamCloseMethodInfo
ResolveMemoryInputStreamMethod "closeAsync" o = Gio.InputStream.InputStreamCloseAsyncMethodInfo
ResolveMemoryInputStreamMethod "closeFinish" o = Gio.InputStream.InputStreamCloseFinishMethodInfo
ResolveMemoryInputStreamMethod "createSource" o = Gio.PollableInputStream.PollableInputStreamCreateSourceMethodInfo
ResolveMemoryInputStreamMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveMemoryInputStreamMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveMemoryInputStreamMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveMemoryInputStreamMethod "hasPending" o = Gio.InputStream.InputStreamHasPendingMethodInfo
ResolveMemoryInputStreamMethod "isClosed" o = Gio.InputStream.InputStreamIsClosedMethodInfo
ResolveMemoryInputStreamMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveMemoryInputStreamMethod "isReadable" o = Gio.PollableInputStream.PollableInputStreamIsReadableMethodInfo
ResolveMemoryInputStreamMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveMemoryInputStreamMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveMemoryInputStreamMethod "read" o = Gio.InputStream.InputStreamReadMethodInfo
ResolveMemoryInputStreamMethod "readAll" o = Gio.InputStream.InputStreamReadAllMethodInfo
ResolveMemoryInputStreamMethod "readAllAsync" o = Gio.InputStream.InputStreamReadAllAsyncMethodInfo
ResolveMemoryInputStreamMethod "readAllFinish" o = Gio.InputStream.InputStreamReadAllFinishMethodInfo
ResolveMemoryInputStreamMethod "readAsync" o = Gio.InputStream.InputStreamReadAsyncMethodInfo
ResolveMemoryInputStreamMethod "readBytes" o = Gio.InputStream.InputStreamReadBytesMethodInfo
ResolveMemoryInputStreamMethod "readBytesAsync" o = Gio.InputStream.InputStreamReadBytesAsyncMethodInfo
ResolveMemoryInputStreamMethod "readBytesFinish" o = Gio.InputStream.InputStreamReadBytesFinishMethodInfo
ResolveMemoryInputStreamMethod "readFinish" o = Gio.InputStream.InputStreamReadFinishMethodInfo
ResolveMemoryInputStreamMethod "readNonblocking" o = Gio.PollableInputStream.PollableInputStreamReadNonblockingMethodInfo
ResolveMemoryInputStreamMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveMemoryInputStreamMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveMemoryInputStreamMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveMemoryInputStreamMethod "seek" o = Gio.Seekable.SeekableSeekMethodInfo
ResolveMemoryInputStreamMethod "skip" o = Gio.InputStream.InputStreamSkipMethodInfo
ResolveMemoryInputStreamMethod "skipAsync" o = Gio.InputStream.InputStreamSkipAsyncMethodInfo
ResolveMemoryInputStreamMethod "skipFinish" o = Gio.InputStream.InputStreamSkipFinishMethodInfo
ResolveMemoryInputStreamMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveMemoryInputStreamMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveMemoryInputStreamMethod "tell" o = Gio.Seekable.SeekableTellMethodInfo
ResolveMemoryInputStreamMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveMemoryInputStreamMethod "truncate" o = Gio.Seekable.SeekableTruncateMethodInfo
ResolveMemoryInputStreamMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveMemoryInputStreamMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveMemoryInputStreamMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveMemoryInputStreamMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveMemoryInputStreamMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveMemoryInputStreamMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveMemoryInputStreamMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveMemoryInputStreamMethod "setPending" o = Gio.InputStream.InputStreamSetPendingMethodInfo
ResolveMemoryInputStreamMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveMemoryInputStreamMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveMemoryInputStreamMethod t MemoryInputStream, O.MethodInfo info MemoryInputStream p) => OL.IsLabel t (MemoryInputStream -> 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
#if ENABLE_OVERLOADING
instance O.HasAttributeList MemoryInputStream
type instance O.AttributeList MemoryInputStream = MemoryInputStreamAttributeList
type MemoryInputStreamAttributeList = ('[ ] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
#endif
#if ENABLE_OVERLOADING
type instance O.SignalList MemoryInputStream = MemoryInputStreamSignalList
type MemoryInputStreamSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "g_memory_input_stream_new" g_memory_input_stream_new ::
IO (Ptr MemoryInputStream)
memoryInputStreamNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
m MemoryInputStream
memoryInputStreamNew = liftIO $ do
result <- g_memory_input_stream_new
checkUnexpectedReturnNULL "memoryInputStreamNew" result
result' <- (wrapObject MemoryInputStream) result
return result'
#if ENABLE_OVERLOADING
#endif
foreign import ccall "g_memory_input_stream_new_from_bytes" g_memory_input_stream_new_from_bytes ::
Ptr GLib.Bytes.Bytes ->
IO (Ptr MemoryInputStream)
memoryInputStreamNewFromBytes ::
(B.CallStack.HasCallStack, MonadIO m) =>
GLib.Bytes.Bytes
-> m MemoryInputStream
memoryInputStreamNewFromBytes bytes = liftIO $ do
bytes' <- unsafeManagedPtrGetPtr bytes
result <- g_memory_input_stream_new_from_bytes bytes'
checkUnexpectedReturnNULL "memoryInputStreamNewFromBytes" result
result' <- (wrapObject MemoryInputStream) result
touchManagedPtr bytes
return result'
#if ENABLE_OVERLOADING
#endif
foreign import ccall "g_memory_input_stream_new_from_data" g_memory_input_stream_new_from_data ::
Ptr Word8 ->
Int64 ->
FunPtr GLib.Callbacks.C_DestroyNotify ->
IO (Ptr MemoryInputStream)
memoryInputStreamNewFromData ::
(B.CallStack.HasCallStack, MonadIO m) =>
ByteString
-> Maybe (GLib.Callbacks.DestroyNotify)
-> m MemoryInputStream
memoryInputStreamNewFromData data_ destroy = liftIO $ do
let len = fromIntegral $ B.length data_
data_' <- packByteString data_
maybeDestroy <- case destroy of
Nothing -> return (castPtrToFunPtr nullPtr)
Just jDestroy -> do
ptrdestroy <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_DestroyNotify))
jDestroy' <- GLib.Callbacks.mk_DestroyNotify (GLib.Callbacks.wrap_DestroyNotify (Just ptrdestroy) jDestroy)
poke ptrdestroy jDestroy'
return jDestroy'
result <- g_memory_input_stream_new_from_data data_' len maybeDestroy
checkUnexpectedReturnNULL "memoryInputStreamNewFromData" result
result' <- (wrapObject MemoryInputStream) result
return result'
#if ENABLE_OVERLOADING
#endif
foreign import ccall "g_memory_input_stream_add_bytes" g_memory_input_stream_add_bytes ::
Ptr MemoryInputStream ->
Ptr GLib.Bytes.Bytes ->
IO ()
memoryInputStreamAddBytes ::
(B.CallStack.HasCallStack, MonadIO m, IsMemoryInputStream a) =>
a
-> GLib.Bytes.Bytes
-> m ()
memoryInputStreamAddBytes stream bytes = liftIO $ do
stream' <- unsafeManagedPtrCastPtr stream
bytes' <- unsafeManagedPtrGetPtr bytes
g_memory_input_stream_add_bytes stream' bytes'
touchManagedPtr stream
touchManagedPtr bytes
return ()
#if ENABLE_OVERLOADING
data MemoryInputStreamAddBytesMethodInfo
instance (signature ~ (GLib.Bytes.Bytes -> m ()), MonadIO m, IsMemoryInputStream a) => O.MethodInfo MemoryInputStreamAddBytesMethodInfo a signature where
overloadedMethod _ = memoryInputStreamAddBytes
#endif
foreign import ccall "g_memory_input_stream_add_data" g_memory_input_stream_add_data ::
Ptr MemoryInputStream ->
Ptr Word8 ->
Int64 ->
FunPtr GLib.Callbacks.C_DestroyNotify ->
IO ()
memoryInputStreamAddData ::
(B.CallStack.HasCallStack, MonadIO m, IsMemoryInputStream a) =>
a
-> ByteString
-> Maybe (GLib.Callbacks.DestroyNotify)
-> m ()
memoryInputStreamAddData stream data_ destroy = liftIO $ do
let len = fromIntegral $ B.length data_
stream' <- unsafeManagedPtrCastPtr stream
data_' <- packByteString data_
maybeDestroy <- case destroy of
Nothing -> return (castPtrToFunPtr nullPtr)
Just jDestroy -> do
ptrdestroy <- callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_DestroyNotify))
jDestroy' <- GLib.Callbacks.mk_DestroyNotify (GLib.Callbacks.wrap_DestroyNotify (Just ptrdestroy) jDestroy)
poke ptrdestroy jDestroy'
return jDestroy'
g_memory_input_stream_add_data stream' data_' len maybeDestroy
touchManagedPtr stream
return ()
#if ENABLE_OVERLOADING
data MemoryInputStreamAddDataMethodInfo
instance (signature ~ (ByteString -> Maybe (GLib.Callbacks.DestroyNotify) -> m ()), MonadIO m, IsMemoryInputStream a) => O.MethodInfo MemoryInputStreamAddDataMethodInfo a signature where
overloadedMethod _ = memoryInputStreamAddData
#endif