{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- An opaque structure used as the base of all interface types.

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.GObject.Structs.TypeInterface
    ( 

-- * Exported types
    TypeInterface(..)                       ,
    newZeroTypeInterface                    ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [peekParent]("GI.GObject.Structs.TypeInterface#g:method:peekParent").
-- 
-- ==== Getters
-- /None/.
-- 
-- ==== Setters
-- /None/.

#if defined(ENABLE_OVERLOADING)
    ResolveTypeInterfaceMethod              ,
#endif

-- ** addPrerequisite #method:addPrerequisite#

    typeInterfaceAddPrerequisite            ,


-- ** getPlugin #method:getPlugin#

    typeInterfaceGetPlugin                  ,


-- ** instantiatablePrerequisite #method:instantiatablePrerequisite#

    typeInterfaceInstantiatablePrerequisite ,


-- ** peek #method:peek#

    typeInterfacePeek                       ,


-- ** peekParent #method:peekParent#

#if defined(ENABLE_OVERLOADING)
    TypeInterfacePeekParentMethodInfo       ,
#endif
    typeInterfacePeekParent                 ,


-- ** prerequisites #method:prerequisites#

    typeInterfacePrerequisites              ,




    ) 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.GHashTable as B.GHT
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.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)
import qualified GI.GObject.Callbacks as GObject.Callbacks
import {-# SOURCE #-} qualified GI.GObject.Interfaces.TypePlugin as GObject.TypePlugin
import {-# SOURCE #-} qualified GI.GObject.Structs.InterfaceInfo as GObject.InterfaceInfo
import {-# SOURCE #-} qualified GI.GObject.Structs.TypeClass as GObject.TypeClass
import {-# SOURCE #-} qualified GI.GObject.Structs.TypeInfo as GObject.TypeInfo
import {-# SOURCE #-} qualified GI.GObject.Structs.TypeValueTable as GObject.TypeValueTable

#else
import {-# SOURCE #-} qualified GI.GObject.Interfaces.TypePlugin as GObject.TypePlugin
import {-# SOURCE #-} qualified GI.GObject.Structs.TypeClass as GObject.TypeClass

#endif

-- | Memory-managed wrapper type.
newtype TypeInterface = TypeInterface (SP.ManagedPtr TypeInterface)
    deriving (TypeInterface -> TypeInterface -> Bool
(TypeInterface -> TypeInterface -> Bool)
-> (TypeInterface -> TypeInterface -> Bool) -> Eq TypeInterface
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TypeInterface -> TypeInterface -> Bool
== :: TypeInterface -> TypeInterface -> Bool
$c/= :: TypeInterface -> TypeInterface -> Bool
/= :: TypeInterface -> TypeInterface -> Bool
Eq)

instance SP.ManagedPtrNewtype TypeInterface where
    toManagedPtr :: TypeInterface -> ManagedPtr TypeInterface
toManagedPtr (TypeInterface ManagedPtr TypeInterface
p) = ManagedPtr TypeInterface
p

instance BoxedPtr TypeInterface where
    boxedPtrCopy :: TypeInterface -> IO TypeInterface
boxedPtrCopy = \TypeInterface
p -> TypeInterface
-> (Ptr TypeInterface -> IO TypeInterface) -> IO TypeInterface
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr TypeInterface
p (Int -> Ptr TypeInterface -> IO (Ptr TypeInterface)
forall a. (HasCallStack, CallocPtr a) => Int -> Ptr a -> IO (Ptr a)
copyBytes Int
8 (Ptr TypeInterface -> IO (Ptr TypeInterface))
-> (Ptr TypeInterface -> IO TypeInterface)
-> Ptr TypeInterface
-> IO TypeInterface
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr TypeInterface -> TypeInterface)
-> Ptr TypeInterface -> IO TypeInterface
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.wrapPtr ManagedPtr TypeInterface -> TypeInterface
TypeInterface)
    boxedPtrFree :: TypeInterface -> IO ()
boxedPtrFree = \TypeInterface
x -> TypeInterface -> (Ptr TypeInterface -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
SP.withManagedPtr TypeInterface
x Ptr TypeInterface -> IO ()
forall a. Ptr a -> IO ()
SP.freeMem
instance CallocPtr TypeInterface where
    boxedPtrCalloc :: IO (Ptr TypeInterface)
boxedPtrCalloc = Int -> IO (Ptr TypeInterface)
forall a. Int -> IO (Ptr a)
callocBytes Int
8


-- | Construct a t'TypeInterface' struct initialized to zero.
newZeroTypeInterface :: MonadIO m => m TypeInterface
newZeroTypeInterface :: forall (m :: * -> *). MonadIO m => m TypeInterface
newZeroTypeInterface = IO TypeInterface -> m TypeInterface
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TypeInterface -> m TypeInterface)
-> IO TypeInterface -> m TypeInterface
forall a b. (a -> b) -> a -> b
$ IO (Ptr TypeInterface)
forall a. CallocPtr a => IO (Ptr a)
boxedPtrCalloc IO (Ptr TypeInterface)
-> (Ptr TypeInterface -> IO TypeInterface) -> IO TypeInterface
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr TypeInterface -> TypeInterface)
-> Ptr TypeInterface -> IO TypeInterface
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr TypeInterface -> TypeInterface
TypeInterface

instance tag ~ 'AttrSet => Constructible TypeInterface tag where
    new :: forall (m :: * -> *).
MonadIO m =>
(ManagedPtr TypeInterface -> TypeInterface)
-> [AttrOp TypeInterface tag] -> m TypeInterface
new ManagedPtr TypeInterface -> TypeInterface
_ [AttrOp TypeInterface tag]
attrs = do
        o <- m TypeInterface
forall (m :: * -> *). MonadIO m => m TypeInterface
newZeroTypeInterface
        GI.Attributes.set o attrs
        return o



#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList TypeInterface
type instance O.AttributeList TypeInterface = TypeInterfaceAttributeList
type TypeInterfaceAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif

-- method TypeInterface::peek_parent
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "g_iface"
--           , argType =
--               TInterface Name { namespace = "GObject" , name = "TypeInterface" }
--           , argCType = Just "gpointer"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTypeInterface structure"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "GObject" , name = "TypeInterface" })
-- throws : False
-- Skip return : False

foreign import ccall "g_type_interface_peek_parent" g_type_interface_peek_parent :: 
    Ptr TypeInterface ->                    -- g_iface : TInterface (Name {namespace = "GObject", name = "TypeInterface"})
    IO (Ptr TypeInterface)

-- | Returns the corresponding t'GI.GObject.Structs.TypeInterface.TypeInterface' structure of the parent type
-- of the instance type to which /@gIface@/ belongs.
-- 
-- This is useful when deriving the implementation of an interface from the
-- parent type and then possibly overriding some methods.
typeInterfacePeekParent ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TypeInterface
    -- ^ /@gIface@/: a t'GI.GObject.Structs.TypeInterface.TypeInterface' structure
    -> m (Maybe TypeInterface)
    -- ^ __Returns:__ the
    --   corresponding t'GI.GObject.Structs.TypeInterface.TypeInterface' structure of the parent type of the
    --   instance type to which /@gIface@/ belongs, or 'P.Nothing' if the parent
    --   type doesn\'t conform to the interface
typeInterfacePeekParent :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
TypeInterface -> m (Maybe TypeInterface)
typeInterfacePeekParent TypeInterface
gIface = IO (Maybe TypeInterface) -> m (Maybe TypeInterface)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe TypeInterface) -> m (Maybe TypeInterface))
-> IO (Maybe TypeInterface) -> m (Maybe TypeInterface)
forall a b. (a -> b) -> a -> b
$ do
    gIface' <- TypeInterface -> IO (Ptr TypeInterface)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TypeInterface
gIface
    result <- g_type_interface_peek_parent gIface'
    maybeResult <- convertIfNonNull result $ \Ptr TypeInterface
result' -> do
        result'' <- ((ManagedPtr TypeInterface -> TypeInterface)
-> Ptr TypeInterface -> IO TypeInterface
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr TypeInterface -> TypeInterface
TypeInterface) Ptr TypeInterface
result'
        return result''
    touchManagedPtr gIface
    return maybeResult

#if defined(ENABLE_OVERLOADING)
data TypeInterfacePeekParentMethodInfo
instance (signature ~ (m (Maybe TypeInterface)), MonadIO m) => O.OverloadedMethod TypeInterfacePeekParentMethodInfo TypeInterface signature where
    overloadedMethod = typeInterfacePeekParent

instance O.OverloadedMethodInfo TypeInterfacePeekParentMethodInfo TypeInterface where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.GObject.Structs.TypeInterface.typeInterfacePeekParent",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gobject-2.0.31/docs/GI-GObject-Structs-TypeInterface.html#v:typeInterfacePeekParent"
        })


#endif

-- method TypeInterface::add_prerequisite
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "interface_type"
--           , argType = TBasicType TGType
--           , argCType = Just "GType"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "#GType value of an interface type"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "prerequisite_type"
--           , argType = TBasicType TGType
--           , argCType = Just "GType"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "#GType value of an interface or instantiatable type"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_type_interface_add_prerequisite" g_type_interface_add_prerequisite :: 
    CGType ->                               -- interface_type : TBasicType TGType
    CGType ->                               -- prerequisite_type : TBasicType TGType
    IO ()

-- | Adds /@prerequisiteType@/ to the list of prerequisites of /@interfaceType@/.
-- This means that any type implementing /@interfaceType@/ must also implement
-- /@prerequisiteType@/. Prerequisites can be thought of as an alternative to
-- interface derivation (which GType doesn\'t support). An interface can have
-- at most one instantiatable prerequisite type.
typeInterfaceAddPrerequisite ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GType
    -- ^ /@interfaceType@/: t'GType' value of an interface type
    -> GType
    -- ^ /@prerequisiteType@/: t'GType' value of an interface or instantiatable type
    -> m ()
typeInterfaceAddPrerequisite :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GType -> GType -> m ()
typeInterfaceAddPrerequisite GType
interfaceType GType
prerequisiteType = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    let interfaceType' :: CGType
interfaceType' = GType -> CGType
gtypeToCGType GType
interfaceType
    let prerequisiteType' :: CGType
prerequisiteType' = GType -> CGType
gtypeToCGType GType
prerequisiteType
    CGType -> CGType -> IO ()
g_type_interface_add_prerequisite CGType
interfaceType' CGType
prerequisiteType'
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
#endif

-- method TypeInterface::get_plugin
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "instance_type"
--           , argType = TBasicType TGType
--           , argCType = Just "GType"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "#GType of an instantiatable type"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "interface_type"
--           , argType = TBasicType TGType
--           , argCType = Just "GType"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "#GType of an interface type"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "GObject" , name = "TypePlugin" })
-- throws : False
-- Skip return : False

