From 7e36c9df9186d6d3b4f55953d50c2e253fc1bd32 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 11 Mar 2009 16:19:40 +0100 Subject: [PATCH] dbus: add support for fixed size byte array Signed-off-by: Julien Danjou --- dbus.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/dbus.c b/dbus.c index 9a888f973..50882fa10 100644 --- a/dbus.c +++ b/dbus.c @@ -92,9 +92,6 @@ a_dbus_message_iter(DBusMessageIter *iter) { int array_type = dbus_message_iter_get_element_type(iter); - /* create a new table to store all the value */ - lua_newtable(globalconf.L); - if(dbus_type_is_fixed(array_type)) { DBusMessageIter sub; @@ -106,7 +103,8 @@ a_dbus_message_iter(DBusMessageIter *iter) #define DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER(type, dbustype) \ case dbustype: \ { \ - type *data; \ + const type *data; \ + lua_newtable(globalconf.L); \ dbus_message_iter_get_fixed_array(&sub, &data, &datalen); \ for(int i = 0; i < datalen; i++) \ { \ @@ -122,12 +120,21 @@ a_dbus_message_iter(DBusMessageIter *iter) DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER(int64_t, DBUS_TYPE_INT64) DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER(uint64_t, DBUS_TYPE_UINT64) #undef DBUS_MSG_HANDLE_ARRAY_TYPE_NUMBER + case DBUS_TYPE_BYTE: + { + const char *c; + dbus_message_iter_get_fixed_array(&sub, &c, &datalen); + lua_pushlstring(globalconf.L, c, datalen); + } + break; } } else if(array_type == DBUS_TYPE_DICT_ENTRY) { DBusMessageIter subiter; + lua_newtable(globalconf.L); + /* initialize a sub iterator */ dbus_message_iter_recurse(iter, &subiter); /* get the keys and the values @@ -141,6 +148,8 @@ a_dbus_message_iter(DBusMessageIter *iter) { DBusMessageIter subiter; + lua_newtable(globalconf.L); + /* prepare to dig into the array*/ dbus_message_iter_recurse(iter, &subiter);