emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] scratch/dbusbind-type-tests def5829 2/2: dbusbind: Check r


From: Daiki Ueno
Subject: [Emacs-diffs] scratch/dbusbind-type-tests def5829 2/2: dbusbind: Check required args following :type
Date: Thu, 03 Sep 2015 09:21:51 +0000

branch: scratch/dbusbind-type-tests
commit def5829c0769b142b3cc0d69a9ad58935a9f237f
Author: Daiki Ueno <address@hidden>
Commit: Daiki Ueno <address@hidden>

    dbusbind: Check required args following :type
    
    * src/dbusbind.c (xd_build_message): If no argument follows a type
    specification, pass Qnil as OBJECT argument of
    xd_append_arg_with_type_spec.
    * test/automated/dbus-tests.el
    (dbus-test04-create-message-parameters): Remove a temporary
    comment.
---
 src/dbusbind.c               |   11 ++++++++++-
 test/automated/dbus-tests.el |    1 -
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/dbusbind.c b/src/dbusbind.c
index 9747d88..63f4672 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -1683,7 +1683,16 @@ xd_build_message (Lisp_Object caller, struct xd_message 
*xmessage,
     {
       if (EQ (args[count], QCdbus_type_type))
        {
-         xd_append_arg_with_type_spec (args[count+1], args[count+2], &iter);
+         /* At least one object must follow the `:type' symbol.  */
+         if (!(count+1 < nargs))
+           wrong_type_argument (intern ("D-Bus"), QCdbus_type_type);
+
+         /* It is possible that no argument follows a type
+            specification, when the type is an empty compound type.
+            Assume it as nil.  */
+         xd_append_arg_with_type_spec (args[count+1],
+                                       count+2 < nargs ? args[count+2] : Qnil,
+                                       &iter);
          count += 2;
        }
       else
diff --git a/test/automated/dbus-tests.el b/test/automated/dbus-tests.el
index 69afaa3..e989f73 100644
--- a/test/automated/dbus-tests.el
+++ b/test/automated/dbus-tests.el
@@ -214,7 +214,6 @@ This includes initialization and closing the bus."
     (should (equal (plist-get message :args) '(((:array nil) nil))))
     (should (equal (plist-get message :signature) "au"))
     ;; Test explicit type specifications with `:type' keyword for empty array.
-    ;; DOES THIS WORK?
     (setq message (dbus--test-create-message-with-args
                    :type '(:array :uint32)))
     (should (equal (plist-get message :args) '(((:array nil) nil))))



reply via email to

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