gi-gobject-0.2.46.13: GI/GObject/Structs/EnumValue.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
A structure which contains a single enum value, its name, and its
nickname.
-}
module GI.GObject.Structs.EnumValue
(
-- * Exported types
EnumValue(..) ,
newZeroEnumValue ,
noEnumValue ,
-- * Properties
-- ** Value
enumValueReadValue ,
-- ** ValueName
enumValueReadValueName ,
-- ** ValueNick
enumValueReadValueNick ,
) where
import Prelude ()
import Data.GI.Base.ShortPrelude
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import GI.GObject.Types
import GI.GObject.Callbacks
newtype EnumValue = EnumValue (ForeignPtr EnumValue)
-- | Construct a `EnumValue` struct initialized to zero.
newZeroEnumValue :: MonadIO m => m EnumValue
newZeroEnumValue = liftIO $ callocBytes 24 >>= wrapPtr EnumValue
noEnumValue :: Maybe EnumValue
noEnumValue = Nothing
enumValueReadValue :: EnumValue -> IO Int32
enumValueReadValue s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO Int32
return val
enumValueReadValueName :: EnumValue -> IO T.Text
enumValueReadValueName s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 8) :: IO CString
val' <- cstringToText val
return val'
enumValueReadValueNick :: EnumValue -> IO T.Text
enumValueReadValueNick s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 16) :: IO CString
val' <- cstringToText val
return val'
type family ResolveEnumValueMethod (t :: Symbol) (o :: *) :: * where
ResolveEnumValueMethod l o = MethodResolutionFailed l o
instance (info ~ ResolveEnumValueMethod t EnumValue, MethodInfo info EnumValue p) => IsLabelProxy t (EnumValue -> p) where
fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveEnumValueMethod t EnumValue, MethodInfo info EnumValue p) => IsLabel t (EnumValue -> p) where
fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif