{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- An opaque structure representing a test suite.

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

module GI.GLib.Structs.TestSuite
    ( 

-- * Exported types
    TestSuite(..)                           ,
    noTestSuite                             ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveTestSuiteMethod                  ,
#endif


-- ** add #method:add#

#if defined(ENABLE_OVERLOADING)
    TestSuiteAddMethodInfo                  ,
#endif
    testSuiteAdd                            ,


-- ** addSuite #method:addSuite#

#if defined(ENABLE_OVERLOADING)
    TestSuiteAddSuiteMethodInfo             ,
#endif
    testSuiteAddSuite                       ,




    ) 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

import {-# SOURCE #-} qualified GI.GLib.Structs.TestCase as GLib.TestCase

-- | Memory-managed wrapper type.
newtype TestSuite = TestSuite (ManagedPtr TestSuite)
    deriving (TestSuite -> TestSuite -> Bool
(TestSuite -> TestSuite -> Bool)
-> (TestSuite -> TestSuite -> Bool) -> Eq TestSuite
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestSuite -> TestSuite -> Bool
$c/= :: TestSuite -> TestSuite -> Bool
== :: TestSuite -> TestSuite -> Bool
$c== :: TestSuite -> TestSuite -> Bool
Eq)
-- XXX Wrapping a foreign struct/union with no known destructor or size, leak?
instance WrappedPtr TestSuite where
    wrappedPtrCalloc :: IO (Ptr TestSuite)
wrappedPtrCalloc = Ptr TestSuite -> IO (Ptr TestSuite)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr TestSuite
forall a. Ptr a
nullPtr
    wrappedPtrCopy :: TestSuite -> IO TestSuite
wrappedPtrCopy = TestSuite -> IO TestSuite
forall (m :: * -> *) a. Monad m => a -> m a
return
    wrappedPtrFree :: Maybe (GDestroyNotify TestSuite)
wrappedPtrFree = Maybe (GDestroyNotify TestSuite)
forall a. Maybe a
Nothing

-- | A convenience alias for `Nothing` :: `Maybe` `TestSuite`.
noTestSuite :: Maybe TestSuite
noTestSuite :: Maybe TestSuite
noTestSuite = Maybe TestSuite
forall a. Maybe a
Nothing


#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList TestSuite
type instance O.AttributeList TestSuite = TestSuiteAttributeList
type TestSuiteAttributeList = ('[ ] :: [(Symbol, *)])
#endif

-- method TestSuite::add
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "suite"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "TestSuite" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTestSuite" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "test_case"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "TestCase" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTestCase" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_test_suite_add" g_test_suite_add :: 
    Ptr TestSuite ->                        -- suite : TInterface (Name {namespace = "GLib", name = "TestSuite"})
    Ptr GLib.TestCase.TestCase ->           -- test_case : TInterface (Name {namespace = "GLib", name = "TestCase"})
    IO ()

-- | Adds /@testCase@/ to /@suite@/.
-- 
-- /Since: 2.16/
testSuiteAdd ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TestSuite
    -- ^ /@suite@/: a t'GI.GLib.Structs.TestSuite.TestSuite'
    -> GLib.TestCase.TestCase
    -- ^ /@testCase@/: a t'GI.GLib.Structs.TestCase.TestCase'
    -> m ()
testSuiteAdd :: TestSuite -> TestCase -> m ()
testSuiteAdd suite :: TestSuite
suite testCase :: TestCase
testCase = 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 TestSuite
suite' <- TestSuite -> IO (Ptr TestSuite)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TestSuite
suite
    Ptr TestCase
testCase' <- TestCase -> IO (Ptr TestCase)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TestCase
testCase
    Ptr TestSuite -> Ptr TestCase -> IO ()
g_test_suite_add Ptr TestSuite
suite' Ptr TestCase
testCase'
    TestSuite -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TestSuite
suite
    TestCase -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TestCase
testCase
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data TestSuiteAddMethodInfo
instance (signature ~ (GLib.TestCase.TestCase -> m ()), MonadIO m) => O.MethodInfo TestSuiteAddMethodInfo TestSuite signature where
    overloadedMethod = testSuiteAdd

#endif

-- method TestSuite::add_suite
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "suite"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "TestSuite" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GTestSuite" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "nestedsuite"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "TestSuite" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "another #GTestSuite"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_test_suite_add_suite" g_test_suite_add_suite :: 
    Ptr TestSuite ->                        -- suite : TInterface (Name {namespace = "GLib", name = "TestSuite"})
    Ptr TestSuite ->                        -- nestedsuite : TInterface (Name {namespace = "GLib", name = "TestSuite"})
    IO ()

-- | Adds /@nestedsuite@/ to /@suite@/.
-- 
-- /Since: 2.16/
testSuiteAddSuite ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TestSuite
    -- ^ /@suite@/: a t'GI.GLib.Structs.TestSuite.TestSuite'
    -> TestSuite
    -- ^ /@nestedsuite@/: another t'GI.GLib.Structs.TestSuite.TestSuite'
    -> m ()
testSuiteAddSuite :: TestSuite -> TestSuite -> m ()
testSuiteAddSuite suite :: TestSuite
suite nestedsuite :: TestSuite
nestedsuite = 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 TestSuite
suite' <- TestSuite -> IO (Ptr TestSuite)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TestSuite
suite
    Ptr TestSuite
nestedsuite' <- TestSuite -> IO (Ptr TestSuite)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TestSuite
nestedsuite
    Ptr TestSuite -> Ptr TestSuite -> IO ()
g_test_suite_add_suite Ptr TestSuite
suite' Ptr TestSuite
nestedsuite'
    TestSuite -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TestSuite
suite
    TestSuite -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TestSuite
nestedsuite
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data TestSuiteAddSuiteMethodInfo
instance (signature ~ (TestSuite -> m ()), MonadIO m) => O.MethodInfo TestSuiteAddSuiteMethodInfo TestSuite signature where
    overloadedMethod = testSuiteAddSuite

#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveTestSuiteMethod (t :: Symbol) (o :: *) :: * where
    ResolveTestSuiteMethod "add" o = TestSuiteAddMethodInfo
    ResolveTestSuiteMethod "addSuite" o = TestSuiteAddSuiteMethodInfo
    ResolveTestSuiteMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveTestSuiteMethod t TestSuite, O.MethodInfo info TestSuite p) => OL.IsLabel t (TestSuite -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif