#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Gtk.Structs.BindingArg
(
BindingArg(..) ,
newZeroBindingArg ,
noBindingArg ,
#if ENABLE_OVERLOADING
bindingArg_argType ,
#endif
getBindingArgArgType ,
setBindingArgArgType ,
) 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 BindingArg = BindingArg (ManagedPtr BindingArg)
instance WrappedPtr BindingArg where
wrappedPtrCalloc = callocBytes 8
wrappedPtrCopy = \p -> withManagedPtr p (copyBytes 8 >=> wrapPtr BindingArg)
wrappedPtrFree = Just ptr_to_g_free
newZeroBindingArg :: MonadIO m => m BindingArg
newZeroBindingArg = liftIO $ wrappedPtrCalloc >>= wrapPtr BindingArg
instance tag ~ 'AttrSet => Constructible BindingArg tag where
new _ attrs = do
o <- newZeroBindingArg
GI.Attributes.set o attrs
return o
noBindingArg :: Maybe BindingArg
noBindingArg = Nothing
getBindingArgArgType :: MonadIO m => BindingArg -> m GType
getBindingArgArgType s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO CGType
let val' = GType val
return val'
setBindingArgArgType :: MonadIO m => BindingArg -> GType -> m ()
setBindingArgArgType s val = liftIO $ withManagedPtr s $ \ptr -> do
let val' = gtypeToCGType val
poke (ptr `plusPtr` 0) (val' :: CGType)
#if ENABLE_OVERLOADING
data BindingArgArgTypeFieldInfo
instance AttrInfo BindingArgArgTypeFieldInfo where
type AttrAllowedOps BindingArgArgTypeFieldInfo = '[ 'AttrSet, 'AttrGet]
type AttrSetTypeConstraint BindingArgArgTypeFieldInfo = (~) GType
type AttrBaseTypeConstraint BindingArgArgTypeFieldInfo = (~) BindingArg
type AttrGetType BindingArgArgTypeFieldInfo = GType
type AttrLabel BindingArgArgTypeFieldInfo = "arg_type"
type AttrOrigin BindingArgArgTypeFieldInfo = BindingArg
attrGet _ = getBindingArgArgType
attrSet _ = setBindingArgArgType
attrConstruct = undefined
attrClear _ = undefined
bindingArg_argType :: AttrLabelProxy "argType"
bindingArg_argType = AttrLabelProxy
#endif
#if ENABLE_OVERLOADING
instance O.HasAttributeList BindingArg
type instance O.AttributeList BindingArg = BindingArgAttributeList
type BindingArgAttributeList = ('[ '("argType", BindingArgArgTypeFieldInfo)] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
type family ResolveBindingArgMethod (t :: Symbol) (o :: *) :: * where
ResolveBindingArgMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveBindingArgMethod t BindingArg, O.MethodInfo info BindingArg p) => O.IsLabelProxy t (BindingArg -> p) where
fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveBindingArgMethod t BindingArg, O.MethodInfo info BindingArg p) => O.IsLabel t (BindingArg -> 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