[glib] Introduce G_PARAM_DEPRECATED and G_ENABLE_DIAGNOSTIC
- From: Christian Dywan <cdywan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Introduce G_PARAM_DEPRECATED and G_ENABLE_DIAGNOSTIC
- Date: Wed, 23 Jun 2010 14:44:38 +0000 (UTC)
commit 272836936e76a9bf0a0237e6489ce0508fa85534
Author: Christian Dywan <christian twotoasts de>
Date: Fri Jun 18 16:14:27 2010 +0200
Introduce G_PARAM_DEPRECATED and G_ENABLE_DIAGNOSTIC
See https://bugzilla.gnome.org/show_bug.cgi?id=601686
gobject/gobject.c | 16 ++++++++++++++++
gobject/gparam.h | 11 ++++++++---
2 files changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index 1b42070..41c70ee 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -1016,11 +1016,27 @@ object_set_property (GObject *object,
GObjectClass *class = g_type_class_peek (pspec->owner_type);
guint param_id = PARAM_SPEC_PARAM_ID (pspec);
GParamSpec *redirect;
+ static gchar* enable_diagnostic = NULL;
redirect = g_param_spec_get_redirect_target (pspec);
if (redirect)
pspec = redirect;
+ if (G_UNLIKELY (!enable_diagnostic))
+ {
+ enable_diagnostic = g_getenv ("G_ENABLE_DIAGNOSTIC");
+ if (!enable_diagnostic)
+ enable_diagnostic = "0";
+ }
+
+ if (enable_diagnostic[0] == '1')
+ {
+ if (pspec->flags & G_PARAM_DEPRECATED)
+ g_warning ("The property %s::%s is deprecated and shouldn't be used "
+ "anymore. It will be removed in a future version.",
+ G_OBJECT_TYPE_NAME (object), pspec->name);
+ }
+
/* provide a copy to work from, convert (if necessary) and validate */
g_value_init (&tmp_value, pspec->value_type);
if (!g_value_transform (value, &tmp_value))
diff --git a/gobject/gparam.h b/gobject/gparam.h
index 7fc4f61..9b93c0a 100644
--- a/gobject/gparam.h
+++ b/gobject/gparam.h
@@ -132,6 +132,10 @@ G_BEGIN_DECLS
* unmodified for the lifetime of the parameter.
* Since 2.8
* @G_PARAM_PRIVATE: internal
+ * @G_PARAM_DEPRECATED: the parameter is deprecated and will be removed
+ * in a future version. A warning will be generated if it is used
+ * while running with G_ENABLE_DIAGNOSTIC=1.
+ * Since: 2.26
*
* Through the #GParamFlags flag values, certain aspects of parameters
* can be configured.
@@ -148,7 +152,9 @@ typedef enum
G_PARAM_PRIVATE = G_PARAM_STATIC_NAME,
#endif
G_PARAM_STATIC_NICK = 1 << 6,
- G_PARAM_STATIC_BLURB = 1 << 7
+ G_PARAM_STATIC_BLURB = 1 << 7,
+ /* User defined flags go up to 30 */
+ G_PARAM_DEPRECATED = 1 << 31
} GParamFlags;
/**
* G_PARAM_READWRITE:
@@ -175,11 +181,10 @@ typedef enum
* G_PARAM_USER_SHIFT:
*
* Minimum shift count to be used for user defined flags, to be stored in
- * #GParamSpec.flags.
+ * #GParamSpec.flags. The maximum allowed is 30 + G_PARAM_USER_SHIFT.
*/
#define G_PARAM_USER_SHIFT (8)
-
/* --- typedefs & structures --- */
typedef struct _GParamSpec GParamSpec;
typedef struct _GParamSpecClass GParamSpecClass;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]