// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT package glib import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/gobject/types" ) // The GRand struct is an opaque data structure. It should only be // accessed through the g_rand_* functions. type Rand struct { _ structs.HostLayout } var xRandGLibType func() types.GType func RandGLibType() types.GType { return xRandGLibType() } func (x *Rand) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } var xNewRand func() *Rand // Creates a new random number generator initialized with a seed taken // either from `/dev/urandom` (if existing) or from the current time // (as a fallback). // // On Windows, the seed is taken from rand_s(). func NewRand() *Rand { cret := xNewRand() return cret } var xNewRandWithSeed func(uint32) *Rand // Creates a new random number generator initialized with @seed. func NewRandWithSeed(SeedVar uint32) *Rand { cret := xNewRandWithSeed(SeedVar) return cret } var xNewRandWithSeedArray func(uint32, uint) *Rand // Creates a new random number generator initialized with @seed. func NewRandWithSeedArray(SeedVar uint32, SeedLengthVar uint) *Rand { cret := xNewRandWithSeedArray(SeedVar, SeedLengthVar) return cret } var xRandCopy func(uintptr) *Rand // Copies a #GRand into a new one with the same exact state as before. // This way you can take a snapshot of the random number generator for // replaying later. func (x *Rand) Copy() *Rand { cret := xRandCopy(x.GoPointer()) return cret } var xRandDouble func(uintptr) float64 // Returns the next random #gdouble from @rand_ equally distributed over // the range [0..1). func (x *Rand) Double() float64 { cret := xRandDouble(x.GoPointer()) return cret } var xRandDoubleRange func(uintptr, float64, float64) float64 // Returns the next random #gdouble from @rand_ equally distributed over // the range [@begin..@end). func (x *Rand) DoubleRange(BeginVar float64, EndVar float64) float64 { cret := xRandDoubleRange(x.GoPointer(), BeginVar, EndVar) return cret } var xRandFree func(uintptr) // Frees the memory allocated for the #GRand. func (x *Rand) Free() { xRandFree(x.GoPointer()) } var xRandInt func(uintptr) uint32 // Returns the next random #guint32 from @rand_ equally distributed over // the range [0..2^32-1]. func (x *Rand) Int() uint32 { cret := xRandInt(x.GoPointer()) return cret } var xRandIntRange func(uintptr, int32, int32) int32 // Returns the next random #gint32 from @rand_ equally distributed over // the range [@begin..@end-1]. func (x *Rand) IntRange(BeginVar int32, EndVar int32) int32 { cret := xRandIntRange(x.GoPointer(), BeginVar, EndVar) return cret } var xRandSetSeed func(uintptr, uint32) // Sets the seed for the random number generator #GRand to @seed. func (x *Rand) SetSeed(SeedVar uint32) { xRandSetSeed(x.GoPointer(), SeedVar) } var xRandSetSeedArray func(uintptr, uint32, uint) // Initializes the random number generator by an array of longs. // Array can be of arbitrary size, though only the first 624 values // are taken. This function is useful if you have many low entropy // seeds, or if you require more then 32 bits of actual entropy for // your application. func (x *Rand) SetSeedArray(SeedVar uint32, SeedLengthVar uint) { xRandSetSeedArray(x.GoPointer(), SeedVar, SeedLengthVar) } var xRandomDouble func() float64 // Returns a random #gdouble equally distributed over the range [0..1). func RandomDouble() float64 { cret := xRandomDouble() return cret } var xRandomDoubleRange func(float64, float64) float64 // Returns a random #gdouble equally distributed over the range // [@begin..@end). func RandomDoubleRange(BeginVar float64, EndVar float64) float64 { cret := xRandomDoubleRange(BeginVar, EndVar) return cret } var xRandomInt func() uint32 // Return a random #guint32 equally distributed over the range // [0..2^32-1]. func RandomInt() uint32 { cret := xRandomInt() return cret } var xRandomIntRange func(int32, int32) int32 // Returns a random #gint32 equally distributed over the range // [@begin..@end-1]. func RandomIntRange(BeginVar int32, EndVar int32) int32 { cret := xRandomIntRange(BeginVar, EndVar) return cret } var xRandomSetSeed func(uint32) // Sets the seed for the global random number generator, which is used // by the g_random_* functions, to @seed. func RandomSetSeed(SeedVar uint32) { xRandomSetSeed(SeedVar) } func init() { core.SetPackageName("GLIB", "glib-2.0") core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"}) var libs []uintptr for _, libPath := range core.GetPaths("GLIB") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xRandomDouble, libs, "g_random_double") core.PuregoSafeRegister(&xRandomDoubleRange, libs, "g_random_double_range") core.PuregoSafeRegister(&xRandomInt, libs, "g_random_int") core.PuregoSafeRegister(&xRandomIntRange, libs, "g_random_int_range") core.PuregoSafeRegister(&xRandomSetSeed, libs, "g_random_set_seed") core.PuregoSafeRegister(&xRandGLibType, libs, "g_rand_get_type") core.PuregoSafeRegister(&xNewRand, libs, "g_rand_new") core.PuregoSafeRegister(&xNewRandWithSeed, libs, "g_rand_new_with_seed") core.PuregoSafeRegister(&xNewRandWithSeedArray, libs, "g_rand_new_with_seed_array") core.PuregoSafeRegister(&xRandCopy, libs, "g_rand_copy") core.PuregoSafeRegister(&xRandDouble, libs, "g_rand_double") core.PuregoSafeRegister(&xRandDoubleRange, libs, "g_rand_double_range") core.PuregoSafeRegister(&xRandFree, libs, "g_rand_free") core.PuregoSafeRegister(&xRandInt, libs, "g_rand_int") core.PuregoSafeRegister(&xRandIntRange, libs, "g_rand_int_range") core.PuregoSafeRegister(&xRandSetSeed, libs, "g_rand_set_seed") core.PuregoSafeRegister(&xRandSetSeedArray, libs, "g_rand_set_seed_array") }