{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- /No description available in the introspection data./

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

module GI.GLib.Structs.TestLogBuffer
    ( 

-- * Exported types
    TestLogBuffer(..)                       ,
    newZeroTestLogBuffer                    ,
    noTestLogBuffer                         ,


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

#if defined(ENABLE_OVERLOADING)
    ResolveTestLogBufferMethod              ,
#endif


-- ** free #method:free#

#if defined(ENABLE_OVERLOADING)
    TestLogBufferFreeMethodInfo             ,
#endif
    testLogBufferFree                       ,


-- ** push #method:push#

#if defined(ENABLE_OVERLOADING)
    TestLogBufferPushMethodInfo             ,
#endif
    testLogBufferPush                       ,




    ) 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


-- | Memory-managed wrapper type.
newtype TestLogBuffer = TestLogBuffer (ManagedPtr TestLogBuffer)
    deriving (TestLogBuffer -> TestLogBuffer -> Bool
(TestLogBuffer -> TestLogBuffer -> Bool)
-> (TestLogBuffer -> TestLogBuffer -> Bool) -> Eq TestLogBuffer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestLogBuffer -> TestLogBuffer -> Bool
$c/= :: TestLogBuffer -> TestLogBuffer -> Bool
== :: TestLogBuffer -> TestLogBuffer -> Bool
$c== :: TestLogBuffer -> TestLogBuffer -> Bool
Eq)
instance WrappedPtr TestLogBuffer where
    wrappedPtrCalloc :: IO (Ptr TestLogBuffer)
wrappedPtrCalloc = Int -> IO (Ptr TestLogBuffer)
forall a. Int -> IO (Ptr a)
callocBytes 16
    wrappedPtrCopy :: TestLogBuffer -> IO TestLogBuffer
wrappedPtrCopy = \p :: TestLogBuffer
p -> TestLogBuffer
-> (Ptr TestLogBuffer -> IO TestLogBuffer) -> IO TestLogBuffer
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TestLogBuffer
p (Int -> Ptr TestLogBuffer -> IO (Ptr TestLogBuffer)
forall a. WrappedPtr a => Int -> Ptr a -> IO (Ptr a)
copyBytes 16 (Ptr TestLogBuffer -> IO (Ptr TestLogBuffer))
-> (Ptr TestLogBuffer -> IO TestLogBuffer)
-> Ptr TestLogBuffer
-> IO TestLogBuffer
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr TestLogBuffer -> TestLogBuffer)
-> Ptr TestLogBuffer -> IO TestLogBuffer
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr TestLogBuffer -> TestLogBuffer
TestLogBuffer)
    wrappedPtrFree :: Maybe (GDestroyNotify TestLogBuffer)
wrappedPtrFree = GDestroyNotify TestLogBuffer
-> Maybe (GDestroyNotify TestLogBuffer)
forall a. a -> Maybe a
Just GDestroyNotify TestLogBuffer
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free

-- | Construct a `TestLogBuffer` struct initialized to zero.
newZeroTestLogBuffer :: MonadIO m => m TestLogBuffer
newZeroTestLogBuffer :: m TestLogBuffer
newZeroTestLogBuffer = IO TestLogBuffer -> m TestLogBuffer
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TestLogBuffer -> m TestLogBuffer)
-> IO TestLogBuffer -> m TestLogBuffer
forall a b. (a -> b) -> a -> b
$ IO (Ptr TestLogBuffer)
forall a. WrappedPtr a => IO (Ptr a)
wrappedPtrCalloc IO (Ptr TestLogBuffer)
-> (Ptr TestLogBuffer -> IO TestLogBuffer) -> IO TestLogBuffer
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr TestLogBuffer -> TestLogBuffer)
-> Ptr TestLogBuffer -> IO TestLogBuffer
forall a.
(HasCallStack, WrappedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr TestLogBuffer -> TestLogBuffer
TestLogBuffer

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


-- | A convenience alias for `Nothing` :: `Maybe` `TestLogBuffer`.
noTestLogBuffer :: Maybe TestLogBuffer
noTestLogBuffer :: Maybe TestLogBuffer
noTestLogBuffer = Maybe TestLogBuffer
forall a. Maybe a
Nothing


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

-- method TestLogBuffer::free
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "tbuffer"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "TestLogBuffer" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , 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_log_buffer_free" g_test_log_buffer_free :: 
    Ptr TestLogBuffer ->                    -- tbuffer : TInterface (Name {namespace = "GLib", name = "TestLogBuffer"})
    IO ()

-- | Internal function for gtester to free test log messages, no ABI guarantees provided.
testLogBufferFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TestLogBuffer
    -> m ()
testLogBufferFree :: TestLogBuffer -> m ()
testLogBufferFree tbuffer :: TestLogBuffer
tbuffer = 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 TestLogBuffer
tbuffer' <- TestLogBuffer -> IO (Ptr TestLogBuffer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TestLogBuffer
tbuffer
    Ptr TestLogBuffer -> IO ()
g_test_log_buffer_free Ptr TestLogBuffer
tbuffer'
    TestLogBuffer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TestLogBuffer
tbuffer
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data TestLogBufferFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo TestLogBufferFreeMethodInfo TestLogBuffer signature where
    overloadedMethod = testLogBufferFree

#endif

-- method TestLogBuffer::push
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "tbuffer"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "TestLogBuffer" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "n_bytes"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "bytes"
--           , argType = TBasicType TUInt8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation { rawDocText = Nothing , 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_log_buffer_push" g_test_log_buffer_push :: 
    Ptr TestLogBuffer ->                    -- tbuffer : TInterface (Name {namespace = "GLib", name = "TestLogBuffer"})
    Word32 ->                               -- n_bytes : TBasicType TUInt
    Word8 ->                                -- bytes : TBasicType TUInt8
    IO ()

-- | Internal function for gtester to decode test log messages, no ABI guarantees provided.
testLogBufferPush ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    TestLogBuffer
    -> Word32
    -> Word8
    -> m ()
testLogBufferPush :: TestLogBuffer -> Word32 -> Word8 -> m ()
testLogBufferPush tbuffer :: TestLogBuffer
tbuffer nBytes :: Word32
nBytes bytes :: Word8
bytes = 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 TestLogBuffer
tbuffer' <- TestLogBuffer -> IO (Ptr TestLogBuffer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TestLogBuffer
tbuffer
    Ptr TestLogBuffer -> Word32 -> Word8 -> IO ()
g_test_log_buffer_push Ptr TestLogBuffer
tbuffer' Word32
nBytes Word8
bytes
    TestLogBuffer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TestLogBuffer
tbuffer
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data TestLogBufferPushMethodInfo
instance (signature ~ (Word32 -> Word8 -> m ()), MonadIO m) => O.MethodInfo TestLogBufferPushMethodInfo TestLogBuffer signature where
    overloadedMethod = testLogBufferPush

#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveTestLogBufferMethod (t :: Symbol) (o :: *) :: * where
    ResolveTestLogBufferMethod "free" o = TestLogBufferFreeMethodInfo
    ResolveTestLogBufferMethod "push" o = TestLogBufferPushMethodInfo
    ResolveTestLogBufferMethod l o = O.MethodResolutionFailed l o

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

#endif