Skip to content

Commit 8864249

Browse files
committed
Tools/qt-types-gen: Added QDBusArgument stream operators for lists.
Previously we used operators are now deprecated and will be removed in Qt-5.8.
1 parent 7dfa899 commit 8864249

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tools/qt-types-gen.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,40 @@ def provide_all(self):
302302
self.decl(self.faketype(val, real))
303303
self.to_declare.append(self.namespace + '::' + val)
304304

305+
self.both('%s QDBusArgument& operator<<(QDBusArgument& arg, const %s &list)' %
306+
(self.visibility, val))
307+
self.decl(';\n')
308+
self.impl("""
309+
{
310+
int id = qMetaTypeId<%s>();
311+
arg.beginArray(id);
312+
for (int i = 0; i < list.count(); ++i) {
313+
arg << list.at(i);
314+
}
315+
arg.endArray();
316+
return arg;
317+
}
318+
319+
""" % (array_of))
320+
321+
self.both('%s const QDBusArgument& operator>>(const QDBusArgument& arg, %s &list)' %
322+
(self.visibility, val))
323+
self.decl(';\n\n')
324+
self.impl("""
325+
{
326+
arg.beginArray();
327+
list.clear();
328+
while (!arg.atEnd()) {
329+
%s item;
330+
arg >> item;
331+
list.append(item);
332+
}
333+
arg.endArray();
334+
return arg;
335+
}
336+
337+
""" % (array_of))
338+
305339
structs = self.spec.getElementsByTagNameNS(NS_TP, 'struct')
306340
mappings = self.spec.getElementsByTagNameNS(NS_TP, 'mapping')
307341
exts = self.spec.getElementsByTagNameNS(NS_TP, 'external-type')

0 commit comments

Comments
 (0)