From 71a6ca2542299e9bf6d081e033f05e0153a6d210 Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Fri, 15 Dec 2000 05:51:08 +0000 Subject: [PATCH] add an instance member value_type so the default value of the pspec class Fri Dec 15 04:40:23 2000 Tim Janik * gparam.[hc]: add an instance member value_type so the default value of the pspec class can be overridden. --- gobject/ChangeLog | 5 +++++ gobject/gparam.c | 7 +++++-- gobject/gparam.h | 3 ++- gobject/gparamspecs.c | 25 ++++++++++--------------- gobject/gparamspecs.h | 6 ------ gobject/gsignal.h | 6 +++--- gobject/gtype.h | 1 + 7 files changed, 26 insertions(+), 27 deletions(-) diff --git a/gobject/ChangeLog b/gobject/ChangeLog index 2475a754c..c420b14f9 100644 --- a/gobject/ChangeLog +++ b/gobject/ChangeLog @@ -1,3 +1,8 @@ +Fri Dec 15 04:40:23 2000 Tim Janik + + * gparam.[hc]: add an instance member value_type so the default + value of the pspec class can be overridden. + 2000-12-14 Tor Lillqvist * makefile.mingw.in: Update, include parts from Makefile.am to diff --git a/gobject/gparam.c b/gobject/gparam.c index 92882b8fd..3e6b52c99 100644 --- a/gobject/gparam.c +++ b/gobject/gparam.c @@ -34,7 +34,8 @@ static void g_param_spec_class_base_init (GParamSpecClass *class); static void g_param_spec_class_base_finalize (GParamSpecClass *class); static void g_param_spec_class_init (GParamSpecClass *class, gpointer class_data); -static void g_param_spec_init (GParamSpec *pspec); +static void g_param_spec_init (GParamSpec *pspec, + GParamSpecClass *class); static void g_param_spec_finalize (GParamSpec *pspec); static void value_param_init (GValue *value); static void value_param_free_value (GValue *value); @@ -120,12 +121,14 @@ g_param_spec_class_init (GParamSpecClass *class, } static void -g_param_spec_init (GParamSpec *pspec) +g_param_spec_init (GParamSpec *pspec, + GParamSpecClass *class) { pspec->name = NULL; pspec->nick = NULL; pspec->blurb = NULL; pspec->flags = 0; + pspec->value_type = class->value_type; pspec->owner_type = 0; pspec->qdata = NULL; pspec->ref_count = 1; diff --git a/gobject/gparam.h b/gobject/gparam.h index 59c942c07..9ead986ef 100644 --- a/gobject/gparam.h +++ b/gobject/gparam.h @@ -37,7 +37,7 @@ extern "C" { #define G_PARAM_SPEC(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM, GParamSpec)) #define G_IS_PARAM_SPEC(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM)) #define G_PARAM_SPEC_GET_CLASS(pspec) (G_TYPE_INSTANCE_GET_CLASS ((pspec), G_TYPE_PARAM, GParamSpecClass)) -#define G_PARAM_SPEC_VALUE_TYPE(pspec) (G_PARAM_SPEC_GET_CLASS (pspec)->value_type) +#define G_PARAM_SPEC_VALUE_TYPE(pspec) (G_PARAM_SPEC (pspec)->value_type) #define G_IS_VALUE_PARAM(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_PARAM)) @@ -67,6 +67,7 @@ struct _GParamSpec gchar *nick; gchar *blurb; GParamFlags flags; + GType value_type; /*< private >*/ GType owner_type; diff --git a/gobject/gparamspecs.c b/gobject/gparamspecs.c index 54604a350..b3f932c1c 100644 --- a/gobject/gparamspecs.c +++ b/gobject/gparamspecs.c @@ -543,9 +543,7 @@ param_string_values_cmp (GParamSpec *pspec, static void param_spec_param_init (GParamSpec *pspec) { - GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec); - - spec->param_type = G_TYPE_PARAM; + /* GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec); */ } static void @@ -559,11 +557,11 @@ static gboolean param_param_validate (GParamSpec *pspec, GValue *value) { - GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec); + /* GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec); */ GParamSpec *param = value->data[0].v_pointer; guint changed = 0; - if (param && !g_type_is_a (G_PARAM_SPEC_TYPE (param), spec->param_type)) + if (param && !g_type_is_a (G_PARAM_SPEC_TYPE (param), G_PARAM_SPEC_VALUE_TYPE (pspec))) { g_param_spec_unref (param); value->data[0].v_pointer = NULL; @@ -640,9 +638,7 @@ param_ccallback_values_cmp (GParamSpec *pspec, static void param_spec_boxed_init (GParamSpec *pspec) { - GParamSpecBoxed *bspec = G_PARAM_SPEC_BOXED (pspec); - - bspec->boxed_type = G_TYPE_BOXED; + /* GParamSpecBoxed *bspec = G_PARAM_SPEC_BOXED (pspec); */ } static void @@ -675,9 +671,7 @@ param_boxed_values_cmp (GParamSpec *pspec, static void param_spec_object_init (GParamSpec *pspec) { - GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec); - - ospec->object_type = G_TYPE_OBJECT; + /* GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec); */ } static void @@ -695,7 +689,7 @@ param_object_validate (GParamSpec *pspec, GObject *object = value->data[0].v_pointer; guint changed = 0; - if (object && !g_type_is_a (G_OBJECT_TYPE (object), ospec->object_type)) + if (object && !g_type_is_a (G_OBJECT_TYPE (object), G_PARAM_SPEC_VALUE_TYPE (ospec))) { g_object_unref (object); value->data[0].v_pointer = NULL; @@ -1496,7 +1490,7 @@ g_param_spec_param (const gchar *name, nick, blurb, flags); - pspec->param_type = param_type; + G_PARAM_SPEC (pspec)->value_type = param_type; return G_PARAM_SPEC (pspec); } @@ -1543,13 +1537,14 @@ g_param_spec_boxed (const gchar *name, GParamSpecBoxed *bspec; g_return_val_if_fail (G_TYPE_IS_BOXED (boxed_type), NULL); + g_return_val_if_fail (G_TYPE_IS_DERIVED (boxed_type), NULL); bspec = g_param_spec_internal (G_TYPE_PARAM_BOXED, name, nick, blurb, flags); - bspec->boxed_type = boxed_type; + G_PARAM_SPEC (bspec)->value_type = boxed_type; return G_PARAM_SPEC (bspec); } @@ -1570,7 +1565,7 @@ g_param_spec_object (const gchar *name, nick, blurb, flags); - ospec->object_type = object_type; + G_PARAM_SPEC (ospec)->value_type = object_type; return G_PARAM_SPEC (ospec); } diff --git a/gobject/gparamspecs.h b/gobject/gparamspecs.h index d70b1d26b..a4550639e 100644 --- a/gobject/gparamspecs.h +++ b/gobject/gparamspecs.h @@ -188,8 +188,6 @@ struct _GParamSpecString struct _GParamSpecParam { GParamSpec parent_instance; - - GType param_type; }; struct _GParamSpecPointer { @@ -202,14 +200,10 @@ struct _GParamSpecCCallback struct _GParamSpecBoxed { GParamSpec parent_instance; - - GType boxed_type; }; struct _GParamSpecObject { GParamSpec parent_instance; - - GType object_type; }; diff --git a/gobject/gsignal.h b/gobject/gsignal.h index d05459592..971a0e5c7 100644 --- a/gobject/gsignal.h +++ b/gobject/gsignal.h @@ -193,14 +193,14 @@ guint g_signal_handlers_disconnect_matched (gpointer instance, GClosure *closure, gpointer func, gpointer data); - - -/*< private >*/ gboolean g_signal_parse_name (const gchar *detailed_signal, GType itype, guint *signal_id_p, GQuark *detail_p, gboolean force_detail_quark); + + +/*< private >*/ void g_signal_handlers_destroy (gpointer instance); void _g_signals_destroy (GType itype); diff --git a/gobject/gtype.h b/gobject/gtype.h index e86eb7e95..28a22c7da 100644 --- a/gobject/gtype.h +++ b/gobject/gtype.h @@ -103,6 +103,7 @@ typedef enum /*< skip >*/ /* Type Checking Macros */ #define G_TYPE_IS_FUNDAMENTAL(type) (G_TYPE_BRANCH_SEQNO (type) == 0) +#define G_TYPE_IS_DERIVED(type) (G_TYPE_BRANCH_SEQNO (type) > 0) #define G_TYPE_IS_INTERFACE(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_INTERFACE) #define G_TYPE_IS_CLASSED(type) (g_type_check_flags ((type), G_TYPE_FLAG_CLASSED)) #define G_TYPE_IS_INSTANTIATABLE(type) (g_type_check_flags ((type), G_TYPE_FLAG_INSTANTIATABLE))