aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Albinus2007-12-22 14:54:23 +0000
committerMichael Albinus2007-12-22 14:54:23 +0000
commit9af5078b398dbeee60dc39bb91924de7baae5336 (patch)
tree7800bdedc53b9150a01aea0b0a9d1909156b8036 /src
parent6a31c8196e70b966e7125914ba96897d91499196 (diff)
downloademacs-9af5078b398dbeee60dc39bb91924de7baae5336.tar.gz
emacs-9af5078b398dbeee60dc39bb91924de7baae5336.zip
* dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
DBUS_TYPE_INT16, DBUS_TYPE_UINT16, DBUS_TYPE_INT64, DBUS_TYPE_UINT64, DBUS_TYPE_DOUBLE and DBUS_TYPE_SIGNATURE. Return float when DBUS_TYPE_INT32 or DBUS_TYPE_UINT32 do not fit as number. (Fdbus_call_method): Fix docstring.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/dbusbind.c75
2 files changed, 65 insertions, 19 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 7c2bbffd1e4..952f9d7e6e8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
12007-12-22 Michael Albinus <michael.albinus@gmx.de>
2
3 * dbusbind.c (xd_retrieve_arg): Handle DBUS_TYPE_BYTE,
4 DBUS_TYPE_INT16, DBUS_TYPE_UINT16, DBUS_TYPE_INT64,
5 DBUS_TYPE_UINT64, DBUS_TYPE_DOUBLE and DBUS_TYPE_SIGNATURE.
6 Return float when DBUS_TYPE_INT32 or DBUS_TYPE_UINT32 do not fit
7 as number.
8 (Fdbus_call_method): Fix docstring.
9
12007-12-21 Michael Albinus <michael.albinus@gmx.de> 102007-12-21 Michael Albinus <michael.albinus@gmx.de>
2 11
3 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE): 12 * dbusbind.c (XD_BASIC_DBUS_TYPE, XD_DBUS_TYPE_P, XD_NEXT_VALUE):
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 01168f51a95..79f98d0bc55 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -218,7 +218,7 @@ xd_signature(signature, dtype, parent_type, object)
218 break; 218 break;
219 219
220 case DBUS_TYPE_ARRAY: 220 case DBUS_TYPE_ARRAY:
221 /* Check that all elements have the same D-Bus type. For 221 /* Check that all list elements have the same D-Bus type. For
222 complex element types, we just check the container type, not 222 complex element types, we just check the container type, not
223 the whole element's signature. */ 223 the whole element's signature. */
224 CHECK_CONS (object); 224 CHECK_CONS (object);
@@ -239,7 +239,7 @@ xd_signature(signature, dtype, parent_type, object)
239 break; 239 break;
240 240
241 case DBUS_TYPE_VARIANT: 241 case DBUS_TYPE_VARIANT:
242 /* Check that there is exactly one element. */ 242 /* Check that there is exactly one list element. */
243 CHECK_CONS (object); 243 CHECK_CONS (object);
244 244
245 elt = XD_NEXT_VALUE (elt); 245 elt = XD_NEXT_VALUE (elt);
@@ -254,8 +254,8 @@ xd_signature(signature, dtype, parent_type, object)
254 break; 254 break;
255 255
256 case DBUS_TYPE_STRUCT: 256 case DBUS_TYPE_STRUCT:
257 /* A struct might contain any number of objects with different 257 /* A struct list might contain any number of elements with
258 types. No further check needed. */ 258 different types. No further check needed. */
259 CHECK_CONS (object); 259 CHECK_CONS (object);
260 260
261 elt = XD_NEXT_VALUE (elt); 261 elt = XD_NEXT_VALUE (elt);
@@ -274,11 +274,12 @@ xd_signature(signature, dtype, parent_type, object)
274 break; 274 break;
275 275
276 case DBUS_TYPE_DICT_ENTRY: 276 case DBUS_TYPE_DICT_ENTRY:
277 /* Check that there are exactly two elements, and the first one 277 /* Check that there are exactly two list elements, and the first
278 is of basic type. It must also be an element of an 278 one is of basic type. The dictionary entry itself must be an
279 array. */ 279 element of an array. */
280 CHECK_CONS (object); 280 CHECK_CONS (object);
281 281
282 /* Check the parent object type. */
282 if (parent_type != DBUS_TYPE_ARRAY) 283 if (parent_type != DBUS_TYPE_ARRAY)
283 wrong_type_argument (intern ("D-Bus"), object); 284 wrong_type_argument (intern ("D-Bus"), object);
284 285
@@ -381,7 +382,7 @@ xd_append_arg (dtype, object, iter)
381 382
382 case DBUS_TYPE_DOUBLE: 383 case DBUS_TYPE_DOUBLE:
383 XD_DEBUG_MESSAGE ("%c %f", dtype, XFLOAT (object)); 384 XD_DEBUG_MESSAGE ("%c %f", dtype, XFLOAT (object));
384 value = (char *) (float *) XFLOAT (object); 385 value = (char *) (double *) XFLOAT (object);
385 break; 386 break;
386 387
387 case DBUS_TYPE_STRING: 388 case DBUS_TYPE_STRING:
@@ -411,9 +412,9 @@ xd_append_arg (dtype, object, iter)
411 case DBUS_TYPE_ARRAY: 412 case DBUS_TYPE_ARRAY:
412 case DBUS_TYPE_VARIANT: 413 case DBUS_TYPE_VARIANT:
413 /* A variant has just one element. An array has elements of 414 /* A variant has just one element. An array has elements of
414 the same type. Both have been checked already, it is 415 the same type. Both have been checked already for
415 sufficient to retrieve just the signature of the first 416 correct types, it is sufficient to retrieve just the
416 element. */ 417 signature of the first element. */
417 xd_signature (signature, XD_OBJECT_TO_DBUS_TYPE (XCAR (object)), 418 xd_signature (signature, XD_OBJECT_TO_DBUS_TYPE (XCAR (object)),
418 dtype, XCAR (XD_NEXT_VALUE (object))); 419 dtype, XCAR (XD_NEXT_VALUE (object)));
419 XD_DEBUG_MESSAGE ("%c %s %s", dtype, signature, 420 XD_DEBUG_MESSAGE ("%c %s %s", dtype, signature,
@@ -427,6 +428,7 @@ xd_append_arg (dtype, object, iter)
427 428
428 case DBUS_TYPE_STRUCT: 429 case DBUS_TYPE_STRUCT:
429 case DBUS_TYPE_DICT_ENTRY: 430 case DBUS_TYPE_DICT_ENTRY:
431 /* These containers do not require a signature. */
430 XD_DEBUG_MESSAGE ("%c %s", dtype, 432 XD_DEBUG_MESSAGE ("%c %s", dtype,
431 SDATA (format2 ("%s", object, Qnil))); 433 SDATA (format2 ("%s", object, Qnil)));
432 if (!dbus_message_iter_open_container (iter, dtype, NULL, &subiter)) 434 if (!dbus_message_iter_open_container (iter, dtype, NULL, &subiter))
@@ -447,6 +449,7 @@ xd_append_arg (dtype, object, iter)
447 object = XCDR (object); 449 object = XCDR (object);
448 } 450 }
449 451
452 /* Close the subiteration. */
450 if (!dbus_message_iter_close_container (iter, &subiter)) 453 if (!dbus_message_iter_close_container (iter, &subiter))
451 xsignal2 (Qdbus_error, 454 xsignal2 (Qdbus_error,
452 build_string ("Cannot close container"), 455 build_string ("Cannot close container"),
@@ -456,8 +459,8 @@ xd_append_arg (dtype, object, iter)
456 459
457/* Retrieve C value from a DBusMessageIter structure ITER, and return 460/* Retrieve C value from a DBusMessageIter structure ITER, and return
458 a converted Lisp object. The type DTYPE of the argument of the 461 a converted Lisp object. The type DTYPE of the argument of the
459 D-Bus message must be a valid DBusType. Compound D-Bus types are 462 D-Bus message must be a valid DBusType. Compound D-Bus types
460 partly supported; they result always in a Lisp list. */ 463 result always in a Lisp list. */
461Lisp_Object 464Lisp_Object
462xd_retrieve_arg (dtype, iter) 465xd_retrieve_arg (dtype, iter)
463 unsigned int dtype; 466 unsigned int dtype;
@@ -466,6 +469,16 @@ xd_retrieve_arg (dtype, iter)
466 469
467 switch (dtype) 470 switch (dtype)
468 { 471 {
472 case DBUS_TYPE_BYTE:
473 case DBUS_TYPE_INT16:
474 case DBUS_TYPE_UINT16:
475 {
476 dbus_uint16_t val;
477 dbus_message_iter_get_basic (iter, &val);
478 XD_DEBUG_MESSAGE ("%c %d", dtype, val);
479 return make_number (val);
480 }
481
469 case DBUS_TYPE_BOOLEAN: 482 case DBUS_TYPE_BOOLEAN:
470 { 483 {
471 dbus_bool_t val; 484 dbus_bool_t val;
@@ -479,12 +492,36 @@ xd_retrieve_arg (dtype, iter)
479 { 492 {
480 dbus_uint32_t val; 493 dbus_uint32_t val;
481 dbus_message_iter_get_basic (iter, &val); 494 dbus_message_iter_get_basic (iter, &val);
482 XD_DEBUG_MESSAGE ("%c %d", dtype, val); 495 if (FIXNUM_OVERFLOW_P (val))
483 return make_number (val); 496 XD_DEBUG_MESSAGE ("%c %f", dtype, val)
497 else
498 XD_DEBUG_MESSAGE ("%c %d", dtype, val);
499 return make_fixnum_or_float (val);
500 }
501
502 case DBUS_TYPE_INT64:
503 case DBUS_TYPE_UINT64:
504 {
505 dbus_uint64_t val;
506 dbus_message_iter_get_basic (iter, &val);
507 if (FIXNUM_OVERFLOW_P (val))
508 XD_DEBUG_MESSAGE ("%c %f", dtype, val)
509 else
510 XD_DEBUG_MESSAGE ("%c %d", dtype, val);
511 return make_fixnum_or_float (val);
512 }
513
514 case DBUS_TYPE_DOUBLE:
515 {
516 double val;
517 dbus_message_iter_get_basic (iter, &val);
518 XD_DEBUG_MESSAGE ("%c %f", dtype, val);
519 return make_float (val);
484 } 520 }
485 521
486 case DBUS_TYPE_STRING: 522 case DBUS_TYPE_STRING:
487 case DBUS_TYPE_OBJECT_PATH: 523 case DBUS_TYPE_OBJECT_PATH:
524 case DBUS_TYPE_SIGNATURE:
488 { 525 {
489 char *val; 526 char *val;
490 dbus_message_iter_get_basic (iter, &val); 527 dbus_message_iter_get_basic (iter, &val);
@@ -606,10 +643,10 @@ input arguments. It follows the mapping rules:
606 DBUS_TYPE_BYTE => number 643 DBUS_TYPE_BYTE => number
607 DBUS_TYPE_UINT16 => number 644 DBUS_TYPE_UINT16 => number
608 DBUS_TYPE_INT16 => integer 645 DBUS_TYPE_INT16 => integer
609 DBUS_TYPE_UINT32 => number 646 DBUS_TYPE_UINT32 => number or float
610 DBUS_TYPE_INT32 => integer 647 DBUS_TYPE_INT32 => integer or float
611 DBUS_TYPE_UINT64 => number 648 DBUS_TYPE_UINT64 => number or float
612 DBUS_TYPE_INT64 => integer 649 DBUS_TYPE_INT64 => integer or float
613 DBUS_TYPE_DOUBLE => float 650 DBUS_TYPE_DOUBLE => float
614 DBUS_TYPE_STRING => string 651 DBUS_TYPE_STRING => string
615 DBUS_TYPE_OBJECT_PATH => string 652 DBUS_TYPE_OBJECT_PATH => string