{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GLib.Structs.Timer
(
Timer(..) ,
#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)
TimerIsActiveMethodInfo ,
#endif
timerIsActive ,
#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.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 Timer = Timer (SP.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 SP.ManagedPtrNewtype Timer where
toManagedPtr :: Timer -> ManagedPtr Timer
toManagedPtr (Timer ManagedPtr Timer
p) = ManagedPtr Timer
p
instance BoxedPtr Timer where
boxedPtrCopy :: Timer -> IO Timer
boxedPtrCopy = Timer -> IO Timer
forall (m :: * -> *) a. Monad m => a -> m a
return
boxedPtrFree :: Timer -> IO ()
boxedPtrFree = \Timer
_x -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#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 = 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 = 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 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_is_active" g_timer_is_active ::
Ptr Timer ->
IO CInt
timerIsActive ::
(B.CallStack.HasCallStack, MonadIO m) =>
Timer
-> m Bool
timerIsActive :: Timer -> m Bool
timerIsActive Timer
timer = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
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
CInt
result <- Ptr Timer -> IO CInt
g_timer_is_active Ptr Timer
timer'
let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
Timer -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Timer
timer
Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'
#if defined(ENABLE_OVERLOADING)
data TimerIsActiveMethodInfo
instance (signature ~ (m Bool), MonadIO m) => O.MethodInfo TimerIsActiveMethodInfo Timer signature where
overloadedMethod = timerIsActive
#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 = 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 = 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 = 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 "isActive" o = TimerIsActiveMethodInfo
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