Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtDBus module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qdbusxmlparser_p.h" | - |
43 | #include "qdbusutil_p.h" | - |
44 | | - |
45 | #include <QtCore/qmap.h> | - |
46 | #include <QtCore/qvariant.h> | - |
47 | #include <QtCore/qtextstream.h> | - |
48 | #include <QtCore/qxmlstream.h> | - |
49 | #include <QtCore/qdebug.h> | - |
50 | | - |
51 | #ifndef QT_NO_DBUS | - |
52 | | - |
53 | //#define QDBUS_PARSER_DEBUG | - |
54 | #ifdef QDBUS_PARSER_DEBUG | - |
55 | # define qDBusParserError qDebug | - |
56 | #else | - |
57 | # define qDBusParserError if (true) {} else qDebug | - |
58 | #endif | - |
59 | | - |
60 | QT_BEGIN_NAMESPACE | - |
61 | | - |
62 | static bool parseArg(const QXmlStreamAttributes &attributes, QDBusIntrospection::Argument &argData, | - |
63 | QDBusIntrospection::Interface *ifaceData) | - |
64 | { | - |
65 | const QString argType = attributes.value(QLatin1String("type")).toString(); executed (the execution status of this line is deduced): const QString argType = attributes.value(QLatin1String("type")).toString(); | - |
66 | | - |
67 | bool ok = QDBusUtil::isValidSingleSignature(argType); executed (the execution status of this line is deduced): bool ok = QDBusUtil::isValidSingleSignature(argType); | - |
68 | if (!ok) { evaluated: !ok yes Evaluation Count:4 | yes Evaluation Count:1869 |
| 4-1869 |
69 | qDBusParserError("Invalid D-BUS type signature '%s' found while parsing introspection", executed: } Execution Count:4 never executed: QMessageLogger("qdbusxmlparser.cpp", 69, __PRETTY_FUNCTION__).debug("Invalid D-BUS type signature '%s' found while parsing introspection", QString(argType).toLocal8Bit().constData()); partially evaluated: true yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
70 | qPrintable(argType)); never executed: QMessageLogger("qdbusxmlparser.cpp", 69, __PRETTY_FUNCTION__).debug("Invalid D-BUS type signature '%s' found while parsing introspection", QString(argType).toLocal8Bit().constData()); | 0 |
71 | } | - |
72 | | - |
73 | argData.name = attributes.value(QLatin1String("name")).toString(); executed (the execution status of this line is deduced): argData.name = attributes.value(QLatin1String("name")).toString(); | - |
74 | argData.type = argType; executed (the execution status of this line is deduced): argData.type = argType; | - |
75 | | - |
76 | ifaceData->introspection += QLatin1String(" <arg"); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String(" <arg"); | - |
77 | if (attributes.hasAttribute(QLatin1String("direction"))) { evaluated: attributes.hasAttribute(QLatin1String("direction")) yes Evaluation Count:1846 | yes Evaluation Count:27 |
| 27-1846 |
78 | const QString direction = attributes.value(QLatin1String("direction")).toString(); executed (the execution status of this line is deduced): const QString direction = attributes.value(QLatin1String("direction")).toString(); | - |
79 | ifaceData->introspection += QLatin1String(" direction=\"") + direction + QLatin1String("\""); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String(" direction=\"") + direction + QLatin1String("\""); | - |
80 | } executed: } Execution Count:1846 | 1846 |
81 | ifaceData->introspection += QLatin1String(" type=\"") + argData.type + QLatin1String("\""); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String(" type=\"") + argData.type + QLatin1String("\""); | - |
82 | if (!argData.name.isEmpty()) evaluated: !argData.name.isEmpty() yes Evaluation Count:1268 | yes Evaluation Count:605 |
| 605-1268 |
83 | ifaceData->introspection += QLatin1String(" name=\"") + argData.name + QLatin1String("\""); executed: ifaceData->introspection += QLatin1String(" name=\"") + argData.name + QLatin1String("\""); Execution Count:1268 | 1268 |
84 | ifaceData->introspection += QLatin1String("/>\n"); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String("/>\n"); | - |
85 | | - |
86 | return ok; executed: return ok; Execution Count:1873 | 1873 |
87 | } | - |
88 | | - |
89 | static bool parseAnnotation(const QXmlStreamReader &xml, QDBusIntrospection::Annotations &annotations, | - |
90 | QDBusIntrospection::Interface *ifaceData, bool interfaceAnnotation = false) | - |
91 | { | - |
92 | Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("annotation")); executed (the execution status of this line is deduced): qt_noop(); | - |
93 | | - |
94 | const QXmlStreamAttributes attributes = xml.attributes(); executed (the execution status of this line is deduced): const QXmlStreamAttributes attributes = xml.attributes(); | - |
95 | const QString name = attributes.value(QLatin1String("name")).toString(); executed (the execution status of this line is deduced): const QString name = attributes.value(QLatin1String("name")).toString(); | - |
96 | | - |
97 | if (!QDBusUtil::isValidInterfaceName(name)) { partially evaluated: !QDBusUtil::isValidInterfaceName(name) no Evaluation Count:0 | yes Evaluation Count:261 |
| 0-261 |
98 | qDBusParserError("Invalid D-BUS annotation '%s' found while parsing introspection", never executed: } never executed: QMessageLogger("qdbusxmlparser.cpp", 98, __PRETTY_FUNCTION__).debug("Invalid D-BUS annotation '%s' found while parsing introspection", QString(name).toLocal8Bit().constData()); never evaluated: true | 0 |
99 | qPrintable(name)); never executed: QMessageLogger("qdbusxmlparser.cpp", 98, __PRETTY_FUNCTION__).debug("Invalid D-BUS annotation '%s' found while parsing introspection", QString(name).toLocal8Bit().constData()); | 0 |
100 | return false; never executed: return false; | 0 |
101 | } | - |
102 | const QString value = attributes.value(QLatin1String("value")).toString(); executed (the execution status of this line is deduced): const QString value = attributes.value(QLatin1String("value")).toString(); | - |
103 | annotations.insert(name, value); executed (the execution status of this line is deduced): annotations.insert(name, value); | - |
104 | if (!interfaceAnnotation) evaluated: !interfaceAnnotation yes Evaluation Count:255 | yes Evaluation Count:6 |
| 6-255 |
105 | ifaceData->introspection += QLatin1String(" "); executed: ifaceData->introspection += QLatin1String(" "); Execution Count:255 | 255 |
106 | ifaceData->introspection += QLatin1String(" <annotation value=\"") + value + QLatin1String("\" name=\"") + name + QLatin1String("\"/>\n"); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String(" <annotation value=\"") + value + QLatin1String("\" name=\"") + name + QLatin1String("\"/>\n"); | - |
107 | return true; executed: return true; Execution Count:261 | 261 |
108 | } | - |
109 | | - |
110 | static bool parseProperty(QXmlStreamReader &xml, QDBusIntrospection::Property &propertyData, | - |
111 | QDBusIntrospection::Interface *ifaceData) | - |
112 | { | - |
113 | Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("property")); executed (the execution status of this line is deduced): qt_noop(); | - |
114 | | - |
115 | QXmlStreamAttributes attributes = xml.attributes(); executed (the execution status of this line is deduced): QXmlStreamAttributes attributes = xml.attributes(); | - |
116 | const QString propertyName = attributes.value(QLatin1String("name")).toString(); executed (the execution status of this line is deduced): const QString propertyName = attributes.value(QLatin1String("name")).toString(); | - |
117 | if (!QDBusUtil::isValidMemberName(propertyName)) { partially evaluated: !QDBusUtil::isValidMemberName(propertyName) no Evaluation Count:0 | yes Evaluation Count:206 |
| 0-206 |
118 | qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", never executed: } never executed: QMessageLogger("qdbusxmlparser.cpp", 118, __PRETTY_FUNCTION__).debug("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", QString(propertyName).toLocal8Bit().constData(), QString(ifaceData->name).toLocal8Bit().constData()); never evaluated: true | 0 |
119 | qPrintable(propertyName), qPrintable(ifaceData->name)); never executed: QMessageLogger("qdbusxmlparser.cpp", 118, __PRETTY_FUNCTION__).debug("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", QString(propertyName).toLocal8Bit().constData(), QString(ifaceData->name).toLocal8Bit().constData()); | 0 |
120 | xml.skipCurrentElement(); never executed (the execution status of this line is deduced): xml.skipCurrentElement(); | - |
121 | return false; never executed: return false; | 0 |
122 | } | - |
123 | | - |
124 | // parse data | - |
125 | propertyData.name = propertyName; executed (the execution status of this line is deduced): propertyData.name = propertyName; | - |
126 | propertyData.type = attributes.value(QLatin1String("type")).toString(); executed (the execution status of this line is deduced): propertyData.type = attributes.value(QLatin1String("type")).toString(); | - |
127 | | - |
128 | if (!QDBusUtil::isValidSingleSignature(propertyData.type)) { evaluated: !QDBusUtil::isValidSingleSignature(propertyData.type) yes Evaluation Count:1 | yes Evaluation Count:205 |
| 1-205 |
129 | // cannot be! | - |
130 | qDBusParserError("Invalid D-BUS type signature '%s' found in property '%s.%s' while parsing introspection", executed: } Execution Count:1 never executed: QMessageLogger("qdbusxmlparser.cpp", 130, __PRETTY_FUNCTION__).debug("Invalid D-BUS type signature '%s' found in property '%s.%s' while parsing introspection", QString(propertyData.type).toLocal8Bit().constData(), QString(ifaceData->name).toLocal8Bit().constData(), QString(propertyName).toLocal8Bit().constData()); partially evaluated: true yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
131 | qPrintable(propertyData.type), qPrintable(ifaceData->name), never executed: QMessageLogger("qdbusxmlparser.cpp", 130, __PRETTY_FUNCTION__).debug("Invalid D-BUS type signature '%s' found in property '%s.%s' while parsing introspection", QString(propertyData.type).toLocal8Bit().constData(), QString(ifaceData->name).toLocal8Bit().constData(), QString(propertyName).toLocal8Bit().constData()); | 0 |
132 | qPrintable(propertyName)); never executed: QMessageLogger("qdbusxmlparser.cpp", 130, __PRETTY_FUNCTION__).debug("Invalid D-BUS type signature '%s' found in property '%s.%s' while parsing introspection", QString(propertyData.type).toLocal8Bit().constData(), QString(ifaceData->name).toLocal8Bit().constData(), QString(propertyName).toLocal8Bit().constData()); | 0 |
133 | } | - |
134 | | - |
135 | const QString access = attributes.value(QLatin1String("access")).toString(); executed (the execution status of this line is deduced): const QString access = attributes.value(QLatin1String("access")).toString(); | - |
136 | if (access == QLatin1String("read")) evaluated: access == QLatin1String("read") yes Evaluation Count:104 | yes Evaluation Count:102 |
| 102-104 |
137 | propertyData.access = QDBusIntrospection::Property::Read; executed: propertyData.access = QDBusIntrospection::Property::Read; Execution Count:104 | 104 |
138 | else if (access == QLatin1String("write")) evaluated: access == QLatin1String("write") yes Evaluation Count:5 | yes Evaluation Count:97 |
| 5-97 |
139 | propertyData.access = QDBusIntrospection::Property::Write; executed: propertyData.access = QDBusIntrospection::Property::Write; Execution Count:5 | 5 |
140 | else if (access == QLatin1String("readwrite")) partially evaluated: access == QLatin1String("readwrite") yes Evaluation Count:97 | no Evaluation Count:0 |
| 0-97 |
141 | propertyData.access = QDBusIntrospection::Property::ReadWrite; executed: propertyData.access = QDBusIntrospection::Property::ReadWrite; Execution Count:97 | 97 |
142 | else { | - |
143 | qDBusParserError("Invalid D-BUS property access '%s' found in property '%s.%s' while parsing introspection", never executed: } never executed: QMessageLogger("qdbusxmlparser.cpp", 143, __PRETTY_FUNCTION__).debug("Invalid D-BUS property access '%s' found in property '%s.%s' while parsing introspection", QString(access).toLocal8Bit().constData(), QString(ifaceData->name).toLocal8Bit().constData(), QString(propertyName).toLocal8Bit().constData()); never evaluated: true | 0 |
144 | qPrintable(access), qPrintable(ifaceData->name), never executed: QMessageLogger("qdbusxmlparser.cpp", 143, __PRETTY_FUNCTION__).debug("Invalid D-BUS property access '%s' found in property '%s.%s' while parsing introspection", QString(access).toLocal8Bit().constData(), QString(ifaceData->name).toLocal8Bit().constData(), QString(propertyName).toLocal8Bit().constData()); | 0 |
145 | qPrintable(propertyName)); never executed: QMessageLogger("qdbusxmlparser.cpp", 143, __PRETTY_FUNCTION__).debug("Invalid D-BUS property access '%s' found in property '%s.%s' while parsing introspection", QString(access).toLocal8Bit().constData(), QString(ifaceData->name).toLocal8Bit().constData(), QString(propertyName).toLocal8Bit().constData()); | 0 |
146 | return false; // invalid one! never executed: return false; | 0 |
147 | } | - |
148 | | - |
149 | ifaceData->introspection += QLatin1String(" <property access=\"") + access + QLatin1String("\" type=\"") + propertyData.type + QLatin1String("\" name=\"") + propertyName + QLatin1String("\""); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String(" <property access=\"") + access + QLatin1String("\" type=\"") + propertyData.type + QLatin1String("\" name=\"") + propertyName + QLatin1String("\""); | - |
150 | | - |
151 | if (!xml.readNextStartElement()) { evaluated: !xml.readNextStartElement() yes Evaluation Count:200 | yes Evaluation Count:6 |
| 6-200 |
152 | ifaceData->introspection += QLatin1String("/>\n"); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String("/>\n"); | - |
153 | } else { executed: } Execution Count:200 | 200 |
154 | ifaceData->introspection += QLatin1String(">\n"); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String(">\n"); | - |
155 | | - |
156 | do { | - |
157 | if (xml.name() == QLatin1String("annotation")) { partially evaluated: xml.name() == QLatin1String("annotation") yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
158 | parseAnnotation(xml, propertyData.annotations, ifaceData); executed (the execution status of this line is deduced): parseAnnotation(xml, propertyData.annotations, ifaceData); | - |
159 | } else if (xml.prefix().isEmpty()) { executed: } Execution Count:8 never evaluated: xml.prefix().isEmpty() | 0-8 |
160 | qDBusParserError() << "Unknown element" << xml.name() << "while checking for annotations"; never executed: } never executed: QMessageLogger("qdbusxmlparser.cpp", 160, __PRETTY_FUNCTION__).debug() << "Unknown element" << xml.name() << "while checking for annotations"; never evaluated: true | 0 |
161 | } | - |
162 | xml.skipCurrentElement(); executed (the execution status of this line is deduced): xml.skipCurrentElement(); | - |
163 | } while (xml.readNextStartElement()); executed: } Execution Count:8 evaluated: xml.readNextStartElement() yes Evaluation Count:2 | yes Evaluation Count:6 |
| 2-8 |
164 | | - |
165 | ifaceData->introspection += QLatin1String(" </property>\n"); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String(" </property>\n"); | - |
166 | } executed: } Execution Count:6 | 6 |
167 | | - |
168 | if (!xml.isEndElement() || xml.name() != QLatin1String("property")) { partially evaluated: !xml.isEndElement() no Evaluation Count:0 | yes Evaluation Count:206 |
partially evaluated: xml.name() != QLatin1String("property") no Evaluation Count:0 | yes Evaluation Count:206 |
| 0-206 |
169 | qDBusParserError() << "Invalid property specification" << xml.tokenString() << xml.name(); never executed: } never executed: QMessageLogger("qdbusxmlparser.cpp", 169, __PRETTY_FUNCTION__).debug() << "Invalid property specification" << xml.tokenString() << xml.name(); never evaluated: true | 0 |
170 | return false; never executed: return false; | 0 |
171 | } | - |
172 | | - |
173 | return true; executed: return true; Execution Count:206 | 206 |
174 | } | - |
175 | | - |
176 | static bool parseMethod(QXmlStreamReader &xml, QDBusIntrospection::Method &methodData, | - |
177 | QDBusIntrospection::Interface *ifaceData) | - |
178 | { | - |
179 | Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("method")); executed (the execution status of this line is deduced): qt_noop(); | - |
180 | | - |
181 | const QXmlStreamAttributes attributes = xml.attributes(); executed (the execution status of this line is deduced): const QXmlStreamAttributes attributes = xml.attributes(); | - |
182 | const QString methodName = attributes.value(QLatin1String("name")).toString(); executed (the execution status of this line is deduced): const QString methodName = attributes.value(QLatin1String("name")).toString(); | - |
183 | if (!QDBusUtil::isValidMemberName(methodName)) { partially evaluated: !QDBusUtil::isValidMemberName(methodName) no Evaluation Count:0 | yes Evaluation Count:1480 |
| 0-1480 |
184 | qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", never executed: } never executed: QMessageLogger("qdbusxmlparser.cpp", 184, __PRETTY_FUNCTION__).debug("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", QString(methodName).toLocal8Bit().constData(), QString(ifaceData->name).toLocal8Bit().constData()); never evaluated: true | 0 |
185 | qPrintable(methodName), qPrintable(ifaceData->name)); never executed: QMessageLogger("qdbusxmlparser.cpp", 184, __PRETTY_FUNCTION__).debug("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", QString(methodName).toLocal8Bit().constData(), QString(ifaceData->name).toLocal8Bit().constData()); | 0 |
186 | return false; never executed: return false; | 0 |
187 | } | - |
188 | | - |
189 | methodData.name = methodName; executed (the execution status of this line is deduced): methodData.name = methodName; | - |
190 | ifaceData->introspection += QLatin1String(" <method name=\"") + methodName + QLatin1String("\""); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String(" <method name=\"") + methodName + QLatin1String("\""); | - |
191 | | - |
192 | QDBusIntrospection::Arguments outArguments; executed (the execution status of this line is deduced): QDBusIntrospection::Arguments outArguments; | - |
193 | QDBusIntrospection::Arguments inArguments; executed (the execution status of this line is deduced): QDBusIntrospection::Arguments inArguments; | - |
194 | QDBusIntrospection::Annotations annotations; executed (the execution status of this line is deduced): QDBusIntrospection::Annotations annotations; | - |
195 | | - |
196 | if (!xml.readNextStartElement()) { evaluated: !xml.readNextStartElement() yes Evaluation Count:197 | yes Evaluation Count:1283 |
| 197-1283 |
197 | ifaceData->introspection += QLatin1String("/>\n"); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String("/>\n"); | - |
198 | } else { executed: } Execution Count:197 | 197 |
199 | ifaceData->introspection += QLatin1String(">\n"); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String(">\n"); | - |
200 | | - |
201 | do { | - |
202 | if (xml.name() == QLatin1String("annotation")) { evaluated: xml.name() == QLatin1String("annotation") yes Evaluation Count:238 | yes Evaluation Count:1770 |
| 238-1770 |
203 | parseAnnotation(xml, annotations, ifaceData); executed (the execution status of this line is deduced): parseAnnotation(xml, annotations, ifaceData); | - |
204 | } else if (xml.name() == QLatin1String("arg")) { executed: } Execution Count:238 partially evaluated: xml.name() == QLatin1String("arg") yes Evaluation Count:1770 | no Evaluation Count:0 |
| 0-1770 |
205 | const QXmlStreamAttributes attributes = xml.attributes(); executed (the execution status of this line is deduced): const QXmlStreamAttributes attributes = xml.attributes(); | - |
206 | const QString direction = attributes.value(QLatin1String("direction")).toString(); executed (the execution status of this line is deduced): const QString direction = attributes.value(QLatin1String("direction")).toString(); | - |
207 | QDBusIntrospection::Argument argument; executed (the execution status of this line is deduced): QDBusIntrospection::Argument argument; | - |
208 | if (!attributes.hasAttribute(QLatin1String("direction")) partially evaluated: !attributes.hasAttribute(QLatin1String("direction")) no Evaluation Count:0 | yes Evaluation Count:1770 |
| 0-1770 |
209 | || direction == QLatin1String("in")) { evaluated: direction == QLatin1String("in") yes Evaluation Count:972 | yes Evaluation Count:798 |
| 798-972 |
210 | parseArg(attributes, argument, ifaceData); executed (the execution status of this line is deduced): parseArg(attributes, argument, ifaceData); | - |
211 | inArguments << argument; executed (the execution status of this line is deduced): inArguments << argument; | - |
212 | } else if (direction == QLatin1String("out")) { executed: } Execution Count:972 partially evaluated: direction == QLatin1String("out") yes Evaluation Count:798 | no Evaluation Count:0 |
| 0-972 |
213 | parseArg(attributes, argument, ifaceData); executed (the execution status of this line is deduced): parseArg(attributes, argument, ifaceData); | - |
214 | outArguments << argument; executed (the execution status of this line is deduced): outArguments << argument; | - |
215 | } executed: } Execution Count:798 | 798 |
216 | } else if (xml.prefix().isEmpty()) { never evaluated: xml.prefix().isEmpty() | 0 |
217 | qDBusParserError() << "Unknown element" << xml.name() << "while checking for method arguments"; never executed: } never executed: QMessageLogger("qdbusxmlparser.cpp", 217, __PRETTY_FUNCTION__).debug() << "Unknown element" << xml.name() << "while checking for method arguments"; never evaluated: true | 0 |
218 | } | - |
219 | xml.skipCurrentElement(); executed (the execution status of this line is deduced): xml.skipCurrentElement(); | - |
220 | } while (xml.readNextStartElement()); executed: } Execution Count:2008 evaluated: xml.readNextStartElement() yes Evaluation Count:725 | yes Evaluation Count:1283 |
| 725-2008 |
221 | | - |
222 | ifaceData->introspection += QLatin1String(" </method>\n"); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String(" </method>\n"); | - |
223 | } executed: } Execution Count:1283 | 1283 |
224 | | - |
225 | methodData.inputArgs = inArguments; executed (the execution status of this line is deduced): methodData.inputArgs = inArguments; | - |
226 | methodData.outputArgs = outArguments; executed (the execution status of this line is deduced): methodData.outputArgs = outArguments; | - |
227 | methodData.annotations = annotations; executed (the execution status of this line is deduced): methodData.annotations = annotations; | - |
228 | | - |
229 | return true; executed: return true; Execution Count:1480 | 1480 |
230 | } | - |
231 | | - |
232 | | - |
233 | static bool parseSignal(QXmlStreamReader &xml, QDBusIntrospection::Signal &signalData, | - |
234 | QDBusIntrospection::Interface *ifaceData) | - |
235 | { | - |
236 | Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("signal")); executed (the execution status of this line is deduced): qt_noop(); | - |
237 | | - |
238 | const QXmlStreamAttributes attributes = xml.attributes(); executed (the execution status of this line is deduced): const QXmlStreamAttributes attributes = xml.attributes(); | - |
239 | const QString signalName = attributes.value(QLatin1String("name")).toString(); executed (the execution status of this line is deduced): const QString signalName = attributes.value(QLatin1String("name")).toString(); | - |
240 | | - |
241 | if (!QDBusUtil::isValidMemberName(signalName)) { partially evaluated: !QDBusUtil::isValidMemberName(signalName) no Evaluation Count:0 | yes Evaluation Count:180 |
| 0-180 |
242 | qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", never executed: } never executed: QMessageLogger("qdbusxmlparser.cpp", 242, __PRETTY_FUNCTION__).debug("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", QString(signalName).toLocal8Bit().constData(), QString(ifaceData->name).toLocal8Bit().constData()); never evaluated: true | 0 |
243 | qPrintable(signalName), qPrintable(ifaceData->name)); never executed: QMessageLogger("qdbusxmlparser.cpp", 242, __PRETTY_FUNCTION__).debug("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", QString(signalName).toLocal8Bit().constData(), QString(ifaceData->name).toLocal8Bit().constData()); | 0 |
244 | return false; never executed: return false; | 0 |
245 | } | - |
246 | | - |
247 | signalData.name = signalName; executed (the execution status of this line is deduced): signalData.name = signalName; | - |
248 | ifaceData->introspection += QLatin1String(" <signal name=\"") + signalName + QLatin1String("\""); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String(" <signal name=\"") + signalName + QLatin1String("\""); | - |
249 | | - |
250 | QDBusIntrospection::Arguments arguments; executed (the execution status of this line is deduced): QDBusIntrospection::Arguments arguments; | - |
251 | QDBusIntrospection::Annotations annotations; executed (the execution status of this line is deduced): QDBusIntrospection::Annotations annotations; | - |
252 | | - |
253 | if (!xml.readNextStartElement()) { evaluated: !xml.readNextStartElement() yes Evaluation Count:79 | yes Evaluation Count:101 |
| 79-101 |
254 | ifaceData->introspection += QLatin1String("/>\n"); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String("/>\n"); | - |
255 | } else { executed: } Execution Count:79 | 79 |
256 | ifaceData->introspection += QLatin1String(">\n"); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String(">\n"); | - |
257 | | - |
258 | do { | - |
259 | if (xml.name() == QLatin1String("annotation")) { evaluated: xml.name() == QLatin1String("annotation") yes Evaluation Count:9 | yes Evaluation Count:103 |
| 9-103 |
260 | parseAnnotation(xml, annotations, ifaceData); executed (the execution status of this line is deduced): parseAnnotation(xml, annotations, ifaceData); | - |
261 | } else if (xml.name() == QLatin1String("arg")) { executed: } Execution Count:9 partially evaluated: xml.name() == QLatin1String("arg") yes Evaluation Count:103 | no Evaluation Count:0 |
| 0-103 |
262 | const QXmlStreamAttributes attributes = xml.attributes(); executed (the execution status of this line is deduced): const QXmlStreamAttributes attributes = xml.attributes(); | - |
263 | QDBusIntrospection::Argument argument; executed (the execution status of this line is deduced): QDBusIntrospection::Argument argument; | - |
264 | if (!attributes.hasAttribute(QLatin1String("direction")) || evaluated: !attributes.hasAttribute(QLatin1String("direction")) yes Evaluation Count:27 | yes Evaluation Count:76 |
| 27-76 |
265 | attributes.value(QLatin1String("direction")) == QLatin1String("out")) { partially evaluated: attributes.value(QLatin1String("direction")) == QLatin1String("out") yes Evaluation Count:76 | no Evaluation Count:0 |
| 0-76 |
266 | parseArg(attributes, argument, ifaceData); executed (the execution status of this line is deduced): parseArg(attributes, argument, ifaceData); | - |
267 | arguments << argument; executed (the execution status of this line is deduced): arguments << argument; | - |
268 | } executed: } Execution Count:103 | 103 |
269 | } else { executed: } Execution Count:103 | 103 |
270 | qDBusParserError() << "Unknown element" << xml.name() << "while checking for signal arguments"; never executed: } never executed: QMessageLogger("qdbusxmlparser.cpp", 270, __PRETTY_FUNCTION__).debug() << "Unknown element" << xml.name() << "while checking for signal arguments"; never evaluated: true | 0 |
271 | } | - |
272 | xml.skipCurrentElement(); executed (the execution status of this line is deduced): xml.skipCurrentElement(); | - |
273 | } while (xml.readNextStartElement()); executed: } Execution Count:112 evaluated: xml.readNextStartElement() yes Evaluation Count:11 | yes Evaluation Count:101 |
| 11-112 |
274 | | - |
275 | ifaceData->introspection += QLatin1String(" </signal>\n"); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String(" </signal>\n"); | - |
276 | } executed: } Execution Count:101 | 101 |
277 | | - |
278 | signalData.outputArgs = arguments; executed (the execution status of this line is deduced): signalData.outputArgs = arguments; | - |
279 | signalData.annotations = annotations; executed (the execution status of this line is deduced): signalData.annotations = annotations; | - |
280 | | - |
281 | return true; executed: return true; Execution Count:180 | 180 |
282 | } | - |
283 | | - |
284 | static void readInterface(QXmlStreamReader &xml, QDBusIntrospection::Object *objData, | - |
285 | QDBusIntrospection::Interfaces *interfaces) | - |
286 | { | - |
287 | const QString ifaceName = xml.attributes().value(QLatin1String("name")).toString(); executed (the execution status of this line is deduced): const QString ifaceName = xml.attributes().value(QLatin1String("name")).toString(); | - |
288 | if (!QDBusUtil::isValidInterfaceName(ifaceName)) { partially evaluated: !QDBusUtil::isValidInterfaceName(ifaceName) no Evaluation Count:0 | yes Evaluation Count:460 |
| 0-460 |
289 | qDBusParserError("Invalid D-BUS interface name '%s' found while parsing introspection", never executed: } never executed: QMessageLogger("qdbusxmlparser.cpp", 289, __PRETTY_FUNCTION__).debug("Invalid D-BUS interface name '%s' found while parsing introspection", QString(ifaceName).toLocal8Bit().constData()); never evaluated: true | 0 |
290 | qPrintable(ifaceName)); never executed: QMessageLogger("qdbusxmlparser.cpp", 289, __PRETTY_FUNCTION__).debug("Invalid D-BUS interface name '%s' found while parsing introspection", QString(ifaceName).toLocal8Bit().constData()); | 0 |
291 | return; | 0 |
292 | } | - |
293 | | - |
294 | objData->interfaces.append(ifaceName); executed (the execution status of this line is deduced): objData->interfaces.append(ifaceName); | - |
295 | | - |
296 | QDBusIntrospection::Interface *ifaceData = new QDBusIntrospection::Interface; executed (the execution status of this line is deduced): QDBusIntrospection::Interface *ifaceData = new QDBusIntrospection::Interface; | - |
297 | ifaceData->name = ifaceName; executed (the execution status of this line is deduced): ifaceData->name = ifaceName; | - |
298 | ifaceData->introspection += QLatin1String(" <interface name=\"") + ifaceName + QLatin1String("\">\n"); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String(" <interface name=\"") + ifaceName + QLatin1String("\">\n"); | - |
299 | | - |
300 | while (xml.readNextStartElement()) { evaluated: xml.readNextStartElement() yes Evaluation Count:1878 | yes Evaluation Count:460 |
| 460-1878 |
301 | if (xml.name() == QLatin1String("method")) { evaluated: xml.name() == QLatin1String("method") yes Evaluation Count:1480 | yes Evaluation Count:398 |
| 398-1480 |
302 | QDBusIntrospection::Method methodData; executed (the execution status of this line is deduced): QDBusIntrospection::Method methodData; | - |
303 | if (parseMethod(xml, methodData, ifaceData)) partially evaluated: parseMethod(xml, methodData, ifaceData) yes Evaluation Count:1480 | no Evaluation Count:0 |
| 0-1480 |
304 | ifaceData->methods.insert(methodData.name, methodData); executed: ifaceData->methods.insert(methodData.name, methodData); Execution Count:1480 | 1480 |
305 | } else if (xml.name() == QLatin1String("signal")) { executed: } Execution Count:1480 evaluated: xml.name() == QLatin1String("signal") yes Evaluation Count:180 | yes Evaluation Count:218 |
| 180-1480 |
306 | QDBusIntrospection::Signal signalData; executed (the execution status of this line is deduced): QDBusIntrospection::Signal signalData; | - |
307 | if (parseSignal(xml, signalData, ifaceData)) partially evaluated: parseSignal(xml, signalData, ifaceData) yes Evaluation Count:180 | no Evaluation Count:0 |
| 0-180 |
308 | ifaceData->signals_.insert(signalData.name, signalData); executed: ifaceData->signals_.insert(signalData.name, signalData); Execution Count:180 | 180 |
309 | } else if (xml.name() == QLatin1String("property")) { executed: } Execution Count:180 evaluated: xml.name() == QLatin1String("property") yes Evaluation Count:206 | yes Evaluation Count:12 |
| 12-206 |
310 | QDBusIntrospection::Property propertyData; executed (the execution status of this line is deduced): QDBusIntrospection::Property propertyData; | - |
311 | if (parseProperty(xml, propertyData, ifaceData)) partially evaluated: parseProperty(xml, propertyData, ifaceData) yes Evaluation Count:206 | no Evaluation Count:0 |
| 0-206 |
312 | ifaceData->properties.insert(propertyData.name, propertyData); executed: ifaceData->properties.insert(propertyData.name, propertyData); Execution Count:206 | 206 |
313 | } else if (xml.name() == QLatin1String("annotation")) { executed: } Execution Count:206 evaluated: xml.name() == QLatin1String("annotation") yes Evaluation Count:6 | yes Evaluation Count:6 |
| 6-206 |
314 | parseAnnotation(xml, ifaceData->annotations, ifaceData, true); executed (the execution status of this line is deduced): parseAnnotation(xml, ifaceData->annotations, ifaceData, true); | - |
315 | xml.skipCurrentElement(); // skip over annotation object executed (the execution status of this line is deduced): xml.skipCurrentElement(); | - |
316 | } else { executed: } Execution Count:6 | 6 |
317 | if (xml.prefix().isEmpty()) { partially evaluated: xml.prefix().isEmpty() no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
318 | qDBusParserError() << "Unknown element while parsing interface" << xml.name(); never executed: } never executed: QMessageLogger("qdbusxmlparser.cpp", 318, __PRETTY_FUNCTION__).debug() << "Unknown element while parsing interface" << xml.name(); never evaluated: true | 0 |
319 | } | - |
320 | xml.skipCurrentElement(); executed (the execution status of this line is deduced): xml.skipCurrentElement(); | - |
321 | } executed: } Execution Count:6 | 6 |
322 | } | - |
323 | | - |
324 | ifaceData->introspection += QLatin1String(" </interface>"); executed (the execution status of this line is deduced): ifaceData->introspection += QLatin1String(" </interface>"); | - |
325 | | - |
326 | interfaces->insert(ifaceName, QSharedDataPointer<QDBusIntrospection::Interface>(ifaceData)); executed (the execution status of this line is deduced): interfaces->insert(ifaceName, QSharedDataPointer<QDBusIntrospection::Interface>(ifaceData)); | - |
327 | | - |
328 | if (!xml.isEndElement() || xml.name() != QLatin1String("interface")) { evaluated: !xml.isEndElement() yes Evaluation Count:6 | yes Evaluation Count:454 |
partially evaluated: xml.name() != QLatin1String("interface") no Evaluation Count:0 | yes Evaluation Count:454 |
| 0-454 |
329 | qDBusParserError() << "Invalid Interface specification"; executed: } Execution Count:6 never executed: QMessageLogger("qdbusxmlparser.cpp", 329, __PRETTY_FUNCTION__).debug() << "Invalid Interface specification"; partially evaluated: true yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
330 | } | - |
331 | } executed: } Execution Count:460 | 460 |
332 | | - |
333 | static void readNode(const QXmlStreamReader &xml, QDBusIntrospection::Object *objData, int nodeLevel) | - |
334 | { | - |
335 | const QString objName = xml.attributes().value(QLatin1String("name")).toString(); executed (the execution status of this line is deduced): const QString objName = xml.attributes().value(QLatin1String("name")).toString(); | - |
336 | const QString fullName = objData->path.endsWith(QLatin1Char('/')) evaluated: objData->path.endsWith(QLatin1Char('/')) yes Evaluation Count:24 | yes Evaluation Count:215 |
| 24-215 |
337 | ? (objData->path + objName) executed (the execution status of this line is deduced): ? (objData->path + objName) | - |
338 | : QString(objData->path + QLatin1Char('/') + objName); executed (the execution status of this line is deduced): : QString(objData->path + QLatin1Char('/') + objName); | - |
339 | if (!QDBusUtil::isValidObjectPath(fullName)) { partially evaluated: !QDBusUtil::isValidObjectPath(fullName) no Evaluation Count:0 | yes Evaluation Count:239 |
| 0-239 |
340 | qDBusParserError("Invalid D-BUS object path '%s' found while parsing introspection", never executed: } never executed: QMessageLogger("qdbusxmlparser.cpp", 340, __PRETTY_FUNCTION__).debug("Invalid D-BUS object path '%s' found while parsing introspection", QString(fullName).toLocal8Bit().constData()); never evaluated: true | 0 |
341 | qPrintable(fullName)); never executed: QMessageLogger("qdbusxmlparser.cpp", 340, __PRETTY_FUNCTION__).debug("Invalid D-BUS object path '%s' found while parsing introspection", QString(fullName).toLocal8Bit().constData()); | 0 |
342 | return; | 0 |
343 | } | - |
344 | | - |
345 | if (nodeLevel > 0) evaluated: nodeLevel > 0 yes Evaluation Count:24 | yes Evaluation Count:215 |
| 24-215 |
346 | objData->childObjects.append(objName); executed: objData->childObjects.append(objName); Execution Count:24 | 24 |
347 | } executed: } Execution Count:239 | 239 |
348 | | - |
349 | QDBusXmlParser::QDBusXmlParser(const QString& service, const QString& path, | - |
350 | const QString& xmlData) | - |
351 | : m_service(service), m_path(path), m_object(new QDBusIntrospection::Object) | - |
352 | { | - |
353 | // qDBusParserError() << "parsing" << xmlData; | - |
354 | | - |
355 | m_object->service = m_service; executed (the execution status of this line is deduced): m_object->service = m_service; | - |
356 | m_object->path = m_path; executed (the execution status of this line is deduced): m_object->path = m_path; | - |
357 | | - |
358 | QXmlStreamReader xml(xmlData); executed (the execution status of this line is deduced): QXmlStreamReader xml(xmlData); | - |
359 | | - |
360 | int nodeLevel = -1; executed (the execution status of this line is deduced): int nodeLevel = -1; | - |
361 | | - |
362 | while (!xml.atEnd()) { evaluated: !xml.atEnd() yes Evaluation Count:1964 | yes Evaluation Count:245 |
| 245-1964 |
363 | xml.readNext(); executed (the execution status of this line is deduced): xml.readNext(); | - |
364 | | - |
365 | switch (xml.tokenType()) { | - |
366 | case QXmlStreamReader::StartElement: | - |
367 | if (xml.name() == QLatin1String("node")) { evaluated: xml.name() == QLatin1String("node") yes Evaluation Count:239 | yes Evaluation Count:478 |
| 239-478 |
368 | readNode(xml, m_object, ++nodeLevel); executed (the execution status of this line is deduced): readNode(xml, m_object, ++nodeLevel); | - |
369 | } else if (xml.name() == QLatin1String("interface")) { executed: } Execution Count:239 evaluated: xml.name() == QLatin1String("interface") yes Evaluation Count:460 | yes Evaluation Count:18 |
| 18-460 |
370 | readInterface(xml, m_object, &m_interfaces); executed (the execution status of this line is deduced): readInterface(xml, m_object, &m_interfaces); | - |
371 | } else { executed: } Execution Count:460 | 460 |
372 | if (xml.prefix().isEmpty()) { partially evaluated: xml.prefix().isEmpty() yes Evaluation Count:18 | no Evaluation Count:0 |
| 0-18 |
373 | qDBusParserError() << "skipping unknown element" << xml.name(); executed: } Execution Count:18 never executed: QMessageLogger("qdbusxmlparser.cpp", 373, __PRETTY_FUNCTION__).debug() << "skipping unknown element" << xml.name(); partially evaluated: true yes Evaluation Count:18 | no Evaluation Count:0 |
| 0-18 |
374 | } | - |
375 | xml.skipCurrentElement(); executed (the execution status of this line is deduced): xml.skipCurrentElement(); | - |
376 | } executed: } Execution Count:18 | 18 |
377 | break; executed: break; Execution Count:717 | 717 |
378 | case QXmlStreamReader::EndElement: | - |
379 | if (xml.name() == QLatin1String("node")) { partially evaluated: xml.name() == QLatin1String("node") yes Evaluation Count:233 | no Evaluation Count:0 |
| 0-233 |
380 | --nodeLevel; executed (the execution status of this line is deduced): --nodeLevel; | - |
381 | } else { executed: } Execution Count:233 | 233 |
382 | qDBusParserError() << "Invalid Node declaration" << xml.name(); never executed: } never executed: QMessageLogger("qdbusxmlparser.cpp", 382, __PRETTY_FUNCTION__).debug() << "Invalid Node declaration" << xml.name(); never evaluated: true | 0 |
383 | } | - |
384 | break; executed: break; Execution Count:233 | 233 |
385 | case QXmlStreamReader::StartDocument: | - |
386 | case QXmlStreamReader::EndDocument: | - |
387 | case QXmlStreamReader::DTD: | - |
388 | // not interested | - |
389 | break; executed: break; Execution Count:585 | 585 |
390 | case QXmlStreamReader::Comment: | - |
391 | // ignore comments and processing instructions | - |
392 | break; | 0 |
393 | default: | - |
394 | qDBusParserError() << "unknown token" << xml.name() << xml.tokenString(); executed: } Execution Count:429 never executed: QMessageLogger("qdbusxmlparser.cpp", 394, __PRETTY_FUNCTION__).debug() << "unknown token" << xml.name() << xml.tokenString(); partially evaluated: true yes Evaluation Count:429 | no Evaluation Count:0 |
| 0-429 |
395 | break; executed: break; Execution Count:429 | 429 |
396 | } | - |
397 | } executed: } Execution Count:1964 | 1964 |
398 | | - |
399 | if (xml.hasError()) { evaluated: xml.hasError() yes Evaluation Count:18 | yes Evaluation Count:227 |
| 18-227 |
400 | qDBusParserError() << "xml error" << xml.errorString() << "doc" << xmlData; executed: } Execution Count:18 never executed: QMessageLogger("qdbusxmlparser.cpp", 400, __PRETTY_FUNCTION__).debug() << "xml error" << xml.errorString() << "doc" << xmlData; partially evaluated: true yes Evaluation Count:18 | no Evaluation Count:0 |
| 0-18 |
401 | } | - |
402 | } executed: } Execution Count:245 | 245 |
403 | | - |
404 | QT_END_NAMESPACE | - |
405 | | - |
406 | #endif // QT_NO_DBUS | - |
407 | | - |
| | |