QtDBus: Convert some loops to ranged for loops
Convert some loops that are using Java-style iterators into ranged for loops for better readability. Change-Id: I14f6339608d201fe06a753be236db52815cbf5c4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
4768fcf836
commit
0f37c47713
@ -37,11 +37,9 @@ QDBusAdaptorConnector *qDBusFindAdaptorConnector(QObject *obj)
|
||||
{
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
const QObjectList &children = obj->children();
|
||||
QObjectList::ConstIterator it = children.constBegin();
|
||||
QObjectList::ConstIterator end = children.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
QDBusAdaptorConnector *connector = qobject_cast<QDBusAdaptorConnector *>(*it);
|
||||
|
||||
for (QObject *child : std::as_const(obj->children())) {
|
||||
QDBusAdaptorConnector *connector = qobject_cast<QDBusAdaptorConnector *>(child);
|
||||
if (connector) {
|
||||
connector->polish();
|
||||
return connector;
|
||||
@ -227,11 +225,8 @@ void QDBusAdaptorConnector::polish()
|
||||
return; // avoid working multiple times if multiple adaptors were added
|
||||
|
||||
waitingForPolish = false;
|
||||
const QObjectList &objs = parent()->children();
|
||||
QObjectList::ConstIterator it = objs.constBegin();
|
||||
QObjectList::ConstIterator end = objs.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
QDBusAbstractAdaptor *adaptor = qobject_cast<QDBusAbstractAdaptor *>(*it);
|
||||
for (QObject *child : std::as_const(parent()->children())) {
|
||||
QDBusAbstractAdaptor *adaptor = qobject_cast<QDBusAbstractAdaptor *>(child);
|
||||
if (adaptor)
|
||||
addAdaptor(adaptor);
|
||||
}
|
||||
|
@ -222,10 +222,8 @@ inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<T> &l
|
||||
inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantList &list)
|
||||
{
|
||||
arg.beginArray(QMetaType::fromType<QDBusVariant>());
|
||||
QVariantList::ConstIterator it = list.constBegin();
|
||||
QVariantList::ConstIterator end = list.constEnd();
|
||||
for ( ; it != end; ++it)
|
||||
arg << QDBusVariant(*it);
|
||||
for (const QVariant &value : list)
|
||||
arg << QDBusVariant(value);
|
||||
arg.endArray();
|
||||
return arg;
|
||||
}
|
||||
@ -284,11 +282,9 @@ inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<Key,
|
||||
inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantMap &map)
|
||||
{
|
||||
arg.beginMap(QMetaType::fromType<QString>(), QMetaType::fromType<QDBusVariant>());
|
||||
QVariantMap::ConstIterator it = map.constBegin();
|
||||
QVariantMap::ConstIterator end = map.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
for (const auto &[key, value] : map.asKeyValueRange()) {
|
||||
arg.beginMapEntry();
|
||||
arg << it.key() << QDBusVariant(it.value());
|
||||
arg << key << QDBusVariant(value);
|
||||
arg.endMapEntry();
|
||||
}
|
||||
arg.endMap();
|
||||
@ -298,11 +294,9 @@ inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantMap &map)
|
||||
inline QDBusArgument &operator<<(QDBusArgument &arg, const QVariantHash &map)
|
||||
{
|
||||
arg.beginMap(QMetaType::fromType<QString>(), QMetaType::fromType<QDBusVariant>());
|
||||
QVariantHash::ConstIterator it = map.constBegin();
|
||||
QVariantHash::ConstIterator end = map.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
for (const auto &[key, value] : map.asKeyValueRange()) {
|
||||
arg.beginMapEntry();
|
||||
arg << it.key() << QDBusVariant(it.value());
|
||||
arg << key << QDBusVariant(value);
|
||||
arg.endMapEntry();
|
||||
}
|
||||
arg.endMap();
|
||||
|
@ -124,9 +124,7 @@ void QDBusConnectionManager::run()
|
||||
|
||||
// cleanup:
|
||||
const auto locker = qt_scoped_lock(mutex);
|
||||
for (QHash<QString, QDBusConnectionPrivate *>::const_iterator it = connectionHash.constBegin();
|
||||
it != connectionHash.constEnd(); ++it) {
|
||||
QDBusConnectionPrivate *d = it.value();
|
||||
for (QDBusConnectionPrivate *d : std::as_const(connectionHash)) {
|
||||
if (!d->ref.deref()) {
|
||||
delete d;
|
||||
} else {
|
||||
|
@ -409,17 +409,14 @@ static QObject *findChildObject(const QDBusConnectionPrivate::ObjectTreeNode *ro
|
||||
pos = (pos == -1 ? length : pos);
|
||||
auto pathComponent = QStringView{fullpath}.mid(start, pos - start);
|
||||
|
||||
const QObjectList children = obj->children();
|
||||
|
||||
// find a child with the proper name
|
||||
QObject *next = nullptr;
|
||||
QObjectList::ConstIterator it = children.constBegin();
|
||||
QObjectList::ConstIterator end = children.constEnd();
|
||||
for ( ; it != end; ++it)
|
||||
if ((*it)->objectName() == pathComponent) {
|
||||
next = *it;
|
||||
for (QObject *child : std::as_const(obj->children())) {
|
||||
if (child->objectName() == pathComponent) {
|
||||
next = child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!next)
|
||||
break;
|
||||
@ -561,7 +558,7 @@ bool QDBusConnectionPrivate::handleMessage(const QDBusMessage &amsg)
|
||||
|
||||
static void huntAndDestroy(QObject *needle, QDBusConnectionPrivate::ObjectTreeNode &haystack)
|
||||
{
|
||||
for (auto &node : haystack.children)
|
||||
for (QDBusConnectionPrivate::ObjectTreeNode &node : haystack.children)
|
||||
huntAndDestroy(needle, node);
|
||||
|
||||
auto isInactive = [](const QDBusConnectionPrivate::ObjectTreeNode &node) { return !node.isActive(); };
|
||||
@ -605,11 +602,11 @@ static void huntAndEmit(DBusConnection *connection, DBusMessage *msg,
|
||||
QObject *needle, const QDBusConnectionPrivate::ObjectTreeNode &haystack,
|
||||
bool isScriptable, bool isAdaptor, const QString &path = QString())
|
||||
{
|
||||
QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator it = haystack.children.constBegin();
|
||||
QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator end = haystack.children.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
if (it->isActive())
|
||||
huntAndEmit(connection, msg, needle, *it, isScriptable, isAdaptor, path + u'/' + it->name);
|
||||
for (const QDBusConnectionPrivate::ObjectTreeNode &node : std::as_const(haystack.children)) {
|
||||
if (node.isActive()) {
|
||||
huntAndEmit(connection, msg, needle, node, isScriptable, isAdaptor,
|
||||
path + u'/' + node.name);
|
||||
}
|
||||
}
|
||||
|
||||
if (needle == haystack.obj) {
|
||||
@ -1074,12 +1071,8 @@ QDBusConnectionPrivate::~QDBusConnectionPrivate()
|
||||
void QDBusConnectionPrivate::collectAllObjects(QDBusConnectionPrivate::ObjectTreeNode &haystack,
|
||||
QSet<QObject *> &set)
|
||||
{
|
||||
QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator it = haystack.children.begin();
|
||||
|
||||
while (it != haystack.children.end()) {
|
||||
collectAllObjects(*it, set);
|
||||
it++;
|
||||
}
|
||||
for (ObjectTreeNode &child : haystack.children)
|
||||
collectAllObjects(child, set);
|
||||
|
||||
if (haystack.obj)
|
||||
set.insert(haystack.obj);
|
||||
@ -1107,11 +1100,9 @@ void QDBusConnectionPrivate::closeConnection()
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = pendingCalls.begin(); it != pendingCalls.end(); ++it) {
|
||||
auto call = *it;
|
||||
if (!call->ref.deref()) {
|
||||
for (QDBusPendingCallPrivate *call : pendingCalls) {
|
||||
if (!call->ref.deref())
|
||||
delete call;
|
||||
}
|
||||
}
|
||||
pendingCalls.clear();
|
||||
|
||||
@ -1122,18 +1113,12 @@ void QDBusConnectionPrivate::closeConnection()
|
||||
// dangling pointer.
|
||||
QSet<QObject *> allObjects;
|
||||
collectAllObjects(rootNode, allObjects);
|
||||
SignalHookHash::const_iterator sit = signalHooks.constBegin();
|
||||
while (sit != signalHooks.constEnd()) {
|
||||
allObjects.insert(sit.value().obj);
|
||||
++sit;
|
||||
}
|
||||
for (const SignalHook &signalHook : std::as_const(signalHooks))
|
||||
allObjects.insert(signalHook.obj);
|
||||
|
||||
// now disconnect ourselves
|
||||
QSet<QObject *>::const_iterator oit = allObjects.constBegin();
|
||||
while (oit != allObjects.constEnd()) {
|
||||
(*oit)->disconnect(this);
|
||||
++oit;
|
||||
}
|
||||
for (QObject *obj : std::as_const(allObjects))
|
||||
obj->disconnect(this);
|
||||
}
|
||||
|
||||
void QDBusConnectionPrivate::handleDBusDisconnection()
|
||||
@ -1175,11 +1160,9 @@ void QDBusConnectionPrivate::doDispatch()
|
||||
if (mode == ClientMode || mode == PeerMode) {
|
||||
if (dispatchEnabled && !pendingMessages.isEmpty()) {
|
||||
// dispatch previously queued messages
|
||||
PendingMessageList::Iterator it = pendingMessages.begin();
|
||||
PendingMessageList::Iterator end = pendingMessages.end();
|
||||
for ( ; it != end; ++it) {
|
||||
qDBusDebug() << this << "dequeueing message" << *it;
|
||||
handleMessage(std::move(*it));
|
||||
for (QDBusMessage &message : pendingMessages) {
|
||||
qDBusDebug() << this << "dequeueing message" << message;
|
||||
handleMessage(std::move(message));
|
||||
}
|
||||
pendingMessages.clear();
|
||||
}
|
||||
@ -1459,14 +1442,11 @@ void QDBusConnectionPrivate::activateObject(ObjectTreeNode &node, const QDBusMes
|
||||
if (msg.interface().isEmpty()) {
|
||||
// place the call in all interfaces
|
||||
// let the first one that handles it to work
|
||||
QDBusAdaptorConnector::AdaptorMap::ConstIterator it =
|
||||
connector->adaptors.constBegin();
|
||||
QDBusAdaptorConnector::AdaptorMap::ConstIterator end =
|
||||
connector->adaptors.constEnd();
|
||||
|
||||
for ( ; it != end; ++it)
|
||||
if (activateCall(it->adaptor, newflags, msg))
|
||||
for (const QDBusAdaptorConnector::AdaptorData &adaptorData :
|
||||
std::as_const(connector->adaptors)) {
|
||||
if (activateCall(adaptorData.adaptor, newflags, msg))
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// check if we have an interface matching the name that was asked:
|
||||
QDBusAdaptorConnector::AdaptorMap::ConstIterator it;
|
||||
|
@ -76,11 +76,8 @@ static const char peerInterfaceXml[] =
|
||||
static QString generateSubObjectXml(QObject *object)
|
||||
{
|
||||
QString retval;
|
||||
const QObjectList &objs = object->children();
|
||||
QObjectList::ConstIterator it = objs.constBegin();
|
||||
QObjectList::ConstIterator end = objs.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
QString name = (*it)->objectName();
|
||||
for (const QObject *child : object->children()) {
|
||||
QString name = child->objectName();
|
||||
if (!name.isEmpty() && QDBusUtil::isValidPartOfObjectPath(name))
|
||||
retval += " <node name=\""_L1 + name + "\"/>\n"_L1;
|
||||
}
|
||||
@ -116,20 +113,22 @@ QString qDBusIntrospectObject(const QDBusConnectionPrivate::ObjectTreeNode &node
|
||||
(connector = qDBusFindAdaptorConnector(node.obj))) {
|
||||
|
||||
// trasverse every adaptor in this object
|
||||
QDBusAdaptorConnector::AdaptorMap::ConstIterator it = connector->adaptors.constBegin();
|
||||
QDBusAdaptorConnector::AdaptorMap::ConstIterator end = connector->adaptors.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
for (const QDBusAdaptorConnector::AdaptorData &adaptorData :
|
||||
std::as_const(connector->adaptors)) {
|
||||
// add the interface:
|
||||
QString ifaceXml = QDBusAbstractAdaptorPrivate::retrieveIntrospectionXml(it->adaptor);
|
||||
QString ifaceXml =
|
||||
QDBusAbstractAdaptorPrivate::retrieveIntrospectionXml(adaptorData.adaptor);
|
||||
if (ifaceXml.isEmpty()) {
|
||||
// add the interface's contents:
|
||||
ifaceXml += qDBusGenerateMetaObjectXml(QString::fromLatin1(it->interface),
|
||||
it->adaptor->metaObject(),
|
||||
&QDBusAbstractAdaptor::staticMetaObject,
|
||||
QDBusConnection::ExportScriptableContents
|
||||
| QDBusConnection::ExportNonScriptableContents);
|
||||
ifaceXml += qDBusGenerateMetaObjectXml(
|
||||
QString::fromLatin1(adaptorData.interface),
|
||||
adaptorData.adaptor->metaObject(),
|
||||
&QDBusAbstractAdaptor::staticMetaObject,
|
||||
QDBusConnection::ExportScriptableContents
|
||||
| QDBusConnection::ExportNonScriptableContents);
|
||||
|
||||
QDBusAbstractAdaptorPrivate::saveIntrospectionXml(it->adaptor, ifaceXml);
|
||||
QDBusAbstractAdaptorPrivate::saveIntrospectionXml(adaptorData.adaptor,
|
||||
ifaceXml);
|
||||
}
|
||||
|
||||
xml_data += ifaceXml;
|
||||
@ -151,13 +150,10 @@ QString qDBusIntrospectObject(const QDBusConnectionPrivate::ObjectTreeNode &node
|
||||
xml_data += generateSubObjectXml(node.obj);
|
||||
} else {
|
||||
// generate from the object tree
|
||||
QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator it =
|
||||
node.children.constBegin();
|
||||
QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator end =
|
||||
node.children.constEnd();
|
||||
for ( ; it != end; ++it)
|
||||
if (it->obj || !it->children.isEmpty())
|
||||
xml_data += " <node name=\""_L1 + it->name + "\"/>\n"_L1;
|
||||
for (const QDBusConnectionPrivate::ObjectTreeNode &node : node.children) {
|
||||
if (node.obj || !node.children.isEmpty())
|
||||
xml_data += " <node name=\""_L1 + node.name + "\"/>\n"_L1;
|
||||
}
|
||||
}
|
||||
|
||||
xml_data += "</node>\n"_L1;
|
||||
@ -195,7 +191,7 @@ QDBusMessage qDBusPropertyGet(const QDBusConnectionPrivate::ObjectTreeNode &node
|
||||
QString interface_name = msg.arguments().at(0).toString();
|
||||
QByteArray property_name = msg.arguments().at(1).toString().toUtf8();
|
||||
|
||||
QDBusAdaptorConnector *connector;
|
||||
const QDBusAdaptorConnector *connector;
|
||||
QVariant value;
|
||||
bool interfaceFound = false;
|
||||
if (node.flags & QDBusConnection::ExportAdaptors &&
|
||||
@ -204,12 +200,11 @@ QDBusMessage qDBusPropertyGet(const QDBusConnectionPrivate::ObjectTreeNode &node
|
||||
// find the class that implements interface_name or try until we've found the property
|
||||
// in case of an empty interface
|
||||
if (interface_name.isEmpty()) {
|
||||
for (QDBusAdaptorConnector::AdaptorMap::ConstIterator it = connector->adaptors.constBegin(),
|
||||
end = connector->adaptors.constEnd(); it != end; ++it) {
|
||||
const QMetaObject *mo = it->adaptor->metaObject();
|
||||
for (const QDBusAdaptorConnector::AdaptorData &adaptorData : connector->adaptors) {
|
||||
const QMetaObject *mo = adaptorData.adaptor->metaObject();
|
||||
int pidx = mo->indexOfProperty(property_name);
|
||||
if (pidx != -1) {
|
||||
value = mo->property(pidx).read(it->adaptor);
|
||||
value = mo->property(pidx).read(adaptorData.adaptor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -361,9 +356,9 @@ QDBusMessage qDBusPropertySet(const QDBusConnectionPrivate::ObjectTreeNode &node
|
||||
// find the class that implements interface_name or try until we've found the property
|
||||
// in case of an empty interface
|
||||
if (interface_name.isEmpty()) {
|
||||
for (QDBusAdaptorConnector::AdaptorMap::ConstIterator it = connector->adaptors.constBegin(),
|
||||
end = connector->adaptors.constEnd(); it != end; ++it) {
|
||||
int status = writeProperty(it->adaptor, property_name, value);
|
||||
for (const QDBusAdaptorConnector::AdaptorData &adaptorData :
|
||||
std::as_const(connector->adaptors)) {
|
||||
int status = writeProperty(adaptorData.adaptor, property_name, value);
|
||||
if (status == PropertyNotFound)
|
||||
continue;
|
||||
return propertyWriteReply(msg, interface_name, property_name, status);
|
||||
@ -401,10 +396,8 @@ QDBusMessage qDBusPropertySet(const QDBusConnectionPrivate::ObjectTreeNode &node
|
||||
// unite two QVariantMaps, but don't generate duplicate keys
|
||||
static QVariantMap &operator+=(QVariantMap &lhs, const QVariantMap &rhs)
|
||||
{
|
||||
QVariantMap::ConstIterator it = rhs.constBegin(),
|
||||
end = rhs.constEnd();
|
||||
for ( ; it != end; ++it)
|
||||
lhs.insert(it.key(), it.value());
|
||||
for (const auto &[key, value] : rhs.asKeyValueRange())
|
||||
lhs.insert(key, value);
|
||||
return lhs;
|
||||
}
|
||||
|
||||
@ -461,9 +454,10 @@ QDBusMessage qDBusPropertyGetAll(const QDBusConnectionPrivate::ObjectTreeNode &n
|
||||
|
||||
if (interface_name.isEmpty()) {
|
||||
// iterate over all interfaces
|
||||
for (QDBusAdaptorConnector::AdaptorMap::ConstIterator it = connector->adaptors.constBegin(),
|
||||
end = connector->adaptors.constEnd(); it != end; ++it) {
|
||||
result += readAllProperties(it->adaptor, QDBusConnection::ExportAllProperties);
|
||||
for (const QDBusAdaptorConnector::AdaptorData &adaptorData :
|
||||
std::as_const(connector->adaptors)) {
|
||||
result += readAllProperties(adaptorData.adaptor,
|
||||
QDBusConnection::ExportAllProperties);
|
||||
}
|
||||
} else {
|
||||
// find the class that implements interface_name
|
||||
|
@ -206,10 +206,8 @@ inline void QDBusMarshaller::append(const QStringList &arg)
|
||||
|
||||
QDBusMarshaller sub(capabilities);
|
||||
open(sub, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING);
|
||||
QStringList::ConstIterator it = arg.constBegin();
|
||||
QStringList::ConstIterator end = arg.constEnd();
|
||||
for ( ; it != end; ++it)
|
||||
sub.append(*it);
|
||||
for (const QString &s : arg)
|
||||
sub.append(s);
|
||||
// don't call sub.close(): it auto-closes
|
||||
}
|
||||
|
||||
|
@ -155,14 +155,12 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB
|
||||
d_ptr->parametersValidated = true;
|
||||
|
||||
QDBusMarshaller marshaller(capabilities);
|
||||
QVariantList::ConstIterator it = d_ptr->arguments.constBegin();
|
||||
QVariantList::ConstIterator cend = d_ptr->arguments.constEnd();
|
||||
q_dbus_message_iter_init_append(msg, &marshaller.iterator);
|
||||
if (!d_ptr->message.isEmpty())
|
||||
// prepend the error message
|
||||
marshaller.append(d_ptr->message);
|
||||
for ( ; it != cend; ++it)
|
||||
marshaller.appendVariantInternal(*it);
|
||||
for (const QVariant &argument : std::as_const(d_ptr->arguments))
|
||||
marshaller.appendVariantInternal(argument);
|
||||
|
||||
// check if everything is ok
|
||||
if (marshaller.ok)
|
||||
@ -239,10 +237,8 @@ QDBusMessage QDBusMessagePrivate::makeLocal(const QDBusConnectionPrivate &conn,
|
||||
|
||||
// determine if we are carrying any complex types
|
||||
QString computedSignature;
|
||||
QVariantList::ConstIterator it = asSent.d_ptr->arguments.constBegin();
|
||||
QVariantList::ConstIterator end = asSent.d_ptr->arguments.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
QMetaType id = it->metaType();
|
||||
for (const QVariant &argument : std::as_const(asSent.d_ptr->arguments)) {
|
||||
QMetaType id = argument.metaType();
|
||||
const char *signature = QDBusMetaType::typeToSignature(id);
|
||||
if ((id.id() != QMetaType::QStringList && id.id() != QMetaType::QByteArray &&
|
||||
qstrlen(signature) != 1) || id == QMetaType::fromType<QDBusVariant>()) {
|
||||
@ -804,12 +800,10 @@ static QDebug operator<<(QDebug dbg, QDBusMessage::MessageType t)
|
||||
static void debugVariantList(QDebug dbg, const QVariantList &list)
|
||||
{
|
||||
bool first = true;
|
||||
QVariantList::ConstIterator it = list.constBegin();
|
||||
QVariantList::ConstIterator end = list.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
for (const QVariant &elem : list) {
|
||||
if (!first)
|
||||
dbg.nospace() << ", ";
|
||||
dbg.nospace() << qPrintable(QDBusUtil::argumentToString(*it));
|
||||
dbg.nospace() << qPrintable(QDBusUtil::argumentToString(elem));
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
@ -208,10 +208,7 @@ void QDBusMetaObjectGenerator::parseMethods()
|
||||
// Add cloned methods when the remote object has return types
|
||||
//
|
||||
|
||||
QDBusIntrospection::Methods::ConstIterator method_it = data->methods.constBegin();
|
||||
QDBusIntrospection::Methods::ConstIterator method_end = data->methods.constEnd();
|
||||
for ( ; method_it != method_end; ++method_it) {
|
||||
const QDBusIntrospection::Method &m = *method_it;
|
||||
for (const QDBusIntrospection::Method &m : std::as_const(data->methods)) {
|
||||
Method mm;
|
||||
|
||||
mm.name = m.name.toLatin1();
|
||||
@ -284,10 +281,7 @@ void QDBusMetaObjectGenerator::parseMethods()
|
||||
|
||||
void QDBusMetaObjectGenerator::parseSignals()
|
||||
{
|
||||
QDBusIntrospection::Signals::ConstIterator signal_it = data->signals_.constBegin();
|
||||
QDBusIntrospection::Signals::ConstIterator signal_end = data->signals_.constEnd();
|
||||
for ( ; signal_it != signal_end; ++signal_it) {
|
||||
const QDBusIntrospection::Signal &s = *signal_it;
|
||||
for (const QDBusIntrospection::Signal &s : std::as_const(data->signals_)) {
|
||||
Method mm;
|
||||
|
||||
mm.name = s.name.toLatin1();
|
||||
@ -331,10 +325,7 @@ void QDBusMetaObjectGenerator::parseSignals()
|
||||
|
||||
void QDBusMetaObjectGenerator::parseProperties()
|
||||
{
|
||||
QDBusIntrospection::Properties::ConstIterator prop_it = data->properties.constBegin();
|
||||
QDBusIntrospection::Properties::ConstIterator prop_end = data->properties.constEnd();
|
||||
for ( ; prop_it != prop_end; ++prop_it) {
|
||||
const QDBusIntrospection::Property &p = *prop_it;
|
||||
for (const QDBusIntrospection::Property &p : std::as_const(data->properties)) {
|
||||
Property mp;
|
||||
Type type = findType(p.type.toLatin1(), p.annotations);
|
||||
if (type.id == QMetaType::UnknownType)
|
||||
@ -363,11 +354,8 @@ void QDBusMetaObjectGenerator::parseProperties()
|
||||
qsizetype QDBusMetaObjectGenerator::aggregateParameterCount(const QMap<QByteArray, Method> &map)
|
||||
{
|
||||
qsizetype sum = 0;
|
||||
QMap<QByteArray, Method>::const_iterator it;
|
||||
for (it = map.constBegin(); it != map.constEnd(); ++it) {
|
||||
const Method &m = it.value();
|
||||
for (const Method &m : map)
|
||||
sum += m.inputTypes.size() + qMax(qsizetype(1), m.outputTypes.size());
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
@ -444,11 +432,8 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
|
||||
qsizetype currentMethodMetaTypeOffset = properties.size() + 1;
|
||||
for (int x = 0; x < 2; ++x) {
|
||||
// Signals must be added before other methods, to match moc.
|
||||
QMap<QByteArray, Method> &map = (x == 0) ? signals_ : methods;
|
||||
for (QMap<QByteArray, Method>::ConstIterator it = map.constBegin();
|
||||
it != map.constEnd(); ++it) {
|
||||
const Method &mm = it.value();
|
||||
|
||||
const QMap<QByteArray, Method> &map = (x == 0) ? signals_ : methods;
|
||||
for (const Method &mm : map) {
|
||||
qsizetype argc = mm.inputTypes.size() + qMax(qsizetype(0), mm.outputTypes.size() - 1);
|
||||
|
||||
idata[offset++] = strings.enter(mm.name);
|
||||
@ -514,12 +499,9 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
|
||||
|
||||
// add each property
|
||||
signatureOffset = header->propertyDBusData;
|
||||
for (QMap<QByteArray, Property>::ConstIterator it = properties.constBegin();
|
||||
it != properties.constEnd(); ++it) {
|
||||
const Property &mp = it.value();
|
||||
|
||||
for (const auto &[name, mp] : std::as_const(properties).asKeyValueRange()) {
|
||||
// form is name, typeinfo, flags
|
||||
idata[offset++] = strings.enter(it.key()); // name
|
||||
idata[offset++] = strings.enter(name);
|
||||
Q_ASSERT(mp.type != QMetaType::UnknownType);
|
||||
idata[offset++] = mp.type;
|
||||
idata[offset++] = mp.flags;
|
||||
|
@ -117,10 +117,7 @@ int qDBusParametersForMethod(const QList<QByteArray> ¶meterTypes, QList<QMet
|
||||
metaTypes.append(QMetaType()); // return type
|
||||
int inputCount = 0;
|
||||
bool seenMessage = false;
|
||||
QList<QByteArray>::ConstIterator it = parameterTypes.constBegin();
|
||||
QList<QByteArray>::ConstIterator end = parameterTypes.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
QByteArray type = *it;
|
||||
for (QByteArray type : parameterTypes) {
|
||||
if (type.endsWith('*')) {
|
||||
errorMsg = "Pointers are not supported: "_L1 + QLatin1StringView(type);
|
||||
return -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user