From 4a48fff0c7c0377d68d1e24cc113e275057b4800 Mon Sep 17 00:00:00 2001 From: Robert McQueen Date: Mon, 13 Feb 2006 22:30:11 +0000 Subject: 2006-02-13 Robert McQueen * glib/dbus-binding-tool-glib.c, glib/dbus-gmain.c, glib/dbus-gsignature.c, glib/dbus-gtype-specialized.c, glib/dbus-gtype-specialized.h, glib/dbus-gvalue-utils.c, glib/dbus-gvalue-utils.h, glib/dbus-gvalue.c: Patch from Rob Taylor to add a big missing piece of the glib bindings jigsaw puzzle. This modifies the existing specialised types to have N type parameters (rather than the current 1 or 2 for arrays and dictionaries respectively). You can then use this to get a glib type to represent any arbitrary D-Bus struct type using dbus_g_type_get_struct. The only implementation of these types is with GValueArrays as before, but it's now possible to store these in arrays, emit them in signals, etc. --- glib/dbus-binding-tool-glib.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'glib/dbus-binding-tool-glib.c') diff --git a/glib/dbus-binding-tool-glib.c b/glib/dbus-binding-tool-glib.c index 21e02744..1386e3f1 100644 --- a/glib/dbus-binding-tool-glib.c +++ b/glib/dbus-binding-tool-glib.c @@ -98,6 +98,10 @@ static const char * dbus_g_type_get_c_name (GType gtype) { GType subtype; + if (dbus_g_type_is_struct (gtype)) + { + return "GValueArray"; + } if (dbus_g_type_is_collection (gtype)) { subtype = dbus_g_type_get_collection_specialization(gtype); @@ -1050,6 +1054,28 @@ dbus_g_type_get_lookup_function (GType gtype) g_free (value_lookup); return type_lookup; } + else if (dbus_g_type_is_struct (gtype)) + { + GType value_gtype; + GString *string; + char *value_lookup = NULL; + guint size, i; + + string = g_string_new ("dbus_g_type_get_struct (\"GValueArray\""); + + size = dbus_g_type_get_struct_size (gtype); + for (i=0; i < size; i++) + { + value_gtype = dbus_g_type_get_struct_member_type(gtype, i); + value_lookup = dbus_g_type_get_lookup_function (value_gtype); + g_assert (value_lookup); + g_string_append_printf (string, ", %s", value_lookup); + g_free (value_lookup); + } + g_string_append (string, ", G_TYPE_INVALID)"); + return g_string_free (string, FALSE); + } + MAP_KNOWN(G_TYPE_VALUE); MAP_KNOWN(G_TYPE_STRV); MAP_KNOWN(G_TYPE_VALUE_ARRAY); -- cgit