packages feed

gi-gobject-0.2.46.13: GI/GObject/Structs/FlagsValue.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 flags value, its name, and its
nickname.
-}

module GI.GObject.Structs.FlagsValue
    ( 

-- * Exported types
    FlagsValue(..)                          ,
    newZeroFlagsValue                       ,
    noFlagsValue                            ,


 -- * Properties
-- ** Value
    flagsValueReadValue                     ,


-- ** ValueName
    flagsValueReadValueName                 ,


-- ** ValueNick
    flagsValueReadValueNick                 ,




    ) 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 FlagsValue = FlagsValue (ForeignPtr FlagsValue)
-- | Construct a `FlagsValue` struct initialized to zero.
newZeroFlagsValue :: MonadIO m => m FlagsValue
newZeroFlagsValue = liftIO $ callocBytes 24 >>= wrapPtr FlagsValue

noFlagsValue :: Maybe FlagsValue
noFlagsValue = Nothing

flagsValueReadValue :: FlagsValue -> IO Word32
flagsValueReadValue s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO Word32
    return val

flagsValueReadValueName :: FlagsValue -> IO T.Text
flagsValueReadValueName s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO CString
    val' <- cstringToText val
    return val'

flagsValueReadValueNick :: FlagsValue -> IO T.Text
flagsValueReadValueNick s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO CString
    val' <- cstringToText val
    return val'

type family ResolveFlagsValueMethod (t :: Symbol) (o :: *) :: * where
    ResolveFlagsValueMethod l o = MethodResolutionFailed l o

instance (info ~ ResolveFlagsValueMethod t FlagsValue, MethodInfo info FlagsValue p) => IsLabelProxy t (FlagsValue -> p) where
    fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveFlagsValueMethod t FlagsValue, MethodInfo info FlagsValue p) => IsLabel t (FlagsValue -> p) where
    fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif