{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GLib.Structs.Bytes
    ( 
    Bytes(..)                               ,
 
#if defined(ENABLE_OVERLOADING)
    ResolveBytesMethod                      ,
#endif
#if defined(ENABLE_OVERLOADING)
    BytesCompareMethodInfo                  ,
#endif
    bytesCompare                            ,
#if defined(ENABLE_OVERLOADING)
    BytesEqualMethodInfo                    ,
#endif
    bytesEqual                              ,
#if defined(ENABLE_OVERLOADING)
    BytesGetDataMethodInfo                  ,
#endif
    bytesGetData                            ,
#if defined(ENABLE_OVERLOADING)
    BytesGetRegionMethodInfo                ,
#endif
    bytesGetRegion                          ,
#if defined(ENABLE_OVERLOADING)
    BytesGetSizeMethodInfo                  ,
#endif
    bytesGetSize                            ,
#if defined(ENABLE_OVERLOADING)
    BytesHashMethodInfo                     ,
#endif
    bytesHash                               ,
    bytesNew                                ,
#if defined(ENABLE_OVERLOADING)
    BytesNewFromBytesMethodInfo             ,
#endif
    bytesNewFromBytes                       ,
    bytesNewTake                            ,
#if defined(ENABLE_OVERLOADING)
    BytesRefMethodInfo                      ,
#endif
    bytesRef                                ,
#if defined(ENABLE_OVERLOADING)
    BytesUnrefMethodInfo                    ,
#endif
    bytesUnref                              ,
#if defined(ENABLE_OVERLOADING)
    BytesUnrefToArrayMethodInfo             ,
#endif
    bytesUnrefToArray                       ,
#if defined(ENABLE_OVERLOADING)
    BytesUnrefToDataMethodInfo              ,
#endif
    bytesUnrefToData                        ,
    ) 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.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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 GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT
#if MIN_VERSION_base(4,18,0)
#else
#endif
newtype Bytes = Bytes (SP.ManagedPtr Bytes)
    deriving (Bytes -> Bytes -> Bool
(Bytes -> Bytes -> Bool) -> (Bytes -> Bytes -> Bool) -> Eq Bytes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Bytes -> Bytes -> Bool
== :: Bytes -> Bytes -> Bool
$c/= :: Bytes -> Bytes -> Bool
/= :: Bytes -> Bytes -> Bool
Eq)
instance SP.ManagedPtrNewtype Bytes where
    toManagedPtr :: Bytes -> ManagedPtr Bytes
toManagedPtr (Bytes ManagedPtr Bytes
p) = ManagedPtr Bytes
p
foreign import ccall "g_bytes_get_type" c_g_bytes_get_type :: 
    IO GType
type instance O.ParentTypes Bytes = '[]
instance O.HasParentTypes Bytes
instance B.Types.TypedObject Bytes where
    glibType :: IO GType
glibType = IO GType
c_g_bytes_get_type
instance B.Types.GBoxed Bytes
instance B.GValue.IsGValue (Maybe Bytes) where
    gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_g_bytes_get_type
    gvalueSet_ :: Ptr GValue -> Maybe Bytes -> IO ()
gvalueSet_ Ptr GValue
gv Maybe Bytes
P.Nothing = Ptr GValue -> Ptr Bytes -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr Bytes
forall a. Ptr a
FP.nullPtr :: FP.Ptr Bytes)
    gvalueSet_ Ptr GValue
gv (P.Just Bytes
obj) = Bytes -> (Ptr Bytes -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Bytes
obj (Ptr GValue -> Ptr Bytes -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
    gvalueGet_ :: Ptr GValue -> IO (Maybe Bytes)
gvalueGet_ Ptr GValue
gv = do
        Ptr Bytes
ptr <- Ptr GValue -> IO (Ptr Bytes)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr Bytes)
        if Ptr Bytes
ptr Ptr Bytes -> Ptr Bytes -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr Bytes
forall a. Ptr a
FP.nullPtr
        then Bytes -> Maybe Bytes
forall a. a -> Maybe a
P.Just (Bytes -> Maybe Bytes) -> IO Bytes -> IO (Maybe Bytes)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr Bytes -> Bytes) -> Ptr Bytes -> IO Bytes
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr Bytes -> Bytes
Bytes Ptr Bytes
ptr
        else Maybe Bytes -> IO (Maybe Bytes)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Bytes
forall a. Maybe a
P.Nothing
        
    
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Bytes
type instance O.AttributeList Bytes = BytesAttributeList
type BytesAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif
foreign import ccall "g_bytes_new" g_bytes_new :: 
    Ptr Word8 ->                            
    FCT.CSize ->                            
    IO (Ptr Bytes)
bytesNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (ByteString)
    
    
    -> m Bytes
    
bytesNew :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Maybe ByteString -> m Bytes
bytesNew Maybe ByteString
data_ = IO Bytes -> m Bytes
forall a. IO a -> m a
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
    let size :: CSize
size = case Maybe ByteString
data_ of
            Maybe ByteString
Nothing -> CSize
0
            Just ByteString
jData_ -> Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CSize) -> Int -> CSize
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
jData_
    Ptr Word8
maybeData_ <- case Maybe ByteString
data_ of
        Maybe ByteString
Nothing -> Ptr Word8 -> IO (Ptr Word8)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Word8
forall a. Ptr a
nullPtr
        Just ByteString
jData_ -> do
            Ptr Word8
jData_' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
jData_
            Ptr Word8 -> IO (Ptr Word8)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Word8
jData_'
    Ptr Bytes
result <- Ptr Word8 -> CSize -> IO (Ptr Bytes)
g_bytes_new Ptr Word8
maybeData_ CSize
size
    Text -> Ptr Bytes -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"bytesNew" 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
Bytes) Ptr Bytes
result
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
maybeData_
    Bytes -> IO Bytes
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bytes
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_bytes_new_take" g_bytes_new_take :: 
    Ptr Word8 ->                            
    FCT.CSize ->                            
    IO (Ptr Bytes)
bytesNewTake ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (ByteString)
    
    
    -> m Bytes
    
bytesNewTake :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Maybe ByteString -> m Bytes
bytesNewTake Maybe ByteString
data_ = IO Bytes -> m Bytes
forall a. IO a -> m a
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
    let size :: CSize
size = case Maybe ByteString
data_ of
            Maybe ByteString
Nothing -> CSize
0
            Just ByteString
jData_ -> Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CSize) -> Int -> CSize
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
jData_
    Ptr Word8
maybeData_ <- case Maybe ByteString
data_ of
        Maybe ByteString
Nothing -> Ptr Word8 -> IO (Ptr Word8)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Word8
forall a. Ptr a
nullPtr
        Just ByteString
jData_ -> do
            Ptr Word8
jData_' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
jData_
            Ptr Word8 -> IO (Ptr Word8)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Word8
jData_'
    Ptr Bytes
result <- Ptr Word8 -> CSize -> IO (Ptr Bytes)
g_bytes_new_take Ptr Word8
maybeData_ CSize
size
    Text -> Ptr Bytes -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"bytesNewTake" 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
Bytes) Ptr Bytes
result
    Bytes -> IO Bytes
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bytes
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_bytes_compare" g_bytes_compare :: 
    Ptr Bytes ->                            
    Ptr Bytes ->                            
    IO Int32
bytesCompare ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Bytes
    
    -> Bytes
    
    -> m Int32
    
    
    
bytesCompare :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Bytes -> Bytes -> m Int32
bytesCompare Bytes
bytes1 Bytes
bytes2 = IO Int32 -> m Int32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr Bytes
bytes1' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Bytes
bytes1
    Ptr Bytes
bytes2' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Bytes
bytes2
    Int32
result <- Ptr Bytes -> Ptr Bytes -> IO Int32
g_bytes_compare Ptr Bytes
bytes1' Ptr Bytes
bytes2'
    Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
bytes1
    Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
bytes2
    Int32 -> IO Int32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result
#if defined(ENABLE_OVERLOADING)
data BytesCompareMethodInfo
instance (signature ~ (Bytes -> m Int32), MonadIO m) => O.OverloadedMethod BytesCompareMethodInfo Bytes signature where
    overloadedMethod = bytesCompare