foreign import ccall "g_type_interface_get_plugin" g_type_interface_get_plugin :: 
    CGType ->                               -- instance_type : TBasicType TGType
    CGType ->                               -- interface_type : TBasicType TGType
    IO (Ptr GObject.TypePlugin.TypePlugin)

-- | Returns the t'GI.GObject.Interfaces.TypePlugin.TypePlugin' structure for the dynamic interface
-- /@interfaceType@/ which has been added to /@instanceType@/, or 'P.Nothing'
-- if /@interfaceType@/ has not been added to /@instanceType@/ or does
-- not have a t'GI.GObject.Interfaces.TypePlugin.TypePlugin' structure. See 'GI.GObject.Functions.typeAddInterfaceDynamic'.
typeInterfaceGetPlugin ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GType
    -- ^ /@instanceType@/: t'GType' of an instantiatable type
    -> GType
    -- ^ /@interfaceType@/: t'GType' of an interface type
    -> m GObject.TypePlugin.TypePlugin
    -- ^ __Returns:__ the t'GI.GObject.Interfaces.TypePlugin.TypePlugin' for the dynamic
    --     interface /@interfaceType@/ of /@instanceType@/
typeInterfaceGetPlugin :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GType -> GType -> m TypePlugin
typeInterfaceGetPlugin GType
instanceType GType
interfaceType = IO TypePlugin -> m TypePlugin
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TypePlugin -> m TypePlugin) -> IO TypePlugin -> m TypePlugin
forall a b. (a -> b) -> a -> b
$ do
    let instanceType' :: CGType
instanceType' = GType -> CGType
gtypeToCGType GType
instanceType
    let interfaceType' :: CGType
interfaceType' = GType -> CGType
gtypeToCGType GType
interfaceType
    result <- CGType -> CGType -> IO (Ptr TypePlugin)
g_type_interface_get_plugin CGType
instanceType' CGType
interfaceType'
    checkUnexpectedReturnNULL "typeInterfaceGetPlugin" result
    result' <- (newPtr GObject.TypePlugin.TypePlugin) result
    return result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method TypeInterface::instantiatable_prerequisite
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "interface_type"
--           , argType = TBasicType TGType
--           , argCType = Just "GType"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an interface type" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TGType)
-- throws : False
-- Skip return : False

foreign import ccall "g_type_interface_instantiatable_prerequisite" g_type_interface_instantiatable_prerequisite :: 
    CGType ->                               -- interface_type : TBasicType TGType
    IO CGType

-- | Returns the most specific instantiatable prerequisite of an
-- interface type. If the interface type has no instantiatable
-- prerequisite, @/G_TYPE_INVALID/@ is returned.
-- 
-- See 'GI.GObject.Functions.typeInterfaceAddPrerequisite' for more information
-- about prerequisites.
-- 
-- /Since: 2.68/
typeInterfaceInstantiatablePrerequisite ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GType
    -- ^ /@interfaceType@/: an interface type
    -> m GType
    -- ^ __Returns:__ the instantiatable prerequisite type or @/G_TYPE_INVALID/@ if none
