{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Dazzle.Structs.CounterValue
(
CounterValue(..) ,
newZeroCounterValue ,
#if defined(ENABLE_OVERLOADING)
ResolveCounterValueMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
counterValue_value ,
#endif
getCounterValueValue ,
setCounterValueValue ,
) 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 CounterValue = CounterValue (SP.ManagedPtr CounterValue)
deriving (CounterValue -> CounterValue -> Bool
(CounterValue -> CounterValue -> Bool)
-> (CounterValue -> CounterValue -> Bool) -> Eq CounterValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CounterValue -> CounterValue -> Bool
== :: CounterValue -> CounterValue -> Bool
$c/= :: CounterValue -> CounterValue -> Bool
/= :: CounterValue -> CounterValue -> Bool
Eq)
instance SP.ManagedPtrNewtype CounterValue where
toManagedPtr :: CounterValue -> ManagedPtr CounterValue
toManagedPtr (CounterValue ManagedPtr CounterValue
p) = ManagedPtr CounterValue
p
instance BoxedPtr CounterValue where
boxedPtrCopy :: CounterValue -> IO CounterValue
boxedPtrCopy = \CounterValue
p -> CounterValue
-> (Ptr CounterValue -> IO CounterValue) -> IO CounterValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr CounterValue
p (Int -> Ptr CounterValue -> IO (Ptr CounterValue)
forall a. (HasCallStack, CallocPtr a) => Int -> Ptr a -> IO (Ptr a)
copyBytes Int
64 (Ptr CounterValue -> IO (Ptr CounterValue))
-> (Ptr CounterValue -> IO CounterValue)
-> Ptr CounterValue
-> IO CounterValue
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr CounterValue -> CounterValue)
-> Ptr CounterValue -> IO CounterValue
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.wrapPtr ManagedPtr CounterValue -> CounterValue
CounterValue)
boxedPtrFree :: CounterValue -> IO ()
boxedPtrFree = \CounterValue
x -> CounterValue -> (Ptr CounterValue -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
SP.withManagedPtr CounterValue
x Ptr CounterValue -> IO ()
forall a. Ptr a -> IO ()
SP.freeMem
instance CallocPtr CounterValue where
boxedPtrCalloc :: IO (Ptr CounterValue)
boxedPtrCalloc = Int -> IO (Ptr CounterValue)
forall a. Int -> IO (Ptr a)
callocBytes Int
64
newZeroCounterValue :: MonadIO m => m CounterValue
newZeroCounterValue :: forall (m :: * -> *). MonadIO m => m CounterValue
newZeroCounterValue = IO CounterValue -> m CounterValue
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CounterValue -> m CounterValue)
-> IO CounterValue -> m CounterValue
forall a b. (a -> b) -> a -> b
$ IO (Ptr CounterValue)
forall a. CallocPtr a => IO (Ptr a)
boxedPtrCalloc IO (Ptr CounterValue)
-> (Ptr CounterValue -> IO CounterValue) -> IO CounterValue
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr CounterValue -> CounterValue)
-> Ptr CounterValue -> IO CounterValue
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr CounterValue -> CounterValue
CounterValue
instance tag ~ 'AttrSet => Constructible CounterValue tag where
new :: forall (m :: * -> *).
MonadIO m =>
(ManagedPtr CounterValue -> CounterValue)
-> [AttrOp CounterValue tag] -> m CounterValue
new ManagedPtr CounterValue -> CounterValue
_ [AttrOp CounterValue tag]
attrs = do
CounterValue
o <- m CounterValue
forall (m :: * -> *). MonadIO m => m CounterValue
newZeroCounterValue
CounterValue -> [AttrOp CounterValue 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set CounterValue
o [AttrOp CounterValue tag]
[AttrOp CounterValue 'AttrSet]
attrs
CounterValue -> m CounterValue
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return CounterValue
o
getCounterValueValue :: MonadIO m => CounterValue -> m Int64
getCounterValueValue :: forall (m :: * -> *). MonadIO m => CounterValue -> m Int64
getCounterValueValue CounterValue
s = IO Int64 -> m Int64
forall a. IO a -> m a
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
$ CounterValue -> (Ptr CounterValue -> IO Int64) -> IO Int64
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr CounterValue
s ((Ptr CounterValue -> IO Int64) -> IO Int64)
-> (Ptr CounterValue -> IO Int64) -> IO Int64
forall a b. (a -> b) -> a -> b
$ \Ptr CounterValue
ptr -> do
Int64
val <- Ptr Int64 -> IO Int64
forall a. Storable a => Ptr a -> IO a
peek (Ptr CounterValue
ptr Ptr CounterValue -> Int -> Ptr Int64
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) :: IO Int64
Int64 -> IO Int64
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
val
setCounterValueValue :: MonadIO m => CounterValue -> Int64 -> m ()
setCounterValueValue :: forall (m :: * -> *). MonadIO m => CounterValue -> Int64 -> m ()
setCounterValueValue CounterValue
s Int64
val = 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
$ CounterValue -> (Ptr CounterValue -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr CounterValue
s ((Ptr CounterValue -> IO ()) -> IO ())
-> (Ptr CounterValue -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr CounterValue
ptr -> do
Ptr Int64 -> Int64 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr CounterValue
ptr Ptr CounterValue -> Int -> Ptr Int64
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) (Int64
val :: Int64)
#if defined(ENABLE_OVERLOADING)
data CounterValueValueFieldInfo
instance AttrInfo CounterValueValueFieldInfo where
type AttrBaseTypeConstraint CounterValueValueFieldInfo = (~) CounterValue
type AttrAllowedOps CounterValueValueFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint CounterValueValueFieldInfo = (~) Int64
type AttrTransferTypeConstraint CounterValueValueFieldInfo = (~)Int64
type AttrTransferType CounterValueValueFieldInfo = Int64
type AttrGetType CounterValueValueFieldInfo = Int64
type AttrLabel CounterValueValueFieldInfo = "value"
type AttrOrigin CounterValueValueFieldInfo = CounterValue
attrGet = getCounterValueValue
attrSet = setCounterValueValue
attrConstruct = undefined
attrClear = undefined
attrTransfer _ v = do
return v
dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Dazzle.Structs.CounterValue.value"
, O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-dazzle-1.0.2/docs/GI-Dazzle-Structs-CounterValue.html#g:attr:value"
})
counterValue_value :: AttrLabelProxy "value"
counterValue_value = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList CounterValue
type instance O.AttributeList CounterValue = CounterValueAttributeList
type CounterValueAttributeList = ('[ '("value", CounterValueValueFieldInfo)] :: [(Symbol, DK.Type)])
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveCounterValueMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolveCounterValueMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveCounterValueMethod t CounterValue, O.OverloadedMethod info CounterValue p) => OL.IsLabel t (CounterValue -> 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 ~ ResolveCounterValueMethod t CounterValue, O.OverloadedMethod info CounterValue p, R.HasField t CounterValue p) => R.HasField t CounterValue p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveCounterValueMethod t CounterValue, O.OverloadedMethodInfo info CounterValue) => OL.IsLabel t (O.MethodProxy info CounterValue) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif