packages feed

gi-glib-0.2.46.13: GI/GLib/Structs/DebugKey.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)

Associates a string with a bit flag.
Used in g_parse_debug_string().
-}

module GI.GLib.Structs.DebugKey
    ( 

-- * Exported types
    DebugKey(..)                            ,
    newZeroDebugKey                         ,
    noDebugKey                              ,


 -- * Properties
-- ** Key
    debugKeyReadKey                         ,


-- ** Value
    debugKeyReadValue                       ,




    ) 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.GLib.Types
import GI.GLib.Callbacks

newtype DebugKey = DebugKey (ForeignPtr DebugKey)
-- | Construct a `DebugKey` struct initialized to zero.
newZeroDebugKey :: MonadIO m => m DebugKey
newZeroDebugKey = liftIO $ callocBytes 16 >>= wrapPtr DebugKey

noDebugKey :: Maybe DebugKey
noDebugKey = Nothing

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

debugKeyReadValue :: DebugKey -> IO Word32
debugKeyReadValue s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO Word32
    return val

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

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

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