{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GObject.Structs.TypeClass
(
TypeClass(..) ,
newZeroTypeClass ,
noTypeClass ,
#if defined(ENABLE_OVERLOADING)
ResolveTypeClassMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
TypeClassAddPrivateMethodInfo ,
#endif
typeClassAddPrivate ,
typeClassAdjustPrivateOffset ,
#if defined(ENABLE_OVERLOADING)
TypeClassGetPrivateMethodInfo ,
#endif
typeClassGetPrivate ,
typeClassPeek ,
#if defined(ENABLE_OVERLOADING)
TypeClassPeekParentMethodInfo ,
#endif
typeClassPeekParent ,
typeClassPeekStatic ,
typeClassRef ,
#if defined(ENABLE_OVERLOADING)
TypeClassUnrefMethodInfo ,
#endif
typeClassUnref ,
) 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.GI.Base.Signals as B.Signals
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
newtype TypeClass = TypeClass (ManagedPtr TypeClass)
deriving (TypeClass -> TypeClass -> Bool
(TypeClass -> TypeClass -> Bool)
-> (TypeClass -> TypeClass -> Bool) -> Eq TypeClass
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TypeClass -> TypeClass -> Bool
$c/= :: TypeClass -> TypeClass -> Bool
== :: TypeClass -> TypeClass -> Bool
$c== :: TypeClass -> TypeClass -> Bool
Eq)
instance WrappedPtr TypeClass where
wrappedPtrCalloc :: IO (Ptr TypeClass)
wrappedPtrCalloc = Int -> IO (Ptr TypeClass)
forall a. Int -> IO (Ptr a)
callocBytes 8
wrappedPtrCopy :: TypeClass -> IO TypeClass
wrappedPtrCopy = \p :: TypeClass
p -> TypeClass -> (Ptr TypeClass -> IO TypeClass) -> IO TypeClass
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TypeClass
p (Int -> Ptr TypeClass -> IO (Ptr TypeClass)
forall a. WrappedPtr a => Int -> Ptr a -> IO (Ptr a)
copyBytes 8 (Ptr TypeClass -> IO (Ptr TypeClass))
-> (Ptr TypeClass -> IO TypeClass) -> Ptr TypeClass -> IO TypeClass
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr TypeClass -> TypeClass)
-> Ptr TypeClass -> IO TypeClass
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr TypeClass -> TypeClass
TypeClass)
wrappedPtrFree :: Maybe (GDestroyNotify TypeClass)
wrappedPtrFree = GDestroyNotify TypeClass -> Maybe (GDestroyNotify TypeClass)
forall a. a -> Maybe a
Just GDestroyNotify TypeClass
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free
newZeroTypeClass :: MonadIO m => m TypeClass
newZeroTypeClass :: m TypeClass
newZeroTypeClass = IO TypeClass -> m TypeClass
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TypeClass -> m TypeClass) -> IO TypeClass -> m TypeClass
forall a b. (a -> b) -> a -> b
$ IO (Ptr TypeClass)
forall a. WrappedPtr a => IO (Ptr a)
wrappedPtrCalloc IO (Ptr TypeClass)
-> (Ptr TypeClass -> IO TypeClass) -> IO TypeClass
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr TypeClass -> TypeClass)
-> Ptr TypeClass -> IO TypeClass
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr TypeClass -> TypeClass
TypeClass
instance tag ~ 'AttrSet => Constructible TypeClass tag where
new :: (ManagedPtr TypeClass -> TypeClass)
-> [AttrOp TypeClass tag] -> m TypeClass
new _ attrs :: [AttrOp TypeClass tag]
attrs = do
TypeClass
o <- m TypeClass
forall (m :: * -> *). MonadIO m => m TypeClass
newZeroTypeClass
TypeClass -> [AttrOp TypeClass 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set TypeClass
o [AttrOp TypeClass tag]
[AttrOp TypeClass 'AttrSet]
attrs
TypeClass -> m TypeClass
forall (m :: * -> *) a. Monad m => a -> m a
return TypeClass
o
noTypeClass :: Maybe TypeClass
noTypeClass :: Maybe TypeClass
noTypeClass = Maybe TypeClass
forall a. Maybe a
Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList TypeClass
type instance O.AttributeList TypeClass = TypeClassAttributeList
type TypeClassAttributeList = ('[ ] :: [(Symbol, *)])
#endif
foreign import ccall "g_type_class_add_private" g_type_class_add_private ::
Ptr TypeClass ->
Word64 ->
IO ()
{-# DEPRECATED typeClassAddPrivate ["(Since version 2.58)","Use the @/G_ADD_PRIVATE()/@ macro with the @G_DEFINE_*@"," family of macros to add instance private data to a type"] #-}
typeClassAddPrivate ::
(B.CallStack.HasCallStack, MonadIO m) =>
TypeClass
-> Word64
-> m ()
typeClassAddPrivate :: TypeClass -> Word64 -> m ()
typeClassAddPrivate gClass :: TypeClass
gClass privateSize :: Word64
privateSize = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr TypeClass
gClass' <- TypeClass -> IO (Ptr TypeClass)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TypeClass
gClass
Ptr TypeClass -> Word64 -> IO ()
g_type_class_add_private Ptr TypeClass
gClass' Word64
privateSize
TypeClass -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TypeClass
gClass
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data TypeClassAddPrivateMethodInfo
instance (signature ~ (Word64 -> m ()), MonadIO m) => O.MethodInfo TypeClassAddPrivateMethodInfo TypeClass signature where
overloadedMethod = typeClassAddPrivate
#endif
foreign import ccall "g_type_class_get_private" g_type_class_get_private ::
Ptr TypeClass ->
CGType ->
IO (Ptr ())
typeClassGetPrivate ::
(B.CallStack.HasCallStack, MonadIO m) =>
TypeClass
-> GType
-> m (Ptr ())
typeClassGetPrivate :: TypeClass -> GType -> m (Ptr ())
typeClassGetPrivate klass :: TypeClass
klass privateType :: GType
privateType = IO (Ptr ()) -> m (Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr ()) -> m (Ptr ())) -> IO (Ptr ()) -> m (Ptr ())
forall a b. (a -> b) -> a -> b
$ do
Ptr TypeClass
klass' <- TypeClass -> IO (Ptr TypeClass)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TypeClass
klass
let privateType' :: Word64
privateType' = GType -> Word64
gtypeToCGType GType
privateType
Ptr ()
result <- Ptr TypeClass -> Word64 -> IO (Ptr ())
g_type_class_get_private Ptr TypeClass
klass' Word64
privateType'
TypeClass -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TypeClass
klass
Ptr () -> IO (Ptr ())
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr ()
result
#if defined(ENABLE_OVERLOADING)
data TypeClassGetPrivateMethodInfo
instance (signature ~ (GType -> m (Ptr ())), MonadIO m) => O.MethodInfo TypeClassGetPrivateMethodInfo TypeClass signature where
overloadedMethod = typeClassGetPrivate
#endif
foreign import ccall "g_type_class_peek_parent" g_type_class_peek_parent ::
Ptr TypeClass ->
IO (Ptr TypeClass)
typeClassPeekParent ::
(B.CallStack.HasCallStack, MonadIO m) =>
TypeClass
-> m TypeClass
typeClassPeekParent :: TypeClass -> m TypeClass
typeClassPeekParent gClass :: TypeClass
gClass = IO TypeClass -> m TypeClass
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TypeClass -> m TypeClass) -> IO TypeClass -> m TypeClass
forall a b. (a -> b) -> a -> b
$ do
Ptr TypeClass
gClass' <- TypeClass -> IO (Ptr TypeClass)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TypeClass
gClass
Ptr TypeClass
result <- Ptr TypeClass -> IO (Ptr TypeClass)
g_type_class_peek_parent Ptr TypeClass
gClass'
Text -> Ptr TypeClass -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "typeClassPeekParent" Ptr TypeClass
result
TypeClass
result' <- ((ManagedPtr TypeClass -> TypeClass)
-> Ptr TypeClass -> IO TypeClass
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr TypeClass -> TypeClass
TypeClass) Ptr TypeClass
result
TypeClass -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TypeClass
gClass
TypeClass -> IO TypeClass
forall (m :: * -> *) a. Monad m => a -> m a
return TypeClass
result'
#if defined(ENABLE_OVERLOADING)
data TypeClassPeekParentMethodInfo
instance (signature ~ (m TypeClass), MonadIO m) => O.MethodInfo TypeClassPeekParentMethodInfo TypeClass signature where
overloadedMethod = typeClassPeekParent
#endif
foreign import ccall "g_type_class_unref" g_type_class_unref ::
Ptr TypeClass ->
IO ()
typeClassUnref ::
(B.CallStack.HasCallStack, MonadIO m) =>
TypeClass
-> m ()
typeClassUnref :: TypeClass -> m ()
typeClassUnref gClass :: TypeClass
gClass = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr TypeClass
gClass' <- TypeClass -> IO (Ptr TypeClass)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TypeClass
gClass
Ptr TypeClass -> IO ()
g_type_class_unref Ptr TypeClass
gClass'
TypeClass -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TypeClass
gClass
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data TypeClassUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo TypeClassUnrefMethodInfo TypeClass signature where
overloadedMethod = typeClassUnref
#endif
foreign import ccall "g_type_class_adjust_private_offset" g_type_class_adjust_private_offset ::
Ptr () ->
Int32 ->
IO ()
typeClassAdjustPrivateOffset ::
(B.CallStack.HasCallStack, MonadIO m) =>
Ptr ()
-> Int32
-> m ()
typeClassAdjustPrivateOffset :: Ptr () -> Int32 -> m ()
typeClassAdjustPrivateOffset gClass :: Ptr ()
gClass privateSizeOrOffset :: Int32
privateSizeOrOffset = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr () -> Int32 -> IO ()
g_type_class_adjust_private_offset Ptr ()
gClass Int32
privateSizeOrOffset
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_type_class_peek" g_type_class_peek ::
CGType ->
IO (Ptr TypeClass)
typeClassPeek ::
(B.CallStack.HasCallStack, MonadIO m) =>
GType
-> m TypeClass
typeClassPeek :: GType -> m TypeClass
typeClassPeek type_ :: GType
type_ = IO TypeClass -> m TypeClass
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TypeClass -> m TypeClass) -> IO TypeClass -> m TypeClass
forall a b. (a -> b) -> a -> b
$ do
let type_' :: Word64
type_' = GType -> Word64
gtypeToCGType GType
type_
Ptr TypeClass
result <- Word64 -> IO (Ptr TypeClass)
g_type_class_peek Word64
type_'
Text -> Ptr TypeClass -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "typeClassPeek" Ptr TypeClass
result
TypeClass
result' <- ((ManagedPtr TypeClass -> TypeClass)
-> Ptr TypeClass -> IO TypeClass
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr TypeClass -> TypeClass
TypeClass) Ptr TypeClass
result
TypeClass -> IO TypeClass
forall (m :: * -> *) a. Monad m => a -> m a
return TypeClass
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_type_class_peek_static" g_type_class_peek_static ::
CGType ->
IO (Ptr TypeClass)
typeClassPeekStatic ::
(B.CallStack.HasCallStack, MonadIO m) =>
GType
-> m TypeClass
typeClassPeekStatic :: GType -> m TypeClass
typeClassPeekStatic type_ :: GType
type_ = IO TypeClass -> m TypeClass
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TypeClass -> m TypeClass) -> IO TypeClass -> m TypeClass
forall a b. (a -> b) -> a -> b
$ do
let type_' :: Word64
type_' = GType -> Word64
gtypeToCGType GType
type_
Ptr TypeClass
result <- Word64 -> IO (Ptr TypeClass)
g_type_class_peek_static Word64
type_'
Text -> Ptr TypeClass -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "typeClassPeekStatic" Ptr TypeClass
result
TypeClass
result' <- ((ManagedPtr TypeClass -> TypeClass)
-> Ptr TypeClass -> IO TypeClass
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr TypeClass -> TypeClass
TypeClass) Ptr TypeClass
result
TypeClass -> IO TypeClass
forall (m :: * -> *) a. Monad m => a -> m a
return TypeClass
result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "g_type_class_ref" g_type_class_ref ::
CGType ->
IO (Ptr TypeClass)
typeClassRef ::
(B.CallStack.HasCallStack, MonadIO m) =>
GType
-> m TypeClass
typeClassRef :: GType -> m TypeClass
typeClassRef type_ :: GType
type_ = IO TypeClass -> m TypeClass
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TypeClass -> m TypeClass) -> IO TypeClass -> m TypeClass
forall a b. (a -> b) -> a -> b
$ do
let type_' :: Word64
type_' = GType -> Word64
gtypeToCGType GType
type_
Ptr TypeClass
result <- Word64 -> IO (Ptr TypeClass)
g_type_class_ref Word64
type_'
Text -> Ptr TypeClass -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "typeClassRef" Ptr TypeClass
result
TypeClass
result' <- ((ManagedPtr TypeClass -> TypeClass)
-> Ptr TypeClass -> IO TypeClass
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr TypeClass -> TypeClass
TypeClass) Ptr TypeClass
result
TypeClass -> IO TypeClass
forall (m :: * -> *) a. Monad m => a -> m a
return TypeClass
result'
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveTypeClassMethod (t :: Symbol) (o :: *) :: * where
ResolveTypeClassMethod "addPrivate" o = TypeClassAddPrivateMethodInfo
ResolveTypeClassMethod "peekParent" o = TypeClassPeekParentMethodInfo
ResolveTypeClassMethod "unref" o = TypeClassUnrefMethodInfo
ResolveTypeClassMethod "getPrivate" o = TypeClassGetPrivateMethodInfo
ResolveTypeClassMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveTypeClassMethod t TypeClass, O.MethodInfo info TypeClass p) => OL.IsLabel t (TypeClass -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif