Removed is_refcounted and GBoxedInitFunc from

2001-09-10  Alex Larsson  <alexl@redhat.com>

	* gobject/gboxed.[ch]:
	* gobject/gsourceclosure.c:
	Removed is_refcounted and GBoxedInitFunc from
	g_boxed_type_register_static().
This commit is contained in:
Alex Larsson 2001-09-10 16:48:42 +00:00 committed by Alexander Larsson
parent 16fc3b22c0
commit ae2c2ca6c3
11 changed files with 66 additions and 43 deletions

View File

@ -1,3 +1,10 @@
2001-09-10 Alex Larsson <alexl@redhat.com>
* gobject/gboxed.[ch]:
* gobject/gsourceclosure.c:
Removed is_refcounted and GBoxedInitFunc from
g_boxed_type_register_static().
Mon Sep 10 11:42:58 2001 Owen Taylor <otaylor@redhat.com> Mon Sep 10 11:42:58 2001 Owen Taylor <otaylor@redhat.com>
* glib/gutf8.c glib/gstring.c glib/gfileutils.c glib/gmain.c: * glib/gutf8.c glib/gstring.c glib/gfileutils.c glib/gmain.c:

View File

@ -1,3 +1,10 @@
2001-09-10 Alex Larsson <alexl@redhat.com>
* gobject/gboxed.[ch]:
* gobject/gsourceclosure.c:
Removed is_refcounted and GBoxedInitFunc from
g_boxed_type_register_static().
Mon Sep 10 11:42:58 2001 Owen Taylor <otaylor@redhat.com> Mon Sep 10 11:42:58 2001 Owen Taylor <otaylor@redhat.com>
* glib/gutf8.c glib/gstring.c glib/gfileutils.c glib/gmain.c: * glib/gutf8.c glib/gstring.c glib/gfileutils.c glib/gmain.c:

View File

@ -1,3 +1,10 @@
2001-09-10 Alex Larsson <alexl@redhat.com>
* gobject/gboxed.[ch]:
* gobject/gsourceclosure.c:
Removed is_refcounted and GBoxedInitFunc from
g_boxed_type_register_static().
Mon Sep 10 11:42:58 2001 Owen Taylor <otaylor@redhat.com> Mon Sep 10 11:42:58 2001 Owen Taylor <otaylor@redhat.com>
* glib/gutf8.c glib/gstring.c glib/gfileutils.c glib/gmain.c: * glib/gutf8.c glib/gstring.c glib/gfileutils.c glib/gmain.c:

View File

@ -1,3 +1,10 @@
2001-09-10 Alex Larsson <alexl@redhat.com>
* gobject/gboxed.[ch]:
* gobject/gsourceclosure.c:
Removed is_refcounted and GBoxedInitFunc from
g_boxed_type_register_static().
Mon Sep 10 11:42:58 2001 Owen Taylor <otaylor@redhat.com> Mon Sep 10 11:42:58 2001 Owen Taylor <otaylor@redhat.com>
* glib/gutf8.c glib/gstring.c glib/gfileutils.c glib/gmain.c: * glib/gutf8.c glib/gstring.c glib/gfileutils.c glib/gmain.c:

View File

@ -1,3 +1,10 @@
2001-09-10 Alex Larsson <alexl@redhat.com>
* gobject/gboxed.[ch]:
* gobject/gsourceclosure.c:
Removed is_refcounted and GBoxedInitFunc from
g_boxed_type_register_static().
Mon Sep 10 11:42:58 2001 Owen Taylor <otaylor@redhat.com> Mon Sep 10 11:42:58 2001 Owen Taylor <otaylor@redhat.com>
* glib/gutf8.c glib/gstring.c glib/gfileutils.c glib/gmain.c: * glib/gutf8.c glib/gstring.c glib/gfileutils.c glib/gmain.c:

View File

@ -1,3 +1,10 @@
2001-09-10 Alex Larsson <alexl@redhat.com>
* gobject/gboxed.[ch]:
* gobject/gsourceclosure.c:
Removed is_refcounted and GBoxedInitFunc from
g_boxed_type_register_static().
Mon Sep 10 11:42:58 2001 Owen Taylor <otaylor@redhat.com> Mon Sep 10 11:42:58 2001 Owen Taylor <otaylor@redhat.com>
* glib/gutf8.c glib/gstring.c glib/gfileutils.c glib/gmain.c: * glib/gutf8.c glib/gstring.c glib/gfileutils.c glib/gmain.c:

