Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | extern __attribute__((visibility("default"))) QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo, | - |
9 | const QMetaObject *base, int flags); | - |
10 | | - |
11 | static inline QString typeNameToXml(const char *typeName) | - |
12 | { | - |
13 | | - |
14 | | - |
15 | QString plain = QLatin1String(typeName); | - |
16 | QString rich; | - |
17 | rich.reserve(int(plain.length() * 1.1)); | - |
18 | for (int i = 0; i < plain.length(); ++i) { evaluated: i < plain.length() yes Evaluation Count:2738 | yes Evaluation Count:555 |
| 555-2738 |
19 | if (plain.at(i) == QLatin1Char('<')) partially evaluated: plain.at(i) == QLatin1Char('<') no Evaluation Count:0 | yes Evaluation Count:2738 |
| 0-2738 |
20 | rich += QLatin1String("<"); never executed: rich += QLatin1String("<"); | 0 |
21 | else if (plain.at(i) == QLatin1Char('>')) partially evaluated: plain.at(i) == QLatin1Char('>') no Evaluation Count:0 | yes Evaluation Count:2738 |
| 0-2738 |
22 | rich += QLatin1String(">"); never executed: rich += QLatin1String(">"); | 0 |
23 | else if (plain.at(i) == QLatin1Char('&')) partially evaluated: plain.at(i) == QLatin1Char('&') no Evaluation Count:0 | yes Evaluation Count:2738 |
| 0-2738 |
24 | rich += QLatin1String("&"); never executed: rich += QLatin1String("&"); | 0 |
25 | else | - |
26 | rich += plain.at(i); executed: rich += plain.at(i); Execution Count:2738 | 2738 |
27 | } | - |
28 | return rich; executed: return rich; Execution Count:555 | 555 |
29 | } | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | static QString generateInterfaceXml(const QMetaObject *mo, int flags, int methodOffset, int propOffset) | - |
35 | { | - |
36 | QString retval; | - |
37 | | - |
38 | | - |
39 | if (flags & (QDBusConnection::ExportScriptableProperties | | 4-56 |
40 | QDBusConnection::ExportNonScriptableProperties)) { evaluated: flags & (QDBusConnection::ExportScriptableProperties | QDBusConnection::ExportNonScriptableProperties) yes Evaluation Count:56 | yes Evaluation Count:4 |
| 4-56 |
41 | for (int i = propOffset; i < mo->propertyCount(); ++i) { evaluated: i < mo->propertyCount() yes Evaluation Count:42 | yes Evaluation Count:56 |
| 42-56 |
42 | static const char *accessvalues[] = {0, "read", "write", "readwrite"}; | - |
43 | | - |
44 | QMetaProperty mp = mo->property(i); | - |
45 | | - |
46 | if (!((mp.isScriptable() && (flags & QDBusConnection::ExportScriptableProperties)) || partially evaluated: mp.isScriptable() yes Evaluation Count:42 | no Evaluation Count:0 |
partially evaluated: (flags & QDBusConnection::ExportScriptableProperties) yes Evaluation Count:42 | no Evaluation Count:0 |
| 0-42 |
47 | (!mp.isScriptable() && (flags & QDBusConnection::ExportNonScriptableProperties)))) never evaluated: !mp.isScriptable() never evaluated: (flags & QDBusConnection::ExportNonScriptableProperties) | 0 |
48 | continue; never executed: continue; | 0 |
49 | | - |
50 | int access = 0; | - |
51 | if (mp.isReadable()) partially evaluated: mp.isReadable() yes Evaluation Count:42 | no Evaluation Count:0 |
| 0-42 |
52 | access |= 1; executed: access |= 1; Execution Count:42 | 42 |
53 | if (mp.isWritable()) evaluated: mp.isWritable() yes Evaluation Count:16 | yes Evaluation Count:26 |
| 16-26 |
54 | access |= 2; executed: access |= 2; Execution Count:16 | 16 |
55 | | - |
56 | int typeId = mp.userType(); | - |
57 | if (!typeId) partially evaluated: !typeId no Evaluation Count:0 | yes Evaluation Count:42 |
| 0-42 |
58 | continue; never executed: continue; | 0 |
59 | const char *signature = QDBusMetaType::typeToSignature(typeId); | - |
60 | if (!signature) evaluated: !signature yes Evaluation Count:6 | yes Evaluation Count:36 |
| 6-36 |
61 | continue; executed: continue; Execution Count:6 | 6 |
62 | | - |
63 | retval += QString::fromLatin1(" <property name=\"%1\" type=\"%2\" access=\"%3\"") | - |
64 | .arg(QLatin1String(mp.name())) | - |
65 | .arg(QLatin1String(signature)) | - |
66 | .arg(QLatin1String(accessvalues[access])); | - |
67 | | - |
68 | if (QDBusMetaType::signatureToType(signature) == QVariant::Invalid) { evaluated: QDBusMetaType::signatureToType(signature) == QVariant::Invalid yes Evaluation Count:1 | yes Evaluation Count:35 |
| 1-35 |
69 | const char *typeName = QMetaType::typeName(typeId); | - |
70 | retval += QString::fromLatin1(">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n") | - |
71 | .arg(typeNameToXml(typeName)); | - |
72 | } else { executed: } Execution Count:1 | 1 |
73 | retval += QLatin1String("/>\n"); | - |
74 | } executed: } Execution Count:35 | 35 |
75 | } | - |
76 | } executed: } Execution Count:56 | 56 |
77 | | - |
78 | | - |
79 | for (int i = methodOffset; i < mo->methodCount(); ++i) { evaluated: i < mo->methodCount() yes Evaluation Count:849 | yes Evaluation Count:60 |
| 60-849 |
80 | QMetaMethod mm = mo->method(i); | - |
81 | | - |
82 | bool isSignal; | - |
83 | if (mm.methodType() == QMetaMethod::Signal) evaluated: mm.methodType() == QMetaMethod::Signal yes Evaluation Count:34 | yes Evaluation Count:815 |
| 34-815 |
84 | | - |
85 | isSignal = true; executed: isSignal = true; Execution Count:34 | 34 |
86 | else if (mm.access() == QMetaMethod::Public && (mm.methodType() == QMetaMethod::Slot || mm.methodType() == QMetaMethod::Method)) partially evaluated: mm.access() == QMetaMethod::Public yes Evaluation Count:815 | no Evaluation Count:0 |
partially evaluated: mm.methodType() == QMetaMethod::Slot yes Evaluation Count:815 | no Evaluation Count:0 |
never evaluated: mm.methodType() == QMetaMethod::Method | 0-815 |
87 | isSignal = false; executed: isSignal = false; Execution Count:815 | 815 |
88 | else | - |
89 | continue; never executed: continue; | 0 |
90 | | - |
91 | if (isSignal && !(flags & (QDBusConnection::ExportScriptableSignals | evaluated: isSignal yes Evaluation Count:34 | yes Evaluation Count:815 |
| 0-815 |
92 | QDBusConnection::ExportNonScriptableSignals))) partially evaluated: !(flags & (QDBusConnection::ExportScriptableSignals | QDBusConnection::ExportNonScriptableSignals)) no Evaluation Count:0 | yes Evaluation Count:34 |
| 0-34 |
93 | continue; never executed: continue; | 0 |
94 | if (!isSignal && (!(flags & (QDBusConnection::ExportScriptableSlots | QDBusConnection::ExportNonScriptableSlots)) && evaluated: !isSignal yes Evaluation Count:815 | yes Evaluation Count:34 |
partially evaluated: !(flags & (QDBusConnection::ExportScriptableSlots | QDBusConnection::ExportNonScriptableSlots)) no Evaluation Count:0 | yes Evaluation Count:815 |
| 0-815 |
95 | !(flags & (QDBusConnection::ExportScriptableInvokables | QDBusConnection::ExportNonScriptableInvokables)))) never evaluated: !(flags & (QDBusConnection::ExportScriptableInvokables | QDBusConnection::ExportNonScriptableInvokables)) | 0 |
96 | continue; never executed: continue; | 0 |
97 | | - |
98 | QString xml = QString::fromLatin1(" <%1 name=\"%2\">\n") | - |
99 | .arg(isSignal ? QLatin1String("signal") : QLatin1String("method")) | - |
100 | .arg(QString::fromLatin1(mm.name())); | - |
101 | | - |
102 | | - |
103 | int typeId = mm.returnType(); | - |
104 | if (typeId != QMetaType::UnknownType && typeId != QMetaType::Void) { evaluated: typeId != QMetaType::UnknownType yes Evaluation Count:845 | yes Evaluation Count:4 |
evaluated: typeId != QMetaType::Void yes Evaluation Count:406 | yes Evaluation Count:439 |
| 4-845 |
105 | const char *typeName = QDBusMetaType::typeToSignature(typeId); | - |
106 | if (typeName) { partially evaluated: typeName yes Evaluation Count:406 | no Evaluation Count:0 |
| 0-406 |
107 | xml += QString::fromLatin1(" <arg type=\"%1\" direction=\"out\"/>\n") | - |
108 | .arg(typeNameToXml(typeName)); | - |
109 | | - |
110 | | - |
111 | if (QDBusMetaType::signatureToType(typeName) == QVariant::Invalid) evaluated: QDBusMetaType::signatureToType(typeName) == QVariant::Invalid yes Evaluation Count:75 | yes Evaluation Count:331 |
| 75-331 |
112 | xml += QString::fromLatin1(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n") | 75 |
113 | .arg(typeNameToXml(QMetaType::typeName(typeId))); executed: xml += QString::fromLatin1(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n") .arg(typeNameToXml(QMetaType::typeName(typeId))); Execution Count:75 | 75 |
114 | } else executed: } Execution Count:406 | 406 |
115 | continue; never executed: continue; | 0 |
116 | } | - |
117 | else if (typeId == QMetaType::UnknownType) evaluated: typeId == QMetaType::UnknownType yes Evaluation Count:4 | yes Evaluation Count:439 |
| 4-439 |
118 | continue; executed: continue; Execution Count:4 | 4 |
119 | | - |
120 | QList<QByteArray> names = mm.parameterNames(); | - |
121 | QVector<int> types; | - |
122 | int inputCount = qDBusParametersForMethod(mm, types); | - |
123 | if (inputCount == -1) partially evaluated: inputCount == -1 no Evaluation Count:0 | yes Evaluation Count:845 |
| 0-845 |
124 | continue; never executed: continue; | 0 |
125 | if (isSignal && inputCount + 1 != types.count()) evaluated: isSignal yes Evaluation Count:34 | yes Evaluation Count:811 |
partially evaluated: inputCount + 1 != types.count() no Evaluation Count:0 | yes Evaluation Count:34 |
| 0-811 |
126 | continue; never executed: continue; | 0 |
127 | if (isSignal && types.at(inputCount) == QDBusMetaTypeId::message()) evaluated: isSignal yes Evaluation Count:34 | yes Evaluation Count:811 |
partially evaluated: types.at(inputCount) == QDBusMetaTypeId::message() no Evaluation Count:0 | yes Evaluation Count:34 |
| 0-811 |
128 | continue; never executed: continue; | 0 |
129 | if (isSignal && mm.attributes() & QMetaMethod::Cloned) evaluated: isSignal yes Evaluation Count:34 | yes Evaluation Count:811 |
partially evaluated: mm.attributes() & QMetaMethod::Cloned no Evaluation Count:0 | yes Evaluation Count:34 |
| 0-811 |
130 | continue; never executed: continue; | 0 |
131 | | - |
132 | int j; | - |
133 | bool isScriptable = mm.attributes() & QMetaMethod::Scriptable; | - |
134 | for (j = 1; j < types.count(); ++j) { evaluated: j < types.count() yes Evaluation Count:406 | yes Evaluation Count:845 |
| 406-845 |
135 | | - |
136 | if (types.at(j) == QDBusMetaTypeId::message()) { evaluated: types.at(j) == QDBusMetaTypeId::message() yes Evaluation Count:2 | yes Evaluation Count:404 |
| 2-404 |
137 | isScriptable = true; | - |
138 | continue; executed: continue; Execution Count:2 | 2 |
139 | } | - |
140 | | - |
141 | QString name; | - |
142 | if (!names.at(j - 1).isEmpty()) evaluated: !names.at(j - 1).isEmpty() yes Evaluation Count:373 | yes Evaluation Count:31 |
| 31-373 |
143 | name = QString::fromLatin1("name=\"%1\" ").arg(QLatin1String(names.at(j - 1))); executed: name = QString::fromLatin1("name=\"%1\" ").arg(QLatin1String(names.at(j - 1))); Execution Count:373 | 373 |
144 | | - |
145 | bool isOutput = isSignal || j > inputCount; evaluated: isSignal yes Evaluation Count:16 | yes Evaluation Count:388 |
evaluated: j > inputCount yes Evaluation Count:7 | yes Evaluation Count:381 |
| 7-388 |
146 | | - |
147 | const char *signature = QDBusMetaType::typeToSignature(types.at(j)); | - |
148 | xml += QString::fromLatin1(" <arg %1type=\"%2\" direction=\"%3\"/>\n") | - |
149 | .arg(name) | - |
150 | .arg(QLatin1String(signature)) | - |
151 | .arg(isOutput ? QLatin1String("out") : QLatin1String("in")); | - |
152 | | - |
153 | | - |
154 | if (QDBusMetaType::signatureToType(signature) == QVariant::Invalid) { evaluated: QDBusMetaType::signatureToType(signature) == QVariant::Invalid yes Evaluation Count:73 | yes Evaluation Count:331 |
| 73-331 |
155 | const char *typeName = QMetaType::typeName(types.at(j)); | - |
156 | xml += QString::fromLatin1(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.%1%2\" value=\"%3\"/>\n") | - |
157 | .arg(isOutput ? QLatin1String("Out") : QLatin1String("In")) | - |
158 | .arg(isOutput && !isSignal ? j - inputCount : j - 1) | - |
159 | .arg(typeNameToXml(typeName)); | - |
160 | } executed: } Execution Count:73 | 73 |
161 | } executed: } Execution Count:404 | 404 |
162 | | - |
163 | int wantedMask; | - |
164 | if (isScriptable) evaluated: isScriptable yes Evaluation Count:16 | yes Evaluation Count:829 |
| 16-829 |
165 | wantedMask = isSignal ? QDBusConnection::ExportScriptableSignals evaluated: isSignal yes Evaluation Count:3 | yes Evaluation Count:13 |
| 3-16 |
166 | : QDBusConnection::ExportScriptableSlots; executed: wantedMask = isSignal ? QDBusConnection::ExportScriptableSignals : QDBusConnection::ExportScriptableSlots; Execution Count:16 | 16 |
167 | else | - |
168 | wantedMask = isSignal ? QDBusConnection::ExportNonScriptableSignals evaluated: isSignal yes Evaluation Count:31 | yes Evaluation Count:798 |
| 31-829 |
169 | : QDBusConnection::ExportNonScriptableSlots; executed: wantedMask = isSignal ? QDBusConnection::ExportNonScriptableSignals : QDBusConnection::ExportNonScriptableSlots; Execution Count:829 | 829 |
170 | if ((flags & wantedMask) != wantedMask) partially evaluated: (flags & wantedMask) != wantedMask no Evaluation Count:0 | yes Evaluation Count:845 |
| 0-845 |
171 | continue; never executed: continue; | 0 |
172 | | - |
173 | if (qDBusCheckAsyncTag(mm.tag())) partially evaluated: qDBusCheckAsyncTag(mm.tag()) no Evaluation Count:0 | yes Evaluation Count:845 |
| 0-845 |
174 | | - |
175 | xml += QLatin1String(" <annotation name=\"" "org.freedesktop.DBus.Method.NoReply" "\"" | 0 |
176 | " value=\"true\"/>\n"); never executed: xml += QLatin1String(" <annotation name=\"" "org.freedesktop.DBus.Method.NoReply" "\"" " value=\"true\"/>\n"); | 0 |
177 | | - |
178 | retval += xml; | - |
179 | retval += QString::fromLatin1(" </%1>\n") | - |
180 | .arg(isSignal ? QLatin1String("signal") : QLatin1String("method")); | - |
181 | } executed: } Execution Count:845 | 845 |
182 | | - |
183 | return retval; executed: return retval; Execution Count:60 | 60 |
184 | } | - |
185 | | - |
186 | QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo, | - |
187 | const QMetaObject *base, int flags) | - |
188 | { | - |
189 | if (interface.isEmpty()) evaluated: interface.isEmpty() yes Evaluation Count:9 | yes Evaluation Count:54 |
| 9-54 |
190 | | - |
191 | interface = qDBusInterfaceFromMetaObject(mo); executed: interface = qDBusInterfaceFromMetaObject(mo); Execution Count:9 | 9 |
192 | | - |
193 | QString xml; | - |
194 | int idx = mo->indexOfClassInfo("D-Bus Introspection"); | - |
195 | if (idx >= mo->classInfoOffset()) evaluated: idx >= mo->classInfoOffset() yes Evaluation Count:3 | yes Evaluation Count:60 |
| 3-60 |
196 | return QString::fromUtf8(mo->classInfo(idx).value()); executed: return QString::fromUtf8(mo->classInfo(idx).value()); Execution Count:3 | 3 |
197 | else | - |
198 | xml = generateInterfaceXml(mo, flags, base->methodCount(), base->propertyCount()); executed: xml = generateInterfaceXml(mo, flags, base->methodCount(), base->propertyCount()); Execution Count:60 | 60 |
199 | | - |
200 | if (xml.isEmpty()) evaluated: xml.isEmpty() yes Evaluation Count:19 | yes Evaluation Count:41 |
| 19-41 |
201 | return QString(); executed: return QString(); Execution Count:19 | 19 |
202 | return QString::fromLatin1(" <interface name=\"%1\">\n%2 </interface>\n") | 41 |
203 | .arg(interface, xml); executed: return QString::fromLatin1(" <interface name=\"%1\">\n%2 </interface>\n") .arg(interface, xml); Execution Count:41 | 41 |
204 | } | - |
205 | | - |
206 | | - |
| | |