{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) -} module GI.GLib.Structs.TestLogMsg ( -- * Exported types TestLogMsg(..) , newZeroTestLogMsg , noTestLogMsg , -- * Methods -- ** testLogMsgFree TestLogMsgFreeMethodInfo , testLogMsgFree , -- * Properties -- ** LogType testLogMsgReadLogType , -- ** NNums testLogMsgReadNNums , -- ** NStrings testLogMsgReadNStrings , -- ** Nums testLogMsgReadNums , -- ** Strings testLogMsgReadStrings , ) where import Prelude () import Data.GI.Base.ShortPrelude import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import GI.GLib.Types import GI.GLib.Callbacks newtype TestLogMsg = TestLogMsg (ForeignPtr TestLogMsg) -- | Construct a `TestLogMsg` struct initialized to zero. newZeroTestLogMsg :: MonadIO m => m TestLogMsg newZeroTestLogMsg = liftIO $ callocBytes 32 >>= wrapPtr TestLogMsg noTestLogMsg :: Maybe TestLogMsg noTestLogMsg = Nothing testLogMsgReadLogType :: TestLogMsg -> IO TestLogType testLogMsgReadLogType s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 0) :: IO CUInt let val' = (toEnum . fromIntegral) val return val' testLogMsgReadNStrings :: TestLogMsg -> IO Word32 testLogMsgReadNStrings s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 4) :: IO Word32 return val testLogMsgReadStrings :: TestLogMsg -> IO T.Text testLogMsgReadStrings s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 8) :: IO CString val' <- cstringToText val return val' testLogMsgReadNNums :: TestLogMsg -> IO Word32 testLogMsgReadNNums s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 16) :: IO Word32 return val testLogMsgReadNums :: TestLogMsg -> IO Int64 testLogMsgReadNums s = withManagedPtr s $ \ptr -> do val <- peek (ptr `plusPtr` 24) :: IO Int64 return val -- method TestLogMsg::free -- method type : OrdinaryMethod -- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "TestLogMsg", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "g_test_log_msg_free" g_test_log_msg_free :: Ptr TestLogMsg -> -- _obj : TInterface "GLib" "TestLogMsg" IO () testLogMsgFree :: (MonadIO m) => TestLogMsg -- _obj -> m () -- result testLogMsgFree _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj g_test_log_msg_free _obj' touchManagedPtr _obj return () data TestLogMsgFreeMethodInfo instance (signature ~ (m ()), MonadIO m) => MethodInfo TestLogMsgFreeMethodInfo TestLogMsg signature where overloadedMethod _ = testLogMsgFree type family ResolveTestLogMsgMethod (t :: Symbol) (o :: *) :: * where ResolveTestLogMsgMethod "free" o = TestLogMsgFreeMethodInfo ResolveTestLogMsgMethod l o = MethodResolutionFailed l o instance (info ~ ResolveTestLogMsgMethod t TestLogMsg, MethodInfo info TestLogMsg p) => IsLabelProxy t (TestLogMsg -> p) where fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info) #if MIN_VERSION_base(4,9,0) instance (info ~ ResolveTestLogMsgMethod t TestLogMsg, MethodInfo info TestLogMsg p) => IsLabel t (TestLogMsg -> p) where fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info) #endif