View File

@ -1,3 +1,10 @@
2001-09-10 Alex Larsson <alexl@redhat.com>
* gobject/gboxed.[ch]:
* gobject/gsourceclosure.c:
Removed is_refcounted and GBoxedInitFunc from
g_boxed_type_register_static().
Mon Sep 10 11:42:58 2001 Owen Taylor <otaylor@redhat.com> Mon Sep 10 11:42:58 2001 Owen Taylor <otaylor@redhat.com>
* glib/gutf8.c glib/gstring.c glib/gfileutils.c glib/gmain.c: * glib/gutf8.c glib/gstring.c glib/gfileutils.c glib/gmain.c:

View File

@ -1,3 +1,10 @@
2001-09-10 Alex Larsson <alexl@redhat.com>
* gobject/gboxed.[ch]:
* gobject/gsourceclosure.c:
Removed is_refcounted and GBoxedInitFunc from
g_boxed_type_register_static().
Mon Sep 10 11:42:58 2001 Owen Taylor <otaylor@redhat.com> Mon Sep 10 11:42:58 2001 Owen Taylor <otaylor@redhat.com>
* glib/gutf8.c glib/gstring.c glib/gfileutils.c glib/gmain.c: * glib/gutf8.c glib/gstring.c glib/gfileutils.c glib/gmain.c:

View File

