[glib] Move GStrv typedef to glib.h instead of gobject.h
- From: Xavier Claessens <xclaesse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Move GStrv typedef to glib.h instead of gobject.h
- Date: Tue, 22 Sep 2015 15:18:39 +0000 (UTC)
commit b81f3ced716b81ea604876ba1e89b953e0d04813
Author: Xavier Claessens <xavier claessens collabora com>
Date: Mon Sep 21 10:41:00 2015 -0400
Move GStrv typedef to glib.h instead of gobject.h
GStrv was historically only needed for the boxed G_TYPE_STRV,
but it is now useful for g_auto(GStrv) as well. This is not
an ABI change.
https://bugzilla.gnome.org/show_bug.cgi?id=755355
docs/reference/glib/glib-sections.txt | 3 +++
docs/reference/gobject/gobject-sections.txt | 1 -
glib/docs.c | 2 ++
glib/glib-autocleanups.h | 1 +
glib/gstrfuncs.c | 7 +++++++
glib/gstrfuncs.h | 1 +
glib/tests/autoptr.c | 8 ++++++++
gobject/glib-types.h | 7 -------
gobject/gobject-autocleanups.h | 1 -
9 files changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 718ac62..e7d68d5 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -1453,6 +1453,9 @@ g_strfreev
g_strconcat
g_strjoin
g_strjoinv
+
+<SUBSECTION>
+GStrv
g_strv_length
g_strv_contains
diff --git a/docs/reference/gobject/gobject-sections.txt b/docs/reference/gobject/gobject-sections.txt
index b9f26c9..0f14f93 100644
--- a/docs/reference/gobject/gobject-sections.txt
+++ b/docs/reference/gobject/gobject-sections.txt
@@ -398,7 +398,6 @@ G_TYPE_SOURCE
G_TYPE_POLLFD
G_TYPE_THREAD
G_TYPE_OPTION_GROUP
-GStrv
<SUBSECTION Standard>
G_TYPE_IS_BOXED
diff --git a/glib/docs.c b/glib/docs.c
index d41899c..99531bc 100644
--- a/glib/docs.c
+++ b/glib/docs.c
@@ -2343,8 +2343,10 @@
* {
* g_auto(GQueue) queue = G_QUEUE_INIT;
* g_auto(GVariantBuilder) builder;
+ * g_auto(GStrv) strv;
*
* g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
+ * strv = g_strsplit("a:b:c", ":", -1);
*
* ...
*
diff --git a/glib/glib-autocleanups.h b/glib/glib-autocleanups.h
index f3929c0..6355f75 100644
--- a/glib/glib-autocleanups.h
+++ b/glib/glib-autocleanups.h
@@ -86,3 +86,4 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantIter, g_variant_iter_free)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantDict, g_variant_dict_unref)
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GVariantDict, g_variant_dict_clear)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantType, g_variant_type_free)
+G_DEFINE_AUTO_CLEANUP_FREE_FUNC(GStrv, g_strfreev, NULL)
diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c
index dde6126..6712a64 100644
--- a/glib/gstrfuncs.c
+++ b/glib/gstrfuncs.c
@@ -2459,6 +2459,13 @@ g_strsplit_set (const gchar *string,
}
/**
+ * GStrv:
+ *
+ * A typedef alias for gchar**. This is mostly useful when used together with
+ * g_auto().
+ */
+
+/**
* g_strfreev:
* @str_array: a %NULL-terminated array of strings to free
*
diff --git a/glib/gstrfuncs.h b/glib/gstrfuncs.h
index 76004aa..bc0c48e 100644
--- a/glib/gstrfuncs.h
+++ b/glib/gstrfuncs.h
@@ -265,6 +265,7 @@ gpointer g_memdup (gconstpointer mem,
* g_strdupv() copies a NULL-terminated array of strings
* g_strv_length() returns the length of a NULL-terminated array of strings
*/
+typedef gchar** GStrv;
GLIB_AVAILABLE_IN_ALL
gchar** g_strsplit (const gchar *string,
const gchar *delimiter,
diff --git a/glib/tests/autoptr.c b/glib/tests/autoptr.c
index 6f0eafb..b44cf13 100644
--- a/glib/tests/autoptr.c
+++ b/glib/tests/autoptr.c
@@ -398,6 +398,13 @@ test_g_variant_type (void)
g_assert (val != NULL);
}
+static void
+test_strv (void)
+{
+ g_auto(GStrv) val = g_strsplit("a:b:c", ":", -1);
+ g_assert (val != NULL);
+}
+
int
main (int argc, gchar *argv[])
{
@@ -449,6 +456,7 @@ main (int argc, gchar *argv[])
g_test_add_func ("/autoptr/g_variant_iter", test_g_variant_iter);
g_test_add_func ("/autoptr/g_variant_dict", test_g_variant_dict);
g_test_add_func ("/autoptr/g_variant_type", test_g_variant_type);
+ g_test_add_func ("/autoptr/strv", test_strv);
return g_test_run ();
}
diff --git a/gobject/glib-types.h b/gobject/glib-types.h
index ac222b8..36d7e6e 100644
--- a/gobject/glib-types.h
+++ b/gobject/glib-types.h
@@ -357,13 +357,6 @@ GType g_option_group_get_type (void) G_GNUC_CONST;
GLIB_DEPRECATED_FOR('G_TYPE_VARIANT')
GType g_variant_get_gtype (void) G_GNUC_CONST;
-/**
- * GStrv:
- *
- * A C representable type name for #G_TYPE_STRV.
- */
-typedef gchar** GStrv;
-
G_END_DECLS
#endif /* __GLIB_TYPES_H__ */
diff --git a/gobject/gobject-autocleanups.h b/gobject/gobject-autocleanups.h
index 797f315..980203f 100644
--- a/gobject/gobject-autocleanups.h
+++ b/gobject/gobject-autocleanups.h
@@ -21,7 +21,6 @@
#error "Only <glib-object.h> can be included directly."
#endif
-G_DEFINE_AUTO_CLEANUP_FREE_FUNC(GStrv, g_strfreev, NULL)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GObject, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GInitiallyUnowned, g_object_unref)
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GValue, g_value_unset)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]