gi-gio-0.2.44.12: GI/Gio/Objects/MemoryInputStream.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}
module GI.Gio.Objects.MemoryInputStream
(
-- * Exported types
MemoryInputStream(..) ,
MemoryInputStreamK ,
toMemoryInputStream ,
noMemoryInputStream ,
-- * Methods
-- ** memoryInputStreamAddBytes
memoryInputStreamAddBytes ,
-- ** memoryInputStreamAddData
memoryInputStreamAddData ,
-- ** memoryInputStreamNew
memoryInputStreamNew ,
-- ** memoryInputStreamNewFromBytes
memoryInputStreamNewFromBytes ,
-- ** memoryInputStreamNewFromData
memoryInputStreamNewFromData ,
) where
import Prelude ()
import Data.GI.Base.ShortPrelude
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import GI.Gio.Types
import GI.Gio.Callbacks
import qualified GI.GLib as GLib
import qualified GI.GObject as GObject
newtype MemoryInputStream = MemoryInputStream (ForeignPtr MemoryInputStream)
foreign import ccall "g_memory_input_stream_get_type"
c_g_memory_input_stream_get_type :: IO GType
type instance ParentTypes MemoryInputStream = MemoryInputStreamParentTypes
type MemoryInputStreamParentTypes = '[InputStream, GObject.Object, PollableInputStream, Seekable]
instance GObject MemoryInputStream where
gobjectIsInitiallyUnowned _ = False
gobjectType _ = c_g_memory_input_stream_get_type
class GObject o => MemoryInputStreamK o
instance (GObject o, IsDescendantOf MemoryInputStream o) => MemoryInputStreamK o
toMemoryInputStream :: MemoryInputStreamK o => o -> IO MemoryInputStream
toMemoryInputStream = unsafeCastTo MemoryInputStream
noMemoryInputStream :: Maybe MemoryInputStream
noMemoryInputStream = Nothing
type instance AttributeList MemoryInputStream = MemoryInputStreamAttributeList
type MemoryInputStreamAttributeList = ('[ ] :: [(Symbol, *)])
type instance SignalList MemoryInputStream = MemoryInputStreamSignalList
type MemoryInputStreamSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])
-- method MemoryInputStream::new
-- method type : Constructor
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TInterface "Gio" "MemoryInputStream"
-- throws : False
-- Skip return : False
foreign import ccall "g_memory_input_stream_new" g_memory_input_stream_new ::
IO (Ptr MemoryInputStream)
memoryInputStreamNew ::
(MonadIO m) =>
m MemoryInputStream
memoryInputStreamNew = liftIO $ do
result <- g_memory_input_stream_new
checkUnexpectedReturnNULL "g_memory_input_stream_new" result
result' <- (wrapObject MemoryInputStream) result
return result'
-- method MemoryInputStream::new_from_bytes
-- method type : Constructor
-- Args : [Arg {argName = "bytes", argType = TInterface "GLib" "Bytes", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "bytes", argType = TInterface "GLib" "Bytes", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "MemoryInputStream"
-- throws : False
-- Skip return : False
foreign import ccall "g_memory_input_stream_new_from_bytes" g_memory_input_stream_new_from_bytes ::
Ptr GLib.Bytes -> -- bytes : TInterface "GLib" "Bytes"
IO (Ptr MemoryInputStream)
memoryInputStreamNewFromBytes ::
(MonadIO m) =>
GLib.Bytes -> -- bytes
m MemoryInputStream
memoryInputStreamNewFromBytes bytes = liftIO $ do
let bytes' = unsafeManagedPtrGetPtr bytes
result <- g_memory_input_stream_new_from_bytes bytes'
checkUnexpectedReturnNULL "g_memory_input_stream_new_from_bytes" result
result' <- (wrapObject MemoryInputStream) result
touchManagedPtr bytes
return result'
-- method MemoryInputStream::new_from_data
-- method type : Constructor
-- Args : [Arg {argName = "data", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "destroy", argType = TInterface "GLib" "DestroyNotify", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : [Arg {argName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- hInArgs : [Arg {argName = "data", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "destroy", argType = TInterface "GLib" "DestroyNotify", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "MemoryInputStream"
-- throws : False
-- Skip return : False
foreign import ccall "g_memory_input_stream_new_from_data" g_memory_input_stream_new_from_data ::
Ptr Word8 -> -- data : TCArray False (-1) 1 (TBasicType TUInt8)
Int64 -> -- len : TBasicType TInt64
FunPtr GLib.DestroyNotifyC -> -- destroy : TInterface "GLib" "DestroyNotify"
IO (Ptr MemoryInputStream)
memoryInputStreamNewFromData ::
(MonadIO m) =>
ByteString -> -- data
Maybe (GLib.DestroyNotify) -> -- destroy
m MemoryInputStream
memoryInputStreamNewFromData data_ destroy = liftIO $ do
let len = fromIntegral $ B.length data_
data_' <- packByteString data_
ptrdestroy <- callocMem :: IO (Ptr (FunPtr GLib.DestroyNotifyC))
maybeDestroy <- case destroy of
Nothing -> return (castPtrToFunPtr nullPtr)
Just jDestroy -> do
jDestroy' <- GLib.mkDestroyNotify (GLib.destroyNotifyWrapper (Just ptrdestroy) jDestroy)
poke ptrdestroy jDestroy'
return jDestroy'
result <- g_memory_input_stream_new_from_data data_' len maybeDestroy
checkUnexpectedReturnNULL "g_memory_input_stream_new_from_data" result
result' <- (wrapObject MemoryInputStream) result
return result'
-- method MemoryInputStream::add_bytes
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "MemoryInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "bytes", argType = TInterface "GLib" "Bytes", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "MemoryInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "bytes", argType = TInterface "GLib" "Bytes", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_memory_input_stream_add_bytes" g_memory_input_stream_add_bytes ::
Ptr MemoryInputStream -> -- _obj : TInterface "Gio" "MemoryInputStream"
Ptr GLib.Bytes -> -- bytes : TInterface "GLib" "Bytes"
IO ()
memoryInputStreamAddBytes ::
(MonadIO m, MemoryInputStreamK a) =>
a -> -- _obj
GLib.Bytes -> -- bytes
m ()
memoryInputStreamAddBytes _obj bytes = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
let bytes' = unsafeManagedPtrGetPtr bytes
g_memory_input_stream_add_bytes _obj' bytes'
touchManagedPtr _obj
touchManagedPtr bytes
return ()
-- method MemoryInputStream::add_data
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "MemoryInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "data", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "destroy", argType = TInterface "GLib" "DestroyNotify", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : [Arg {argName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "MemoryInputStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "data", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "destroy", argType = TInterface "GLib" "DestroyNotify", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_memory_input_stream_add_data" g_memory_input_stream_add_data ::
Ptr MemoryInputStream -> -- _obj : TInterface "Gio" "MemoryInputStream"
Ptr Word8 -> -- data : TCArray False (-1) 2 (TBasicType TUInt8)
Int64 -> -- len : TBasicType TInt64
FunPtr GLib.DestroyNotifyC -> -- destroy : TInterface "GLib" "DestroyNotify"
IO ()
memoryInputStreamAddData ::
(MonadIO m, MemoryInputStreamK a) =>
a -> -- _obj
ByteString -> -- data
Maybe (GLib.DestroyNotify) -> -- destroy
m ()
memoryInputStreamAddData _obj data_ destroy = liftIO $ do
let len = fromIntegral $ B.length data_
let _obj' = unsafeManagedPtrCastPtr _obj
data_' <- packByteString data_
ptrdestroy <- callocMem :: IO (Ptr (FunPtr GLib.DestroyNotifyC))
maybeDestroy <- case destroy of
Nothing -> return (castPtrToFunPtr nullPtr)
Just jDestroy -> do
jDestroy' <- GLib.mkDestroyNotify (GLib.destroyNotifyWrapper (Just ptrdestroy) jDestroy)
poke ptrdestroy jDestroy'
return jDestroy'
g_memory_input_stream_add_data _obj' data_' len maybeDestroy
touchManagedPtr _obj
return ()