@ -30,10 +30,8 @@
typedef struct typedef struct
{ {
GType type; GType type;
GBoxedInitFunc init;
GBoxedCopyFunc copy; GBoxedCopyFunc copy;
GBoxedFreeFunc free; GBoxedFreeFunc free;
gboolean is_refcounted;
} BoxedNode; } BoxedNode;
@ -88,18 +86,6 @@ value_free (gpointer boxed)
g_free (value); g_free (value);
} }
static gpointer
value_array_init (void)
{
return g_value_array_new (0);
}
static gpointer
gstring_init (void)
{
return g_string_new ("");
}
static gpointer static gpointer
gstring_copy (gpointer boxed) gstring_copy (gpointer boxed)
{ {
@ -143,38 +129,30 @@ g_boxed_type_init (void) /* sync with gtype.c */
/* boxed: G_TYPE_CLOSURE /* boxed: G_TYPE_CLOSURE
*/ */
type = g_boxed_type_register_static ("GClosure", type = g_boxed_type_register_static ("GClosure",
(GBoxedInitFunc) NULL,
(GBoxedCopyFunc) g_closure_ref, (GBoxedCopyFunc) g_closure_ref,
(GBoxedFreeFunc) g_closure_unref, (GBoxedFreeFunc) g_closure_unref);
TRUE);
g_assert (type == G_TYPE_CLOSURE); g_assert (type == G_TYPE_CLOSURE);
/* boxed: G_TYPE_VALUE /* boxed: G_TYPE_VALUE
*/ */
type = g_boxed_type_register_static ("GValue", type = g_boxed_type_register_static ("GValue",
(GBoxedInitFunc) NULL,
value_copy, value_copy,
value_free, value_free);
FALSE);
g_assert (type == G_TYPE_VALUE); g_assert (type == G_TYPE_VALUE);
/* boxed: G_TYPE_VALUE_ARRAY /* boxed: G_TYPE_VALUE_ARRAY
*/ */
type = g_boxed_type_register_static ("GValueArray", type = g_boxed_type_register_static ("GValueArray",
value_array_init, /* don't allow NULL values */
(GBoxedCopyFunc) g_value_array_copy, (GBoxedCopyFunc) g_value_array_copy,
(GBoxedFreeFunc) g_value_array_free, (GBoxedFreeFunc) g_value_array_free);
FALSE);
g_assert (type == G_TYPE_VALUE_ARRAY); g_assert (type == G_TYPE_VALUE_ARRAY);
/* boxed: G_TYPE_GSTRING /* boxed: G_TYPE_GSTRING
* yes, the naming is a bit odd, but GString is obviously not G_TYPE_STRING * yes, the naming is a bit odd, but GString is obviously not G_TYPE_STRING
*/ */
type = g_boxed_type_register_static ("GString", type = g_boxed_type_register_static ("GString",
gstring_init, /* don't allow NULL values */
gstring_copy, gstring_copy,
gstring_free, gstring_free);
FALSE);
g_assert (type == G_TYPE_GSTRING); g_assert (type == G_TYPE_GSTRING);
} }
@ -185,7 +163,7 @@ boxed_proxy_value_init (GValue *value)
key.type = G_VALUE_TYPE (value); key.type = G_VALUE_TYPE (value);
node = g_bsearch_array_lookup (&boxed_bsa, &key); 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 static void
@ -234,13 +212,11 @@ boxed_proxy_collect_value (GValue *value,
key.type = G_VALUE_TYPE (value); key.type = G_VALUE_TYPE (value);
node = g_bsearch_array_lookup (&boxed_bsa, &key); node = g_bsearch_array_lookup (&boxed_bsa, &key);
/* for NULL values, we have to call GBoxedInitFunc */
if (!collect_values[0].v_pointer) if (!collect_values[0].v_pointer)
value->data[0].v_pointer = node->init ? node->init () : NULL; value->data[0].v_pointer = NULL;
else else
{ {
/* never honour G_VALUE_NOCOPY_CONTENTS for ref-counted types */ if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
if (!node->is_refcounted && (collect_flags & G_VALUE_NOCOPY_CONTENTS))
{ {
value->data[0].v_pointer = collect_values[0].v_pointer; value->data[0].v_pointer = collect_values[0].v_pointer;
value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS; value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
@ -281,10 +257,8 @@ boxed_proxy_lcopy_value (const GValue *value,
GType GType
g_boxed_type_register_static (const gchar *name, g_boxed_type_register_static (const gchar *name,
GBoxedInitFunc boxed_init,
GBoxedCopyFunc boxed_copy, GBoxedCopyFunc boxed_copy,
GBoxedFreeFunc boxed_free, GBoxedFreeFunc boxed_free)
gboolean is_refcounted)
{ {
static const GTypeValueTable vtable = { static const GTypeValueTable vtable = {
boxed_proxy_value_init, boxed_proxy_value_init,
@ -323,10 +297,8 @@ g_boxed_type_register_static (const gchar *name,
BoxedNode key; BoxedNode key;
key.type = type; key.type = type;
key.init = boxed_init;
key.copy = boxed_copy; key.copy = boxed_copy;
key.free = boxed_free; key.free = boxed_free;
key.is_refcounted = is_refcounted != FALSE;
g_bsearch_array_insert (&boxed_bsa, &key, TRUE); g_bsearch_array_insert (&boxed_bsa, &key, TRUE);
} }

View File

@ -29,7 +29,6 @@ G_BEGIN_DECLS
/* --- typedefs --- */ /* --- typedefs --- */
typedef gpointer (*GBoxedInitFunc) (void);
typedef gpointer (*GBoxedCopyFunc) (gpointer boxed); typedef gpointer (*GBoxedCopyFunc) (gpointer boxed);
typedef void (*GBoxedFreeFunc) (gpointer boxed); typedef void (*GBoxedFreeFunc) (gpointer boxed);
@ -49,10 +48,8 @@ gpointer g_value_dup_boxed (const GValue *value);
/* --- convenience --- */ /* --- convenience --- */
GType g_boxed_type_register_static (const gchar *name, GType g_boxed_type_register_static (const gchar *name,
GBoxedInitFunc boxed_init,
GBoxedCopyFunc boxed_copy, GBoxedCopyFunc boxed_copy,
GBoxedFreeFunc boxed_free, GBoxedFreeFunc boxed_free);
gboolean is_refcounted);
/* --- marshaller specific --- */ /* --- marshaller specific --- */

View File

@ -31,10 +31,8 @@ g_io_channel_get_type (void)
if (our_type == 0) if (our_type == 0)
our_type = g_boxed_type_register_static ("GIOChannel", our_type = g_boxed_type_register_static ("GIOChannel",
NULL,
(GBoxedCopyFunc) g_io_channel_ref, (GBoxedCopyFunc) g_io_channel_ref,
(GBoxedFreeFunc) g_io_channel_unref, (GBoxedFreeFunc) g_io_channel_unref);
FALSE);
return our_type; return our_type;
} }