diff --git a/gobject/gboxed.c b/gobject/gboxed.c index b321ef077..e30bd1051 100644 --- a/gobject/gboxed.c +++ b/gobject/gboxed.c @@ -21,11 +21,14 @@ #include +/* 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 931f32198..1b617b76d 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 86d569905..0043cace0 100644 --- a/gobject/gparamspecs.c +++ b/gobject/gparamspecs.c @@ -26,9 +26,12 @@ #include +#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 e6f817df3..3e0ff6e3a 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 56d2707c9..9f6210c39 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 524dc9fe9..0dc9b9834 100644 --- a/gobject/gvaluearray.h +++ b/gobject/gvaluearray.h @@ -27,7 +27,6 @@ #include - 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 47bd26d54..7fe06b72c 100644 --- a/gobject/tests/valuearray.c +++ b/gobject/tests/valuearray.c @@ -1,3 +1,4 @@ +#define GLIB_DISABLE_DEPRECATION_WARNINGS #include static gint