dbus/glib dbus-gvalue-utils.c,1.11,1.12
Rob McQueen
robot101 at kemper.freedesktop.org
Tue Jun 6 12:45:41 PDT 2006
Update of /cvs/dbus/dbus/glib
In directory kemper:/tmp/cvs-serv10093/glib
Modified Files:
dbus-gvalue-utils.c
Log Message:
2005-05-06 Robert McQueen <robot101 at debian.org>
* glib/dbus-gvalue-utils.c: Remove duplicated code by having all of
the iterators use gvalue_take_ptrarray_value (the GValues themselves
are discarded without unsetting, so it makes no difference whether
we take or set_static). Remove cases for G_TYPE_POINTER because
there really is nothing useful we can do with them in our
specialised types - we *need* boxed copy/free functions at the very
least.
Index: dbus-gvalue-utils.c
===================================================================
RCS file: /cvs/dbus/dbus/glib/dbus-gvalue-utils.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- dbus-gvalue-utils.c 21 May 2006 05:33:52 -0000 1.11
+++ dbus-gvalue-utils.c 6 Jun 2006 19:45:39 -0000 1.12
@@ -113,9 +113,6 @@
case G_TYPE_STRING:
*((gchar **) storage) = (char*) g_value_get_string (value);
return TRUE;
- case G_TYPE_POINTER:
- *((gpointer *) storage) = g_value_get_pointer (value);
- return TRUE;
case G_TYPE_OBJECT:
*((gpointer *) storage) = g_value_get_object (value);
return TRUE;
@@ -167,9 +164,6 @@
case G_TYPE_STRING:
g_value_set_string (value, *((gchar **) storage));
return TRUE;
- case G_TYPE_POINTER:
- g_value_set_pointer (value, *((gpointer *) storage));
- return TRUE;
case G_TYPE_OBJECT:
g_value_set_object (value, *((gpointer *) storage));
return TRUE;
@@ -403,8 +397,10 @@
return func;
}
+static void gvalue_take_ptrarray_value (GValue *value, gpointer instance);
+
static void
-gvalue_from_hash_value (GValue *value, gpointer instance)
+gvalue_take_hash_value (GValue *value, gpointer instance)
{
switch (g_type_fundamental (G_VALUE_TYPE (value)))
{
@@ -426,25 +422,14 @@
case G_TYPE_DOUBLE:
g_value_set_double (value, *(gdouble *) instance);
break;
- case G_TYPE_STRING:
- g_value_set_static_string (value, instance);
- break;
- case G_TYPE_POINTER:
- g_value_set_pointer (value, instance);
- break;
- case G_TYPE_BOXED:
- g_value_set_static_boxed (value, instance);
- break;
- case G_TYPE_OBJECT:
- g_value_set_object (value, instance);
- g_object_unref (g_value_get_object (value));
- break;
default:
- g_assert_not_reached ();
+ gvalue_take_ptrarray_value (value, instance);
break;
}
}
+static gpointer ptrarray_value_from_gvalue (const GValue *value);
+
static gpointer
hash_value_from_gvalue (GValue *value)
{
@@ -472,21 +457,9 @@
return (gpointer) p;
}
break;
- case G_TYPE_STRING:
- return (gpointer) g_value_get_string (value);
- break;
- case G_TYPE_POINTER:
- return g_value_get_pointer (value);
- break;
- case G_TYPE_BOXED:
- return g_value_get_boxed (value);
- break;
- case G_TYPE_OBJECT:
- return g_value_get_object (value);
- break;
default:
- g_assert_not_reached ();
- return NULL;
+ return ptrarray_value_from_gvalue (value);
+ break;
}
}
@@ -507,8 +480,8 @@
g_value_init (&key_val, data->key_type);
g_value_init (&value_val, data->value_type);
- gvalue_from_hash_value (&key_val, key);
- gvalue_from_hash_value (&value_val, value);
+ gvalue_take_hash_value (&key_val, key);
+ gvalue_take_hash_value (&value_val, value);
data->func (&key_val, &value_val, data->data);
}
@@ -749,47 +722,18 @@
}
static void
-gvalue_from_ptrarray_value (GValue *value, gpointer instance)
-{
- switch (g_type_fundamental (G_VALUE_TYPE (value)))
- {
- case G_TYPE_STRING:
- g_value_set_string (value, instance);
- break;
- case G_TYPE_POINTER:
- g_value_set_pointer (value, instance);
- break;
- case G_TYPE_BOXED:
- g_value_set_static_boxed (value, instance);
- break;
- case G_TYPE_OBJECT:
- g_value_set_object (value, instance);
- g_object_unref (g_value_get_object (value));
- break;
- default:
- g_assert_not_reached ();
- break;
- }
-}
-
-static void
-gvalue_take_from_ptrarray_value (GValue *value, gpointer instance)
+gvalue_take_ptrarray_value (GValue *value, gpointer instance)
{
switch (g_type_fundamental (G_VALUE_TYPE (value)))
{
case G_TYPE_STRING:
g_value_take_string (value, instance);
break;
- case G_TYPE_POINTER:
- g_value_set_pointer (value, instance);
- g_assert_not_reached ();
- break;
case G_TYPE_BOXED:
g_value_take_boxed (value, instance);
break;
case G_TYPE_OBJECT:
g_value_take_object (value, instance);
- g_object_unref (g_value_get_object (value));
break;
default:
g_assert_not_reached ();
@@ -805,9 +749,6 @@
case G_TYPE_STRING:
return (gpointer) g_value_get_string (value);
break;
- case G_TYPE_POINTER:
- return g_value_get_pointer (value);
- break;
case G_TYPE_BOXED:
return g_value_get_boxed (value);
break;
@@ -838,7 +779,7 @@
{
GValue val = {0, };
g_value_init (&val, elt_gtype);
- gvalue_from_ptrarray_value (&val, g_ptr_array_index (ptrarray, i));
+ gvalue_take_ptrarray_value (&val, g_ptr_array_index (ptrarray, i));
iterator (&val, user_data);
}
}
@@ -895,7 +836,7 @@
for (i = 0; i < array->len; i++)
{
g_value_init (&elt_val, elt_gtype);
- gvalue_take_from_ptrarray_value (&elt_val, g_ptr_array_index (array, i));
+ gvalue_take_ptrarray_value (&elt_val, g_ptr_array_index (array, i));
g_value_unset (&elt_val);
}
@@ -925,7 +866,7 @@
{
GValue val = {0, };
g_value_init (&val, elt_gtype);
- gvalue_from_ptrarray_value (&val, slist->data);
+ gvalue_take_ptrarray_value (&val, slist->data);
iterator (&val, user_data);
}
}
@@ -996,9 +937,9 @@
{
GValue elt_val = {0, };
g_value_init (&elt_val, elt_gtype);
- gvalue_take_from_ptrarray_value (&elt_val, list->data);
+ gvalue_take_ptrarray_value (&elt_val, list->data);
g_value_unset (&elt_val);
- list = g_slist_next(list);
+ list = g_slist_next(list);
}
list=val;
g_slist_free (list);
More information about the dbus-commit
mailing list