qdbuscpp2xml: eradicate all Q_FOREACH loops
... replacing them with C++11 range-for loops. Change-Id: I0233bcf874cdadcd7461e11b89f752dabde086c0 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
This commit is contained in:
parent
3ef7f1615a
commit
18597b2ae2
@ -86,8 +86,9 @@ static const char help[] =
|
|||||||
int qDBusParametersForMethod(const FunctionDef &mm, QVector<int>& metaTypes, QString &errorMsg)
|
int qDBusParametersForMethod(const FunctionDef &mm, QVector<int>& metaTypes, QString &errorMsg)
|
||||||
{
|
{
|
||||||
QList<QByteArray> parameterTypes;
|
QList<QByteArray> parameterTypes;
|
||||||
|
parameterTypes.reserve(mm.arguments.size());
|
||||||
|
|
||||||
foreach (const ArgumentDef &arg, mm.arguments)
|
for (const ArgumentDef &arg : mm.arguments)
|
||||||
parameterTypes.append(arg.normalizedType);
|
parameterTypes.append(arg.normalizedType);
|
||||||
|
|
||||||
return qDBusParametersForMethod(parameterTypes, metaTypes, errorMsg);
|
return qDBusParametersForMethod(parameterTypes, metaTypes, errorMsg);
|
||||||
@ -200,7 +201,7 @@ static QString generateInterfaceXml(const ClassDef *mo)
|
|||||||
if (flags & (QDBusConnection::ExportScriptableProperties |
|
if (flags & (QDBusConnection::ExportScriptableProperties |
|
||||||
QDBusConnection::ExportNonScriptableProperties)) {
|
QDBusConnection::ExportNonScriptableProperties)) {
|
||||||
static const char *accessvalues[] = {0, "read", "write", "readwrite"};
|
static const char *accessvalues[] = {0, "read", "write", "readwrite"};
|
||||||
foreach (const PropertyDef &mp, mo->propertyList) {
|
for (const PropertyDef &mp : mo->propertyList) {
|
||||||
if (!((!mp.scriptable.isEmpty() && (flags & QDBusConnection::ExportScriptableProperties)) ||
|
if (!((!mp.scriptable.isEmpty() && (flags & QDBusConnection::ExportScriptableProperties)) ||
|
||||||
(!mp.scriptable.isEmpty() && (flags & QDBusConnection::ExportNonScriptableProperties))))
|
(!mp.scriptable.isEmpty() && (flags & QDBusConnection::ExportNonScriptableProperties))))
|
||||||
continue;
|
continue;
|
||||||
@ -235,7 +236,7 @@ static QString generateInterfaceXml(const ClassDef *mo)
|
|||||||
// now add methods:
|
// now add methods:
|
||||||
|
|
||||||
if (flags & (QDBusConnection::ExportScriptableSignals | QDBusConnection::ExportNonScriptableSignals)) {
|
if (flags & (QDBusConnection::ExportScriptableSignals | QDBusConnection::ExportNonScriptableSignals)) {
|
||||||
foreach (const FunctionDef &mm, mo->signalList) {
|
for (const FunctionDef &mm : mo->signalList) {
|
||||||
if (mm.wasCloned)
|
if (mm.wasCloned)
|
||||||
continue;
|
continue;
|
||||||
if (!mm.isScriptable && !(flags & QDBusConnection::ExportNonScriptableSignals))
|
if (!mm.isScriptable && !(flags & QDBusConnection::ExportNonScriptableSignals))
|
||||||
@ -246,13 +247,13 @@ static QString generateInterfaceXml(const ClassDef *mo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags & (QDBusConnection::ExportScriptableSlots | QDBusConnection::ExportNonScriptableSlots)) {
|
if (flags & (QDBusConnection::ExportScriptableSlots | QDBusConnection::ExportNonScriptableSlots)) {
|
||||||
foreach (const FunctionDef &slot, mo->slotList) {
|
for (const FunctionDef &slot : mo->slotList) {
|
||||||
if (!slot.isScriptable && !(flags & QDBusConnection::ExportNonScriptableSlots))
|
if (!slot.isScriptable && !(flags & QDBusConnection::ExportNonScriptableSlots))
|
||||||
continue;
|
continue;
|
||||||
if (slot.access == FunctionDef::Public)
|
if (slot.access == FunctionDef::Public)
|
||||||
retval += addFunction(slot);
|
retval += addFunction(slot);
|
||||||
}
|
}
|
||||||
foreach (const FunctionDef &method, mo->methodList) {
|
for (const FunctionDef &method : mo->methodList) {
|
||||||
if (!method.isScriptable && !(flags & QDBusConnection::ExportNonScriptableSlots))
|
if (!method.isScriptable && !(flags & QDBusConnection::ExportNonScriptableSlots))
|
||||||
continue;
|
continue;
|
||||||
if (method.access == FunctionDef::Public)
|
if (method.access == FunctionDef::Public)
|
||||||
@ -266,7 +267,7 @@ QString qDBusInterfaceFromClassDef(const ClassDef *mo)
|
|||||||
{
|
{
|
||||||
QString interface;
|
QString interface;
|
||||||
|
|
||||||
foreach (const ClassInfoDef &cid, mo->classInfoList) {
|
for (const ClassInfoDef &cid : mo->classInfoList) {
|
||||||
if (cid.name == QCLASSINFO_DBUS_INTERFACE)
|
if (cid.name == QCLASSINFO_DBUS_INTERFACE)
|
||||||
return QString::fromUtf8(cid.value);
|
return QString::fromUtf8(cid.value);
|
||||||
}
|
}
|
||||||
@ -289,7 +290,7 @@ QString qDBusInterfaceFromClassDef(const ClassDef *mo)
|
|||||||
|
|
||||||
QString qDBusGenerateClassDefXml(const ClassDef *cdef)
|
QString qDBusGenerateClassDefXml(const ClassDef *cdef)
|
||||||
{
|
{
|
||||||
foreach (const ClassInfoDef &cid, cdef->classInfoList) {
|
for (const ClassInfoDef &cid : cdef->classInfoList) {
|
||||||
if (cid.name == QCLASSINFO_DBUS_INTROSPECTION)
|
if (cid.name == QCLASSINFO_DBUS_INTROSPECTION)
|
||||||
return QString::fromUtf8(cid.value);
|
return QString::fromUtf8(cid.value);
|
||||||
}
|
}
|
||||||
@ -444,7 +445,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
output.write(docTypeHeader);
|
output.write(docTypeHeader);
|
||||||
output.write("<node>\n");
|
output.write("<node>\n");
|
||||||
foreach (const ClassDef &cdef, classes) {
|
for (const ClassDef &cdef : qAsConst(classes)) {
|
||||||
QString xml = qDBusGenerateClassDefXml(&cdef);
|
QString xml = qDBusGenerateClassDefXml(&cdef);
|
||||||
output.write(xml.toLocal8Bit());
|
output.write(xml.toLocal8Bit());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user