{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Soup.Structs.Buffer
(
Buffer(..) ,
newZeroBuffer ,
#if defined(ENABLE_OVERLOADING)
ResolveBufferMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
BufferCopyMethodInfo ,
#endif
bufferCopy ,
#if defined(ENABLE_OVERLOADING)
BufferFreeMethodInfo ,
#endif
bufferFree ,
#if defined(ENABLE_OVERLOADING)
BufferGetAsBytesMethodInfo ,
#endif
bufferGetAsBytes ,
#if defined(ENABLE_OVERLOADING)
BufferGetDataMethodInfo ,
#endif
bufferGetData ,
#if defined(ENABLE_OVERLOADING)
BufferGetOwnerMethodInfo ,
#endif
bufferGetOwner ,
bufferNew ,
#if defined(ENABLE_OVERLOADING)
BufferNewSubbufferMethodInfo ,
#endif
bufferNewSubbuffer ,
bufferNewWithOwner ,
#if defined(ENABLE_OVERLOADING)
buffer_data ,
#endif
clearBufferData ,
getBufferData ,
setBufferData ,
#if defined(ENABLE_OVERLOADING)
buffer_length ,
#endif
getBufferLength ,
setBufferLength ,
) 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.BasicTypes as B.Types
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 Control.Monad.IO.Class as MIO
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
newtype Buffer = Buffer (SP.ManagedPtr Buffer)
deriving (Buffer -> Buffer -> Bool
(Buffer -> Buffer -> Bool)
-> (Buffer -> Buffer -> Bool) -> Eq Buffer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Buffer -> Buffer -> Bool
$c/= :: Buffer -> Buffer -> Bool
== :: Buffer -> Buffer -> Bool
$c== :: Buffer -> Buffer -> Bool
Eq)
instance SP.ManagedPtrNewtype Buffer where
toManagedPtr :: Buffer -> ManagedPtr Buffer
toManagedPtr (Buffer ManagedPtr Buffer
p) = ManagedPtr Buffer
p
foreign import ccall "soup_buffer_get_type" c_soup_buffer_get_type ::
IO GType
type instance O.ParentTypes Buffer = '[]
instance O.HasParentTypes Buffer
instance B.Types.TypedObject Buffer where
glibType :: IO GType
glibType = IO GType
c_soup_buffer_get_type
instance B.Types.GBoxed Buffer
instance B.GValue.IsGValue Buffer where
toGValue :: Buffer -> IO GValue
toGValue Buffer
o = do
GType
gtype <- IO GType
c_soup_buffer_get_type
Buffer -> (Ptr Buffer -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Buffer
o (GType -> (GValue -> Ptr Buffer -> IO ()) -> Ptr Buffer -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Buffer -> IO ()
forall a. GValue -> Ptr a -> IO ()
B.GValue.set_boxed)
fromGValue :: GValue -> IO Buffer
fromGValue GValue
gv = do
Ptr Buffer
ptr <- GValue -> IO (Ptr Buffer)
forall b. GValue -> IO (Ptr b)
B.GValue.get_boxed GValue
gv :: IO (Ptr Buffer)
(ManagedPtr Buffer -> Buffer) -> Ptr Buffer -> IO Buffer
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr Buffer -> Buffer
Buffer Ptr Buffer
ptr
newZeroBuffer :: MonadIO m => m Buffer
newZeroBuffer :: m Buffer
newZeroBuffer = IO Buffer -> m Buffer
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Buffer -> m Buffer) -> IO Buffer -> m Buffer
forall a b. (a -> b) -> a -> b
$ Int -> IO (Ptr Buffer)
forall a. GBoxed a => Int -> IO (Ptr a)
callocBoxedBytes Int
16 IO (Ptr Buffer) -> (Ptr Buffer -> IO Buffer) -> IO Buffer
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr Buffer -> Buffer) -> Ptr Buffer -> IO Buffer
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Buffer -> Buffer
Buffer
instance tag ~ 'AttrSet => Constructible Buffer tag where
new :: (ManagedPtr Buffer -> Buffer) -> [AttrOp Buffer tag] -> m Buffer
new ManagedPtr Buffer -> Buffer
_ [AttrOp Buffer tag]
attrs = do
Buffer
o <- m Buffer
forall (m :: * -> *). MonadIO m => m Buffer
newZeroBuffer
Buffer -> [AttrOp Buffer 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set Buffer
o [AttrOp Buffer tag]
[AttrOp Buffer 'AttrSet]
attrs
Buffer -> m Buffer
forall (m :: * -> *) a. Monad m => a -> m a
return Buffer
o
getBufferData :: MonadIO m => Buffer -> m (Ptr ())
getBufferData :: Buffer -> m (Ptr ())
getBufferData Buffer
s = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ Buffer -> (Ptr Buffer -> IO (Ptr ())) -> IO (Ptr ())
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Buffer
s ((Ptr Buffer -> IO (Ptr ())) -> IO (Ptr ()))
-> (Ptr Buffer -> IO (Ptr ())) -> IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ \Ptr Buffer
ptr -> do
Ptr ()
val <- Ptr (Ptr ()) -> IO (Ptr ())
forall a. Storable a => Ptr a -> IO a
peek (Ptr Buffer
ptr Ptr Buffer -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) :: IO (Ptr ())
Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
val
setBufferData :: MonadIO m => Buffer -> Ptr () -> m ()
setBufferData :: Buffer -> Ptr () -> m ()
setBufferData Buffer
s Ptr ()
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Buffer -> (Ptr Buffer -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Buffer
s ((Ptr Buffer -> IO ()) -> IO ()) -> (Ptr Buffer -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Buffer
ptr -> do
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Buffer
ptr Ptr Buffer -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) (Ptr ()
val :: Ptr ())
clearBufferData :: MonadIO m => Buffer -> m ()
clearBufferData :: Buffer -> m ()
clearBufferData Buffer
s = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Buffer -> (Ptr Buffer -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Buffer
s ((Ptr Buffer -> IO ()) -> IO ()) -> (Ptr Buffer -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Buffer
ptr -> do
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Buffer
ptr Ptr Buffer -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) (Ptr ()
forall a. Ptr a
FP.nullPtr :: Ptr ())
#if defined(ENABLE_OVERLOADING)
data BufferDataFieldInfo
instance AttrInfo BufferDataFieldInfo where
type AttrBaseTypeConstraint BufferDataFieldInfo = (~) Buffer
type AttrAllowedOps BufferDataFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint BufferDataFieldInfo = (~) (Ptr ())
type AttrTransferTypeConstraint BufferDataFieldInfo = (~)(Ptr ())
type AttrTransferType BufferDataFieldInfo = (Ptr ())
type AttrGetType BufferDataFieldInfo = Ptr ()
type AttrLabel BufferDataFieldInfo = "data"
type AttrOrigin BufferDataFieldInfo = Buffer
attrGet = getBufferData
attrSet = setBufferData
attrConstruct = undefined
attrClear = clearBufferData
attrTransfer _ v = do
return v
buffer_data :: AttrLabelProxy "data"
buffer_data = AttrLabelProxy
#endif
getBufferLength :: MonadIO m => Buffer -> m Word64
getBufferLength :: Buffer -> m Word64
getBufferLength Buffer
s = 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
$ Buffer -> (Ptr Buffer -> IO Word64) -> IO Word64
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Buffer
s ((Ptr Buffer -> IO Word64) -> IO Word64)
-> (Ptr Buffer -> IO Word64) -> IO Word64
forall a b. (a -> b) -> a -> b
$ \Ptr Buffer
ptr -> do
Word64
val <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek (Ptr Buffer
ptr Ptr Buffer -> Int -> Ptr Word64
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8) :: IO Word64
Word64 -> IO Word64
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
val
setBufferLength :: MonadIO m => Buffer -> Word64 -> m ()
setBufferLength :: Buffer -> Word64 -> m ()
setBufferLength Buffer
s Word64
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Buffer -> (Ptr Buffer -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr Buffer
s ((Ptr Buffer -> IO ()) -> IO ()) -> (Ptr Buffer -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Buffer
ptr -> do
Ptr Word64 -> Word64 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Buffer
ptr Ptr Buffer -> Int -> Ptr Word64
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8) (Word64
val :: Word64)
#if defined(ENABLE_OVERLOADING)
data BufferLengthFieldInfo
instance AttrInfo BufferLengthFieldInfo where
type AttrBaseTypeConstraint BufferLengthFieldInfo = (~) Buffer
type AttrAllowedOps BufferLengthFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint BufferLengthFieldInfo = (~) Word64
type AttrTransferTypeConstraint BufferLengthFieldInfo = (~)Word64
type AttrTransferType BufferLengthFieldInfo = Word64
type AttrGetType BufferLengthFieldInfo = Word64
type AttrLabel BufferLengthFieldInfo = "length"
type AttrOrigin BufferLengthFieldInfo = Buffer
attrGet = getBufferLength
attrSet = setBufferLength
attrConstruct = undefined
attrClear = undefined
attrTransfer _ v = do
return v
buffer_length :: AttrLabelProxy "length"
buffer_length = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Buffer
type instance O.AttributeList Buffer = BufferAttributeList
type BufferAttributeList = ('[ '("data", BufferDataFieldInfo), '("length", BufferLengthFieldInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "soup_buffer_new_take" soup_buffer_new_take ::
Ptr Word8 ->
Word64 ->
IO (Ptr Buffer)
bufferNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
ByteString
-> m Buffer
bufferNew :: ByteString -> m Buffer
bufferNew ByteString
data_ = IO Buffer -> m Buffer
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Buffer -> m Buffer) -> IO Buffer -> m Buffer
forall a b. (a -> b) -> a -> b
$ do
let length_ :: Word64
length_ = 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
data_
Ptr Word8
data_' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
data_
Ptr Buffer
result <- Ptr Word8 -> Word64 -> IO (Ptr Buffer)
soup_buffer_new_take Ptr Word8
data_' Word64
length_
Text -> Ptr Buffer -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"bufferNew" Ptr Buffer
result
Buffer
result' <- ((ManagedPtr Buffer -> Buffer) -> Ptr Buffer -> IO Buffer
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Buffer -> Buffer
Buffer) Ptr Buffer
result
Buffer -> IO Buffer
forall (m :: * -> *) a. Monad m => a -> m a
return Buffer
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "soup_buffer_new_with_owner" soup_buffer_new_with_owner ::
Ptr Word8 ->
Word64 ->
Ptr () ->
FunPtr GLib.Callbacks.C_DestroyNotify ->
IO (Ptr Buffer)
bufferNewWithOwner ::
(B.CallStack.HasCallStack, MonadIO m) =>
ByteString
-> Ptr ()
-> Maybe (GLib.Callbacks.DestroyNotify)
-> m Buffer
bufferNewWithOwner :: ByteString -> Ptr () -> Maybe (Ptr () -> IO ()) -> m Buffer
bufferNewWithOwner ByteString
data_ Ptr ()
owner Maybe (Ptr () -> IO ())
ownerDnotify = IO Buffer -> m Buffer
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Buffer -> m Buffer) -> IO Buffer -> m Buffer
forall a b. (a -> b) -> a -> b
$ do
let length_ :: Word64
length_ = 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
data_
Ptr Word8
data_' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
data_
FunPtr (Ptr () -> IO ())
maybeOwnerDnotify <- case Maybe (Ptr () -> IO ())
ownerDnotify of
Maybe (Ptr () -> IO ())
Nothing -> FunPtr (Ptr () -> IO ()) -> IO (FunPtr (Ptr () -> IO ()))
forall (m :: * -> *) a. Monad m => a -> m a
return (Ptr Any -> FunPtr (Ptr () -> IO ())
forall a b. Ptr a -> FunPtr b
castPtrToFunPtr Ptr Any
forall a. Ptr a
nullPtr)
Just Ptr () -> IO ()
jOwnerDnotify -> do
Ptr (FunPtr (Ptr () -> IO ()))
ptrownerDnotify <- IO (Ptr (FunPtr (Ptr () -> IO ())))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr GLib.Callbacks.C_DestroyNotify))
FunPtr (Ptr () -> IO ())
jOwnerDnotify' <- (Ptr () -> IO ()) -> IO (FunPtr (Ptr () -> IO ()))
GLib.Callbacks.mk_DestroyNotify (Maybe (Ptr (FunPtr (Ptr () -> IO ())))
-> (Ptr () -> IO ()) -> Ptr () -> IO ()
GLib.Callbacks.wrap_DestroyNotify (Ptr (FunPtr (Ptr () -> IO ()))
-> Maybe (Ptr (FunPtr (Ptr () -> IO ())))
forall a. a -> Maybe a
Just Ptr (FunPtr (Ptr () -> IO ()))
ptrownerDnotify) Ptr () -> IO ()
jOwnerDnotify)
Ptr (FunPtr (Ptr () -> IO ())) -> FunPtr (Ptr () -> IO ()) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr (FunPtr (Ptr () -> IO ()))
ptrownerDnotify FunPtr (Ptr () -> IO ())
jOwnerDnotify'
FunPtr (Ptr () -> IO ()) -> IO (FunPtr (Ptr () -> IO ()))
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr (Ptr () -> IO ())
jOwnerDnotify'
Ptr Buffer
result <- Ptr Word8
-> Word64 -> Ptr () -> FunPtr (Ptr () -> IO ()) -> IO (Ptr Buffer)
soup_buffer_new_with_owner Ptr Word8
data_' Word64
length_ Ptr ()
owner FunPtr (Ptr () -> IO ())
maybeOwnerDnotify
Text -> Ptr Buffer -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"bufferNewWithOwner" Ptr Buffer
result
Buffer
result' <- ((ManagedPtr Buffer -> Buffer) -> Ptr Buffer -> IO Buffer
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Buffer -> Buffer
Buffer) Ptr Buffer
result
Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
data_'
Buffer -> IO Buffer
forall (m :: * -> *) a. Monad m => a -> m a
return Buffer
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "soup_buffer_copy" soup_buffer_copy ::
Ptr Buffer ->
IO (Ptr Buffer)
bufferCopy ::
(B.CallStack.HasCallStack, MonadIO m) =>
Buffer
-> m Buffer
bufferCopy :: Buffer -> m Buffer
bufferCopy Buffer
buffer = IO Buffer -> m Buffer
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Buffer -> m Buffer) -> IO Buffer -> m Buffer
forall a b. (a -> b) -> a -> b
$ do
Ptr Buffer
buffer' <- Buffer -> IO (Ptr Buffer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Buffer
buffer
Ptr Buffer
result <- Ptr Buffer -> IO (Ptr Buffer)
soup_buffer_copy Ptr Buffer
buffer'
Text -> Ptr Buffer -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"bufferCopy" Ptr Buffer
result
Buffer
result' <- ((ManagedPtr Buffer -> Buffer) -> Ptr Buffer -> IO Buffer
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Buffer -> Buffer
Buffer) Ptr Buffer
result
Buffer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Buffer
buffer
Buffer -> IO Buffer
forall (m :: * -> *) a. Monad m => a -> m a
return Buffer
result'
#if defined(ENABLE_OVERLOADING)
data BufferCopyMethodInfo
instance (signature ~ (m Buffer), MonadIO m) => O.MethodInfo BufferCopyMethodInfo Buffer signature where
overloadedMethod = bufferCopy
#endif
foreign import ccall "soup_buffer_free" soup_buffer_free ::
Ptr Buffer ->
IO ()
bufferFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
Buffer
-> m ()
bufferFree :: Buffer -> m ()
bufferFree Buffer
buffer = 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 Buffer
buffer' <- Buffer -> IO (Ptr Buffer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Buffer
buffer
Ptr Buffer -> IO ()
soup_buffer_free Ptr Buffer
buffer'
Buffer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Buffer
buffer
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data BufferFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo BufferFreeMethodInfo Buffer signature where
overloadedMethod = bufferFree
#endif
foreign import ccall "soup_buffer_get_as_bytes" soup_buffer_get_as_bytes ::
Ptr Buffer ->
IO (Ptr GLib.Bytes.Bytes)
bufferGetAsBytes ::
(B.CallStack.HasCallStack, MonadIO m) =>
Buffer
-> m GLib.Bytes.Bytes
bufferGetAsBytes :: Buffer -> m Bytes
bufferGetAsBytes Buffer
buffer = IO Bytes -> m Bytes
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bytes -> m Bytes) -> IO Bytes -> m Bytes
forall a b. (a -> b) -> a -> b
$ do
Ptr Buffer
buffer' <- Buffer -> IO (Ptr Buffer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Buffer
buffer
Ptr Bytes
result <- Ptr Buffer -> IO (Ptr Bytes)
soup_buffer_get_as_bytes Ptr Buffer
buffer'
Text -> Ptr Bytes -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"bufferGetAsBytes" Ptr Bytes
result
Bytes
result' <- ((ManagedPtr Bytes -> Bytes) -> Ptr Bytes -> IO Bytes
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Bytes -> Bytes
GLib.Bytes.Bytes) Ptr Bytes
result
Buffer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Buffer
buffer
Bytes -> IO Bytes
forall (m :: * -> *) a. Monad m => a -> m a
return Bytes
result'
#if defined(ENABLE_OVERLOADING)
data BufferGetAsBytesMethodInfo
instance (signature ~ (m GLib.Bytes.Bytes), MonadIO m) => O.MethodInfo BufferGetAsBytesMethodInfo Buffer signature where
overloadedMethod = bufferGetAsBytes
#endif
foreign import ccall "soup_buffer_get_data" soup_buffer_get_data ::
Ptr Buffer ->
Ptr (Ptr Word8) ->
Ptr Word64 ->
IO ()
bufferGetData ::
(B.CallStack.HasCallStack, MonadIO m) =>
Buffer
-> m (ByteString)
bufferGetData :: Buffer -> m ByteString
bufferGetData Buffer
buffer = IO ByteString -> m ByteString
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ByteString -> m ByteString) -> IO ByteString -> m ByteString
forall a b. (a -> b) -> a -> b
$ do
Ptr Buffer
buffer' <- Buffer -> IO (Ptr Buffer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Buffer
buffer
Ptr (Ptr Word8)
data_ <- IO (Ptr (Ptr Word8))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (Ptr Word8))
Ptr Word64
length_ <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
Ptr Buffer -> Ptr (Ptr Word8) -> Ptr Word64 -> IO ()
soup_buffer_get_data Ptr Buffer
buffer' Ptr (Ptr Word8)
data_ Ptr Word64
length_
Word64
length_' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
length_
Ptr Word8
data_' <- Ptr (Ptr Word8) -> IO (Ptr Word8)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr Word8)
data_
ByteString
data_'' <- (Word64 -> Ptr Word8 -> IO ByteString
forall a. Integral a => a -> Ptr Word8 -> IO ByteString
unpackByteStringWithLength Word64
length_') Ptr Word8
data_'
Buffer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Buffer
buffer
Ptr (Ptr Word8) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr Word8)
data_
Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
length_
ByteString -> IO ByteString
forall (m :: * -> *) a. Monad m => a -> m a
return ByteString
data_''
#if defined(ENABLE_OVERLOADING)
data BufferGetDataMethodInfo
instance (signature ~ (m (ByteString)), MonadIO m) => O.MethodInfo BufferGetDataMethodInfo Buffer signature where
overloadedMethod = bufferGetData
#endif
foreign import ccall "soup_buffer_get_owner" soup_buffer_get_owner ::
Ptr Buffer ->
IO (Ptr ())
bufferGetOwner ::
(B.CallStack.HasCallStack, MonadIO m) =>
Buffer
-> m (Ptr ())
bufferGetOwner :: Buffer -> m (Ptr ())
bufferGetOwner Buffer
buffer = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
Ptr Buffer
buffer' <- Buffer -> IO (Ptr Buffer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Buffer
buffer
Ptr ()
result <- Ptr Buffer -> IO (Ptr ())
soup_buffer_get_owner Ptr Buffer
buffer'
Buffer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Buffer
buffer
Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
result
#if defined(ENABLE_OVERLOADING)
data BufferGetOwnerMethodInfo
instance (signature ~ (m (Ptr ())), MonadIO m) => O.MethodInfo BufferGetOwnerMethodInfo Buffer signature where
overloadedMethod = bufferGetOwner
#endif
foreign import ccall "soup_buffer_new_subbuffer" soup_buffer_new_subbuffer ::
Ptr Buffer ->
Word64 ->
Word64 ->
IO (Ptr Buffer)
bufferNewSubbuffer ::
(B.CallStack.HasCallStack, MonadIO m) =>
Buffer
-> Word64
-> Word64
-> m Buffer
bufferNewSubbuffer :: Buffer -> Word64 -> Word64 -> m Buffer
bufferNewSubbuffer Buffer
parent Word64
offset Word64
length_ = IO Buffer -> m Buffer
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Buffer -> m Buffer) -> IO Buffer -> m Buffer
forall a b. (a -> b) -> a -> b
$ do
Ptr Buffer
parent' <- Buffer -> IO (Ptr Buffer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Buffer
parent
Ptr Buffer
result <- Ptr Buffer -> Word64 -> Word64 -> IO (Ptr Buffer)
soup_buffer_new_subbuffer Ptr Buffer
parent' Word64
offset Word64
length_
Text -> Ptr Buffer -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"bufferNewSubbuffer" Ptr Buffer
result
Buffer
result' <- ((ManagedPtr Buffer -> Buffer) -> Ptr Buffer -> IO Buffer
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Buffer -> Buffer
Buffer) Ptr Buffer
result
Buffer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Buffer
parent
Buffer -> IO Buffer
forall (m :: * -> *) a. Monad m => a -> m a
return Buffer
result'
#if defined(ENABLE_OVERLOADING)
data BufferNewSubbufferMethodInfo
instance (signature ~ (Word64 -> Word64 -> m Buffer), MonadIO m) => O.MethodInfo BufferNewSubbufferMethodInfo Buffer signature where
overloadedMethod = bufferNewSubbuffer
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveBufferMethod (t :: Symbol) (o :: *) :: * where
ResolveBufferMethod "copy" o = BufferCopyMethodInfo
ResolveBufferMethod "free" o = BufferFreeMethodInfo
ResolveBufferMethod "newSubbuffer" o = BufferNewSubbufferMethodInfo
ResolveBufferMethod "getAsBytes" o = BufferGetAsBytesMethodInfo
ResolveBufferMethod "getData" o = BufferGetDataMethodInfo
ResolveBufferMethod "getOwner" o = BufferGetOwnerMethodInfo
ResolveBufferMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveBufferMethod t Buffer, O.MethodInfo info Buffer p) => OL.IsLabel t (Buffer -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif