remove boxed init func and is_refcounted



Here is a patch to remove the init func and is_refcounted from GBoxed.

Owen, if you like this could you apply it, it collides with some 
outstanding patches i have here.

/ Alex

Index: gobject/gboxed.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/gboxed.c,v
retrieving revision 1.10
diff -u -p -r1.10 gboxed.c
--- gobject/gboxed.c	2001/06/19 12:13:22	1.10
+++ gobject/gboxed.c	2001/09/09 19:00:48
@@ -30,10 +30,8 @@
 typedef struct
 {
   GType		 type;
-  GBoxedInitFunc init;
   GBoxedCopyFunc copy;
   GBoxedFreeFunc free;
-  gboolean	 is_refcounted;
 } BoxedNode;
 
 
@@ -89,18 +87,6 @@ value_free (gpointer boxed)
 }
 
 static gpointer
-value_array_init (void)
-{
-  return g_value_array_new (0);
-}
-
-static gpointer
-gstring_init (void)
-{
-  return g_string_new ("");
-}
-
-static gpointer
 gstring_copy (gpointer boxed)
 {
   const GString *src_gstring = boxed;
@@ -143,38 +129,30 @@ g_boxed_type_init (void)  /* sync with g
   /* boxed: G_TYPE_CLOSURE
    */
   type = g_boxed_type_register_static ("GClosure",
-				       (GBoxedInitFunc) NULL,
 				       (GBoxedCopyFunc) g_closure_ref,
-				       (GBoxedFreeFunc) g_closure_unref,
-				       TRUE);
+				       (GBoxedFreeFunc) g_closure_unref);
   g_assert (type == G_TYPE_CLOSURE);
 
   /* boxed: G_TYPE_VALUE
    */
   type = g_boxed_type_register_static ("GValue",
-				       (GBoxedInitFunc) NULL,
 				       value_copy,
-				       value_free,
-				       FALSE);
+				       value_free);
   g_assert (type == G_TYPE_VALUE);
 
   /* boxed: G_TYPE_VALUE_ARRAY
    */
   type = g_boxed_type_register_static ("GValueArray",
-				       value_array_init,	/* don't allow NULL values */
 				       (GBoxedCopyFunc) g_value_array_copy,
-				       (GBoxedFreeFunc) g_value_array_free,
-				       FALSE);
+				       (GBoxedFreeFunc) g_value_array_free);
   g_assert (type == G_TYPE_VALUE_ARRAY);
 
   /* boxed: G_TYPE_GSTRING
    * yes, the naming is a bit odd, but GString is obviously not G_TYPE_STRING
    */
   type = g_boxed_type_register_static ("GString",
-				       gstring_init,		/* don't allow NULL values */
 				       gstring_copy,
-				       gstring_free,
-				       FALSE);
+				       gstring_free);
   g_assert (type == G_TYPE_GSTRING);
 }
 
@@ -185,7 +163,7 @@ boxed_proxy_value_init (GValue *value)
 
   key.type = G_VALUE_TYPE (value);
   node = g_bsearch_array_lookup (&boxed_bsa, &key);
-  value->data[0].v_pointer = node->init ? node->init () : NULL;
+  value->data[0].v_pointer = NULL;
 }
 
 static void
@@ -234,13 +212,11 @@ boxed_proxy_collect_value (GValue      *
   key.type = G_VALUE_TYPE (value);
   node = g_bsearch_array_lookup (&boxed_bsa, &key);
 
-  /* for NULL values, we have to call GBoxedInitFunc */
   if (!collect_values[0].v_pointer)
-    value->data[0].v_pointer = node->init ? node->init () : NULL;
+    value->data[0].v_pointer = NULL;
   else
     {
-      /* never honour G_VALUE_NOCOPY_CONTENTS for ref-counted types */
-      if (!node->is_refcounted && (collect_flags & G_VALUE_NOCOPY_CONTENTS))
+      if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
 	{
 	  value->data[0].v_pointer = collect_values[0].v_pointer;
 	  value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
@@ -281,10 +257,8 @@ boxed_proxy_lcopy_value (const GValue *v
 
 GType
 g_boxed_type_register_static (const gchar   *name,
-			      GBoxedInitFunc boxed_init,
 			      GBoxedCopyFunc boxed_copy,
-			      GBoxedFreeFunc boxed_free,
-			      gboolean	     is_refcounted)
+			      GBoxedFreeFunc boxed_free)
 {
   static const GTypeValueTable vtable = {
     boxed_proxy_value_init,
@@ -323,10 +297,8 @@ g_boxed_type_register_static (const gcha
       BoxedNode key;
 
       key.type = type;
-      key.init = boxed_init;
       key.copy = boxed_copy;
       key.free = boxed_free;
-      key.is_refcounted = is_refcounted != FALSE;
       g_bsearch_array_insert (&boxed_bsa, &key, TRUE);
     }
 
Index: gobject/gboxed.h
===================================================================
RCS file: /cvs/gnome/glib/gobject/gboxed.h,v
retrieving revision 1.6
diff -u -p -r1.6 gboxed.h
--- gobject/gboxed.h	2001/06/19 12:13:22	1.6
+++ gobject/gboxed.h	2001/09/09 19:00:48
@@ -29,7 +29,6 @@ G_BEGIN_DECLS
 
 
 /* --- typedefs --- */
-typedef gpointer (*GBoxedInitFunc)	(void);
 typedef gpointer (*GBoxedCopyFunc)	(gpointer	 boxed);
 typedef void     (*GBoxedFreeFunc)	(gpointer	 boxed);
 
@@ -49,10 +48,8 @@ gpointer	g_value_dup_boxed		(const GValu
 
 /* --- convenience --- */
 GType	g_boxed_type_register_static		(const gchar	*name,
-						 GBoxedInitFunc	 boxed_init,
 						 GBoxedCopyFunc	 boxed_copy,
-						 GBoxedFreeFunc	 boxed_free,
-						 gboolean	 is_refcounted);
+						 GBoxedFreeFunc	 boxed_free);
 
 
 /* --- marshaller specific --- */
Index: gobject/gsourceclosure.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/gsourceclosure.c,v
retrieving revision 1.2
diff -u -p -r1.2 gsourceclosure.c
--- gobject/gsourceclosure.c	2001/09/03 23:46:04	1.2
+++ gobject/gsourceclosure.c	2001/09/09 19:00:48
@@ -31,10 +31,8 @@ g_io_channel_get_type (void)
   
   if (our_type == 0)
     our_type = g_boxed_type_register_static ("GIOChannel",
-					     NULL,
 					     (GBoxedCopyFunc) g_io_channel_ref,
-					     (GBoxedFreeFunc) g_io_channel_unref,
-					     FALSE);
+					     (GBoxedFreeFunc) g_io_channel_unref);
 
   return our_type;
 }





Index: pango/fonts.c
===================================================================
RCS file: /cvs/gnome/pango/pango/fonts.c,v
retrieving revision 1.26
diff -u -p -r1.26 fonts.c
--- pango/fonts.c	2001/09/02 17:56:49	1.26
+++ pango/fonts.c	2001/09/09 19:01:22
@@ -36,10 +36,8 @@ pango_font_description_get_type (void)
   
   if (our_type == 0)
     our_type = g_boxed_type_register_static ("PangoFontDescription",
-					     NULL,
 					     (GBoxedCopyFunc)pango_font_description_copy,
-					     (GBoxedFreeFunc)pango_font_description_free,
-					     FALSE);
+					     (GBoxedFreeFunc)pango_font_description_free);
 
   return our_type;
 }
Index: pango/glyphstring.c
===================================================================
RCS file: /cvs/gnome/pango/pango/glyphstring.c,v
retrieving revision 1.13
diff -u -p -r1.13 glyphstring.c
--- pango/glyphstring.c	2001/07/02 14:17:18	1.13
+++ pango/glyphstring.c	2001/09/09 19:01:22
@@ -78,10 +78,8 @@ pango_glyph_string_get_type (void)
   
   if (our_type == 0)
     our_type = g_boxed_type_register_static ("PangoGlyphString",
-					     NULL,
 					     (GBoxedCopyFunc)pango_glyph_string_copy,
-					     (GBoxedFreeFunc)pango_glyph_string_free,
-					     FALSE);
+					     (GBoxedFreeFunc)pango_glyph_string_free);
 
   return our_type;
 }
Index: pango/pango-attributes.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-attributes.c,v
retrieving revision 1.29
diff -u -p -r1.29 pango-attributes.c
--- pango/pango-attributes.c	2001/08/30 21:47:53	1.29
+++ pango/pango-attributes.c	2001/09/09 19:01:22
@@ -717,10 +717,8 @@ pango_attr_list_get_type (void)
   
   if (our_type == 0)
     our_type = g_boxed_type_register_static ("PangoAttrList",
-					     NULL,
 					     (GBoxedCopyFunc) pango_attr_list_copy,
-					     (GBoxedFreeFunc) pango_attr_list_unref,
-					     FALSE);
+					     (GBoxedFreeFunc) pango_attr_list_unref);
 
   return our_type;
 }
Index: pango/pango-color.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-color.c,v
retrieving revision 1.1
diff -u -p -r1.1 pango-color.c
--- pango/pango-color.c	2001/08/30 21:47:53	1.1
+++ pango/pango-color.c	2001/09/09 19:01:23
@@ -32,10 +32,8 @@ pango_color_get_type (void)
   
   if (our_type == 0)
     our_type = g_boxed_type_register_static ("PangoColor",
-					     NULL,
 					     (GBoxedCopyFunc) pango_color_copy,
-					     (GBoxedFreeFunc) pango_color_free,
-					     FALSE);
+					     (GBoxedFreeFunc) pango_color_free);
 
   return our_type;
 }
Index: pango/pango-tabs.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-tabs.c,v
retrieving revision 1.5
diff -u -p -r1.5 pango-tabs.c
--- pango/pango-tabs.c	2001/07/02 14:17:18	1.5
+++ pango/pango-tabs.c	2001/09/09 19:01:24
@@ -159,10 +159,8 @@ pango_tab_array_get_type (void)
   
   if (our_type == 0)
     our_type = g_boxed_type_register_static ("PangoTabArray",
-                                             NULL,
                                              (GBoxedCopyFunc)pango_tab_array_copy,
-                                             (GBoxedFreeFunc)pango_tab_array_free,
-                                             FALSE);
+                                             (GBoxedFreeFunc)pango_tab_array_free);
   return our_type;
 }
 
Index: pango/pango-utils.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-utils.c,v
retrieving revision 1.20
diff -u -p -r1.20 pango-utils.c
--- pango/pango-utils.c	2001/09/02 17:56:49	1.20
+++ pango/pango-utils.c	2001/09/09 19:01:24
@@ -952,10 +961,8 @@ pango_language_get_type (void)
   
   if (our_type == 0)
     our_type = g_boxed_type_register_static ("PangoLanguage",
-                                             NULL,
                                              (GBoxedCopyFunc)pango_language_copy,
-                                             (GBoxedFreeFunc)pango_language_free,
-                                             FALSE);
+                                             (GBoxedFreeFunc)pango_language_free);
   return our_type;
 }
 



Index: demos/gtk-demo/stock_browser.c
===================================================================
RCS file: /cvs/gnome/gtk+/demos/gtk-demo/stock_browser.c,v
retrieving revision 1.9
diff -u -p -r1.9 stock_browser.c
--- demos/gtk-demo/stock_browser.c	2001/09/08 00:56:28	1.9
+++ demos/gtk-demo/stock_browser.c	2001/09/09 19:02:39
@@ -65,10 +65,8 @@ stock_item_info_get_type (void)
   
   if (our_type == 0)
     our_type = g_boxed_type_register_static ("StockItemInfo",
-					     NULL,
                                              (GBoxedCopyFunc) stock_item_info_copy,
-                                             (GBoxedFreeFunc) stock_item_info_free,
-					     FALSE);
+                                             (GBoxedFreeFunc) stock_item_info_free);
 
   return our_type;
 }
Index: gdk/gdkcolor.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkcolor.c,v
retrieving revision 1.26
diff -u -p -r1.26 gdkcolor.c
--- gdk/gdkcolor.c	2001/06/30 02:56:49	1.26
+++ gdk/gdkcolor.c	2001/09/09 19:02:40
@@ -224,9 +224,7 @@ gdk_color_get_type (void)
   
   if (our_type == 0)
     our_type = g_boxed_type_register_static ("GdkColor",
-					     NULL,
 					     (GBoxedCopyFunc)gdk_color_copy,
-					     (GBoxedFreeFunc)gdk_color_free,
-					     FALSE);
+					     (GBoxedFreeFunc)gdk_color_free);
   return our_type;
 }
Index: gdk/gdkcursor.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkcursor.c,v
retrieving revision 1.14
diff -u -p -r1.14 gdkcursor.c
--- gdk/gdkcursor.c	2001/06/28 16:35:38	1.14
+++ gdk/gdkcursor.c	2001/09/09 19:02:40
@@ -34,10 +34,8 @@ gdk_cursor_get_type (void)
   
   if (our_type == 0)
     our_type = g_boxed_type_register_static ("GdkCursor",
-					     NULL,
 					     (GBoxedCopyFunc)gdk_cursor_ref,
-					     (GBoxedFreeFunc)gdk_cursor_unref,
-					     TRUE);
+					     (GBoxedFreeFunc)gdk_cursor_unref);
   return our_type;
 }
 
Index: gdk/gdkevents.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkevents.c,v
retrieving revision 1.40
diff -u -p -r1.40 gdkevents.c
--- gdk/gdkevents.c	2001/09/07 21:49:49	1.40
+++ gdk/gdkevents.c	2001/09/09 19:02:40
@@ -1000,10 +1000,8 @@ gdk_event_get_type (void)
   
   if (our_type == 0)
     our_type = g_boxed_type_register_static ("GdkEvent",
-					     NULL,
 					     (GBoxedCopyFunc)gdk_event_copy,
-					     (GBoxedFreeFunc)gdk_event_free,
-					     FALSE);
+					     (GBoxedFreeFunc)gdk_event_free);
   return our_type;
 }
 
Index: gdk/gdkfont.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkfont.c,v
retrieving revision 1.22
diff -u -p -r1.22 gdkfont.c
--- gdk/gdkfont.c	2001/04/02 23:33:46	1.22
+++ gdk/gdkfont.c	2001/09/09 19:02:40
@@ -34,10 +34,8 @@ gdk_font_get_type (void)
   
   if (our_type == 0)
     our_type = g_boxed_type_register_static ("GdkFont",
-					     NULL,
 					     (GBoxedCopyFunc)gdk_font_ref,
-					     (GBoxedFreeFunc)gdk_font_unref,
-					     TRUE);
+					     (GBoxedFreeFunc)gdk_font_unref);
   return our_type;
 }
 
Index: gdk/gdkrectangle.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkrectangle.c,v
retrieving revision 1.12
diff -u -p -r1.12 gdkrectangle.c
--- gdk/gdkrectangle.c	2001/06/01 15:44:13	1.12
+++ gdk/gdkrectangle.c	2001/09/09 19:02:40
@@ -98,10 +98,8 @@ gdk_rectangle_get_type (void)
   
   if (our_type == 0)
     our_type = g_boxed_type_register_static ("GdkRectangle",
-					     NULL,
 					     (GBoxedCopyFunc)gdk_rectangle_copy,
-					     (GBoxedFreeFunc)g_free,
-					     FALSE);
+					     (GBoxedFreeFunc)g_free);
   return our_type;
 }
 
Index: gtk/gtktypeutils.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktypeutils.c,v
retrieving revision 1.72
diff -u -p -r1.72 gtktypeutils.c
--- gtk/gtktypeutils.c	2001/07/01 00:57:21	1.72
+++ gtk/gtktypeutils.c	2001/09/09 19:02:41
@@ -169,25 +169,10 @@ gtk_type_init (GTypeDebugFlags debug_fla
 	    type_id = g_flags_register_static (builtin_info[i].type_name, builtin_info[i].pointer1);
 	  else if (builtin_info[i].parent == GTK_TYPE_BOXED)
 	    {
-	      static const gchar *copy_types[] = {
-		"GtkSelectionData", "GtkBorder", "GtkTextIter", "PangoTabArray",
-		"PangoFontDescription", "GtkTreeIter", "GtkTreePath", "GtkRequisition"
-	      };
-	      gboolean ref_counted = TRUE;
-	      guint j;
-
-	      for (j = 0; j < sizeof (copy_types) / sizeof (copy_types[0]); j++)
-		if (strcmp (copy_types[j], builtin_info[i].type_name) == 0)
-		  {
-		    ref_counted = FALSE;
-		    break;
-		  }
 	      if (builtin_info[i].pointer1 && builtin_info[i].pointer2)
 		type_id = g_boxed_type_register_static (builtin_info[i].type_name,
-							NULL,
 							builtin_info[i].pointer1,
-							builtin_info[i].pointer2,
-							ref_counted);
+							builtin_info[i].pointer2);
 	      else
 		type_id = g_type_register_static (GTK_TYPE_BOXED, builtin_info[i].type_name, &tinfo, 0);
 	    }





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]