Add boxed GType for GRand

Signed-off-by: Tanmay Patil <tanmaynpatil105@gmail.com>
This commit is contained in:
Tanmay 2023-12-31 09:09:48 +00:00 committed by Philip Withnall
parent eddd04add1
commit dbbd9c60ba
3 changed files with 35 additions and 0 deletions

View File

@ -140,6 +140,7 @@ G_DEFINE_BOXED_TYPE (GMappedFile, g_mapped_file, g_mapped_file_ref, g_mapped_fil
G_DEFINE_BOXED_TYPE (GBookmarkFile, g_bookmark_file, g_bookmark_file_copy, g_bookmark_file_free)
G_DEFINE_BOXED_TYPE (GHmac, g_hmac, g_hmac_ref, g_hmac_unref)
G_DEFINE_BOXED_TYPE (GDir, g_dir, g_dir_ref, g_dir_unref)
G_DEFINE_BOXED_TYPE (GRand, g_rand, g_rand_copy, g_rand_free)
G_DEFINE_BOXED_TYPE (GMainLoop, g_main_loop, g_main_loop_ref, g_main_loop_unref)
G_DEFINE_BOXED_TYPE (GMainContext, g_main_context, g_main_context_ref, g_main_context_unref)

View File

@ -354,6 +354,15 @@ typedef gsize GType;
*/
#define G_TYPE_DIR (g_dir_get_type ())
/**
* G_TYPE_RAND:
*
* The #GType for a boxed type holding a #GRand.
*
* Since: 2.80
*/
#define G_TYPE_RAND (g_rand_get_type ())
/**
* G_TYPE_STRV_BUILDER:
*
@ -432,6 +441,8 @@ GType g_hmac_get_type (void) G_GNUC_CONST;
GOBJECT_AVAILABLE_IN_2_80
GType g_dir_get_type (void) G_GNUC_CONST;
GOBJECT_AVAILABLE_IN_2_80
GType g_rand_get_type (void) G_GNUC_CONST;
GOBJECT_AVAILABLE_IN_2_80
GType g_strv_builder_get_type (void) G_GNUC_CONST;
GOBJECT_DEPRECATED_FOR('G_TYPE_VARIANT')

View File

@ -668,6 +668,28 @@ test_boxed_pattern_spec (void)
g_value_unset (&value);
}
static void
test_boxed_rand (void)
{
GRand *r, *r2;
GValue value = G_VALUE_INIT;
g_value_init (&value, G_TYPE_RAND);
g_assert_true (G_VALUE_HOLDS_BOXED (&value));
r = g_rand_new ();
g_value_take_boxed (&value, r);
r2 = g_value_get_boxed (&value);
g_assert_true (r == r2);
r2 = g_value_dup_boxed (&value);
g_assert_true (r != r2);
g_rand_free (r2);
g_value_unset (&value);
}
int
main (int argc, char *argv[])
{
@ -699,6 +721,7 @@ main (int argc, char *argv[])
g_test_add_func ("/boxed/checksum", test_boxed_checksum);
g_test_add_func ("/boxed/tree", test_boxed_tree);
g_test_add_func ("/boxed/patternspec", test_boxed_pattern_spec);
g_test_add_func ("/boxed/rand", test_boxed_rand);
return g_test_run ();
}