summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2003-10-29 00:06:07 +0000
committerDavid Zeuthen <davidz@redhat.com>2003-10-29 00:06:07 +0000
commitddc560a9aa276416e7b5c51dc407c90926263b82 (patch)
treea956baf7ea2687389fd1b69011cd0d31af14ba3c /python
parentbebc830fc47cbf191f7518dfd0cd88c4938c2dbf (diff)
2003-10-28 David Zeuthen <david@fubar.dk>
* python/dbus_bindings.pyx.in: add get_dict to handle dictionaries return types. Fixup TYPE_* to reflect changes in dbus/dbus-protocol.h
Diffstat (limited to 'python')
-rw-r--r--python/dbus_bindings.pyx.in25
1 files changed, 24 insertions, 1 deletions
diff --git a/python/dbus_bindings.pyx.in b/python/dbus_bindings.pyx.in
index 7127ece4..dfcc1e79 100644
--- a/python/dbus_bindings.pyx.in
+++ b/python/dbus_bindings.pyx.in
@@ -428,10 +428,33 @@ cdef class MessageIter:
retval = self.get_boolean_array()
else:
raise TypeError, "Unknown array type %d in MessageIter" % (array_type)
+ elif arg_type == TYPE_DICT:
+ retval = self.get_dict()
else:
raise TypeError, 'Unknown arg type %d in MessageIter' % (arg_type)
return retval
+
+ def get_dict(self):
+ cdef DBusMessageIter dict_iter
+ cdef DBusMessageIter* old_iter
+
+ dict = {}
+ dbus_message_iter_init_dict_iterator(self.iter, &dict_iter)
+ # FIXME: nasty hack so we can use existing self.get() method
+ old_iter = self.iter
+ self.iter = &dict_iter
+
+ while True:
+ key = self.get_dict_key()
+ value = self.get()
+ dict[key] = value
+ if not self.has_next():
+ break
+ self.next()
+
+ self.iter = old_iter
+ return dict
def get_arg_type(self):
return dbus_message_iter_get_arg_type(self.iter)
@@ -569,7 +592,7 @@ cdef class MessageIter:
(MESSAGE_TYPE_INVALID, MESSAGE_TYPE_METHOD_CALL, MESSAGE_TYPE_METHOD_RETURN, MESSAGE_TYPE_ERROR, MESSAGE_TYPE_SIGNAL) = range(5)
-(TYPE_INVALID, TYPE_NIL, TYPE_BYTE, TYPE_BOOLEAN, TYPE_INT32, TYPE_UINT32, TYPE_INT64, TYPE_UINT64, TYPE_DOUBLE, TYPE_STRING, TYPE_NAMED, TYPE_ARRAY, TYPE_DICT, TYPE_OBJECT_PATH) = (0, 118, 121, 98, 105, 117, 120, 116, 100, 115, 110, 97, 99, 111)
+(TYPE_INVALID, TYPE_NIL, TYPE_BYTE, TYPE_BOOLEAN, TYPE_INT32, TYPE_UINT32, TYPE_INT64, TYPE_UINT64, TYPE_DOUBLE, TYPE_STRING, TYPE_CUSTOM, TYPE_ARRAY, TYPE_DICT, TYPE_OBJECT_PATH) = (0, ord('v'), ord('y'), ord('b'), ord('i'), ord('u'), ord('x'), ord('t'), ord('d'), ord('s'), ord('c'), ord('a'), ord('m'), ord('o'))
cdef class Message:
cdef DBusMessage *msg