gi-ggit-1.0.4: GI/Ggit/Objects/Native.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)
Represents a generic native object.
-}
#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Ggit.Objects.Native
(
-- * Exported types
Native(..) ,
IsNative ,
toNative ,
noNative ,
-- * Properties
-- ** native #attr:native#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
NativeNativePropertyInfo ,
#endif
constructNativeNative ,
#if ENABLE_OVERLOADING
nativeNative ,
#endif
) 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.GClosure as B.GClosure
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.GI.Base.Properties as B.Properties
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
import qualified GHC.OverloadedLabels as OL
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Ggit.Objects.ObjectFactoryBase as Ggit.ObjectFactoryBase
-- | Memory-managed wrapper type.
newtype Native = Native (ManagedPtr Native)
foreign import ccall "ggit_native_get_type"
c_ggit_native_get_type :: IO GType
instance GObject Native where
gobjectType = c_ggit_native_get_type
-- | Type class for types which can be safely cast to `Native`, for instance with `toNative`.
class (GObject o, O.IsDescendantOf Native o) => IsNative o
instance (GObject o, O.IsDescendantOf Native o) => IsNative o
instance O.HasParentTypes Native
type instance O.ParentTypes Native = '[Ggit.ObjectFactoryBase.ObjectFactoryBase, GObject.Object.Object]
-- | Cast to `Native`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toNative :: (MonadIO m, IsNative o) => o -> m Native
toNative = liftIO . unsafeCastTo Native
-- | A convenience alias for `Nothing` :: `Maybe` `Native`.
noNative :: Maybe Native
noNative = Nothing
#if ENABLE_OVERLOADING
type family ResolveNativeMethod (t :: Symbol) (o :: *) :: * where
ResolveNativeMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveNativeMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveNativeMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveNativeMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveNativeMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveNativeMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveNativeMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveNativeMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveNativeMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveNativeMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveNativeMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveNativeMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveNativeMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveNativeMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveNativeMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveNativeMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveNativeMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveNativeMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveNativeMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveNativeMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveNativeMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveNativeMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveNativeMethod t Native, O.MethodInfo info Native p) => OL.IsLabel t (Native -> 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
-- VVV Prop "native"
-- Type: TBasicType TPtr
-- Flags: [PropertyWritable,PropertyConstructOnly]
-- Nullable: (Nothing,Nothing)
{- |
Construct a `GValueConstruct` with valid value for the “@native@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructNativeNative :: (IsNative o) => Ptr () -> IO (GValueConstruct o)
constructNativeNative val = B.Properties.constructObjectPropertyPtr "native" val
#if ENABLE_OVERLOADING
data NativeNativePropertyInfo
instance AttrInfo NativeNativePropertyInfo where
type AttrAllowedOps NativeNativePropertyInfo = '[ 'AttrConstruct]
type AttrSetTypeConstraint NativeNativePropertyInfo = (~) (Ptr ())
type AttrBaseTypeConstraint NativeNativePropertyInfo = IsNative
type AttrGetType NativeNativePropertyInfo = ()
type AttrLabel NativeNativePropertyInfo = "native"
type AttrOrigin NativeNativePropertyInfo = Native
attrGet _ = undefined
attrSet _ = undefined
attrConstruct _ = constructNativeNative
attrClear _ = undefined
#endif
#if ENABLE_OVERLOADING
instance O.HasAttributeList Native
type instance O.AttributeList Native = NativeAttributeList
type NativeAttributeList = ('[ '("native", NativeNativePropertyInfo)] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
nativeNative :: AttrLabelProxy "native"
nativeNative = AttrLabelProxy
#endif
#if ENABLE_OVERLOADING
type instance O.SignalList Native = NativeSignalList
type NativeSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif