[glib] Deprecate GValueArray
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Deprecate GValueArray
- Date: Wed, 25 Jan 2012 04:38:57 +0000 (UTC)
commit 0ac9ab4e271c8dbaaddd3e748aa687faa4a75523
Author: Emmanuele Bassi <ebassi gnome org>
Date: Wed Jan 4 09:31:12 2012 +0000
Deprecate GValueArray
The GValueArray type was added in a time, during the Jurassic era or so,
when GArray did not have a representable GType. The GValueArray API has
various issues as well:
- it doesn't match the other GLib array types;
- it is not reference counted;
- the structure is fully exposed on the stack, so it cannot be
extended to add reference counting;
- it cannot be forcibly resized.
The nice thing is that now we have a GArray type that can replace in
full GValueArray, so we can deprecate the latter, and reduce the
complexity in GLib, application code, and bindings.
https://bugzilla.gnome.org/show_bug.cgi?id=667228
gobject/gboxed.c | 5 ++++-
gobject/gboxed.h | 4 ++++
gobject/gparamspecs.c | 3 +++
gobject/gparamspecs.h | 6 ++++++
gobject/gvaluearray.c | 37 +++++++++++++++++++++++++++++++++++++
gobject/gvaluearray.h | 20 +++++++++++++++++++-
gobject/tests/valuearray.c | 1 +
7 files changed, 74 insertions(+), 2 deletions(-)
---
diff --git a/gobject/gboxed.c b/gobject/gboxed.c
index b321ef0..e30bd10 100644
--- a/gobject/gboxed.c
+++ b/gobject/gboxed.c
@@ -21,11 +21,14 @@
#include <string.h>
+/* for GValueArray */
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
#include "gboxed.h"
+#include "gclosure.h"
#include "gtype-private.h"
#include "gvalue.h"
#include "gvaluearray.h"
-#include "gclosure.h"
#include "gvaluecollector.h"
diff --git a/gobject/gboxed.h b/gobject/gboxed.h
index 931f321..1b617b7 100644
--- a/gobject/gboxed.h
+++ b/gobject/gboxed.h
@@ -111,11 +111,15 @@ GType g_boxed_type_register_static (const gchar *name,
*
* The type ID of the "GValueArray" type which is a boxed type,
* used to pass around pointers to GValueArrays.
+ *
+ * Deprecated: 2.32: Use #GArray instead of #GValueArray
*/
#define G_TYPE_VALUE_ARRAY (g_value_array_get_type ())
GType g_closure_get_type (void) G_GNUC_CONST;
GType g_value_get_type (void) G_GNUC_CONST;
+
+GLIB_DEPRECATED
GType g_value_array_get_type (void) G_GNUC_CONST;
G_END_DECLS
diff --git a/gobject/gparamspecs.c b/gobject/gparamspecs.c
index 86d5699..0043cac 100644
--- a/gobject/gparamspecs.c
+++ b/gobject/gparamspecs.c
@@ -26,9 +26,12 @@
#include <string.h>
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
#include "gparamspecs.h"
#include "gtype-private.h"
#include "gvaluecollector.h"
+
#include "gvaluearray.h"
diff --git a/gobject/gparamspecs.h b/gobject/gparamspecs.h
index e6f817d..3e0ff6e 100644
--- a/gobject/gparamspecs.h
+++ b/gobject/gparamspecs.h
@@ -451,6 +451,8 @@ G_BEGIN_DECLS
* G_TYPE_PARAM_VALUE_ARRAY:
*
* The #GType of #GParamSpecValueArray.
+ *
+ * Deprecated: 2.32: Use #GArray instead of #GValueArray
*/
#define G_TYPE_PARAM_VALUE_ARRAY (g_param_spec_types[18])
/**
@@ -460,6 +462,8 @@ G_BEGIN_DECLS
* Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_VALUE_ARRAY.
*
* Returns: %TRUE on success.
+ *
+ * Deprecated: 2.32: Use #GArray instead of #GValueArray
*/
#define G_IS_PARAM_SPEC_VALUE_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_VALUE_ARRAY))
/**
@@ -467,6 +471,8 @@ G_BEGIN_DECLS
* @pspec: a valid #GParamSpec instance
*
* Cast a #GParamSpec instance into a #GParamSpecValueArray.
+ *
+ * Deprecated: 2.32: Use #GArray instead of #GValueArray
*/
#define G_PARAM_SPEC_VALUE_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_VALUE_ARRAY, GParamSpecValueArray))
diff --git a/gobject/gvaluearray.c b/gobject/gvaluearray.c
index 56d2707..9f6210c 100644
--- a/gobject/gvaluearray.c
+++ b/gobject/gvaluearray.c
@@ -40,6 +40,23 @@
* object property that holds an array of values. A #GValueArray wraps
* an array of #GValue elements in order for it to be used as a boxed
* type through %G_TYPE_VALUE_ARRAY.
+ *
+ * #GValueArray is deprecated in favour of #GArray since GLib 2.32. It
+ * is possible to create a #GArray that behaves like a #GValueArray by
+ * using the size of #GValue as the element size, and by setting
+ * g_value_unset() as the clear function using g_array_set_clear_func(),
+ * for instance, the following code:
+ *
+ * |[
+ * GValueArray *array = g_value_array_new (10);
+ * |]
+ *
+ * can be replaced by:
+ *
+ * |[
+ * GArray *array = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 10);
+ * g_array_set_clear_func (array, (GDestroyNotify) g_value_unset);
+ * ]|
*/
@@ -59,6 +76,8 @@
* Return a pointer to the value at @index_ containd in @value_array.
*
* Returns: (transfer none): pointer to a value at @index_ in @value_array
+ *
+ * Deprecated: 2.32: Use g_array_index() instead.
*/
GValue*
g_value_array_get_nth (GValueArray *value_array,
@@ -112,6 +131,8 @@ value_array_shrink (GValueArray *value_array)
* regardless of the value of @n_prealloced.
*
* Returns: a newly allocated #GValueArray with 0 values
+ *
+ * Deprecated: 2.32: Use #GArray and g_array_sized_new() instead.
*/
GValueArray*
g_value_array_new (guint n_prealloced)
@@ -132,6 +153,8 @@ g_value_array_new (guint n_prealloced)
* @value_array: #GValueArray to free
*
* Free a #GValueArray including its contents.
+ *
+ * Deprecated: 2.32: Use #GArray and g_array_unref() instead.
*/
void
g_value_array_free (GValueArray *value_array)
@@ -159,6 +182,8 @@ g_value_array_free (GValueArray *value_array)
* contents.
*
* Returns: (transfer full): Newly allocated copy of #GValueArray
+ *
+ * Deprecated: 2.32: Use #GArray and g_array_ref() instead.
*/
GValueArray*
g_value_array_copy (const GValueArray *value_array)
@@ -194,6 +219,8 @@ g_value_array_copy (const GValueArray *value_array)
*
*
* Returns: (transfer none): the #GValueArray passed in as @value_array
+ *
+ * Deprecated: 2.32: Use #GArray and g_array_prepend_val() instead.
*/
GValueArray*
g_value_array_prepend (GValueArray *value_array,
@@ -213,6 +240,8 @@ g_value_array_prepend (GValueArray *value_array,
* %NULL, an uninitialized value is appended.
*
* Returns: (transfer none): the #GValueArray passed in as @value_array
+ *
+ * Deprecated: 2.32: Use #GArray and g_array_append_val() instead.
*/
GValueArray*
g_value_array_append (GValueArray *value_array,
@@ -233,6 +262,8 @@ g_value_array_append (GValueArray *value_array,
* is %NULL, an uninitialized value is inserted.
*
* Returns: (transfer none): the #GValueArray passed in as @value_array
+ *
+ * Deprecated: 2.32: Use #GArray and g_array_insert_val() instead.
*/
GValueArray*
g_value_array_insert (GValueArray *value_array,
@@ -268,6 +299,8 @@ g_value_array_insert (GValueArray *value_array,
* Remove the value at position @index_ from @value_array.
*
* Returns: (transfer none): the #GValueArray passed in as @value_array
+ *
+ * Deprecated: 2.32: Use #GArray and g_array_remove_index() instead.
*/
GValueArray*
g_value_array_remove (GValueArray *value_array,
@@ -300,6 +333,8 @@ g_value_array_remove (GValueArray *value_array,
* The current implementation uses Quick-Sort as sorting algorithm.
*
* Returns: (transfer none): the #GValueArray passed in as @value_array
+ *
+ * Deprecated: 2.32: Use #GArray and g_array_sort().
*/
GValueArray*
g_value_array_sort (GValueArray *value_array,
@@ -328,6 +363,8 @@ g_value_array_sort (GValueArray *value_array,
*
* Rename to: g_value_array_sort
* Returns: (transfer none): the #GValueArray passed in as @value_array
+ *
+ * Deprecated: 2.32: Use #GArray and g_array_sort_with_data().
*/
GValueArray*
g_value_array_sort_with_data (GValueArray *value_array,
diff --git a/gobject/gvaluearray.h b/gobject/gvaluearray.h
index 524dc9f..0dc9b98 100644
--- a/gobject/gvaluearray.h
+++ b/gobject/gvaluearray.h
@@ -27,7 +27,6 @@
#include <gobject/gvalue.h>
-
G_BEGIN_DECLS
@@ -51,22 +50,41 @@ struct _GValueArray
/* --- prototypes --- */
+GLIB_DEPRECATED_FOR(g_array_index)
GValue* g_value_array_get_nth (GValueArray *value_array,
guint index_);
+
+GLIB_DEPRECATED_FOR(g_array_new)
GValueArray* g_value_array_new (guint n_prealloced);
+
+GLIB_DEPRECATED_FOR(g_array_unref)
void g_value_array_free (GValueArray *value_array);
+
+GLIB_DEPRECATED_FOR(g_array_ref)
GValueArray* g_value_array_copy (const GValueArray *value_array);
+
+GLIB_DEPRECATED_FOR(g_array_prepend_vals)
GValueArray* g_value_array_prepend (GValueArray *value_array,
const GValue *value);
+
+GLIB_DEPRECATED_FOR(g_array_append_vals)
GValueArray* g_value_array_append (GValueArray *value_array,
const GValue *value);
+
+GLIB_DEPRECATED_FOR(g_array_insert_vals)
GValueArray* g_value_array_insert (GValueArray *value_array,
guint index_,
const GValue *value);
+
+GLIB_DEPRECATED_FOR(g_array_remove_index)
GValueArray* g_value_array_remove (GValueArray *value_array,
guint index_);
+
+GLIB_DEPRECATED_FOR(g_array_sort)
GValueArray* g_value_array_sort (GValueArray *value_array,
GCompareFunc compare_func);
+
+GLIB_DEPRECATED_FOR(g_array_sort_with_data)
GValueArray* g_value_array_sort_with_data (GValueArray *value_array,
GCompareDataFunc compare_func,
gpointer user_data);
diff --git a/gobject/tests/valuearray.c b/gobject/tests/valuearray.c
index 47bd26d..7fe06b7 100644
--- a/gobject/tests/valuearray.c
+++ b/gobject/tests/valuearray.c
@@ -1,3 +1,4 @@
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
#include <glib-object.h>
static gint
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]