{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) An opaque structure used as the base of all type instances. -} module GI.GObject.Structs.TypeInstance ( -- * Exported types TypeInstance(..) , newZeroTypeInstance , noTypeInstance , ) where import Data.GI.Base.ShortPrelude import qualified Data.GI.Base.Attributes as GI.Attributes 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 TypeInstance = TypeInstance (ForeignPtr TypeInstance) -- | Construct a `TypeInstance` struct initialized to zero. newZeroTypeInstance :: MonadIO m => m TypeInstance newZeroTypeInstance = liftIO $ callocBytes 8 >>= wrapPtr TypeInstance instance tag ~ 'AttrSet => Constructible TypeInstance tag where new _ attrs = do o <- newZeroTypeInstance GI.Attributes.set o attrs return o noTypeInstance :: Maybe TypeInstance noTypeInstance = Nothing type instance AttributeList TypeInstance = TypeInstanceAttributeList type TypeInstanceAttributeList = ('[ ] :: [(Symbol, *)]) type family ResolveTypeInstanceMethod (t :: Symbol) (o :: *) :: * where ResolveTypeInstanceMethod l o = MethodResolutionFailed l o instance (info ~ ResolveTypeInstanceMethod t TypeInstance, MethodInfo info TypeInstance p) => IsLabelProxy t (TypeInstance -> p) where fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info) #if MIN_VERSION_base(4,9,0) instance (info ~ ResolveTypeInstanceMethod t TypeInstance, MethodInfo info TypeInstance p) => IsLabel t (TypeInstance -> p) where fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info) #endif