mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-12 20:36:15 +01:00
Merge branch 'boxing_gtree_gqueue_gnode' into 'master'
Add boxing for GTree, GQueue and GNode Closes #1233 See merge request GNOME/glib!1029
This commit is contained in:
commit
97956c2d3d
@ -409,6 +409,7 @@ G_TYPE_POLLFD
|
||||
G_TYPE_THREAD
|
||||
G_TYPE_OPTION_GROUP
|
||||
G_TYPE_URI
|
||||
G_TYPE_TREE
|
||||
|
||||
<SUBSECTION Standard>
|
||||
G_TYPE_IS_BOXED
|
||||
@ -443,6 +444,7 @@ g_markup_parse_context_get_type
|
||||
g_thread_get_type
|
||||
g_option_group_get_type
|
||||
g_uri_get_type
|
||||
g_tree_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
|
@ -145,6 +145,7 @@ G_DEFINE_BOXED_TYPE (GArray, g_array, g_array_ref, g_array_unref)
|
||||
G_DEFINE_BOXED_TYPE (GPtrArray, g_ptr_array,g_ptr_array_ref, g_ptr_array_unref)
|
||||
G_DEFINE_BOXED_TYPE (GByteArray, g_byte_array, g_byte_array_ref, g_byte_array_unref)
|
||||
G_DEFINE_BOXED_TYPE (GBytes, g_bytes, g_bytes_ref, g_bytes_unref)
|
||||
G_DEFINE_BOXED_TYPE (GTree, g_tree, g_tree_ref, g_tree_unref)
|
||||
|
||||
G_DEFINE_BOXED_TYPE (GRegex, g_regex, g_regex_ref, g_regex_unref)
|
||||
G_DEFINE_BOXED_TYPE (GMatchInfo, g_match_info, g_match_info_ref, g_match_info_unref)
|
||||
|
@ -306,6 +306,15 @@ typedef gsize GType;
|
||||
*/
|
||||
#define G_TYPE_URI (g_uri_get_type ())
|
||||
|
||||
/**
|
||||
* G_TYPE_TREE:
|
||||
*
|
||||
* The #GType for #GTree.
|
||||
*
|
||||
* Since: 2.68
|
||||
*/
|
||||
#define G_TYPE_TREE (g_tree_get_type ())
|
||||
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
GType g_date_get_type (void) G_GNUC_CONST;
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
@ -364,6 +373,8 @@ GLIB_AVAILABLE_IN_2_44
|
||||
GType g_option_group_get_type (void) G_GNUC_CONST;
|
||||
GLIB_AVAILABLE_IN_2_66
|
||||
GType g_uri_get_type (void) G_GNUC_CONST;
|
||||
GLIB_AVAILABLE_IN_2_68
|
||||
GType g_tree_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GLIB_DEPRECATED_FOR('G_TYPE_VARIANT')
|
||||
GType g_variant_get_gtype (void) G_GNUC_CONST;
|
||||
|
@ -617,6 +617,34 @@ test_boxed_checksum (void)
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
||||
static gint
|
||||
treecmp (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
return (a < b) ? -1 : (a > b);
|
||||
}
|
||||
|
||||
static void
|
||||
test_boxed_tree (void)
|
||||
{
|
||||
GTree *t, *t2;
|
||||
GValue value = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&value, G_TYPE_TREE);
|
||||
g_assert_true (G_VALUE_HOLDS_BOXED (&value));
|
||||
|
||||
t = g_tree_new (treecmp);
|
||||
g_value_take_boxed (&value, t);
|
||||
|
||||
t2 = g_value_get_boxed (&value);
|
||||
g_assert_true (t == t2);
|
||||
|
||||
t2 = g_value_dup_boxed (&value);
|
||||
g_assert_true (t == t2); /* trees use ref/unref for copy/free */
|
||||
g_tree_unref (t2);
|
||||
|
||||
g_value_unset (&value);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@ -646,6 +674,7 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/boxed/markup", test_boxed_markup);
|
||||
g_test_add_func ("/boxed/thread", test_boxed_thread);
|
||||
g_test_add_func ("/boxed/checksum", test_boxed_checksum);
|
||||
g_test_add_func ("/boxed/tree", test_boxed_tree);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user