gi-glib-0.2.44.12: GI/GLib/Structs/Rand.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
The GRand struct is an opaque data structure. It should only be
accessed through the g_rand_* functions.
-}
module GI.GLib.Structs.Rand
(
-- * Exported types
Rand(..) ,
noRand ,
-- * Methods
-- ** randDouble
randDouble ,
-- ** randDoubleRange
randDoubleRange ,
-- ** randFree
randFree ,
-- ** randInt
randInt ,
-- ** randIntRange
randIntRange ,
-- ** randSetSeed
randSetSeed ,
-- ** randSetSeedArray
randSetSeedArray ,
) 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 Rand = Rand (ForeignPtr Rand)
noRand :: Maybe Rand
noRand = Nothing
-- method Rand::double
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Rand", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Rand", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TDouble
-- throws : False
-- Skip return : False
foreign import ccall "g_rand_double" g_rand_double ::
Ptr Rand -> -- _obj : TInterface "GLib" "Rand"
IO CDouble
randDouble ::
(MonadIO m) =>
Rand -> -- _obj
m Double
randDouble _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- g_rand_double _obj'
let result' = realToFrac result
touchManagedPtr _obj
return result'
-- method Rand::double_range
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Rand", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "begin", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "end", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Rand", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "begin", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "end", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TDouble
-- throws : False
-- Skip return : False
foreign import ccall "g_rand_double_range" g_rand_double_range ::
Ptr Rand -> -- _obj : TInterface "GLib" "Rand"
CDouble -> -- begin : TBasicType TDouble
CDouble -> -- end : TBasicType TDouble
IO CDouble
randDoubleRange ::
(MonadIO m) =>
Rand -> -- _obj
Double -> -- begin
Double -> -- end
m Double
randDoubleRange _obj begin end = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
let begin' = realToFrac begin
let end' = realToFrac end
result <- g_rand_double_range _obj' begin' end'
let result' = realToFrac result
touchManagedPtr _obj
return result'
-- method Rand::free
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Rand", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Rand", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_rand_free" g_rand_free ::
Ptr Rand -> -- _obj : TInterface "GLib" "Rand"
IO ()
randFree ::
(MonadIO m) =>
Rand -> -- _obj
m ()
randFree _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
g_rand_free _obj'
touchManagedPtr _obj
return ()
-- method Rand::int
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Rand", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Rand", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False
foreign import ccall "g_rand_int" g_rand_int ::
Ptr Rand -> -- _obj : TInterface "GLib" "Rand"
IO Word32
randInt ::
(MonadIO m) =>
Rand -> -- _obj
m Word32
randInt _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- g_rand_int _obj'
touchManagedPtr _obj
return result
-- method Rand::int_range
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Rand", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "begin", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "end", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Rand", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "begin", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "end", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False
foreign import ccall "g_rand_int_range" g_rand_int_range ::
Ptr Rand -> -- _obj : TInterface "GLib" "Rand"
Int32 -> -- begin : TBasicType TInt32
Int32 -> -- end : TBasicType TInt32
IO Int32
randIntRange ::
(MonadIO m) =>
Rand -> -- _obj
Int32 -> -- begin
Int32 -> -- end
m Int32
randIntRange _obj begin end = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- g_rand_int_range _obj' begin end
touchManagedPtr _obj
return result
-- method Rand::set_seed
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Rand", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "seed", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Rand", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "seed", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_rand_set_seed" g_rand_set_seed ::
Ptr Rand -> -- _obj : TInterface "GLib" "Rand"
Word32 -> -- seed : TBasicType TUInt32
IO ()
randSetSeed ::
(MonadIO m) =>
Rand -> -- _obj
Word32 -> -- seed
m ()
randSetSeed _obj seed = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
g_rand_set_seed _obj' seed
touchManagedPtr _obj
return ()
-- method Rand::set_seed_array
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Rand", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "seed", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "seed_length", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Rand", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "seed", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "seed_length", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_rand_set_seed_array" g_rand_set_seed_array ::
Ptr Rand -> -- _obj : TInterface "GLib" "Rand"
Word32 -> -- seed : TBasicType TUInt32
Word32 -> -- seed_length : TBasicType TUInt32
IO ()
randSetSeedArray ::
(MonadIO m) =>
Rand -> -- _obj
Word32 -> -- seed
Word32 -> -- seed_length
m ()
randSetSeedArray _obj seed seed_length = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
g_rand_set_seed_array _obj' seed seed_length
touchManagedPtr _obj
return ()