#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.GObject.Structs.EnumValue
(
EnumValue(..) ,
newZeroEnumValue ,
noEnumValue ,
#if ENABLE_OVERLOADING
enumValue_value ,
#endif
getEnumValueValue ,
setEnumValueValue ,
clearEnumValueValueName ,
#if ENABLE_OVERLOADING
enumValue_valueName ,
#endif
getEnumValueValueName ,
setEnumValueValueName ,
clearEnumValueValueNick ,
#if 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.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.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
newtype EnumValue = EnumValue (ManagedPtr EnumValue)
instance WrappedPtr EnumValue where
wrappedPtrCalloc = callocBytes 24
wrappedPtrCopy = \p -> withManagedPtr p (copyBytes 24 >=> wrapPtr EnumValue)
wrappedPtrFree = Just ptr_to_g_free
newZeroEnumValue :: MonadIO m => m EnumValue
newZeroEnumValue = liftIO $ wrappedPtrCalloc >>= wrapPtr EnumValue
instance tag ~ 'AttrSet => Constructible EnumValue tag where
new _ attrs = do
o <- newZeroEnumValue
GI.Attributes.set o attrs
return o
noEnumValue :: Maybe EnumValue
noEnumValue = Nothing
getEnumValueValue :: MonadIO m => EnumValue -> m Int32
getEnumValueValue s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO Int32
return val
setEnumValueValue :: MonadIO m => EnumValue -> Int32 -> m ()
setEnumValueValue s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 0) (val :: Int32)
#if ENABLE_OVERLOADING
data EnumValueValueFieldInfo
instance AttrInfo EnumValueValueFieldInfo where
type AttrAllowedOps EnumValueValueFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint EnumValueValueFieldInfo = (~) Int32
type AttrBaseTypeConstraint EnumValueValueFieldInfo = (~) EnumValue
type AttrGetType EnumValueValueFieldInfo = Int32
type AttrLabel EnumValueValueFieldInfo = "value"
type AttrOrigin EnumValueValueFieldInfo = EnumValue
attrGet _ = getEnumValueValue
attrSet _ = setEnumValueValue
attrConstruct = undefined
attrClear _ = undefined
enumValue_value :: AttrLabelProxy "value"
enumValue_value = AttrLabelProxy
#endif
getEnumValueValueName :: MonadIO m => EnumValue -> m (Maybe T.Text)
getEnumValueValueName s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 8) :: IO CString
result <- SP.convertIfNonNull val $ \val' -> do
val'' <- cstringToText val'
return val''
return result
setEnumValueValueName :: MonadIO m => EnumValue -> CString -> m ()
setEnumValueValueName s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 8) (val :: CString)
clearEnumValueValueName :: MonadIO m => EnumValue -> m ()
clearEnumValueValueName s = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 8) (FP.nullPtr :: CString)
#if ENABLE_OVERLOADING
data EnumValueValueNameFieldInfo
instance AttrInfo EnumValueValueNameFieldInfo where
type AttrAllowedOps EnumValueValueNameFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint EnumValueValueNameFieldInfo = (~) CString
type AttrBaseTypeConstraint EnumValueValueNameFieldInfo = (~) EnumValue
type AttrGetType EnumValueValueNameFieldInfo = Maybe T.Text
type AttrLabel EnumValueValueNameFieldInfo = "value_name"
type AttrOrigin EnumValueValueNameFieldInfo = EnumValue
attrGet _ = getEnumValueValueName
attrSet _ = setEnumValueValueName
attrConstruct = undefined
attrClear _ = clearEnumValueValueName
enumValue_valueName :: AttrLabelProxy "valueName"
enumValue_valueName = AttrLabelProxy
#endif
getEnumValueValueNick :: MonadIO m => EnumValue -> m (Maybe T.Text)
getEnumValueValueNick s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 16) :: IO CString
result <- SP.convertIfNonNull val $ \val' -> do
val'' <- cstringToText val'
return val''
return result
setEnumValueValueNick :: MonadIO m => EnumValue -> CString -> m ()
setEnumValueValueNick s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 16) (val :: CString)
clearEnumValueValueNick :: MonadIO m => EnumValue -> m ()
clearEnumValueValueNick s = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 16) (FP.nullPtr :: CString)
#if ENABLE_OVERLOADING
data EnumValueValueNickFieldInfo
instance AttrInfo EnumValueValueNickFieldInfo where
type AttrAllowedOps EnumValueValueNickFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint EnumValueValueNickFieldInfo = (~) CString
type AttrBaseTypeConstraint EnumValueValueNickFieldInfo = (~) EnumValue
type AttrGetType EnumValueValueNickFieldInfo = Maybe T.Text
type AttrLabel EnumValueValueNickFieldInfo = "value_nick"
type AttrOrigin EnumValueValueNickFieldInfo = EnumValue
attrGet _ = getEnumValueValueNick
attrSet _ = setEnumValueValueNick
attrConstruct = undefined
attrClear _ = clearEnumValueValueNick
enumValue_valueNick :: AttrLabelProxy "valueNick"
enumValue_valueNick = AttrLabelProxy
#endif
#if ENABLE_OVERLOADING
instance O.HasAttributeList EnumValue
type instance O.AttributeList EnumValue = EnumValueAttributeList
type EnumValueAttributeList = ('[ '("value", EnumValueValueFieldInfo), '("valueName", EnumValueValueNameFieldInfo), '("valueNick", EnumValueValueNickFieldInfo)] :: [(Symbol, *)])
#endif
#if 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) => O.IsLabelProxy t (EnumValue -> p) where
fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveEnumValueMethod t EnumValue, O.MethodInfo info EnumValue p) => O.IsLabel t (EnumValue -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif
#endif