[patch] initial conversion of glib bindings to use signatures

Colin Walters walters at verbum.org
Fri Feb 25 12:49:08 PST 2005


On Thu, 2005-02-24 at 15:27 -0500, Havoc Pennington wrote:
>On Thu, 2005-02-24 at 15:09 -0500, Colin Walters wrote:
>> One thing I'd like to discuss is what exactly various container types
>> should map to in GLib.  I would think that:
>> 
>> a{..} -> GHashTable
>
>Yes, dict to hash table seems right. Though it's completely untypesafe
>and awful on some level.

Yeah, although GLib programmers are used to the type-unsafety of
GHashTable anyways.

>The glib bindings have to copy the data because the DBusMessage is never
>passed out, so nobody is holding a reference to it.

Ah, right.

>> The thing I'm most unsure about is how structures will work, both on the
>> client wrapper end and the server side.
>
>The options I know of are:
> - they are hashes from string to GValue
> - they are a special object with iterator, like DBusMessage
>   (in fact it could just be DBusGMessage with the iter stuff also
>wrapped)
> - the CORBA thing (convert to a C struct)
>
>My suggestion is #2, on the theory that usually a struct will really be
>some special type like a pixbuf or point or rectangle, and people will
>want to add awareness of that specific special type. i.e. I imagine
>things like gdk_rectangle_from_dbus/to_dbus

Hmmm.  Yeah, I can see the value in #2.  

>One suckage here is the need to wrap all the message iter stuff.

So on the client end, if the frobnicate method's input signature was
"s(ii)" and output signature was "(ii)", the code might look like this:

DBusGStructureIter iter;
DBusGStructureIter ret_iter;
GError *error = NULL;

dbus_g_structure_init_append (&iter);
dbus_g_structure_append_values (&iter, G_TYPE_INT32, 10, G_TYPE_INT32, 42, G_TYPE_INVALID);
if (!org_freedesktop_NetworkManager_frobnicate (proxy, "Blah", &iter, &ret_iter, &error))
  ...

printf ("returned %d", dbus_g_structure_iter_get_int32 (&ret_iter));
dbus_g_structure_iter_next (&ret_iter);
printf (":%d\n", dbus_g_structure_iter_get_int32 (&ret_iter));


Or something like that?


Have you had a chance to look at the patch, by the way?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.freedesktop.org/archives/dbus/attachments/20050225/82bb127a/attachment.pgp


More information about the dbus mailing list