| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/dbus/qdbusmetaobject.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | - | |||||||||||||
| 8 | - | |||||||||||||
| 9 | class QDBusMetaObjectGenerator | - | ||||||||||||
| 10 | { | - | ||||||||||||
| 11 | public: | - | ||||||||||||
| 12 | QDBusMetaObjectGenerator(const QString &interface, | - | ||||||||||||
| 13 | const QDBusIntrospection::Interface *parsedData); | - | ||||||||||||
| 14 | void write(QDBusMetaObject *obj); | - | ||||||||||||
| 15 | void writeWithoutXml(QDBusMetaObject *obj); | - | ||||||||||||
| 16 | - | |||||||||||||
| 17 | private: | - | ||||||||||||
| 18 | struct Method { | - | ||||||||||||
| 19 | QList<QByteArray> parameterNames; | - | ||||||||||||
| 20 | QByteArray tag; | - | ||||||||||||
| 21 | QByteArray name; | - | ||||||||||||
| 22 | QVarLengthArray<int, 4> inputTypes; | - | ||||||||||||
| 23 | QVarLengthArray<int, 4> outputTypes; | - | ||||||||||||
| 24 | QByteArray rawReturnType; | - | ||||||||||||
| 25 | int flags; | - | ||||||||||||
| 26 | }; | - | ||||||||||||
| 27 | - | |||||||||||||
| 28 | struct Property { | - | ||||||||||||
| 29 | QByteArray typeName; | - | ||||||||||||
| 30 | QByteArray signature; | - | ||||||||||||
| 31 | int type; | - | ||||||||||||
| 32 | int flags; | - | ||||||||||||
| 33 | }; | - | ||||||||||||
| 34 | struct Type { | - | ||||||||||||
| 35 | int id; | - | ||||||||||||
| 36 | QByteArray name; | - | ||||||||||||
| 37 | }; | - | ||||||||||||
| 38 | - | |||||||||||||
| 39 | QMap<QByteArray, Method> signals_; | - | ||||||||||||
| 40 | QMap<QByteArray, Method> methods; | - | ||||||||||||
| 41 | QMap<QByteArray, Property> properties; | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | const QDBusIntrospection::Interface *data; | - | ||||||||||||
| 44 | QString interface; | - | ||||||||||||
| 45 | - | |||||||||||||
| 46 | Type findType(const QByteArray &signature, | - | ||||||||||||
| 47 | const QDBusIntrospection::Annotations &annotations, | - | ||||||||||||
| 48 | const char *direction = "Out", int id = -1); | - | ||||||||||||
| 49 | - | |||||||||||||
| 50 | void parseMethods(); | - | ||||||||||||
| 51 | void parseSignals(); | - | ||||||||||||
| 52 | void parseProperties(); | - | ||||||||||||
| 53 | - | |||||||||||||
| 54 | static int aggregateParameterCount(const QMap<QByteArray, Method> &map); | - | ||||||||||||
| 55 | }; | - | ||||||||||||
| 56 | - | |||||||||||||
| 57 | static const int intsPerProperty = 2; | - | ||||||||||||
| 58 | static const int intsPerMethod = 2; | - | ||||||||||||
| 59 | - | |||||||||||||
| 60 | struct QDBusMetaObjectPrivate : public QMetaObjectPrivate | - | ||||||||||||
| 61 | { | - | ||||||||||||
| 62 | int propertyDBusData; | - | ||||||||||||
| 63 | int methodDBusData; | - | ||||||||||||
| 64 | }; | - | ||||||||||||
| 65 | - | |||||||||||||
| 66 | QDBusMetaObjectGenerator::QDBusMetaObjectGenerator(const QString &interfaceName, | - | ||||||||||||
| 67 | const QDBusIntrospection::Interface *parsedData) | - | ||||||||||||
| 68 | : data(parsedData), interface(interfaceName) | - | ||||||||||||
| 69 | { | - | ||||||||||||
| 70 | if (data) { | - | ||||||||||||
| 71 | parseProperties(); | - | ||||||||||||
| 72 | parseSignals(); | - | ||||||||||||
| 73 | parseMethods(); | - | ||||||||||||
| 74 | } | - | ||||||||||||
| 75 | } | - | ||||||||||||
| 76 | - | |||||||||||||
| 77 | static int registerComplexDBusType(const char *typeName) | - | ||||||||||||
| 78 | { | - | ||||||||||||
| 79 | struct QDBusRawTypeHandler { | - | ||||||||||||
| 80 | static void destruct(void *) | - | ||||||||||||
| 81 | { | - | ||||||||||||
| 82 | QMessageLogger(__FILE__, 128135, __PRETTY_FUNCTION__).fatal("Cannot destruct placeholder type QDBusRawType"); | - | ||||||||||||
| 83 | } | - | ||||||||||||
| 84 | - | |||||||||||||
| 85 | static void *construct(void *, const void *) | - | ||||||||||||
| 86 | { | - | ||||||||||||
| 87 | QMessageLogger(__FILE__, 133140, __PRETTY_FUNCTION__).fatal("Cannot construct placeholder type QDBusRawType"); | - | ||||||||||||
| 88 | return 0; | - | ||||||||||||
| 89 | } | - | ||||||||||||
| 90 | }; | - | ||||||||||||
| 91 | - | |||||||||||||
| 92 | return QMetaType::registerNormalizedType(typeName, | - | ||||||||||||
| 93 | QDBusRawTypeHandler::destruct, | - | ||||||||||||
| 94 | QDBusRawTypeHandler::construct, | - | ||||||||||||
| 95 | sizeof(void *), | - | ||||||||||||
| 96 | QMetaType::MovableType, | - | ||||||||||||
| 97 | 0); | - | ||||||||||||
| 98 | } | - | ||||||||||||
| 99 | - | |||||||||||||
| 100 | __attribute__((visibility("default"))) bool qt_dbus_metaobject_skip_annotations = false; | - | ||||||||||||
| 101 | - | |||||||||||||
| 102 | QDBusMetaObjectGenerator::Type | - | ||||||||||||
| 103 | QDBusMetaObjectGenerator::findType(const QByteArray &signature, | - | ||||||||||||
| 104 | const QDBusIntrospection::Annotations &annotations, | - | ||||||||||||
| 105 | const char *direction, int id) | - | ||||||||||||
| 106 | { | - | ||||||||||||
| 107 | Type result; | - | ||||||||||||
| 108 | result.id = QVariant::Invalid; | - | ||||||||||||
| 109 | - | |||||||||||||
| 110 | int type = QDBusMetaType::signatureToType(signature); | - | ||||||||||||
| 111 | if (type == QVariant::Invalid && !qt_dbus_metaobject_skip_annotations) { | - | ||||||||||||
| 112 | - | |||||||||||||
| 113 | - | |||||||||||||
| 114 | QString annotationName = QString::fromLatin1("org.qtproject.QtDBus.QtTypeName"); | - | ||||||||||||
| 115 | if (id >= 0) | - | ||||||||||||
| 116 | annotationName += QString::fromLatin1(".%1%2") | - | ||||||||||||
| 117 | .arg(QLatin1String(direction)) | - | ||||||||||||
| 118 | .arg(id); | - | ||||||||||||
| 119 | - | |||||||||||||
| 120 | - | |||||||||||||
| 121 | QByteArray typeName = annotations.value(annotationName).toLatin1(); | - | ||||||||||||
| 122 | - | |||||||||||||
| 123 | - | |||||||||||||
| 124 | if (typeName.isEmpty()) { | - | ||||||||||||
| 125 | - | |||||||||||||
| 126 | annotationName = QString::fromLatin1("com.trolltech.QtDBus.QtTypeName"); | - | ||||||||||||
| 127 | if (id >= 0) | - | ||||||||||||
| 128 | annotationName += QString::fromLatin1(".%1%2") | - | ||||||||||||
| 129 | .arg(QLatin1String(direction)) | - | ||||||||||||
| 130 | .arg(id); | - | ||||||||||||
| 131 | typeName = annotations.value(annotationName).toLatin1(); | - | ||||||||||||
| 132 | } | - | ||||||||||||
| 133 | - | |||||||||||||
| 134 | if (!typeName.isEmpty()) { | - | ||||||||||||
| 135 | - | |||||||||||||
| 136 | type = QMetaType::type(typeName); | - | ||||||||||||
| 137 | } | - | ||||||||||||
| 138 | - | |||||||||||||
| 139 | if (type == QVariant::Invalid || signature != QDBusMetaType::typeToSignature(type)) { | - | ||||||||||||
| 140 | - | |||||||||||||
| 141 | - | |||||||||||||
| 142 | typeName = "QDBusRawType<0x" + signature.toHex() + ">*"; | - | ||||||||||||
| 143 | type = registerComplexDBusType(typeName); | - | ||||||||||||
| 144 | } | - | ||||||||||||
| 145 | - | |||||||||||||
| 146 | result.name = typeName; | - | ||||||||||||
| 147 | } else if (type == QVariant::Invalid) { | - | ||||||||||||
| 148 | - | |||||||||||||
| 149 | - | |||||||||||||
| 150 | - | |||||||||||||
| 151 | if (signature == "av") { | - | ||||||||||||
| 152 | result.name = "QVariantList"; | - | ||||||||||||
| 153 | type = QVariant::List; | - | ||||||||||||
| 154 | } else if (signature == "a{sv}") { | - | ||||||||||||
| 155 | result.name = "QVariantMap"; | - | ||||||||||||
| 156 | type = QVariant::Map; | - | ||||||||||||
| 157 | } else if (signature == "a{ss}") { | - | ||||||||||||
| 158 | result.name = "QMap<QString,QString>"; | - | ||||||||||||
| 159 | type = qMetaTypeId<QMap<QString, QString> >(); | - | ||||||||||||
| 160 | } else { | - | ||||||||||||
| 161 | result.name = "{D-Bus type \"" + signature + "\"}"; | - | ||||||||||||
| 162 | type = registerComplexDBusType(result.name); | - | ||||||||||||
| 163 | } | - | ||||||||||||
| 164 | } else { | - | ||||||||||||
| 165 | result.name = QMetaType::typeName(type); | - | ||||||||||||
| 166 | } | - | ||||||||||||
| 167 | - | |||||||||||||
| 168 | result.id = type; | - | ||||||||||||
| 169 | return result; | - | ||||||||||||
| 170 | } | - | ||||||||||||
| 171 | - | |||||||||||||
| 172 | void QDBusMetaObjectGenerator::parseMethods() | - | ||||||||||||
| 173 | { | - | ||||||||||||
| 174 | - | |||||||||||||
| 175 | - | |||||||||||||
| 176 | - | |||||||||||||
| 177 | - | |||||||||||||
| 178 | - | |||||||||||||
| 179 | QDBusIntrospection::Methods::ConstIterator method_it = data->methods.constBegin(); | - | ||||||||||||
| 180 | QDBusIntrospection::Methods::ConstIterator method_end = data->methods.constEnd(); | - | ||||||||||||
| 181 | for ( ; method_it != method_end; ++method_it) { | - | ||||||||||||
| 182 | const QDBusIntrospection::Method &m = *method_it; | - | ||||||||||||
| 183 | Method mm; | - | ||||||||||||
| 184 | - | |||||||||||||
| 185 | mm.name = m.name.toLatin1(); | - | ||||||||||||
| 186 | QByteArray prototype = mm.name; | - | ||||||||||||
| 187 | prototype += '('; | - | ||||||||||||
| 188 | - | |||||||||||||
| 189 | bool ok = true; | - | ||||||||||||
| 190 | - | |||||||||||||
| 191 | - | |||||||||||||
| 192 | for (int i = 0; i < m.inputArgs.count(); ++i) { | - | ||||||||||||
| 193 | const QDBusIntrospection::Argument &arg = m.inputArgs.at(i); | - | ||||||||||||
| 194 | - | |||||||||||||
| 195 | Type type = findType(arg.type.toLatin1(), m.annotations, "In", i); | - | ||||||||||||
| 196 | if (type.id == QVariant::Invalid) { | - | ||||||||||||
| 197 | ok = false; | - | ||||||||||||
| 198 | break; | - | ||||||||||||
| 199 | } | - | ||||||||||||
| 200 | - | |||||||||||||
| 201 | mm.inputTypes.append(type.id); | - | ||||||||||||
| 202 | - | |||||||||||||
| 203 | mm.parameterNames.append(arg.name.toLatin1()); | - | ||||||||||||
| 204 | - | |||||||||||||
| 205 | prototype.append(type.name); | - | ||||||||||||
| 206 | prototype.append(','); | - | ||||||||||||
| 207 | } | - | ||||||||||||
| 208 | if (!ok) continue; | - | ||||||||||||
| 209 | - | |||||||||||||
| 210 | - | |||||||||||||
| 211 | for (int i = 0; i < m.outputArgs.count(); ++i) { | - | ||||||||||||
| 212 | const QDBusIntrospection::Argument &arg = m.outputArgs.at(i); | - | ||||||||||||
| 213 | - | |||||||||||||
| 214 | Type type = findType(arg.type.toLatin1(), m.annotations, "Out", i); | - | ||||||||||||
| 215 | if (type.id == QVariant::Invalid) { | - | ||||||||||||
| 216 | ok = false; | - | ||||||||||||
| 217 | break; | - | ||||||||||||
| 218 | } | - | ||||||||||||
| 219 | - | |||||||||||||
| 220 | mm.outputTypes.append(type.id); | - | ||||||||||||
| 221 | - | |||||||||||||
| 222 | if (i == 0 && type.id == -1) { | - | ||||||||||||
| 223 | mm.rawReturnType = type.name; | - | ||||||||||||
| 224 | } | - | ||||||||||||
| 225 | if (i != 0) { | - | ||||||||||||
| 226 | - | |||||||||||||
| 227 | mm.parameterNames.append(arg.name.toLatin1()); | - | ||||||||||||
| 228 | - | |||||||||||||
| 229 | prototype.append(type.name); | - | ||||||||||||
| 230 | prototype.append("&,"); | - | ||||||||||||
| 231 | } | - | ||||||||||||
| 232 | } | - | ||||||||||||
| 233 | if (!ok) continue; | - | ||||||||||||
| 234 | - | |||||||||||||
| 235 | - | |||||||||||||
| 236 | if (!mm.parameterNames.isEmpty()) | - | ||||||||||||
| 237 | prototype[prototype.length() - 1] = ')'; | - | ||||||||||||
| 238 | else | - | ||||||||||||
| 239 | prototype.append(')'); | - | ||||||||||||
| 240 | - | |||||||||||||
| 241 | - | |||||||||||||
| 242 | if (m.annotations.value(QLatin1String("org.freedesktop.DBus.Method.NoReply")) == QLatin1String("true")) | - | ||||||||||||
| 243 | mm.tag = "Q_NOREPLY"; | - | ||||||||||||
| 244 | - | |||||||||||||
| 245 | - | |||||||||||||
| 246 | mm.flags = AccessPublic | MethodSlot | MethodScriptable; | - | ||||||||||||
| 247 | - | |||||||||||||
| 248 | - | |||||||||||||
| 249 | methods.insert(QMetaObject::normalizedSignature(prototype), mm); | - | ||||||||||||
| 250 | } | - | ||||||||||||
| 251 | } | - | ||||||||||||
| 252 | - | |||||||||||||
| 253 | void QDBusMetaObjectGenerator::parseSignals() | - | ||||||||||||
| 254 | { | - | ||||||||||||
| 255 | QDBusIntrospection::Signals::ConstIterator signal_it = data->signals_.constBegin(); | - | ||||||||||||
| 256 | QDBusIntrospection::Signals::ConstIterator signal_end = data->signals_.constEnd(); | - | ||||||||||||
| 257 | for ( ; signal_it != signal_end; ++signal_it) { | - | ||||||||||||
| 258 | const QDBusIntrospection::Signal &s = *signal_it; | - | ||||||||||||
| 259 | Method mm; | - | ||||||||||||
| 260 | - | |||||||||||||
| 261 | mm.name = s.name.toLatin1(); | - | ||||||||||||
| 262 | QByteArray prototype = mm.name; | - | ||||||||||||
| 263 | prototype += '('; | - | ||||||||||||
| 264 | - | |||||||||||||
| 265 | bool ok = true; | - | ||||||||||||
| 266 | - | |||||||||||||
| 267 | - | |||||||||||||
| 268 | for (int i = 0; i < s.outputArgs.count(); ++i) { | - | ||||||||||||
| 269 | const QDBusIntrospection::Argument &arg = s.outputArgs.at(i); | - | ||||||||||||
| 270 | - | |||||||||||||
| 271 | Type type = findType(arg.type.toLatin1(), s.annotations, "Out", i); | - | ||||||||||||
| 272 | if (type.id == QVariant::Invalid) { | - | ||||||||||||
| 273 | ok = false; | - | ||||||||||||
| 274 | break; | - | ||||||||||||
| 275 | } | - | ||||||||||||
| 276 | - | |||||||||||||
| 277 | mm.inputTypes.append(type.id); | - | ||||||||||||
| 278 | - | |||||||||||||
| 279 | mm.parameterNames.append(arg.name.toLatin1()); | - | ||||||||||||
| 280 | - | |||||||||||||
| 281 | prototype.append(type.name); | - | ||||||||||||
| 282 | prototype.append(','); | - | ||||||||||||
| 283 | } | - | ||||||||||||
| 284 | if (!ok) continue; | - | ||||||||||||
| 285 | - | |||||||||||||
| 286 | - | |||||||||||||
| 287 | if (!mm.parameterNames.isEmpty()) | - | ||||||||||||
| 288 | prototype[prototype.length() - 1] = ')'; | - | ||||||||||||
| 289 | else | - | ||||||||||||
| 290 | prototype.append(')'); | - | ||||||||||||
| 291 | - | |||||||||||||
| 292 | - | |||||||||||||
| 293 | mm.flags = AccessPublic | MethodSignal | MethodScriptable; | - | ||||||||||||
| 294 | - | |||||||||||||
| 295 | - | |||||||||||||
| 296 | signals_.insert(QMetaObject::normalizedSignature(prototype), mm); | - | ||||||||||||
| 297 | } | - | ||||||||||||
| 298 | } | - | ||||||||||||
| 299 | - | |||||||||||||
| 300 | void QDBusMetaObjectGenerator::parseProperties() | - | ||||||||||||
| 301 | { | - | ||||||||||||
| 302 | QDBusIntrospection::Properties::ConstIterator prop_it = data->properties.constBegin(); | - | ||||||||||||
| 303 | QDBusIntrospection::Properties::ConstIterator prop_end = data->properties.constEnd(); | - | ||||||||||||
| 304 | for ( ; prop_it != prop_end; ++prop_it) { | - | ||||||||||||
| 305 | const QDBusIntrospection::Property &p = *prop_it; | - | ||||||||||||
| 306 | Property mp; | - | ||||||||||||
| 307 | Type type = findType(p.type.toLatin1(), p.annotations); | - | ||||||||||||
| 308 | if (type.id == QVariant::Invalid) | - | ||||||||||||
| 309 | continue; | - | ||||||||||||
| 310 | - | |||||||||||||
| 311 | QByteArray name = p.name.toLatin1(); | - | ||||||||||||
| 312 | mp.signature = p.type.toLatin1(); | - | ||||||||||||
| 313 | mp.type = type.id; | - | ||||||||||||
| 314 | mp.typeName = type.name; | - | ||||||||||||
| 315 | - | |||||||||||||
| 316 | - | |||||||||||||
| 317 | mp.flags = StdCppSet | Scriptable | Stored | Designable; | - | ||||||||||||
| 318 | if (p.access != QDBusIntrospection::Property::Write) | - | ||||||||||||
| 319 | mp.flags |= Readable; | - | ||||||||||||
| 320 | if (p.access != QDBusIntrospection::Property::Read) | - | ||||||||||||
| 321 | mp.flags |= Writable; | - | ||||||||||||
| 322 | - | |||||||||||||
| 323 | - | |||||||||||||
| 324 | properties.insert(name, mp); | - | ||||||||||||
| 325 | } | - | ||||||||||||
| 326 | } | - | ||||||||||||
| 327 | - | |||||||||||||
| 328 | - | |||||||||||||
| 329 | - | |||||||||||||
| 330 | - | |||||||||||||
| 331 | int QDBusMetaObjectGenerator::aggregateParameterCount(const QMap<QByteArray, Method> &map) | - | ||||||||||||
| 332 | { | - | ||||||||||||
| 333 | int sum = 0; | - | ||||||||||||
| 334 | QMap<QByteArray, Method>::const_iterator it; | - | ||||||||||||
| 335 | for (it = map.constBegin(); it != map.constEnd(); ++it) { | - | ||||||||||||
| 336 | const Method &m = it.value(); | - | ||||||||||||
| 337 | sum += m.inputTypes.size() + qMax(1, m.outputTypes.size()); | - | ||||||||||||
| 338 | } | - | ||||||||||||
| 339 | return sum; | - | ||||||||||||
| 340 | } | - | ||||||||||||
| 341 | - | |||||||||||||
| 342 | void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) | - | ||||||||||||
| 343 | { | - | ||||||||||||
| 344 | - | |||||||||||||
| 345 | - | |||||||||||||
| 346 | - | |||||||||||||
| 347 | QString className = interface; | - | ||||||||||||
| 348 | className.replace(QLatin1Char('.'), QLatin1String("::")); | - | ||||||||||||
| 349 | if (className.isEmpty()
| 0-152 | ||||||||||||
| 350 | className = QLatin1String("QDBusInterface"); never executed: className = QLatin1String("QDBusInterface"); | 0 | ||||||||||||
| 351 | - | |||||||||||||
| 352 | QVarLengthArray<int> idata; | - | ||||||||||||
| 353 | idata.resize(sizeof(QDBusMetaObjectPrivate) / sizeof(int)); | - | ||||||||||||
| 354 | - | |||||||||||||
| 355 | int methodParametersDataSize = | - | ||||||||||||
| 356 | ((aggregateParameterCount(signals_) | - | ||||||||||||
| 357 | + aggregateParameterCount(methods)) * 2) | - | ||||||||||||
| 358 | - signals_.count() | - | ||||||||||||
| 359 | - methods.count(); | - | ||||||||||||
| 360 | - | |||||||||||||
| 361 | QDBusMetaObjectPrivate *header = reinterpret_cast<QDBusMetaObjectPrivate *>(idata.data()); | - | ||||||||||||
| 362 | static_assert(bool(QMetaObjectPrivate::OutputRevision == 7), "QtDBus meta-object generator should generate the same version as moc"); | - | ||||||||||||
| 363 | header->revision = QMetaObjectPrivate::OutputRevision; | - | ||||||||||||
| 364 | header->className = 0; | - | ||||||||||||
| 365 | header->classInfoCount = 0; | - | ||||||||||||
| 366 | header->classInfoData = 0; | - | ||||||||||||
| 367 | header->methodCount = signals_.count() + methods.count(); | - | ||||||||||||
| 368 | header->methodData = idata.size(); | - | ||||||||||||
| 369 | header->propertyCount = properties.count(); | - | ||||||||||||
| 370 | header->propertyData = header->methodData + header->methodCount * 5 + methodParametersDataSize; | - | ||||||||||||
| 371 | header->enumeratorCount = 0; | - | ||||||||||||
| 372 | header->enumeratorData = 0; | - | ||||||||||||
| 373 | header->constructorCount = 0; | - | ||||||||||||
| 374 | header->constructorData = 0; | - | ||||||||||||
| 375 | header->flags = RequiresVariantMetaObject; | - | ||||||||||||
| 376 | header->signalCount = signals_.count(); | - | ||||||||||||
| 377 | - | |||||||||||||
| 378 | header->propertyDBusData = header->propertyData + header->propertyCount * 3; | - | ||||||||||||
| 379 | header->methodDBusData = header->propertyDBusData + header->propertyCount * intsPerProperty; | - | ||||||||||||
| 380 | - | |||||||||||||
| 381 | int data_size = idata.size() + | - | ||||||||||||
| 382 | (header->methodCount * (5+intsPerMethod)) + methodParametersDataSize + | - | ||||||||||||
| 383 | (header->propertyCount * (3+intsPerProperty)); | - | ||||||||||||
| for (QForeachContainer<typename QtPrivate::remove_reference<decltype(signals_)>::type> _container_((signals_)); | ||||||||||||||
| 384 | _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (const Method &mm = *_container_.i; _container_.control; _container_.control = 0): qAsConst(signals_)) | - | ||||||||||||
| 385 | data_size += 2 + mm.inputTypes.count() + mm.outputTypes.count(); executed 98 times by 12 tests: data_size += 2 + mm.inputTypes.count() + mm.outputTypes.count();Executed by:
| 98 | ||||||||||||
| 386 | for (QForeachContainer<typename QtPrivate::remove_reference<decltype(methods)>::type> _container_((methods)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (const Method &mm = *_container_.i; _container_.control; _container_.control = 0): qAsConst(methods)) | - | ||||||||||||
| 387 | data_size += 2 + mm.inputTypes.count() + mm.outputTypes.count(); executed 990 times by 12 tests: data_size += 2 + mm.inputTypes.count() + mm.outputTypes.count();Executed by:
| 990 | ||||||||||||
| 388 | idata.resize(data_size + 1); | - | ||||||||||||
| 389 | - | |||||||||||||
| 390 | QMetaStringTable strings(className.toLatin1()); | - | ||||||||||||
| 391 | - | |||||||||||||
| 392 | int offset = header->methodData; | - | ||||||||||||
| 393 | int parametersOffset = offset + header->methodCount * 5; | - | ||||||||||||
| 394 | int signatureOffset = header->methodDBusData; | - | ||||||||||||
| 395 | int typeidOffset = header->methodDBusData + header->methodCount * intsPerMethod; | - | ||||||||||||
| 396 | idata[typeidOffset++] = 0; | - | ||||||||||||
| 397 | - | |||||||||||||
| 398 | - | |||||||||||||
| 399 | for (int x = 0; x < 2
| 152-304 | ||||||||||||
| 400 | - | |||||||||||||
| 401 | QMap<QByteArray, Method> &map = (
| 152 | ||||||||||||
| 402 | for (QMap<QByteArray, Method>::ConstIterator it = map.constBegin(); | - | ||||||||||||
| 403 | it != map.constEnd()
| 304-1088 | ||||||||||||
| 404 | const Method &mm = it.value(); | - | ||||||||||||
| 405 | - | |||||||||||||
| 406 | int argc = mm.inputTypes.size() + qMax(0, mm.outputTypes.size() - 1); | - | ||||||||||||
| 407 | - | |||||||||||||
| 408 | idata[offset++] = strings.enter(mm.name); | - | ||||||||||||
| 409 | idata[offset++] = argc; | - | ||||||||||||
| 410 | idata[offset++] = parametersOffset; | - | ||||||||||||
| 411 | idata[offset++] = strings.enter(mm.tag); | - | ||||||||||||
| 412 | idata[offset++] = mm.flags; | - | ||||||||||||
| 413 | - | |||||||||||||
| 414 | - | |||||||||||||
| 415 | for (int i = -1; i < argc
| 1088-1756 | ||||||||||||
| 416 | int type; | - | ||||||||||||
| 417 | QByteArray typeName; | - | ||||||||||||
| 418 | if (i < 0
| 668-1088 | ||||||||||||
| 419 | if (!mm.outputTypes.isEmpty()
| 514-574 | ||||||||||||
| 420 | type = mm.outputTypes.first(); | - | ||||||||||||
| 421 | if (type == -1
| 0-514 | ||||||||||||
| 422 | type = IsUnresolvedType | strings.enter(mm.rawReturnType); | - | ||||||||||||
| 423 | } never executed: end of block | 0 | ||||||||||||
| 424 | } executed 514 times by 11 tests: else {end of blockExecuted by:
| 514 | ||||||||||||
| 425 | type = QMetaType::Void; | - | ||||||||||||
| 426 | } executed 574 times by 12 tests: end of blockExecuted by:
| 574 | ||||||||||||
| 427 | } else if (i < mm.inputTypes.size()
| 19-649 | ||||||||||||
| 428 | type = mm.inputTypes.at(i); | - | ||||||||||||
| 429 | } executed 649 times by 11 tests: else {end of blockExecuted by:
| 649 | ||||||||||||
| 430 | ((!(mm.outputTypes.size() > 1)) ? qt_assert("mm.outputTypes.size() > 1",__FILE__,476483) : qt_noop()); | - | ||||||||||||
| 431 | type = mm.outputTypes.at(i - mm.inputTypes.size() + 1); | - | ||||||||||||
| 432 | - | |||||||||||||
| 433 | typeName = QMetaType::typeName(type); | - | ||||||||||||
| 434 | typeName.append('&'); | - | ||||||||||||
| 435 | } executed 19 times by 5 tests: end of blockExecuted by:
| 19 | ||||||||||||
| 436 | ((!(type != QMetaType::UnknownType)) ? qt_assert("type != QMetaType::UnknownType",__FILE__,482489) : qt_noop()); | - | ||||||||||||
| 437 | int typeInfo; | - | ||||||||||||
| 438 | if (!typeName.isEmpty()
| 19-1737 | ||||||||||||
| 439 | typeInfo = IsUnresolvedType | strings.enter(typeName); executed 19 times by 5 tests: typeInfo = IsUnresolvedType | strings.enter(typeName);Executed by:
| 19 | ||||||||||||
| 440 | else | - | ||||||||||||
| 441 | typeInfo = type; executed 1737 times by 12 tests: typeInfo = type;Executed by:
| 1737 | ||||||||||||
| 442 | idata[parametersOffset++] = typeInfo; | - | ||||||||||||
| 443 | } executed 1756 times by 12 tests: end of blockExecuted by:
| 1756 | ||||||||||||
| 444 | - | |||||||||||||
| 445 | for (int i = 0; i < argc
| 668-1088 | ||||||||||||
| 446 | idata[parametersOffset++] = strings.enter(mm.parameterNames.at(i)); executed 668 times by 11 tests: idata[parametersOffset++] = strings.enter(mm.parameterNames.at(i));Executed by:
| 668 | ||||||||||||
| 447 | - | |||||||||||||
| 448 | idata[signatureOffset++] = typeidOffset; | - | ||||||||||||
| 449 | idata[typeidOffset++] = mm.inputTypes.count(); | - | ||||||||||||
| 450 | memcpy(idata.data() + typeidOffset, mm.inputTypes.data(), mm.inputTypes.count() * sizeof(int)); | - | ||||||||||||
| 451 | typeidOffset += mm.inputTypes.count(); | - | ||||||||||||
| 452 | - | |||||||||||||
| 453 | idata[signatureOffset++] = typeidOffset; | - | ||||||||||||
| 454 | idata[typeidOffset++] = mm.outputTypes.count(); | - | ||||||||||||
| 455 | memcpy(idata.data() + typeidOffset, mm.outputTypes.data(), mm.outputTypes.count() * sizeof(int)); | - | ||||||||||||
| 456 | typeidOffset += mm.outputTypes.count(); | - | ||||||||||||
| 457 | } executed 1088 times by 12 tests: end of blockExecuted by:
| 1088 | ||||||||||||
| 458 | } executed 304 times by 12 tests: end of blockExecuted by:
| 304 | ||||||||||||
| 459 | - | |||||||||||||
| 460 | ((!(offset == header->methodData + header->methodCount * 5)) ? qt_assert("offset == header->methodData + header->methodCount * 5",__FILE__,506513) : qt_noop()); | - | ||||||||||||
| 461 | ((!(parametersOffset == header->propertyData)) ? qt_assert("parametersOffset == header->propertyData",__FILE__,507514) : qt_noop()); | - | ||||||||||||
| 462 | ((!(signatureOffset == header->methodDBusData + header->methodCount * intsPerMethod)) ? qt_assert("signatureOffset == header->methodDBusData + header->methodCount * intsPerMethod",__FILE__,508515) : qt_noop()); | - | ||||||||||||
| 463 | ((!(typeidOffset == idata.size())) ? qt_assert("typeidOffset == idata.size()",__FILE__,509516) : qt_noop()); | - | ||||||||||||
| 464 | offset += methodParametersDataSize; | - | ||||||||||||
| 465 | ((!(offset == header->propertyData)) ? qt_assert("offset == header->propertyData",__FILE__,511518) : qt_noop()); | - | ||||||||||||
| 466 | - | |||||||||||||
| 467 | - | |||||||||||||
| 468 | signatureOffset = header->propertyDBusData; | - | ||||||||||||
| 469 | for (QMap<QByteArray, Property>::ConstIterator it = properties.constBegin(); | - | ||||||||||||
| 470 | it != properties.constEnd()
| 88-152 | ||||||||||||
| 471 | const Property &mp = it.value(); | - | ||||||||||||
| 472 | - | |||||||||||||
| 473 | - | |||||||||||||
| 474 | idata[offset++] = strings.enter(it.key()); | - | ||||||||||||
| 475 | ((!(mp.type != QMetaType::UnknownType)) ? qt_assert("mp.type != QMetaType::UnknownType",__FILE__,521528) : qt_noop()); | - | ||||||||||||
| 476 | idata[offset++] = mp.type; | - | ||||||||||||
| 477 | idata[offset++] = mp.flags; | - | ||||||||||||
| 478 | - | |||||||||||||
| 479 | idata[signatureOffset++] = strings.enter(mp.signature); | - | ||||||||||||
| 480 | idata[signatureOffset++] = mp.type; | - | ||||||||||||
| 481 | } executed 88 times by 4 tests: end of blockExecuted by:
| 88 | ||||||||||||
| 482 | - | |||||||||||||
| 483 | ((!(offset == header->propertyDBusData)) ? qt_assert("offset == header->propertyDBusData",__FILE__,529536) : qt_noop()); | - | ||||||||||||
| 484 | ((!(signatureOffset == header->methodDBusData)) ? qt_assert("signatureOffset == header->methodDBusData",__FILE__,530537) : qt_noop()); | - | ||||||||||||
| 485 | - | |||||||||||||
| 486 | char *string_data = new char[strings.blobSize()]; | - | ||||||||||||
| 487 | strings.writeBlob(string_data); | - | ||||||||||||
| 488 | - | |||||||||||||
| 489 | uint *uint_data = new uint[idata.size()]; | - | ||||||||||||
| 490 | memcpy(uint_data, idata.data(), idata.size() * sizeof(int)); | - | ||||||||||||
| 491 | - | |||||||||||||
| 492 | - | |||||||||||||
| 493 | obj->d.data = uint_data; | - | ||||||||||||
| 494 | obj->d.relatedMetaObjects = 0; | - | ||||||||||||
| 495 | obj->d.static_metacall = 0; | - | ||||||||||||
| 496 | obj->d.extradata = 0; | - | ||||||||||||
| 497 | obj->d.stringdata = reinterpret_cast<const QByteArrayData *>(string_data); | - | ||||||||||||
| 498 | obj->d.superdata = &QDBusAbstractInterface::staticMetaObject; | - | ||||||||||||
| 499 | } executed 152 times by 12 tests: end of blockExecuted by:
| 152 | ||||||||||||
| 500 | QDBusMetaObject *QDBusMetaObject::createMetaObject(const QString &interface, const QString &xml, | - | ||||||||||||
| 501 | QHash<QString, QDBusMetaObject *> &cache, | - | ||||||||||||
| 502 | QDBusError &error) | - | ||||||||||||
| 503 | { | - | ||||||||||||
| 504 | error = QDBusError(); | - | ||||||||||||
| 505 | QDBusIntrospection::Interfaces parsed = QDBusIntrospection::parseInterfaces(xml); | - | ||||||||||||
| 506 | - | |||||||||||||
| 507 | QDBusMetaObject *we = 0; | - | ||||||||||||
| 508 | QDBusIntrospection::Interfaces::ConstIterator it = parsed.constBegin(); | - | ||||||||||||
| 509 | QDBusIntrospection::Interfaces::ConstIterator end = parsed.constEnd(); | - | ||||||||||||
| 510 | for ( ; it != end; ++it) { | - | ||||||||||||
| 511 | - | |||||||||||||
| 512 | bool us = it.key() == interface; | - | ||||||||||||
| 513 | - | |||||||||||||
| 514 | QDBusMetaObject *obj = cache.value(it.key(), 0); | - | ||||||||||||
| 515 | if ( !obj && ( us || !interface.startsWith( QLatin1String("local.") ) ) ) { | - | ||||||||||||
| 516 | - | |||||||||||||
| 517 | obj = new QDBusMetaObject; | - | ||||||||||||
| 518 | QDBusMetaObjectGenerator generator(it.key(), it.value().constData()); | - | ||||||||||||
| 519 | generator.write(obj); | - | ||||||||||||
| 520 | - | |||||||||||||
| 521 | if ( (obj->cached = !it.key().startsWith( QLatin1String("local.") )) ) | - | ||||||||||||
| 522 | - | |||||||||||||
| 523 | cache.insert(it.key(), obj); | - | ||||||||||||
| 524 | else if (!us) | - | ||||||||||||
| 525 | delete obj; | - | ||||||||||||
| 526 | - | |||||||||||||
| 527 | } | - | ||||||||||||
| 528 | - | |||||||||||||
| 529 | if (us) | - | ||||||||||||
| 530 | - | |||||||||||||
| 531 | we = obj; | - | ||||||||||||
| 532 | } | - | ||||||||||||
| 533 | - | |||||||||||||
| 534 | if (we) | - | ||||||||||||
| 535 | return we; | - | ||||||||||||
| 536 | - | |||||||||||||
| 537 | - | |||||||||||||
| 538 | if (parsed.isEmpty()) { | - | ||||||||||||
| 539 | - | |||||||||||||
| 540 | we = new QDBusMetaObject; | - | ||||||||||||
| 541 | QDBusMetaObjectGenerator generator(interface, 0); | - | ||||||||||||
| 542 | generator.write(we); | - | ||||||||||||
| 543 | we->cached = false; | - | ||||||||||||
| 544 | return we; | - | ||||||||||||
| 545 | } else if (interface.isEmpty()) { | - | ||||||||||||
| 546 | - | |||||||||||||
| 547 | it = parsed.constBegin(); | - | ||||||||||||
| 548 | QDBusIntrospection::Interface merged = *it.value().constData(); | - | ||||||||||||
| 549 | - | |||||||||||||
| 550 | for (++it; it != end; ++it) { | - | ||||||||||||
| 551 | merged.annotations.unite(it.value()->annotations); | - | ||||||||||||
| 552 | merged.methods.unite(it.value()->methods); | - | ||||||||||||
| 553 | merged.signals_.unite(it.value()->signals_); | - | ||||||||||||
| 554 | merged.properties.unite(it.value()->properties); | - | ||||||||||||
| 555 | } | - | ||||||||||||
| 556 | - | |||||||||||||
| 557 | merged.name = QLatin1String("local.Merged"); | - | ||||||||||||
| 558 | merged.introspection.clear(); | - | ||||||||||||
| 559 | - | |||||||||||||
| 560 | we = new QDBusMetaObject; | - | ||||||||||||
| 561 | QDBusMetaObjectGenerator generator(merged.name, &merged); | - | ||||||||||||
| 562 | generator.write(we); | - | ||||||||||||
| 563 | we->cached = false; | - | ||||||||||||
| 564 | return we; | - | ||||||||||||
| 565 | } | - | ||||||||||||
| 566 | - | |||||||||||||
| 567 | - | |||||||||||||
| 568 | error = QDBusError(QDBusError::UnknownInterface, | - | ||||||||||||
| 569 | QString::fromLatin1("Interface '%1' was not found") | - | ||||||||||||
| 570 | .arg(interface)); | - | ||||||||||||
| 571 | return 0; | - | ||||||||||||
| 572 | } | - | ||||||||||||
| 573 | - | |||||||||||||
| 574 | QDBusMetaObject::QDBusMetaObject() | - | ||||||||||||
| 575 | { | - | ||||||||||||
| 576 | } | - | ||||||||||||
| 577 | - | |||||||||||||
| 578 | static inline const QDBusMetaObjectPrivate *priv(const uint* data) | - | ||||||||||||
| 579 | { | - | ||||||||||||
| 580 | return reinterpret_cast<const QDBusMetaObjectPrivate *>(data); | - | ||||||||||||
| 581 | } | - | ||||||||||||
| 582 | - | |||||||||||||
| 583 | const int *QDBusMetaObject::inputTypesForMethod(int id) const | - | ||||||||||||
| 584 | { | - | ||||||||||||
| 585 | - | |||||||||||||
| 586 | if (id >= 0 && id < priv(d.data)->methodCount) { | - | ||||||||||||
| 587 | int handle = priv(d.data)->methodDBusData + id*intsPerMethod; | - | ||||||||||||
| 588 | return reinterpret_cast<const int*>(d.data + d.data[handle]); | - | ||||||||||||
| 589 | } | - | ||||||||||||
| 590 | return 0; | - | ||||||||||||
| 591 | } | - | ||||||||||||
| 592 | - | |||||||||||||
| 593 | const int *QDBusMetaObject::outputTypesForMethod(int id) const | - | ||||||||||||
| 594 | { | - | ||||||||||||
| 595 | - | |||||||||||||
| 596 | if (id >= 0 && id < priv(d.data)->methodCount) { | - | ||||||||||||
| 597 | int handle = priv(d.data)->methodDBusData + id*intsPerMethod; | - | ||||||||||||
| 598 | return reinterpret_cast<const int*>(d.data + d.data[handle + 1]); | - | ||||||||||||
| 599 | } | - | ||||||||||||
| 600 | return 0; | - | ||||||||||||
| 601 | } | - | ||||||||||||
| 602 | - | |||||||||||||
| 603 | int QDBusMetaObject::propertyMetaType(int id) const | - | ||||||||||||
| 604 | { | - | ||||||||||||
| 605 | - | |||||||||||||
| 606 | if (id >= 0 && id < priv(d.data)->propertyCount) { | - | ||||||||||||
| 607 | int handle = priv(d.data)->propertyDBusData + id*intsPerProperty; | - | ||||||||||||
| 608 | return d.data[handle + 1]; | - | ||||||||||||
| 609 | } | - | ||||||||||||
| 610 | return 0; | - | ||||||||||||
| 611 | } | - | ||||||||||||
| 612 | - | |||||||||||||
| 613 | - | |||||||||||||
| Switch to Source code | Preprocessed file |