instance O.OverloadedMethodInfo BytesCompareMethodInfo Bytes where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.Bytes.bytesCompare",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-Bytes.html#v:bytesCompare"
        })
#endif
foreign import ccall "g_bytes_equal" g_bytes_equal :: 
    Ptr Bytes ->                            
    Ptr Bytes ->                            
    IO CInt
bytesEqual ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Bytes
    
    -> Bytes
    
    -> m Bool
    
bytesEqual :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Bytes -> Bytes -> m Bool
bytesEqual Bytes
bytes1 Bytes
bytes2 = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Bytes
bytes1' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Bytes
bytes1
    Ptr Bytes
bytes2' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Bytes
bytes2
    CInt
result <- Ptr Bytes -> Ptr Bytes -> IO CInt
g_bytes_equal Ptr Bytes
bytes1' Ptr Bytes
bytes2'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
bytes1
    Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
bytes2
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data BytesEqualMethodInfo
instance (signature ~ (Bytes -> m Bool), MonadIO m) => O.OverloadedMethod BytesEqualMethodInfo Bytes signature where
    overloadedMethod = bytesEqual
instance O.OverloadedMethodInfo BytesEqualMethodInfo Bytes where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.Bytes.bytesEqual",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-Bytes.html#v:bytesEqual"
        })
#endif
foreign import ccall "g_bytes_get_data" g_bytes_get_data :: 
    Ptr Bytes ->                            
    Ptr FCT.CSize ->                        
    IO (Ptr Word8)
bytesGetData ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Bytes
    
    -> m (Maybe ByteString)
    
    
bytesGetData :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Bytes -> m (Maybe ByteString)
bytesGetData Bytes
bytes = IO (Maybe ByteString) -> m (Maybe ByteString)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe ByteString) -> m (Maybe ByteString))
-> IO (Maybe ByteString) -> m (Maybe ByteString)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Bytes
bytes' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Bytes
bytes
    Ptr CSize
size <- IO (Ptr CSize)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr FCT.CSize)
    Ptr Word8
result <- Ptr Bytes -> Ptr CSize -> IO (Ptr Word8)
g_bytes_get_data Ptr Bytes
bytes' Ptr CSize
size
    CSize
size' <- Ptr CSize -> IO CSize
forall a. Storable a => Ptr a -> IO a
peek Ptr CSize
size
    Maybe ByteString
maybeResult <- Ptr Word8 -> (Ptr Word8 -> IO ByteString) -> IO (Maybe ByteString)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Word8
result ((Ptr Word8 -> IO ByteString) -> IO (Maybe ByteString))
-> (Ptr Word8 -> IO ByteString) -> IO (Maybe ByteString)
forall a b. (a -> b) -> a -> b
$ \Ptr Word8
result' -> do
        ByteString
result'' <- (CSize -> Ptr Word8 -> IO ByteString
forall a. Integral a => a -> Ptr Word8 -> IO ByteString
unpackByteStringWithLength CSize
size') Ptr Word8
result'
        ByteString -> IO ByteString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ByteString
result''
    Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
bytes
    Ptr CSize -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CSize
size
    Maybe ByteString -> IO (Maybe ByteString)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe ByteString
maybeResult
#if defined(ENABLE_OVERLOADING)
data BytesGetDataMethodInfo
instance (signature ~ (m (Maybe ByteString)), MonadIO m) => O.OverloadedMethod BytesGetDataMethodInfo Bytes signature where
    overloadedMethod = bytesGetData
instance O.OverloadedMethodInfo BytesGetDataMethodInfo Bytes where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.Bytes.bytesGetData",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-Bytes.html#v:bytesGetData"
        })
#endif
foreign import ccall "g_bytes_get_region" g_bytes_get_region :: 
    Ptr Bytes ->                            
    FCT.CSize ->                            
    FCT.CSize ->                            
    FCT.CSize ->                            
    IO (Ptr ())
bytesGetRegion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Bytes
    
    -> FCT.CSize
    
    -> FCT.CSize
    
    -> FCT.CSize
    
    -> m (Ptr ())
    
bytesGetRegion :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Bytes -> CSize -> CSize -> CSize -> m (Ptr ())
bytesGetRegion Bytes
bytes CSize
elementSize CSize
offset CSize
nElements = IO (Ptr ()) -> m (Ptr ())
forall a. IO a -> m a
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 Bytes
bytes' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Bytes
bytes
    Ptr ()
result <- Ptr Bytes -> CSize -> CSize -> CSize -> IO (Ptr ())
g_bytes_get_region Ptr Bytes
bytes' CSize
elementSize CSize
offset CSize
nElements
    Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
bytes
    Ptr () -> IO (Ptr ())
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
result
#if defined(ENABLE_OVERLOADING)
data BytesGetRegionMethodInfo
instance (signature ~ (FCT.CSize -> FCT.CSize -> FCT.CSize -> m (Ptr ())), MonadIO m) => O.OverloadedMethod BytesGetRegionMethodInfo Bytes signature where
    overloadedMethod = bytesGetRegion
instance O.OverloadedMethodInfo BytesGetRegionMethodInfo Bytes where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.Bytes.bytesGetRegion",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-Bytes.html#v:bytesGetRegion"
        })
#endif
foreign import ccall "g_bytes_get_size" g_bytes_get_size :: 
    Ptr Bytes ->                            
    IO FCT.CSize
bytesGetSize ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Bytes
    
    -> m FCT.CSize
    
bytesGetSize :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Bytes -> m CSize
bytesGetSize Bytes
bytes = IO CSize -> m CSize
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CSize -> m CSize) -> IO CSize -> m CSize
forall a b. (a -> b) -> a -> b
$ do
    Ptr Bytes
bytes' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Bytes
bytes
    CSize
result <- Ptr Bytes -> IO CSize
g_bytes_get_size Ptr Bytes
bytes'
    Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
bytes
    CSize -> IO CSize
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CSize
result
#if defined(ENABLE_OVERLOADING)
data BytesGetSizeMethodInfo
instance (signature ~ (m FCT.CSize), MonadIO m) => O.OverloadedMethod BytesGetSizeMethodInfo Bytes signature where
    overloadedMethod = bytesGetSize
instance O.OverloadedMethodInfo BytesGetSizeMethodInfo Bytes where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.Bytes.bytesGetSize",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-Bytes.html#v:bytesGetSize"
        })
#endif
foreign import ccall "g_bytes_hash" g_bytes_hash :: 
    Ptr Bytes ->                            
    IO Word32
bytesHash ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Bytes
    
    -> m Word32
    
bytesHash :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Bytes -> m Word32
bytesHash Bytes
bytes = IO Word32 -> m Word32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Ptr Bytes
bytes' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Bytes
bytes
    Word32
result <- Ptr Bytes -> IO Word32
g_bytes_hash Ptr Bytes
bytes'
    Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
bytes
    Word32 -> IO Word32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result
#if defined(ENABLE_OVERLOADING)
data BytesHashMethodInfo
instance (signature ~ (m Word32), MonadIO m) => O.OverloadedMethod BytesHashMethodInfo Bytes signature where
    overloadedMethod = bytesHash
instance O.OverloadedMethodInfo BytesHashMethodInfo Bytes where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.Bytes.bytesHash",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-Bytes.html#v:bytesHash"
        })
#endif
foreign import ccall "g_bytes_new_from_bytes" g_bytes_new_from_bytes :: 
    Ptr Bytes ->                            
    FCT.CSize ->                            
    FCT.CSize ->                            
    IO (Ptr Bytes)
bytesNewFromBytes ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Bytes
    
    -> FCT.CSize
    
    -> FCT.CSize
    
    -> m Bytes
    
bytesNewFromBytes :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Bytes -> CSize -> CSize -> m Bytes
bytesNewFromBytes Bytes
bytes CSize
offset CSize
length_ = IO Bytes -> m Bytes
forall a. IO a -> m a
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 Bytes
bytes' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Bytes
bytes
    Ptr Bytes
result <- Ptr Bytes -> CSize -> CSize -> IO (Ptr Bytes)
g_bytes_new_from_bytes Ptr Bytes
bytes' CSize
offset CSize
length_
    Text -> Ptr Bytes -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"bytesNewFromBytes" 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
Bytes) Ptr Bytes
result
    Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
bytes
    Bytes -> IO Bytes
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bytes
result'
#if defined(ENABLE_OVERLOADING)
data BytesNewFromBytesMethodInfo
instance (signature ~ (FCT.CSize -> FCT.CSize -> m Bytes), MonadIO m) => O.OverloadedMethod BytesNewFromBytesMethodInfo Bytes signature where
    overloadedMethod = bytesNewFromBytes
instance O.OverloadedMethodInfo BytesNewFromBytesMethodInfo Bytes where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.Bytes.bytesNewFromBytes",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-Bytes.html#v:bytesNewFromBytes"
        })
#endif
foreign import ccall "g_bytes_ref" g_bytes_ref :: 
    Ptr Bytes ->                            
    IO (Ptr Bytes)
bytesRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Bytes
    
    -> m Bytes
    
bytesRef :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Bytes -> m Bytes
bytesRef Bytes
bytes = IO Bytes -> m Bytes
forall a. IO a -> m a
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 Bytes
bytes' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Bytes
bytes
    Ptr Bytes
result <- Ptr Bytes -> IO (Ptr Bytes)
g_bytes_ref Ptr Bytes
bytes'
    Text -> Ptr Bytes -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"bytesRef" 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
Bytes) Ptr Bytes
result
    Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
bytes
    Bytes -> IO Bytes
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bytes
result'
#if defined(ENABLE_OVERLOADING)
data BytesRefMethodInfo
instance (signature ~ (m Bytes), MonadIO m) => O.OverloadedMethod BytesRefMethodInfo Bytes signature where
    overloadedMethod = bytesRef
instance O.OverloadedMethodInfo BytesRefMethodInfo Bytes where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.Bytes.bytesRef",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-Bytes.html#v:bytesRef"
        })
#endif
foreign import ccall "g_bytes_unref" g_bytes_unref :: 
    Ptr Bytes ->                            
    IO ()
bytesUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (Bytes)
    
    -> m ()
bytesUnref :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Maybe Bytes -> m ()
bytesUnref Maybe Bytes
bytes = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Bytes
maybeBytes <- case Maybe Bytes
bytes of
        Maybe Bytes
Nothing -> Ptr Bytes -> IO (Ptr Bytes)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Bytes
forall a. Ptr a
nullPtr
        Just Bytes
jBytes -> do
            Ptr Bytes
jBytes' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Bytes
jBytes
            Ptr Bytes -> IO (Ptr Bytes)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Bytes
jBytes'
    Ptr Bytes -> IO ()
g_bytes_unref Ptr Bytes
maybeBytes
    Maybe Bytes -> (Bytes -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe Bytes
bytes Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data BytesUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod BytesUnrefMethodInfo Bytes signature where
    overloadedMethod i = bytesUnref (Just i)
instance O.OverloadedMethodInfo BytesUnrefMethodInfo Bytes where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.Bytes.bytesUnref",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-Bytes.html#v:bytesUnref"
        })
#endif
foreign import ccall "g_bytes_unref_to_array" g_bytes_unref_to_array :: 
    Ptr Bytes ->                            
    IO (Ptr GByteArray)
bytesUnrefToArray ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Bytes
    
    -> m ByteString
    
bytesUnrefToArray :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Bytes -> m ByteString
bytesUnrefToArray Bytes
bytes = IO ByteString -> m ByteString
forall a. IO a -> m a
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 Bytes
bytes' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, GBoxed a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed Bytes
bytes
    Ptr GByteArray
result <- Ptr Bytes -> IO (Ptr GByteArray)
g_bytes_unref_to_array Ptr Bytes
bytes'
    Text -> Ptr GByteArray -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"bytesUnrefToArray" Ptr GByteArray
result
    ByteString
result' <- Ptr GByteArray -> IO ByteString
unpackGByteArray Ptr GByteArray
result
    Ptr GByteArray -> IO ()
unrefGByteArray Ptr GByteArray
result
    Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
bytes
    ByteString -> IO ByteString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ByteString
result'
#if defined(ENABLE_OVERLOADING)
data BytesUnrefToArrayMethodInfo
instance (signature ~ (m ByteString), MonadIO m) => O.OverloadedMethod BytesUnrefToArrayMethodInfo Bytes signature where
    overloadedMethod = bytesUnrefToArray
instance O.OverloadedMethodInfo BytesUnrefToArrayMethodInfo Bytes where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.Bytes.bytesUnrefToArray",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-Bytes.html#v:bytesUnrefToArray"
        })
#endif
foreign import ccall "g_bytes_unref_to_data" g_bytes_unref_to_data :: 
    Ptr Bytes ->                            
    Ptr FCT.CSize ->                        
    IO (Ptr Word8)
bytesUnrefToData ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Bytes
    
    -> m ByteString
    
    
bytesUnrefToData :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Bytes -> m ByteString
bytesUnrefToData Bytes
bytes = IO ByteString -> m ByteString
forall a. IO a -> m a
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 Bytes
bytes' <- Bytes -> IO (Ptr Bytes)
forall a. (HasCallStack, GBoxed a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed Bytes
bytes
    Ptr CSize
size <- IO (Ptr CSize)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr FCT.CSize)
    Ptr Word8
result <- Ptr Bytes -> Ptr CSize -> IO (Ptr Word8)
g_bytes_unref_to_data Ptr Bytes
bytes' Ptr CSize
size
    CSize
size' <- Ptr CSize -> IO CSize
forall a. Storable a => Ptr a -> IO a
peek Ptr CSize
size
    Text -> Ptr Word8 -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"bytesUnrefToData" Ptr Word8
result
    ByteString
result' <- (CSize -> Ptr Word8 -> IO ByteString
forall a. Integral a => a -> Ptr Word8 -> IO ByteString
unpackByteStringWithLength CSize
size') Ptr Word8
result
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
result
    Bytes -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Bytes
bytes
    Ptr CSize -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CSize
size
    ByteString -> IO ByteString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ByteString
result'
#if defined(ENABLE_OVERLOADING)
data BytesUnrefToDataMethodInfo
instance (signature ~ (m ByteString), MonadIO m) => O.OverloadedMethod BytesUnrefToDataMethodInfo Bytes signature where
    overloadedMethod = bytesUnrefToData
instance O.OverloadedMethodInfo BytesUnrefToDataMethodInfo Bytes where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GLib.Structs.Bytes.bytesUnrefToData",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-glib-2.0.30/docs/GI-GLib-Structs-Bytes.html#v:bytesUnrefToData"
        })
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveBytesMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveBytesMethod "compare" o = BytesCompareMethodInfo
    ResolveBytesMethod "equal" o = BytesEqualMethodInfo
    ResolveBytesMethod "hash" o = BytesHashMethodInfo
    ResolveBytesMethod "newFromBytes" o = BytesNewFromBytesMethodInfo
    ResolveBytesMethod "ref" o = BytesRefMethodInfo
    ResolveBytesMethod "unref" o = BytesUnrefMethodInfo
    ResolveBytesMethod "unrefToArray" o = BytesUnrefToArrayMethodInfo
    ResolveBytesMethod "unrefToData" o = BytesUnrefToDataMethodInfo
    ResolveBytesMethod "getData" o = BytesGetDataMethodInfo
    ResolveBytesMethod "getRegion" o = BytesGetRegionMethodInfo
    ResolveBytesMethod "getSize" o = BytesGetSizeMethodInfo
    ResolveBytesMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveBytesMethod t Bytes, O.OverloadedMethod info Bytes p) => OL.IsLabel t (Bytes -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif
#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveBytesMethod t Bytes, O.OverloadedMethod info Bytes p, R.HasField t Bytes p) => R.HasField t Bytes p where
    getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveBytesMethod t Bytes, O.OverloadedMethodInfo info Bytes) => OL.IsLabel t (O.MethodProxy info Bytes) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif
#endif