Bindings without callbacks (was Re: [ANN] Squeak bindings for D-Bus)
Daniel B. Faken
faken at cascv.brown.edu
Wed May 25 06:04:58 PDT 2005
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
static DBusHandlerResult _dbusMessageHolderHandler(DBusConnection *conn,
DBusMessage *msg, void *data)
_dbus_assert(conn && msg && data);
dbus_message_ref(msg); // needed?
*((void **)data) = msg;
static DBusObjectPathVTable tbl;
tbl.unregister_function = NULL;
tbl.message_function = _dbusMessageHolderHandler;
(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
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.
> 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. :)
More information about the dbus