[gjs] Bug 586760: Support converting JavaScript doubles to DBus int64/uint64.
- From: C. Scott Ananian <cananian src gnome org>
- To: svn-commits-list gnome org
- Subject: [gjs] Bug 586760: Support converting JavaScript doubles to DBus int64/uint64.
- Date: Wed, 24 Jun 2009 16:53:20 +0000 (UTC)
commit af5265cfdf1277607b00c8485fe574a4006082c5
Author: C. Scott Ananian <cscott litl com>
Date: Tue Jun 23 10:55:22 2009 -0400
Bug 586760: Support converting JavaScript doubles to DBus int64/uint64.
The other direction is sketchy (may involve loss of precision) but all
valid JavaScript integers can fit in a DBus int64/uint64.
modules/dbus-values.c | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/modules/dbus-values.c b/modules/dbus-values.c
index 1a6561a..04fb6d4 100644
--- a/modules/dbus-values.c
+++ b/modules/dbus-values.c
@@ -447,6 +447,20 @@ append_int32(JSContext *context,
append_basic_maybe_in_variant(iter, forced_type, &v_BYTE, FALSE);
}
break;
+ // All JavaScript integers can be converted to DBus INT64/UINT64
+ // (just not the other way 'round)
+ case DBUS_TYPE_INT64:
+ {
+ dbus_int64_t v_INT64 = v_INT32;
+ append_basic_maybe_in_variant(iter, forced_type, &v_INT64, FALSE);
+ }
+ break;
+ case DBUS_TYPE_UINT64:
+ {
+ dbus_uint64_t v_UINT64 = v_INT32;
+ append_basic_maybe_in_variant(iter, forced_type, &v_UINT64, FALSE);
+ }
+ break;
default:
gjs_throw(context,
"JavaScript Integer can't be converted to dbus type '%c'",
@@ -485,6 +499,20 @@ append_double(JSContext *context,
append_basic_maybe_in_variant(iter, forced_type, &v_UINT32, FALSE);
}
break;
+ // All JavaScript integers can be converted to DBus INT64/UINT64
+ // (just not the other way 'round)
+ case DBUS_TYPE_INT64:
+ {
+ dbus_int64_t v_INT64 = v_DOUBLE;
+ append_basic_maybe_in_variant(iter, forced_type, &v_INT64, FALSE);
+ }
+ break;
+ case DBUS_TYPE_UINT64:
+ {
+ dbus_uint64_t v_UINT64 = v_DOUBLE;
+ append_basic_maybe_in_variant(iter, forced_type, &v_UINT64, FALSE);
+ }
+ break;
default:
gjs_throw(context,
"JavaScript Number can't be converted to dbus type '%c'",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]