Bindings without callbacks (was Re: [ANN] Squeak bindings for D-Bus)

John (J5) Palmieri johnp at redhat.com
Wed May 25 06:31:03 PDT 2005


I'm not sure how squeak works but don't you have to write C bindings
anyway or does the virtual machine have a way of marshaling C calls in
which case how does it handle pointers and structs?  Other than that 20
lines of c code for a library - if you need it, do it.  It is a lot
better than asking users to patch and recompile dbus.

On Wed, 2005-05-25 at 09:04 -0400, Daniel B. Faken wrote:
> On Wed, 25 May 2005, John (J5) Palmieri wrote:
> > One note.  It is not the best thing to patch dbus in order to support
> > your bindings.  What you probably want to do is create a helper library
> > that your bindings then link to.
> 
> Yeah.. it just seemed like an awfully small library (~20 lines of C) :).
> 
> Can you think of any better way to go about this?
> 
> The code in question:
> ------------------------
> // Helper function for Squeak bindings
> 
> #include <stdio.h>
> 
> static DBusHandlerResult _dbusMessageHolderHandler(DBusConnection *conn, 
> DBusMessage *msg, void *data)
> {
>   _dbus_assert(conn && msg && data);
>   dbus_message_ref(msg);  // needed?
> 
>   *((void **)data) = msg;
> 
>   return DBUS_HANDLER_RESULT_HANDLED;
> }
> DBusObjectPathVTable *dbus_message_holder_vtable(void);
> 
> DBusObjectPathVTable *dbus_message_holder_vtable(void)
> {
>   static DBusObjectPathVTable tbl;
> 
>   tbl.unregister_function = NULL;
>   tbl.message_function = _dbusMessageHolderHandler;
> 
>   return (&tbl);
> }
> ------------------
> (actually I don't even need the latter part (to get the vtable) - just the 
> callback fn, since I don't know a way to dynamically generate these)
> 
> This allows the application (here: Squeak) to register a fallback 
> (/Squeak) with the result of calling dbus_message_holder_vtable() and a 
> data pointer-pointer.
>   The app can then call dbus_connection_read_write_dispatch() or
> dbus_connection_dispatch() and check the pointer afterwards to see
> if it got a message.
> 
> thanks,
> Daniel
> 
>  
> > On Tue, 2005-05-24 at 14:50 -0400, Daniel B. Faken wrote:
> > > Hello all,
> > > 
> > >   I've put up a first version of my Squeak-Smalltalk bindings to the D-Bus 
> > > IPC system at: http://www.ccv.brown.edu/~faken/squeak/DBus-0.1.1.cs
> > > 
> > >   This is an alpha release; it has some documentation but no examples yet.
> > > 
> > >   Feedback is welcome..
> > > 
> > > thanks,
> > > Daniel Faken
> > > 
> > > P.S. there is kindof an example at 
> > > http://lists.freedesktop.org/archives/dbus/2005-May/002657.html
> > > for the die-hard. :)
> > > 
> > 
> 
-- 
John (J5) Palmieri
Associate Software Engineer
Desktop Group
Red Hat, Inc.
Blog: http://martianrock.com



More information about the dbus mailing list