From aaa6d76898e450936e618a6c793b6ab028378abd Mon Sep 17 00:00:00 2001 From: Marc-Andre Lureau Date: Sat, 4 Oct 2008 23:05:46 +0300 Subject: [PATCH] Lookup derived types, before failing --- dbus/dbus-gvalue.c | 112 ++++++++++++++++++++++++++++++++++------------------ 1 files changed, 73 insertions(+), 39 deletions(-) diff --git a/dbus/dbus-gvalue.c b/dbus/dbus-gvalue.c index 877f32d..9553d21 100644 --- a/dbus/dbus-gvalue.c +++ b/dbus/dbus-gvalue.c @@ -422,9 +422,16 @@ _dbus_gtype_to_signature (GType gtype) } else { - typedata = g_type_get_qdata (gtype, dbus_g_type_metadata_data_quark ()); - if (typedata == NULL) - return NULL; + for (;;) { + typedata = g_type_get_qdata (gtype, dbus_g_type_metadata_data_quark ()); + if (typedata != NULL) + break; + + gtype = g_type_parent (gtype); + if (gtype == 0) + return NULL; + } + ret = g_strdup (typedata->sig); } return ret; @@ -988,29 +995,42 @@ demarshal_struct (DBusGValueMarshalCtx *context, return TRUE; } - static DBusGValueDemarshalFunc get_type_demarshaller (GType type) { DBusGTypeMarshalData *typedata; + GType gtype; - typedata = g_type_get_qdata (type, dbus_g_type_metadata_data_quark ()); - if (typedata == NULL) - { - if (g_type_is_a (type, G_TYPE_VALUE_ARRAY)) - return demarshal_valuearray; - if (dbus_g_type_is_collection (type)) - return demarshal_collection; - if (dbus_g_type_is_map (type)) - return demarshal_map; - if (dbus_g_type_is_struct (type)) - return demarshal_struct; - - g_warning ("No demarshaller registered for type \"%s\"", g_type_name (type)); - return NULL; - } - g_assert (typedata->vtable); - return typedata->vtable->demarshaller; + gtype = type; + + for (;;) { + typedata = g_type_get_qdata (gtype, dbus_g_type_metadata_data_quark ()); + + if (typedata == NULL) + { + if (g_type_is_a (gtype, G_TYPE_VALUE_ARRAY)) + return demarshal_valuearray; + if (dbus_g_type_is_collection (gtype)) + return demarshal_collection; + if (dbus_g_type_is_map (gtype)) + return demarshal_map; + if (dbus_g_type_is_struct (gtype)) + return demarshal_struct; + + gtype = g_type_parent (gtype); + if (gtype == 0) + break; + } + else + { + g_assert (typedata->vtable); + return typedata->vtable->demarshaller; + } + } + + g_warning ("No demarshaller registered for type \"%s\"", g_type_name (type)); + + return NULL; } static gboolean @@ -1247,7 +1267,7 @@ marshal_basic (DBusMessageIter *iter, const GValue *value) value_type = G_VALUE_TYPE (value); - switch (value_type) + switch (G_TYPE_FUNDAMENTAL (value_type)) { case G_TYPE_CHAR: { @@ -1720,24 +1740,38 @@ static DBusGValueMarshalFunc get_type_marshaller (GType type) { DBusGTypeMarshalData *typedata; + GType gtype; - typedata = g_type_get_qdata (type, dbus_g_type_metadata_data_quark ()); - if (typedata == NULL) - { - if (g_type_is_a (type, G_TYPE_VALUE_ARRAY)) - return marshal_valuearray; - if (dbus_g_type_is_collection (type)) - return marshal_collection; - if (dbus_g_type_is_map (type)) - return marshal_map; - if (dbus_g_type_is_struct (type)) - return marshal_struct; - - g_warning ("No marshaller registered for type \"%s\"", g_type_name (type)); - return NULL; - } - g_assert (typedata->vtable); - return typedata->vtable->marshaller; + gtype = type; + + for (;;) { + typedata = g_type_get_qdata (gtype, dbus_g_type_metadata_data_quark ()); + + if (typedata == NULL) + { + if (g_type_is_a (gtype, G_TYPE_VALUE_ARRAY)) + return marshal_valuearray; + if (dbus_g_type_is_collection (gtype)) + return marshal_collection; + if (dbus_g_type_is_map (gtype)) + return marshal_map; + if (dbus_g_type_is_struct (gtype)) + return marshal_struct; + + gtype = g_type_parent (gtype); + if (gtype == 0) + break; + } + else + { + g_assert (typedata->vtable); + return typedata->vtable->marshaller; + } + } + + g_warning ("No marshaller registered for type \"%s\"", g_type_name (type)); + + return NULL; } typedef struct -- 1.5.6.5