{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GObject.Structs.EnumValue
(
EnumValue(..) ,
newZeroEnumValue ,
noEnumValue ,
#if defined(ENABLE_OVERLOADING)
ResolveEnumValueMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
enumValue_value ,
#endif
getEnumValueValue ,
setEnumValueValue ,
clearEnumValueValueName ,
#if defined(ENABLE_OVERLOADING)
enumValue_valueName ,
#endif
getEnumValueValueName ,
setEnumValueValueName ,
clearEnumValueValueNick ,
#if defined(ENABLE_OVERLOADING)
enumValue_valueNick ,
#endif
getEnumValueValueNick ,
setEnumValueValueNick ,
) 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.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 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
newtype EnumValue = EnumValue (ManagedPtr EnumValue)
deriving (EnumValue -> EnumValue -> Bool
(EnumValue -> EnumValue -> Bool)
-> (EnumValue -> EnumValue -> Bool) -> Eq EnumValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnumValue -> EnumValue -> Bool
$c/= :: EnumValue -> EnumValue -> Bool
== :: EnumValue -> EnumValue -> Bool
$c== :: EnumValue -> EnumValue -> Bool
Eq)
instance WrappedPtr EnumValue where
wrappedPtrCalloc :: IO (Ptr EnumValue)
wrappedPtrCalloc = Int -> IO (Ptr EnumValue)
forall a. Int -> IO (Ptr a)
callocBytes 24
wrappedPtrCopy :: EnumValue -> IO EnumValue
wrappedPtrCopy = \p :: EnumValue
p -> EnumValue -> (Ptr EnumValue -> IO EnumValue) -> IO EnumValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EnumValue
p (Int -> Ptr EnumValue -> IO (Ptr EnumValue)
forall a. WrappedPtr a => Int -> Ptr a -> IO (Ptr a)
copyBytes 24 (Ptr EnumValue -> IO (Ptr EnumValue))
-> (Ptr EnumValue -> IO EnumValue) -> Ptr EnumValue -> IO EnumValue
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr EnumValue -> EnumValue)
-> Ptr EnumValue -> IO EnumValue
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr EnumValue -> EnumValue
EnumValue)
wrappedPtrFree :: Maybe (GDestroyNotify EnumValue)
wrappedPtrFree = GDestroyNotify EnumValue -> Maybe (GDestroyNotify EnumValue)
forall a. a -> Maybe a
Just GDestroyNotify EnumValue
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free
newZeroEnumValue :: MonadIO m => m EnumValue
newZeroEnumValue :: m EnumValue
newZeroEnumValue = IO EnumValue -> m EnumValue
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO EnumValue -> m EnumValue) -> IO EnumValue -> m EnumValue
forall a b. (a -> b) -> a -> b
$ IO (Ptr EnumValue)
forall a. WrappedPtr a => IO (Ptr a)
wrappedPtrCalloc IO (Ptr EnumValue)
-> (Ptr EnumValue -> IO EnumValue) -> IO EnumValue
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr EnumValue -> EnumValue)
-> Ptr EnumValue -> IO EnumValue
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr EnumValue -> EnumValue
EnumValue
instance tag ~ 'AttrSet => Constructible EnumValue tag where
new :: (ManagedPtr EnumValue -> EnumValue)
-> [AttrOp EnumValue tag] -> m EnumValue
new _ attrs :: [AttrOp EnumValue tag]
attrs = do
EnumValue
o <- m EnumValue
forall (m :: * -> *). MonadIO m => m EnumValue
newZeroEnumValue
EnumValue -> [AttrOp EnumValue 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set EnumValue
o [AttrOp EnumValue tag]
[AttrOp EnumValue 'AttrSet]
attrs
EnumValue -> m EnumValue
forall (m :: * -> *) a. Monad m => a -> m a
return EnumValue
o
noEnumValue :: Maybe EnumValue
noEnumValue :: Maybe EnumValue
noEnumValue = Maybe EnumValue
forall a. Maybe a
Nothing
getEnumValueValue :: MonadIO m => EnumValue -> m Int32
getEnumValueValue :: EnumValue -> m Int32
getEnumValueValue s :: EnumValue
s = IO Int32 -> m Int32
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
$ EnumValue -> (Ptr EnumValue -> IO Int32) -> IO Int32
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EnumValue
s ((Ptr EnumValue -> IO Int32) -> IO Int32)
-> (Ptr EnumValue -> IO Int32) -> IO Int32
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr EnumValue
ptr -> do
Int32
val <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek (Ptr EnumValue
ptr Ptr EnumValue -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) :: IO Int32
Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
val
setEnumValueValue :: MonadIO m => EnumValue -> Int32 -> m ()
setEnumValueValue :: EnumValue -> Int32 -> m ()
setEnumValueValue s :: EnumValue
s val :: Int32
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ EnumValue -> (Ptr EnumValue -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EnumValue
s ((Ptr EnumValue -> IO ()) -> IO ())
-> (Ptr EnumValue -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr EnumValue
ptr -> do
Ptr Int32 -> Int32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr EnumValue
ptr Ptr EnumValue -> Int -> Ptr Int32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) (Int32
val :: Int32)
#if defined(ENABLE_OVERLOADING)
data EnumValueValueFieldInfo
instance AttrInfo EnumValueValueFieldInfo where
type AttrBaseTypeConstraint EnumValueValueFieldInfo = (~) EnumValue
type AttrAllowedOps EnumValueValueFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint EnumValueValueFieldInfo = (~) Int32
type AttrTransferTypeConstraint EnumValueValueFieldInfo = (~)Int32
type AttrTransferType EnumValueValueFieldInfo = Int32
type AttrGetType EnumValueValueFieldInfo = Int32
type AttrLabel EnumValueValueFieldInfo = "value"
type AttrOrigin EnumValueValueFieldInfo = EnumValue
attrGet = getEnumValueValue
attrSet = setEnumValueValue
attrConstruct = undefined
attrClear = undefined
attrTransfer _ v = do
return v
enumValue_value :: AttrLabelProxy "value"
enumValue_value = AttrLabelProxy
#endif
getEnumValueValueName :: MonadIO m => EnumValue -> m (Maybe T.Text)
getEnumValueValueName :: EnumValue -> m (Maybe Text)
getEnumValueValueName s :: EnumValue
s = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ EnumValue -> (Ptr EnumValue -> IO (Maybe Text)) -> IO (Maybe Text)
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EnumValue
s ((Ptr EnumValue -> IO (Maybe Text)) -> IO (Maybe Text))
-> (Ptr EnumValue -> IO (Maybe Text)) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr EnumValue
ptr -> do
CString
val <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek (Ptr EnumValue
ptr Ptr EnumValue -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8) :: IO CString
Maybe Text
result <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
SP.convertIfNonNull CString
val ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \val' :: CString
val' -> do
Text
val'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
val'
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
val''
Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
result
setEnumValueValueName :: MonadIO m => EnumValue -> CString -> m ()
setEnumValueValueName :: EnumValue -> CString -> m ()
setEnumValueValueName s :: EnumValue
s val :: CString
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ EnumValue -> (Ptr EnumValue -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EnumValue
s ((Ptr EnumValue -> IO ()) -> IO ())
-> (Ptr EnumValue -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr EnumValue
ptr -> do
Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr EnumValue
ptr Ptr EnumValue -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8) (CString
val :: CString)
clearEnumValueValueName :: MonadIO m => EnumValue -> m ()
clearEnumValueValueName :: EnumValue -> m ()
clearEnumValueValueName s :: EnumValue
s = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ EnumValue -> (Ptr EnumValue -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EnumValue
s ((Ptr EnumValue -> IO ()) -> IO ())
-> (Ptr EnumValue -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr EnumValue
ptr -> do
Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr EnumValue
ptr Ptr EnumValue -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8) (CString
forall a. Ptr a
FP.nullPtr :: CString)
#if defined(ENABLE_OVERLOADING)
data EnumValueValueNameFieldInfo
instance AttrInfo EnumValueValueNameFieldInfo where
type AttrBaseTypeConstraint EnumValueValueNameFieldInfo = (~) EnumValue
type AttrAllowedOps EnumValueValueNameFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint EnumValueValueNameFieldInfo = (~) CString
type AttrTransferTypeConstraint EnumValueValueNameFieldInfo = (~)CString
type AttrTransferType EnumValueValueNameFieldInfo = CString
type AttrGetType EnumValueValueNameFieldInfo = Maybe T.Text
type AttrLabel EnumValueValueNameFieldInfo = "value_name"
type AttrOrigin EnumValueValueNameFieldInfo = EnumValue
attrGet = getEnumValueValueName
attrSet = setEnumValueValueName
attrConstruct = undefined
attrClear = clearEnumValueValueName
attrTransfer _ v = do
return v
enumValue_valueName :: AttrLabelProxy "valueName"
enumValue_valueName = AttrLabelProxy
#endif
getEnumValueValueNick :: MonadIO m => EnumValue -> m (Maybe T.Text)
getEnumValueValueNick :: EnumValue -> m (Maybe Text)
getEnumValueValueNick s :: EnumValue
s = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ EnumValue -> (Ptr EnumValue -> IO (Maybe Text)) -> IO (Maybe Text)
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EnumValue
s ((Ptr EnumValue -> IO (Maybe Text)) -> IO (Maybe Text))
-> (Ptr EnumValue -> IO (Maybe Text)) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr EnumValue
ptr -> do
CString
val <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek (Ptr EnumValue
ptr Ptr EnumValue -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16) :: IO CString
Maybe Text
result <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
SP.convertIfNonNull CString
val ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \val' :: CString
val' -> do
Text
val'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
val'
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
val''
Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
result
setEnumValueValueNick :: MonadIO m => EnumValue -> CString -> m ()
setEnumValueValueNick :: EnumValue -> CString -> m ()
setEnumValueValueNick s :: EnumValue
s val :: CString
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ EnumValue -> (Ptr EnumValue -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EnumValue
s ((Ptr EnumValue -> IO ()) -> IO ())
-> (Ptr EnumValue -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr EnumValue
ptr -> do
Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr EnumValue
ptr Ptr EnumValue -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16) (CString
val :: CString)
clearEnumValueValueNick :: MonadIO m => EnumValue -> m ()
clearEnumValueValueNick :: EnumValue -> m ()
clearEnumValueValueNick s :: EnumValue
s = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ EnumValue -> (Ptr EnumValue -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr EnumValue
s ((Ptr EnumValue -> IO ()) -> IO ())
-> (Ptr EnumValue -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr EnumValue
ptr -> do
Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr EnumValue
ptr Ptr EnumValue -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16) (CString
forall a. Ptr a
FP.nullPtr :: CString)
#if defined(ENABLE_OVERLOADING)
data EnumValueValueNickFieldInfo
instance AttrInfo EnumValueValueNickFieldInfo where
type AttrBaseTypeConstraint EnumValueValueNickFieldInfo = (~) EnumValue
type AttrAllowedOps EnumValueValueNickFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint EnumValueValueNickFieldInfo = (~) CString
type AttrTransferTypeConstraint EnumValueValueNickFieldInfo = (~)CString
type AttrTransferType EnumValueValueNickFieldInfo = CString
type AttrGetType EnumValueValueNickFieldInfo = Maybe T.Text
type AttrLabel EnumValueValueNickFieldInfo = "value_nick"
type AttrOrigin EnumValueValueNickFieldInfo = EnumValue
attrGet = getEnumValueValueNick
attrSet = setEnumValueValueNick
attrConstruct = undefined
attrClear = clearEnumValueValueNick
attrTransfer _ v = do
return v
enumValue_valueNick :: AttrLabelProxy "valueNick"
enumValue_valueNick = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList EnumValue
type instance O.AttributeList EnumValue = EnumValueAttributeList
type EnumValueAttributeList = ('[ '("value", EnumValueValueFieldInfo), '("valueName", EnumValueValueNameFieldInfo), '("valueNick", EnumValueValueNickFieldInfo)] :: [(Symbol, *)])
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveEnumValueMethod (t :: Symbol) (o :: *) :: * where
ResolveEnumValueMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveEnumValueMethod t EnumValue, O.MethodInfo info EnumValue p) => OL.IsLabel t (EnumValue -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif