[glib: 2/6] boxed: Register GPatternSpec as boxed type
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/6] boxed: Register GPatternSpec as boxed type
- Date: Tue, 27 Apr 2021 14:43:32 +0000 (UTC)
commit b8a9f4b43637eb60ab149693c5b09744be4da60f
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Sun Apr 25 02:19:36 2021 +0200
boxed: Register GPatternSpec as boxed type
docs/reference/gobject/gobject-sections.txt | 2 ++
gobject/gboxed.c | 1 +
gobject/glib-types.h | 11 +++++++++++
gobject/tests/boxed.c | 24 ++++++++++++++++++++++++
4 files changed, 38 insertions(+)
---
diff --git a/docs/reference/gobject/gobject-sections.txt b/docs/reference/gobject/gobject-sections.txt
index 54fbccaf8..bc8e0c7fb 100644
--- a/docs/reference/gobject/gobject-sections.txt
+++ b/docs/reference/gobject/gobject-sections.txt
@@ -411,6 +411,7 @@ G_TYPE_THREAD
G_TYPE_OPTION_GROUP
G_TYPE_URI
G_TYPE_TREE
+G_TYPE_PATTERN_SPEC
<SUBSECTION Standard>
G_TYPE_IS_BOXED
@@ -446,6 +447,7 @@ g_thread_get_type
g_option_group_get_type
g_uri_get_type
g_tree_get_type
+g_pattern_spec_get_type
</SECTION>
<SECTION>
diff --git a/gobject/gboxed.c b/gobject/gboxed.c
index 194251383..ae48df566 100644
--- a/gobject/gboxed.c
+++ b/gobject/gboxed.c
@@ -175,6 +175,7 @@ G_DEFINE_BOXED_TYPE (GChecksum, g_checksum, g_checksum_copy, g_checksum_free)
G_DEFINE_BOXED_TYPE (GUri, g_uri, g_uri_ref, g_uri_unref)
G_DEFINE_BOXED_TYPE (GOptionGroup, g_option_group, g_option_group_ref, g_option_group_unref)
+G_DEFINE_BOXED_TYPE (GPatternSpec, g_pattern_spec, g_pattern_spec_copy, g_pattern_spec_free);
/* This one can't use G_DEFINE_BOXED_TYPE (GStrv, g_strv, g_strdupv, g_strfreev) */
GType
diff --git a/gobject/glib-types.h b/gobject/glib-types.h
index cdccdaab4..808284622 100644
--- a/gobject/glib-types.h
+++ b/gobject/glib-types.h
@@ -315,6 +315,15 @@ typedef gsize GType;
*/
#define G_TYPE_TREE (g_tree_get_type ())
+/**
+ * G_TYPE_PATTERN_SPEC:
+ *
+ * The #GType for #GPatternSpec.
+ *
+ * Since: 2.70
+ */
+#define G_TYPE_PATTERN_SPEC (g_pattern_spec_get_type ())
+
GLIB_AVAILABLE_IN_ALL
GType g_date_get_type (void) G_GNUC_CONST;
GLIB_AVAILABLE_IN_ALL
@@ -375,6 +384,8 @@ 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_AVAILABLE_IN_2_70
+GType g_pattern_spec_get_type (void) G_GNUC_CONST;
GLIB_DEPRECATED_FOR('G_TYPE_VARIANT')
GType g_variant_get_gtype (void) G_GNUC_CONST;
diff --git a/gobject/tests/boxed.c b/gobject/tests/boxed.c
index 0c8872a82..f961a2f87 100644
--- a/gobject/tests/boxed.c
+++ b/gobject/tests/boxed.c
@@ -645,6 +645,29 @@ test_boxed_tree (void)
g_value_unset (&value);
}
+static void
+test_boxed_pattern_spec (void)
+{
+ GPatternSpec *ps, *ps2;
+ GValue value = G_VALUE_INIT;
+
+ g_value_init (&value, G_TYPE_PATTERN_SPEC);
+ g_assert_true (G_VALUE_HOLDS_BOXED (&value));
+
+ ps = g_pattern_spec_new ("*abc*?cde");
+ g_value_take_boxed (&value, ps);
+
+ ps2 = g_value_get_boxed (&value);
+ g_assert_true (ps == ps2);
+
+ ps2 = g_value_dup_boxed (&value);
+ g_assert_true (ps != ps2);
+ g_assert_true (g_pattern_spec_equal (ps, ps2));
+ g_pattern_spec_free (ps2);
+
+ g_value_unset (&value);
+}
+
int
main (int argc, char *argv[])
{
@@ -675,6 +698,7 @@ main (int argc, char *argv[])
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);
+ g_test_add_func ("/boxed/patternspec", test_boxed_pattern_spec);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]