packages feed

gi-gobject-0.2.46.13: GI/GObject/Structs/ObjectConstructParam.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)

The GObjectConstructParam struct is an auxiliary
structure used to hand #GParamSpec/#GValue pairs to the @constructor of
a #GObjectClass.
-}

module GI.GObject.Structs.ObjectConstructParam
    ( 

-- * Exported types
    ObjectConstructParam(..)                ,
    newZeroObjectConstructParam             ,
    noObjectConstructParam                  ,


 -- * Properties
-- ** Pspec
    objectConstructParamReadPspec           ,


-- ** Value
    objectConstructParamReadValue           ,




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

noObjectConstructParam :: Maybe ObjectConstructParam
noObjectConstructParam = Nothing

objectConstructParamReadPspec :: ObjectConstructParam -> IO GParamSpec
objectConstructParamReadPspec s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO (Ptr GParamSpec)
    val' <- newGParamSpecFromPtr val
    return val'

objectConstructParamReadValue :: ObjectConstructParam -> IO GValue
objectConstructParamReadValue s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO (Ptr GValue)
    val' <- (newBoxed GValue) val
    return val'

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

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

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