add an instance member value_type so the default value of the pspec class
authorTim Janik <timj@gtk.org>
Fri, 15 Dec 2000 05:51:08 +0000 (05:51 +0000)
committerTim Janik <timj@src.gnome.org>
Fri, 15 Dec 2000 05:51:08 +0000 (05:51 +0000)
Fri Dec 15 04:40:23 2000  Tim Janik  <timj@gtk.org>

        * gparam.[hc]: add an instance member value_type so the default
        value of the pspec class can be overridden.

gobject/ChangeLog
gobject/gparam.c
gobject/gparam.h
gobject/gparamspecs.c
gobject/gparamspecs.h
gobject/gsignal.h
gobject/gtype.h

index 2475a754cddd5fe898ed2594bc1f7430a7d420bb..c420b14f9c8495d91ec967e3a271ad2970c5f3cd 100644 (file)
@@ -1,3 +1,8 @@
+Fri Dec 15 04:40:23 2000  Tim Janik  <timj@gtk.org>
+
+       * gparam.[hc]: add an instance member value_type so the default
+       value of the pspec class can be overridden.
+
 2000-12-14  Tor Lillqvist  <tml@iki.fi>
 
        * makefile.mingw.in: Update, include parts from Makefile.am to
index 92882b8fd2e276145204f7c30b11a60e2f7970c1..3e6b52c9976867679a07d40bcb1caafd708ae6c7 100644 (file)
@@ -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;
index 59c942c07ebfc2d69805685ae68a9c61106a643f..9ead986effcebb8757f94fd1cfb8a7509712766a 100644 (file)
@@ -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;
index 54604a350bb17336e5228dbe8df77586ba6c3a01..b3f932c1c124191199303f8b7ec010e3218eab28 100644 (file)
@@ -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);
 }
index d70b1d26b7de0ebd661b6556aa518ec01f2e7f81..a4550639e5214060466b896a40acd7c46969fb48 100644 (file)
@@ -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;
 };
 
 
index d054595923451c33e9ea86a120d59745d8d8b679..971a0e5c7a9e586787d81ae996ff1908b85577df 100644 (file)
@@ -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);
 
index e86eb7e9518f10d62f94c590fd2735271c716dd0..28a22c7dabe9ab88547f4508a0954d28a76e944e 100644 (file)
@@ -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))