Skip to content

Commit 804e8b2

Browse files
committed
encoder: add basic support for array of array and array of object
1 parent 49bc205 commit 804e8b2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/encoder.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,28 @@ namespace Encoder {
103103
return const_cast<char*>(DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING);
104104
}
105105
}
106+
if (lastArrayItem->IsArray()) {
107+
for (unsigned int i = 0; i < arrayDataLength; ++i) {
108+
Local<Value> arrayItem = arrayData->Get(i);
109+
if (!arrayItem->IsArray())
110+
break;
111+
if (i == (arrayDataLength - 1))
112+
return const_cast<char*>(DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_ARRAY_AS_STRING
113+
DBUS_TYPE_VARIANT_AS_STRING);
114+
}
115+
}
116+
if (lastArrayItem->IsObject()) {
117+
for (unsigned int i = 0; i < arrayDataLength; ++i) {
118+
Local<Value> arrayItem = arrayData->Get(i);
119+
if (!arrayItem->IsObject())
120+
break;
121+
if (i == (arrayDataLength - 1))
122+
return const_cast<char*>(DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_ARRAY_AS_STRING
123+
DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
124+
DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
125+
DBUS_DICT_ENTRY_END_CHAR_AS_STRING);
126+
}
127+
}
106128
return const_cast<char*>(DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_VARIANT_AS_STRING);
107129
} else if (value->IsObject()) {
108130
return const_cast<char*>(DBUS_TYPE_ARRAY_AS_STRING

0 commit comments

Comments
 (0)