typeInterfaceInstantiatablePrerequisite :: forall (m :: * -> *). (HasCallStack, MonadIO m) => GType -> m GType
typeInterfaceInstantiatablePrerequisite GType
interfaceType = IO GType -> m GType
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GType -> m GType) -> IO GType -> m GType
forall a b. (a -> b) -> a -> b
$ do
    let interfaceType' :: CGType
interfaceType' = GType -> CGType
gtypeToCGType GType
interfaceType
    result <- CGType -> IO CGType
g_type_interface_instantiatable_prerequisite CGType
interfaceType'
    let result' = CGType -> GType
GType CGType
result
    return result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method TypeInterface::peek
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "instance_class"
--           , argType =
--               TInterface Name { namespace = "GObject" , name = "TypeClass" }
--           , argCType = Just "gpointer"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTypeClass structure"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "iface_type"
--           , argType = TBasicType TGType
--           , argCType = Just "GType"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an interface ID which this class conforms to"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "GObject" , name = "TypeInterface" })
-- throws : False
-- Skip return : False

foreign import ccall "g_type_interface_peek" g_type_interface_peek :: 
    Ptr GObject.TypeClass.TypeClass ->      -- instance_class : TInterface (Name {namespace = "GObject", name = "TypeClass"})
    CGType ->                               -- iface_type : TBasicType TGType
    IO (Ptr TypeInterface)

-- | Returns the t'GI.GObject.Structs.TypeInterface.TypeInterface' structure of an interface to which the
-- passed in class conforms.
typeInterfacePeek ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GObject.TypeClass.TypeClass
    -- ^ /@instanceClass@/: a t'GI.GObject.Structs.TypeClass.TypeClass' structure
    -> GType
    -- ^ /@ifaceType@/: an interface ID which this class conforms to
    -> m (Maybe TypeInterface)
    -- ^ __Returns:__ the t'GI.GObject.Structs.TypeInterface.TypeInterface'
    --   structure of /@ifaceType@/ if implemented by /@instanceClass@/, 'P.Nothing'
    --   otherwise
typeInterfacePeek :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
TypeClass -> GType -> m (Maybe TypeInterface)
typeInterfacePeek TypeClass
instanceClass GType
ifaceType = IO (Maybe TypeInterface) -> m (Maybe TypeInterface)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe TypeInterface) -> m (Maybe TypeInterface))
-> IO (Maybe TypeInterface) -> m (Maybe TypeInterface)
forall a b. (a -> b) -> a -> b
$ do
    instanceClass' <- TypeClass -> IO (Ptr TypeClass)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TypeClass
instanceClass
    let ifaceType' = GType -> CGType
gtypeToCGType GType
ifaceType
    result <- g_type_interface_peek instanceClass' ifaceType'
    maybeResult <- convertIfNonNull result $ \Ptr TypeInterface
result' -> do
        result'' <- ((ManagedPtr TypeInterface -> TypeInterface)
-> Ptr TypeInterface -> IO TypeInterface
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr TypeInterface -> TypeInterface
TypeInterface) Ptr TypeInterface
result'
        return result''
    touchManagedPtr instanceClass
    return maybeResult

#if defined(ENABLE_OVERLOADING)
#endif

-- method TypeInterface::prerequisites
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "interface_type"
--           , argType = TBasicType TGType
--           , argCType = Just "GType"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an interface type" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "n_prerequisites"
--           , argType = TBasicType TUInt
--           , argCType = Just "guint*"
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "location to return the number\n    of prerequisites, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "n_prerequisites"
--              , argType = TBasicType TUInt
--              , argCType = Just "guint*"
--              , direction = DirectionOut
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText =
--                        Just
--                          "location to return the number\n    of prerequisites, or %NULL"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , argCallbackUserData = False
--              , transfer = TransferEverything
--              }
--          ]
-- returnType: Just (TCArray False (-1) 1 (TBasicType TGType))
-- throws : False
-- Skip return : False

foreign import ccall "g_type_interface_prerequisites" g_type_interface_prerequisites :: 
    CGType ->                               -- interface_type : TBasicType TGType
    Ptr Word32 ->                           -- n_prerequisites : TBasicType TUInt
    IO (Ptr CGType)

-- | Returns the prerequisites of an interfaces type.
-- 
-- /Since: 2.2/
typeInterfacePrerequisites ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GType
    -- ^ /@interfaceType@/: an interface type
    -> m [GType]
    -- ^ __Returns:__ a
    --     newly-allocated zero-terminated array of t'GType' containing
    --     the prerequisites of /@interfaceType@/
typeInterfacePrerequisites :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GType -> m [GType]
typeInterfacePrerequisites GType
interfaceType = IO [GType] -> m [GType]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [GType] -> m [GType]) -> IO [GType] -> m [GType]
forall a b. (a -> b) -> a -> b
$ do
    let interfaceType' :: CGType
interfaceType' = GType -> CGType
gtypeToCGType GType
interfaceType
    nPrerequisites <- IO (Ptr CGType)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word32)
    result <- g_type_interface_prerequisites interfaceType' nPrerequisites
    nPrerequisites' <- peek nPrerequisites
    checkUnexpectedReturnNULL "typeInterfacePrerequisites" result
    result' <- (unpackMapStorableArrayWithLength GType nPrerequisites') result
    freeMem result
    freeMem nPrerequisites
    return result'

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveTypeInterfaceMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveTypeInterfaceMethod "peekParent" o = TypeInterfacePeekParentMethodInfo
    ResolveTypeInterfaceMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveTypeInterfaceMethod t TypeInterface, O.OverloadedMethod info TypeInterface p) => OL.IsLabel t (TypeInterface -> 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 ~ ResolveTypeInterfaceMethod t TypeInterface, O.OverloadedMethod info TypeInterface p, R.HasField t TypeInterface p) => R.HasField t TypeInterface p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveTypeInterfaceMethod t TypeInterface, O.OverloadedMethodInfo info TypeInterface) => OL.IsLabel t (O.MethodProxy info TypeInterface) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif