{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GLib.Structs.Checksum
(
Checksum(..) ,
#if defined(ENABLE_OVERLOADING)
ResolveChecksumMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
ChecksumCopyMethodInfo ,
#endif
checksumCopy ,
#if defined(ENABLE_OVERLOADING)
ChecksumFreeMethodInfo ,
#endif
checksumFree ,
#if defined(ENABLE_OVERLOADING)
ChecksumGetStringMethodInfo ,
#endif
checksumGetString ,
checksumNew ,
#if defined(ENABLE_OVERLOADING)
ChecksumResetMethodInfo ,
#endif
checksumReset ,
checksumTypeGetLength ,
#if defined(ENABLE_OVERLOADING)
ChecksumUpdateMethodInfo ,
#endif
checksumUpdate ,
) 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 {-# SOURCE #-} qualified GI.GLib.Enums as GLib.Enums
newtype Checksum = Checksum (SP.ManagedPtr Checksum)
deriving (Checksum -> Checksum -> Bool
(Checksum -> Checksum -> Bool)
-> (Checksum -> Checksum -> Bool) -> Eq Checksum
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Checksum -> Checksum -> Bool
$c/= :: Checksum -> Checksum -> Bool
== :: Checksum -> Checksum -> Bool
$c== :: Checksum -> Checksum -> Bool
Eq)
instance SP.ManagedPtrNewtype Checksum where
toManagedPtr :: Checksum -> ManagedPtr Checksum
toManagedPtr (Checksum ManagedPtr Checksum
p) = ManagedPtr Checksum
p
foreign import ccall "g_checksum_get_type" c_g_checksum_get_type ::
IO GType
type instance O.ParentTypes Checksum = '[]
instance O.HasParentTypes Checksum
instance B.Types.TypedObject Checksum where
glibType :: IO GType
glibType = IO GType
c_g_checksum_get_type
instance B.Types.GBoxed Checksum
instance B.GValue.IsGValue Checksum where
toGValue :: Checksum -> IO GValue
toGValue Checksum
o = do
GType
gtype <- IO GType
c_g_checksum_get_type
Checksum -> (Ptr Checksum -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Checksum
o (GType
-> (GValue -> Ptr Checksum -> IO ()) -> Ptr Checksum -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Checksum -> IO ()
forall a. GValue -> Ptr a -> IO ()
B.GValue.set_boxed)
fromGValue :: GValue -> IO Checksum
fromGValue GValue
gv = do
Ptr Checksum
ptr <- GValue -> IO (Ptr Checksum)
forall b. GValue -> IO (Ptr b)
B.GValue.get_boxed GValue
gv :: IO (Ptr Checksum)
(ManagedPtr Checksum -> Checksum) -> Ptr Checksum -> IO Checksum
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr Checksum -> Checksum
Checksum Ptr Checksum
ptr
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Checksum
type instance O.AttributeList Checksum = ChecksumAttributeList
type ChecksumAttributeList = ('[ ] :: [(Symbol, *)])
#endif
foreign import ccall "g_checksum_new" g_checksum_new ::
CUInt ->
IO (Ptr Checksum)
checksumNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
GLib.Enums.ChecksumType
-> m Checksum
checksumNew :: ChecksumType -> m Checksum
checksumNew ChecksumType
checksumType = IO Checksum -> m Checksum
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Checksum -> m Checksum) -> IO Checksum -> m Checksum
forall a b. (a -> b) -> a -> b
$ do
let checksumType' :: CUInt
checksumType' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (ChecksumType -> Int) -> ChecksumType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChecksumType -> Int
forall a. Enum a => a -> Int
fromEnum) ChecksumType
checksumType
Ptr Checksum
result <- CUInt -> IO (Ptr Checksum)
g_checksum_new CUInt
checksumType'
Text -> Ptr Checksum -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"checksumNew" Ptr Checksum
result
Checksum
result' <- ((ManagedPtr Checksum -> Checksum) -> Ptr Checksum -> IO Checksum
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Checksum -> Checksum
Checksum) Ptr Checksum
result
Checksum -> IO Checksum
forall (m :: * -> *) a. Monad m => a -> m a
return Checksum
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_checksum_copy" g_checksum_copy ::
Ptr Checksum ->
IO (Ptr Checksum)
checksumCopy ::
(B.CallStack.HasCallStack, MonadIO m) =>
Checksum
-> m Checksum
checksumCopy :: Checksum -> m Checksum
checksumCopy Checksum
checksum = IO Checksum -> m Checksum
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Checksum -> m Checksum) -> IO Checksum -> m Checksum
forall a b. (a -> b) -> a -> b
$ do
Ptr Checksum
checksum' <- Checksum -> IO (Ptr Checksum)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Checksum
checksum
Ptr Checksum
result <- Ptr Checksum -> IO (Ptr Checksum)
g_checksum_copy Ptr Checksum
checksum'
Text -> Ptr Checksum -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"checksumCopy" Ptr Checksum
result
Checksum
result' <- ((ManagedPtr Checksum -> Checksum) -> Ptr Checksum -> IO Checksum
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Checksum -> Checksum
Checksum) Ptr Checksum
result
Checksum -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Checksum
checksum
Checksum -> IO Checksum
forall (m :: * -> *) a. Monad m => a -> m a
return Checksum
result'
#if defined(ENABLE_OVERLOADING)
data ChecksumCopyMethodInfo
instance (signature ~ (m Checksum), MonadIO m) => O.MethodInfo ChecksumCopyMethodInfo Checksum signature where
overloadedMethod = checksumCopy
#endif
foreign import ccall "g_checksum_free" g_checksum_free ::
Ptr Checksum ->
IO ()
checksumFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
Checksum
-> m ()
checksumFree :: Checksum -> m ()
checksumFree Checksum
checksum = 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 Checksum
checksum' <- Checksum -> IO (Ptr Checksum)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Checksum
checksum
Ptr Checksum -> IO ()
g_checksum_free Ptr Checksum
checksum'
Checksum -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Checksum
checksum
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data ChecksumFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo ChecksumFreeMethodInfo Checksum signature where
overloadedMethod = checksumFree
#endif
foreign import ccall "g_checksum_get_string" g_checksum_get_string ::
Ptr Checksum ->
IO CString
checksumGetString ::
(B.CallStack.HasCallStack, MonadIO m) =>
Checksum
-> m T.Text
checksumGetString :: Checksum -> m Text
checksumGetString Checksum
checksum = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
Ptr Checksum
checksum' <- Checksum -> IO (Ptr Checksum)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Checksum
checksum
CString
result <- Ptr Checksum -> IO CString
g_checksum_get_string Ptr Checksum
checksum'
Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"checksumGetString" CString
result
Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
Checksum -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Checksum
checksum
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
#if defined(ENABLE_OVERLOADING)
data ChecksumGetStringMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo ChecksumGetStringMethodInfo Checksum signature where
overloadedMethod = checksumGetString
#endif
foreign import ccall "g_checksum_reset" g_checksum_reset ::
Ptr Checksum ->
IO ()
checksumReset ::
(B.CallStack.HasCallStack, MonadIO m) =>
Checksum
-> m ()
checksumReset :: Checksum -> m ()
checksumReset Checksum
checksum = 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 Checksum
checksum' <- Checksum -> IO (Ptr Checksum)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Checksum
checksum
Ptr Checksum -> IO ()
g_checksum_reset Ptr Checksum
checksum'
Checksum -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Checksum
checksum
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data ChecksumResetMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo ChecksumResetMethodInfo Checksum signature where
overloadedMethod = checksumReset
#endif
foreign import ccall "g_checksum_update" g_checksum_update ::
Ptr Checksum ->
Ptr Word8 ->
Int64 ->
IO ()
checksumUpdate ::
(B.CallStack.HasCallStack, MonadIO m) =>
Checksum
-> ByteString
-> m ()
checksumUpdate :: Checksum -> ByteString -> m ()
checksumUpdate Checksum
checksum ByteString
data_ = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
let length_ :: Int64
length_ = Int -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int64) -> Int -> Int64
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
data_
Ptr Checksum
checksum' <- Checksum -> IO (Ptr Checksum)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Checksum
checksum
Ptr Word8
data_' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
data_
Ptr Checksum -> Ptr Word8 -> Int64 -> IO ()
g_checksum_update Ptr Checksum
checksum' Ptr Word8
data_' Int64
length_
Checksum -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Checksum
checksum
Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
data_'
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data ChecksumUpdateMethodInfo
instance (signature ~ (ByteString -> m ()), MonadIO m) => O.MethodInfo ChecksumUpdateMethodInfo Checksum signature where
overloadedMethod = checksumUpdate
#endif
foreign import ccall "g_checksum_type_get_length" g_checksum_type_get_length ::
CUInt ->
IO Int64
checksumTypeGetLength ::
(B.CallStack.HasCallStack, MonadIO m) =>
GLib.Enums.ChecksumType
-> m Int64
checksumTypeGetLength :: ChecksumType -> m Int64
checksumTypeGetLength ChecksumType
checksumType = IO Int64 -> m Int64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
let checksumType' :: CUInt
checksumType' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (ChecksumType -> Int) -> ChecksumType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ChecksumType -> Int
forall a. Enum a => a -> Int
fromEnum) ChecksumType
checksumType
Int64
result <- CUInt -> IO Int64
g_checksum_type_get_length CUInt
checksumType'
Int64 -> IO Int64
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
result
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveChecksumMethod (t :: Symbol) (o :: *) :: * where
ResolveChecksumMethod "copy" o = ChecksumCopyMethodInfo
ResolveChecksumMethod "free" o = ChecksumFreeMethodInfo
ResolveChecksumMethod "reset" o = ChecksumResetMethodInfo
ResolveChecksumMethod "update" o = ChecksumUpdateMethodInfo
ResolveChecksumMethod "getString" o = ChecksumGetStringMethodInfo
ResolveChecksumMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveChecksumMethod t Checksum, O.MethodInfo info Checksum p) => OL.IsLabel t (Checksum -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif