diff options
author | Robert McQueen <robot101@debian.org> | 2006-02-13 22:30:11 +0000 |
---|---|---|
committer | Robert McQueen <robot101@debian.org> | 2006-02-13 22:30:11 +0000 |
commit | 4a48fff0c7c0377d68d1e24cc113e275057b4800 (patch) | |
tree | 729444babf3951c53d44b9be4f0569cc173f81a8 /glib/dbus-gsignature.c | |
parent | 385c443cc7aacaadbdef391d3951699a7511fbb2 (diff) |
2006-02-13 Robert McQueen <robot101@debian.org>
* 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 <rob.taylor@collabora.co.uk> 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.
Diffstat (limited to 'glib/dbus-gsignature.c')
-rw-r--r-- | glib/dbus-gsignature.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/glib/dbus-gsignature.c b/glib/dbus-gsignature.c index a0370b0e..5df959db 100644 --- a/glib/dbus-gsignature.c +++ b/glib/dbus-gsignature.c @@ -117,6 +117,25 @@ signature_iter_to_g_type_array (DBusSignatureIter *iter, gboolean is_client) return G_TYPE_INVALID; } +static GType +signature_iter_to_g_type_struct (DBusSignatureIter *iter, gboolean is_client) +{ + GArray *types; + GType ret; + types = g_array_new (FALSE, FALSE, sizeof (GType)); + do + { + GType curtype; + curtype = _dbus_gtype_from_signature_iter (iter, is_client); + g_array_append_val (types, curtype); + } + while (dbus_signature_iter_next (iter)); + + ret = dbus_g_type_get_structv ("GValueArray", types->len, (GType*) types->data); + g_array_free (types, TRUE); + return ret; +} + GType _dbus_gtype_from_signature_iter (DBusSignatureIter *iter, gboolean is_client) { @@ -136,8 +155,6 @@ _dbus_gtype_from_signature_iter (DBusSignatureIter *iter, gboolean is_client) if (current_type == DBUS_TYPE_VARIANT) return G_TYPE_VALUE; - if (current_type == DBUS_TYPE_STRUCT) - return G_TYPE_VALUE_ARRAY; dbus_signature_iter_recurse (iter, &subiter); @@ -149,6 +166,10 @@ _dbus_gtype_from_signature_iter (DBusSignatureIter *iter, gboolean is_client) else return signature_iter_to_g_type_array (&subiter, is_client); } + else if (current_type == DBUS_TYPE_STRUCT) + { + return signature_iter_to_g_type_struct (&subiter, is_client); + } else { g_assert_not_reached (); |