{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GLib.Structs.Rand
(
Rand(..) ,
noRand ,
#if defined(ENABLE_OVERLOADING)
ResolveRandMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
RandDoubleMethodInfo ,
#endif
randDouble ,
#if defined(ENABLE_OVERLOADING)
RandDoubleRangeMethodInfo ,
#endif
randDoubleRange ,
#if defined(ENABLE_OVERLOADING)
RandFreeMethodInfo ,
#endif
randFree ,
#if defined(ENABLE_OVERLOADING)
RandIntMethodInfo ,
#endif
randInt ,
#if defined(ENABLE_OVERLOADING)
RandIntRangeMethodInfo ,
#endif
randIntRange ,
#if defined(ENABLE_OVERLOADING)
RandSetSeedMethodInfo ,
#endif
randSetSeed ,
#if defined(ENABLE_OVERLOADING)
RandSetSeedArrayMethodInfo ,
#endif
randSetSeedArray ,
) 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 Rand = Rand (ManagedPtr Rand)
deriving (Rand -> Rand -> Bool
(Rand -> Rand -> Bool) -> (Rand -> Rand -> Bool) -> Eq Rand
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Rand -> Rand -> Bool
$c/= :: Rand -> Rand -> Bool
== :: Rand -> Rand -> Bool
$c== :: Rand -> Rand -> Bool
Eq)
instance WrappedPtr Rand where
wrappedPtrCalloc :: IO (Ptr Rand)
wrappedPtrCalloc = Ptr Rand -> IO (Ptr Rand)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Rand
forall a. Ptr a
nullPtr
wrappedPtrCopy :: Rand -> IO Rand
wrappedPtrCopy = Rand -> IO Rand
forall (m :: * -> *) a. Monad m => a -> m a
return
wrappedPtrFree :: Maybe (GDestroyNotify Rand)
wrappedPtrFree = Maybe (GDestroyNotify Rand)
forall a. Maybe a
Nothing
noRand :: Maybe Rand
noRand :: Maybe Rand
noRand = Maybe Rand
forall a. Maybe a
Nothing
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Rand
type instance O.AttributeList Rand = RandAttributeList
type RandAttributeList = ('[ ] :: [(Symbol, *)])
#endif
foreign import ccall "g_rand_double" g_rand_double ::
Ptr Rand ->
IO CDouble
randDouble ::
(B.CallStack.HasCallStack, MonadIO m) =>
Rand
-> m Double
randDouble :: Rand -> m Double
randDouble rand_ :: Rand
rand_ = 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 Rand
rand_' <- Rand -> IO (Ptr Rand)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Rand
rand_
CDouble
result <- Ptr Rand -> IO CDouble
g_rand_double Ptr Rand
rand_'
let result' :: Double
result' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
result
Rand -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Rand
rand_
Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return Double
result'
#if defined(ENABLE_OVERLOADING)
data RandDoubleMethodInfo
instance (signature ~ (m Double), MonadIO m) => O.MethodInfo RandDoubleMethodInfo Rand signature where
overloadedMethod = randDouble
#endif
foreign import ccall "g_rand_double_range" g_rand_double_range ::
Ptr Rand ->
CDouble ->
CDouble ->
IO CDouble
randDoubleRange ::
(B.CallStack.HasCallStack, MonadIO m) =>
Rand
-> Double
-> Double
-> m Double
randDoubleRange :: Rand -> Double -> Double -> m Double
randDoubleRange rand_ :: Rand
rand_ begin :: Double
begin end :: Double
end = 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 Rand
rand_' <- Rand -> IO (Ptr Rand)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Rand
rand_
let begin' :: CDouble
begin' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
begin
let end' :: CDouble
end' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
end
CDouble
result <- Ptr Rand -> CDouble -> CDouble -> IO CDouble
g_rand_double_range Ptr Rand
rand_' CDouble
begin' CDouble
end'
let result' :: Double
result' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
result
Rand -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Rand
rand_
Double -> IO Double
forall (m :: * -> *) a. Monad m => a -> m a
return Double
result'
#if defined(ENABLE_OVERLOADING)
data RandDoubleRangeMethodInfo
instance (signature ~ (Double -> Double -> m Double), MonadIO m) => O.MethodInfo RandDoubleRangeMethodInfo Rand signature where
overloadedMethod = randDoubleRange
#endif
foreign import ccall "g_rand_free" g_rand_free ::
Ptr Rand ->
IO ()
randFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
Rand
-> m ()
randFree :: Rand -> m ()
randFree rand_ :: Rand
rand_ = 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 Rand
rand_' <- Rand -> IO (Ptr Rand)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Rand
rand_
Ptr Rand -> IO ()
g_rand_free Ptr Rand
rand_'
Rand -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Rand
rand_
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data RandFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo RandFreeMethodInfo Rand signature where
overloadedMethod = randFree
#endif
foreign import ccall "g_rand_int" g_rand_int ::
Ptr Rand ->
IO Word32
randInt ::
(B.CallStack.HasCallStack, MonadIO m) =>
Rand
-> m Word32
randInt :: Rand -> m Word32
randInt rand_ :: Rand
rand_ = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
Ptr Rand
rand_' <- Rand -> IO (Ptr Rand)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Rand
rand_
Word32
result <- Ptr Rand -> IO Word32
g_rand_int Ptr Rand
rand_'
Rand -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Rand
rand_
Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result
#if defined(ENABLE_OVERLOADING)
data RandIntMethodInfo
instance (signature ~ (m Word32), MonadIO m) => O.MethodInfo RandIntMethodInfo Rand signature where
overloadedMethod = randInt
#endif
foreign import ccall "g_rand_int_range" g_rand_int_range ::
Ptr Rand ->
Int32 ->
Int32 ->
IO Int32
randIntRange ::
(B.CallStack.HasCallStack, MonadIO m) =>
Rand
-> Int32
-> Int32
-> m Int32
randIntRange :: Rand -> Int32 -> Int32 -> m Int32
randIntRange rand_ :: Rand
rand_ begin :: Int32
begin end :: Int32
end = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
Ptr Rand
rand_' <- Rand -> IO (Ptr Rand)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Rand
rand_
Int32
result <- Ptr Rand -> Int32 -> Int32 -> IO Int32
g_rand_int_range Ptr Rand
rand_' Int32
begin Int32
end
Rand -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Rand
rand_
Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result
#if defined(ENABLE_OVERLOADING)
data RandIntRangeMethodInfo
instance (signature ~ (Int32 -> Int32 -> m Int32), MonadIO m) => O.MethodInfo RandIntRangeMethodInfo Rand signature where
overloadedMethod = randIntRange
#endif
foreign import ccall "g_rand_set_seed" g_rand_set_seed ::
Ptr Rand ->
Word32 ->
IO ()
randSetSeed ::
(B.CallStack.HasCallStack, MonadIO m) =>
Rand
-> Word32
-> m ()
randSetSeed :: Rand -> Word32 -> m ()
randSetSeed rand_ :: Rand
rand_ seed :: Word32
seed = 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 Rand
rand_' <- Rand -> IO (Ptr Rand)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Rand
rand_
Ptr Rand -> Word32 -> IO ()
g_rand_set_seed Ptr Rand
rand_' Word32
seed
Rand -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Rand
rand_
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data RandSetSeedMethodInfo
instance (signature ~ (Word32 -> m ()), MonadIO m) => O.MethodInfo RandSetSeedMethodInfo Rand signature where
overloadedMethod = randSetSeed
#endif
foreign import ccall "g_rand_set_seed_array" g_rand_set_seed_array ::
Ptr Rand ->
Word32 ->
Word32 ->
IO ()
randSetSeedArray ::
(B.CallStack.HasCallStack, MonadIO m) =>
Rand
-> Word32
-> Word32
-> m ()
randSetSeedArray :: Rand -> Word32 -> Word32 -> m ()
randSetSeedArray rand_ :: Rand
rand_ seed :: Word32
seed seedLength :: Word32
seedLength = 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 Rand
rand_' <- Rand -> IO (Ptr Rand)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Rand
rand_
Ptr Rand -> Word32 -> Word32 -> IO ()
g_rand_set_seed_array Ptr Rand
rand_' Word32
seed Word32
seedLength
Rand -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Rand
rand_
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data RandSetSeedArrayMethodInfo
instance (signature ~ (Word32 -> Word32 -> m ()), MonadIO m) => O.MethodInfo RandSetSeedArrayMethodInfo Rand signature where
overloadedMethod = randSetSeedArray
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveRandMethod (t :: Symbol) (o :: *) :: * where
ResolveRandMethod "double" o = RandDoubleMethodInfo
ResolveRandMethod "doubleRange" o = RandDoubleRangeMethodInfo
ResolveRandMethod "free" o = RandFreeMethodInfo
ResolveRandMethod "int" o = RandIntMethodInfo
ResolveRandMethod "intRange" o = RandIntRangeMethodInfo
ResolveRandMethod "setSeed" o = RandSetSeedMethodInfo
ResolveRandMethod "setSeedArray" o = RandSetSeedArrayMethodInfo
ResolveRandMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveRandMethod t Rand, O.MethodInfo info Rand p) => OL.IsLabel t (Rand -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif