emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Automatic value conversion in DBus bindings


From: Jan Moringen
Subject: Automatic value conversion in DBus bindings
Date: Mon, 27 Jul 2009 04:44:21 +0200

While playing around with the DBus bindings, I came across some problems
related to the automatic conversion between LISP and DBus values.

The first problem can be demonstrated by running the following code:

  (require 'dbus)

  (defun test ()
    nil)

  (dbus-register-method
   :session "org.gnu.emacs" "/org/gnu/emacs" "org.gnu.Emacs" "test"
   #'test)

  (dbus-call-method-non-blocking
   :session "org.gnu.emacs" "/org/gnu/emacs" "org.gnu.Emacs" "test")

The last call never returns. The problem is in
`dbus-call-method-non-blocking':

  (while (not (gethash key dbus-return-values-table nil))
    (read-event nil nil 0.1))

Here, the return value nil cannot be distinguished from "no return value
yet". A suggestion for a fix is in the attached patch.

I am writing to emacs-devel rather than reporting a bug because I think
the fix for this particular problem should be accompanied by a small
change of the DBus interface. The original motivation for my experiments
was writing a function that should receive DBus calls but not return a
value. This was necessary since another process (Empathy) would call the
method via DBus and complain if it returned anything.

The current LISP -> DBus conversion rules make it impossible (from what
I understand at least) to not return a value, since an empty list, which
would represent zero return values, is interpreted as a single 'false'
value. I think this special treatment of values that are null or not
lists should be removed, thus always requiring a list as the return
value of a DBus-invokable function. This change is also included in the
attached patch. Note that the documentation would need corresponding
changes.

Since the proposed changes could break existing software, a different
approach may be better. I would be glad to here opinions on the subject.

Kind regards,
Jan Moringen

Attachment: emacs-dbus-return-values.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]