{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GLib.Structs.Timer
(
Timer(..) ,
noTimer ,
#if defined(ENABLE_OVERLOADING)
ResolveTimerMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
TimerContinueMethodInfo ,
#endif
timerContinue ,
#if defined(ENABLE_OVERLOADING)
TimerDestroyMethodInfo ,
#endif
timerDestroy ,
#if defined(ENABLE_OVERLOADING)
TimerElapsedMethodInfo ,
#endif
timerElapsed ,
#if defined(ENABLE_OVERLOADING)
TimerResetMethodInfo ,
#endif
timerReset ,
#if defined(ENABLE_OVERLOADING)
TimerStartMethodInfo ,
#endif
timerStart ,
#if defined(ENABLE_OVERLOADING)
TimerStopMethodInfo ,
#endif
timerStop ,
) 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
newtype Timer = Timer (ManagedPtr Timer)
deriving (Timer -> Timer -> Bool
(Timer -> Timer -> Bool) -> (Timer -> Timer -> Bool) -> Eq Timer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Timer -> Timer -> Bool
$c/= :: Timer -> Timer -> Bool
== :: Timer -> Timer -> Bool
$c== :: Timer -> Timer -> Bool
Eq)
instance WrappedPtr Timer where
wrappedPtrCalloc :: IO (Ptr Timer)
wrappedPtrCalloc = Ptr Timer -> IO (Ptr Timer)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Timer
forall a. Ptr a
nullPtr
wrappedPtrCopy :: Timer -> IO Timer
wrappedPtrCopy = Timer -> IO Timer
forall (m :: * -> *) a. Monad m => a -> m a
return
wrappedPtrFree :: Maybe (GDestroyNotify Timer)
wrappedPtrFree = Maybe (GDestroyNotify Timer)
forall a. Maybe a
Nothing
noTimer :: Maybe Timer
noTimer :: Maybe Timer
noTimer = Maybe Timer
forall a. Maybe a
Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Timer
type instance O.AttributeList Timer = TimerAttributeList
type TimerAttributeList = ('[ ] :: [(Symbol, *)])
#endif
foreign import ccall "g_timer_continue" g_timer_continue ::
Ptr Timer ->
IO ()
timerContinue ::
(B.CallStack.HasCallStack, MonadIO m) =>
Timer
-> m ()
timerContinue :: Timer -> m ()
timerContinue timer :: Timer
timer = 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 Timer
timer' <- Timer -> IO (Ptr Timer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Timer
timer
Ptr Timer -> IO ()
g_timer_continue Ptr Timer
timer'
Timer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Timer
timer
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data TimerContinueMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo TimerContinueMethodInfo Timer signature where
overloadedMethod = timerContinue
#endif
foreign import ccall "g_timer_destroy" g_timer_destroy ::
Ptr Timer ->
IO ()
timerDestroy ::
(B.CallStack.HasCallStack, MonadIO m) =>
Timer
-> m ()
timerDestroy :: Timer -> m ()
timerDestroy timer :: Timer
timer = 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 Timer
timer' <- Timer -> IO (Ptr Timer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Timer
timer
Ptr Timer -> IO ()
g_timer_destroy Ptr Timer
timer'
Timer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Timer
timer
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data TimerDestroyMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo TimerDestroyMethodInfo Timer signature where
overloadedMethod = timerDestroy
#endif
foreign import ccall "g_timer_elapsed" g_timer_elapsed ::
Ptr Timer ->
CULong ->
IO CDouble
timerElapsed ::
(B.CallStack.HasCallStack, MonadIO m) =>
Timer
-> CULong
-> m Double
timerElapsed :: Timer -> CULong -> m Double
timerElapsed timer :: Timer
timer microseconds :: CULong
microseconds = IO Double -> m Double
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Double -> m Double) -> IO Double -> m Double
forall a b. (a -> b) -> a -> b
$ do
Ptr Timer
timer' <- Timer -> IO (Ptr Timer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Timer
timer
CDouble
result <- Ptr Timer -> CULong -> IO CDouble
g_timer_elapsed Ptr Timer
timer' CULong
microseconds
let result' :: Double
result' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
result
Timer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Timer
timer
Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return Double
result'
#if defined(ENABLE_OVERLOADING)
data TimerElapsedMethodInfo
instance (signature ~ (CULong -> m Double), MonadIO m) => O.MethodInfo TimerElapsedMethodInfo Timer signature where
overloadedMethod = timerElapsed
#endif
foreign import ccall "g_timer_reset" g_timer_reset ::
Ptr Timer ->
IO ()
timerReset ::
(B.CallStack.HasCallStack, MonadIO m) =>
Timer
-> m ()
timerReset :: Timer -> m ()
timerReset timer :: Timer
timer = 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 Timer
timer' <- Timer -> IO (Ptr Timer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Timer
timer
Ptr Timer -> IO ()
g_timer_reset Ptr Timer
timer'
Timer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Timer
timer
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data TimerResetMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo TimerResetMethodInfo Timer signature where
overloadedMethod = timerReset
#endif
foreign import ccall "g_timer_start" g_timer_start ::
Ptr Timer ->
IO ()
timerStart ::
(B.CallStack.HasCallStack, MonadIO m) =>
Timer
-> m ()
timerStart :: Timer -> m ()
timerStart timer :: Timer
timer = 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 Timer
timer' <- Timer -> IO (Ptr Timer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Timer
timer
Ptr Timer -> IO ()
g_timer_start Ptr Timer
timer'
Timer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Timer
timer
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data TimerStartMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo TimerStartMethodInfo Timer signature where
overloadedMethod = timerStart
#endif
foreign import ccall "g_timer_stop" g_timer_stop ::
Ptr Timer ->
IO ()
timerStop ::
(B.CallStack.HasCallStack, MonadIO m) =>
Timer
-> m ()
timerStop :: Timer -> m ()
timerStop timer :: Timer
timer = 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 Timer
timer' <- Timer -> IO (Ptr Timer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Timer
timer
Ptr Timer -> IO ()
g_timer_stop Ptr Timer
timer'
Timer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Timer
timer
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data TimerStopMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo TimerStopMethodInfo Timer signature where
overloadedMethod = timerStop
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveTimerMethod (t :: Symbol) (o :: *) :: * where
ResolveTimerMethod "continue" o = TimerContinueMethodInfo
ResolveTimerMethod "destroy" o = TimerDestroyMethodInfo
ResolveTimerMethod "elapsed" o = TimerElapsedMethodInfo
ResolveTimerMethod "reset" o = TimerResetMethodInfo
ResolveTimerMethod "start" o = TimerStartMethodInfo
ResolveTimerMethod "stop" o = TimerStopMethodInfo
ResolveTimerMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveTimerMethod t Timer, O.MethodInfo info Timer p) => OL.IsLabel t (Timer -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif