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