{- |
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 representing a test suite.
-}

#define ENABLE_OVERLOADING \
       (!defined(__HADDOCK_VERSION__))

module GI.GLib.Structs.TestSuite
    ( 

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


 -- * Methods
-- ** add #method:add#

#if ENABLE_OVERLOADING
    TestSuiteAddMethodInfo                  ,
#endif
    testSuiteAdd                            ,


-- ** addSuite #method:addSuite#

#if 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.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.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

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

-- | Memory-managed wrapper type.
newtype TestSuite = TestSuite (ManagedPtr TestSuite)
-- 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 (FunPtr (Ptr TestSuite -> IO ()))
wrappedPtrFree = Maybe (FunPtr (Ptr TestSuite -> IO ()))
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 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 'GI.GLib.Structs.TestSuite.TestSuite' -}
    -> GLib.TestCase.TestCase
    {- ^ /@testCase@/: a '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 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 'GI.GLib.Structs.TestSuite.TestSuite' -}
    -> TestSuite
    {- ^ /@nestedsuite@/: another '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 ENABLE_OVERLOADING
data TestSuiteAddSuiteMethodInfo
instance (signature ~ (TestSuite -> m ()), MonadIO m) => O.MethodInfo TestSuiteAddSuiteMethodInfo TestSuite signature where
    overloadedMethod _ = testSuiteAddSuite

#endif

#if 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) => O.IsLabelProxy t (TestSuite -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

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

#endif