{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GLib.Structs.TestLogBuffer
(
TestLogBuffer(..) ,
newZeroTestLogBuffer ,
#if defined(ENABLE_OVERLOADING)
ResolveTestLogBufferMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
TestLogBufferFreeMethodInfo ,
#endif
testLogBufferFree ,
#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.BasicTypes as B.Types
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 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
newtype TestLogBuffer = TestLogBuffer (SP.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 SP.ManagedPtrNewtype TestLogBuffer where
toManagedPtr :: TestLogBuffer -> ManagedPtr TestLogBuffer
toManagedPtr (TestLogBuffer ManagedPtr TestLogBuffer
p) = ManagedPtr TestLogBuffer
p
instance BoxedPtr TestLogBuffer where
boxedPtrCopy :: TestLogBuffer -> IO TestLogBuffer
boxedPtrCopy = \TestLogBuffer
p -> TestLogBuffer
-> (Ptr TestLogBuffer -> IO TestLogBuffer) -> IO TestLogBuffer
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr TestLogBuffer
p (Int -> Ptr TestLogBuffer -> IO (Ptr TestLogBuffer)
forall a. (HasCallStack, CallocPtr a) => Int -> Ptr a -> IO (Ptr a)
copyBytes Int
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, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.wrapPtr ManagedPtr TestLogBuffer -> TestLogBuffer
TestLogBuffer)
boxedPtrFree :: TestLogBuffer -> IO ()
boxedPtrFree = \TestLogBuffer
x -> TestLogBuffer -> (Ptr TestLogBuffer -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
SP.withManagedPtr TestLogBuffer
x Ptr TestLogBuffer -> IO ()
forall a. Ptr a -> IO ()
SP.freeMem
instance CallocPtr TestLogBuffer where
boxedPtrCalloc :: IO (Ptr TestLogBuffer)
boxedPtrCalloc = Int -> IO (Ptr TestLogBuffer)
forall a. Int -> IO (Ptr a)
callocBytes Int
16
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. CallocPtr a => IO (Ptr a)
boxedPtrCalloc 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, BoxedPtr 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 ManagedPtr TestLogBuffer -> TestLogBuffer
_ [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
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList TestLogBuffer
type instance O.AttributeList TestLogBuffer = TestLogBufferAttributeList
type TestLogBufferAttributeList = ('[ ] :: [(Symbol, *)])
#endif
foreign import ccall "g_test_log_buffer_free" g_test_log_buffer_free ::
Ptr TestLogBuffer ->
IO ()
testLogBufferFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
TestLogBuffer
-> m ()
testLogBufferFree :: TestLogBuffer -> m ()
testLogBufferFree 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
foreign import ccall "g_test_log_buffer_push" g_test_log_buffer_push ::
Ptr TestLogBuffer ->
Word32 ->
Word8 ->
IO ()
testLogBufferPush ::
(B.CallStack.HasCallStack, MonadIO m) =>
TestLogBuffer
-> Word32
-> Word8
-> m ()
testLogBufferPush :: TestLogBuffer -> Word32 -> Word8 -> m ()
testLogBufferPush TestLogBuffer
tbuffer Word32
nBytes 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