{-# 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 ,
#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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
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 Control.Monad.IO.Class as MIO
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 GHC.Records as R
newtype TypeClass = TypeClass (SP.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 SP.ManagedPtrNewtype TypeClass where
toManagedPtr :: TypeClass -> ManagedPtr TypeClass
toManagedPtr (TypeClass ManagedPtr TypeClass
p) = ManagedPtr TypeClass
p
instance BoxedPtr TypeClass where
boxedPtrCopy :: TypeClass -> IO TypeClass
boxedPtrCopy = \TypeClass
p -> TypeClass -> (Ptr TypeClass -> IO TypeClass) -> IO TypeClass
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr TypeClass
p (Int -> Ptr TypeClass -> IO (Ptr TypeClass)
forall a. (HasCallStack, CallocPtr a) => Int -> Ptr a -> IO (Ptr a)
copyBytes Int
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, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.wrapPtr ManagedPtr TypeClass -> TypeClass
TypeClass)
boxedPtrFree :: TypeClass -> IO ()
boxedPtrFree = \TypeClass
x -> TypeClass -> (Ptr TypeClass -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
SP.withManagedPtr TypeClass
x Ptr TypeClass -> IO ()
forall a. Ptr a -> IO ()
SP.freeMem
instance CallocPtr TypeClass where
boxedPtrCalloc :: IO (Ptr TypeClass)
boxedPtrCalloc = Int -> IO (Ptr TypeClass)
forall a. Int -> IO (Ptr a)
callocBytes Int
8
newZeroTypeClass :: MonadIO m => m TypeClass
newZeroTypeClass :: forall (m :: * -> *). MonadIO m => 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. CallocPtr a => IO (Ptr a)
boxedPtrCalloc 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, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr TypeClass -> TypeClass
TypeClass
instance tag ~ 'AttrSet => Constructible TypeClass tag where
new :: forall (m :: * -> *).
MonadIO m =>
(ManagedPtr TypeClass -> TypeClass)
-> [AttrOp TypeClass tag] -> m TypeClass
new ManagedPtr TypeClass -> TypeClass
_ [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
#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 :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
TypeClass -> Word64 -> m ()
typeClassAddPrivate TypeClass
gClass 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.OverloadedMethod TypeClassAddPrivateMethodInfo TypeClass signature where
overloadedMethod = typeClassAddPrivate
instance O.OverloadedMethodInfo TypeClassAddPrivateMethodInfo TypeClass where
overloadedMethodInfo = O.MethodInfo {
O.overloadedMethodName = "GI.GObject.Structs.TypeClass.typeClassAddPrivate",
O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-gobject-2.0.26/docs/GI-GObject-Structs-TypeClass.html#v: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 :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
TypeClass -> GType -> m (Ptr ())
typeClassGetPrivate TypeClass
klass 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.OverloadedMethod TypeClassGetPrivateMethodInfo TypeClass signature where
overloadedMethod = typeClassGetPrivate
instance O.OverloadedMethodInfo TypeClassGetPrivateMethodInfo TypeClass where
overloadedMethodInfo = O.MethodInfo {
O.overloadedMethodName = "GI.GObject.Structs.TypeClass.typeClassGetPrivate",
O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-gobject-2.0.26/docs/GI-GObject-Structs-TypeClass.html#v: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 :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
TypeClass -> m TypeClass
typeClassPeekParent 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 Text
"typeClassPeekParent" Ptr TypeClass
result
TypeClass
result' <- ((ManagedPtr TypeClass -> TypeClass)
-> Ptr TypeClass -> IO TypeClass
forall a.
(HasCallStack, BoxedPtr 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.OverloadedMethod TypeClassPeekParentMethodInfo TypeClass signature where
overloadedMethod = typeClassPeekParent
instance O.OverloadedMethodInfo TypeClassPeekParentMethodInfo TypeClass where
overloadedMethodInfo = O.MethodInfo {
O.overloadedMethodName = "GI.GObject.Structs.TypeClass.typeClassPeekParent",
O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-gobject-2.0.26/docs/GI-GObject-Structs-TypeClass.html#v: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 :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
TypeClass -> m ()
typeClassUnref 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.OverloadedMethod TypeClassUnrefMethodInfo TypeClass signature where
overloadedMethod = typeClassUnref
instance O.OverloadedMethodInfo TypeClassUnrefMethodInfo TypeClass where
overloadedMethodInfo = O.MethodInfo {
O.overloadedMethodName = "GI.GObject.Structs.TypeClass.typeClassUnref",
O.overloadedMethodURL = "https://hackage.haskell.org/package/gi-gobject-2.0.26/docs/GI-GObject-Structs-TypeClass.html#v: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 :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Ptr () -> Int32 -> m ()
typeClassAdjustPrivateOffset Ptr ()
gClass 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 :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GType -> m TypeClass
typeClassPeek 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 Text
"typeClassPeek" Ptr TypeClass
result
TypeClass
result' <- ((ManagedPtr TypeClass -> TypeClass)
-> Ptr TypeClass -> IO TypeClass
forall a.
(HasCallStack, BoxedPtr 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 :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GType -> m TypeClass
typeClassPeekStatic 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 Text
"typeClassPeekStatic" Ptr TypeClass
result
TypeClass
result' <- ((ManagedPtr TypeClass -> TypeClass)
-> Ptr TypeClass -> IO TypeClass
forall a.
(HasCallStack, BoxedPtr 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 :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GType -> m TypeClass
typeClassRef 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 Text
"typeClassRef" Ptr TypeClass
result
TypeClass
result' <- ((ManagedPtr TypeClass -> TypeClass)
-> Ptr TypeClass -> IO TypeClass
forall a.
(HasCallStack, BoxedPtr 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.OverloadedMethod 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
#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveTypeClassMethod t TypeClass, O.OverloadedMethod info TypeClass p, R.HasField t TypeClass p) => R.HasField t TypeClass p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveTypeClassMethod t TypeClass, O.OverloadedMethodInfo info TypeClass) => OL.IsLabel t (O.MethodProxy info TypeClass) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif