QtDBus: stop using QLatin1Char constructor for creating char literals
Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. Change-Id: I48e2946c4cc8d0a6c3e0cc37e1f73510b878d574 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
2c364aef4c
commit
6e77d2a10c
@ -460,7 +460,7 @@ QDBusMessage QDBusAbstractInterface::callWithArgumentList(QDBus::CallMode mode,
|
||||
|
||||
QString m = method;
|
||||
// split out the signature from the method
|
||||
int pos = method.indexOf(QLatin1Char('.'));
|
||||
int pos = method.indexOf(u'.');
|
||||
if (pos != -1)
|
||||
m.truncate(pos);
|
||||
|
||||
|
@ -889,7 +889,7 @@ bool QDBusConnection::registerObject(const QString &path, const QString &interfa
|
||||
if (!d || !d->connection || !object || !options || !QDBusUtil::isValidObjectPath(path))
|
||||
return false;
|
||||
|
||||
auto pathComponents = QStringView{path}.split(QLatin1Char('/'));
|
||||
auto pathComponents = QStringView{path}.split(u'/');
|
||||
if (pathComponents.constLast().isEmpty())
|
||||
pathComponents.removeLast();
|
||||
QDBusWriteLocker locker(RegisterObjectAction, d);
|
||||
@ -998,7 +998,7 @@ QObject *QDBusConnection::objectRegisteredAt(const QString &path) const
|
||||
if (!d || !d->connection || !QDBusUtil::isValidObjectPath(path))
|
||||
return nullptr;
|
||||
|
||||
auto pathComponents = QStringView{path}.split(QLatin1Char('/'));
|
||||
auto pathComponents = QStringView{path}.split(u'/');
|
||||
if (pathComponents.constLast().isEmpty())
|
||||
pathComponents.removeLast();
|
||||
|
||||
|
@ -384,7 +384,7 @@ static bool findObject(const QDBusConnectionPrivate::ObjectTreeNode *root,
|
||||
}
|
||||
int start = 0;
|
||||
int length = fullpath.length();
|
||||
if (fullpath.at(0) == QLatin1Char('/'))
|
||||
if (fullpath.at(0) == u'/')
|
||||
start = 1;
|
||||
|
||||
// walk the object tree
|
||||
@ -394,7 +394,7 @@ static bool findObject(const QDBusConnectionPrivate::ObjectTreeNode *root,
|
||||
break;
|
||||
if ((node->flags & QDBusConnectionPrivate::VirtualObject) && (node->flags & QDBusConnection::SubPath))
|
||||
break;
|
||||
int end = fullpath.indexOf(QLatin1Char('/'), start);
|
||||
int end = fullpath.indexOf(u'/', start);
|
||||
end = (end == -1 ? length : end);
|
||||
QStringView pathComponent = QStringView{fullpath}.mid(start, end - start);
|
||||
|
||||
@ -437,7 +437,7 @@ static QObject *findChildObject(const QDBusConnectionPrivate::ObjectTreeNode *ro
|
||||
// we're at the correct level
|
||||
return obj;
|
||||
|
||||
int pos = fullpath.indexOf(QLatin1Char('/'), start);
|
||||
int pos = fullpath.indexOf(u'/', start);
|
||||
pos = (pos == -1 ? length : pos);
|
||||
auto pathComponent = QStringView{fullpath}.mid(start, pos - start);
|
||||
|
||||
@ -468,7 +468,7 @@ static QObject *findChildObject(const QDBusConnectionPrivate::ObjectTreeNode *ro
|
||||
static QDBusConnectionPrivate::ArgMatchRules matchArgsForService(const QString &service, QDBusServiceWatcher::WatchMode mode)
|
||||
{
|
||||
QDBusConnectionPrivate::ArgMatchRules matchArgs;
|
||||
if (service.endsWith(QLatin1Char('*'))) {
|
||||
if (service.endsWith(u'*')) {
|
||||
matchArgs.arg0namespace = service.chopped(1);
|
||||
matchArgs.args << QString();
|
||||
}
|
||||
@ -641,7 +641,7 @@ static void huntAndEmit(DBusConnection *connection, DBusMessage *msg,
|
||||
QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator end = haystack.children.constEnd();
|
||||
for ( ; it != end; ++it) {
|
||||
if (it->isActive())
|
||||
huntAndEmit(connection, msg, needle, *it, isScriptable, isAdaptor, path + QLatin1Char('/') + it->name);
|
||||
huntAndEmit(connection, msg, needle, *it, isScriptable, isAdaptor, path + u'/' + it->name);
|
||||
}
|
||||
|
||||
if (needle == haystack.obj) {
|
||||
@ -864,7 +864,7 @@ bool QDBusConnectionPrivate::activateCall(QObject* object, int flags, const QDBu
|
||||
QString cacheKey = msg.member(), signature = msg.signature();
|
||||
if (!signature.isEmpty()) {
|
||||
cacheKey.reserve(cacheKey.length() + 1 + signature.length());
|
||||
cacheKey += QLatin1Char('.');
|
||||
cacheKey += u'.';
|
||||
cacheKey += signature;
|
||||
}
|
||||
|
||||
@ -1033,7 +1033,7 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
|
||||
mode(InvalidMode),
|
||||
busService(nullptr),
|
||||
connection(nullptr),
|
||||
rootNode(QString(QLatin1Char('/'))),
|
||||
rootNode(QStringLiteral("/")),
|
||||
anonymousAuthenticationAllowed(false),
|
||||
dispatchEnabled(true),
|
||||
isAuthenticated(false)
|
||||
@ -1363,7 +1363,7 @@ bool QDBusConnectionPrivate::prepareHook(QDBusConnectionPrivate::SignalHook &hoo
|
||||
}
|
||||
key = mname;
|
||||
key.reserve(interface.length() + 1 + mname.length());
|
||||
key += QLatin1Char(':');
|
||||
key += u':';
|
||||
key += interface;
|
||||
|
||||
if (buildSignature) {
|
||||
@ -1665,8 +1665,8 @@ void QDBusConnectionPrivate::handleSignal(const QString &key, const QDBusMessage
|
||||
if (arguments.size() < 1)
|
||||
continue;
|
||||
const QString param = arguments.at(0).toString();
|
||||
if (param != hook.argumentMatch.arg0namespace
|
||||
&& !param.startsWith(hook.argumentMatch.arg0namespace + QLatin1Char('.')))
|
||||
const QStringView ns = hook.argumentMatch.arg0namespace;
|
||||
if (!param.startsWith(ns) || (param.size() != ns.size() && param[ns.size()] != u'.'))
|
||||
continue;
|
||||
}
|
||||
activateSignal(hook, msg);
|
||||
@ -1684,7 +1684,7 @@ void QDBusConnectionPrivate::handleSignal(const QDBusMessage& msg)
|
||||
|
||||
QString key = msg.member();
|
||||
key.reserve(key.length() + 1 + msg.interface().length());
|
||||
key += QLatin1Char(':');
|
||||
key += u':';
|
||||
key += msg.interface();
|
||||
|
||||
QDBusReadLocker locker(HandleSignalAction, this);
|
||||
@ -1693,7 +1693,7 @@ void QDBusConnectionPrivate::handleSignal(const QDBusMessage& msg)
|
||||
key.truncate(msg.member().length() + 1); // keep the ':'
|
||||
handleSignal(key, msg); // second try
|
||||
|
||||
key = QLatin1Char(':');
|
||||
key = u':';
|
||||
key += msg.interface();
|
||||
handleSignal(key, msg); // third try
|
||||
}
|
||||
@ -2437,7 +2437,7 @@ void QDBusConnectionPrivate::unregisterObject(const QString &path, QDBusConnecti
|
||||
if (path == QLatin1String("/")) {
|
||||
i = 0;
|
||||
} else {
|
||||
pathComponents = QStringView{path}.split(QLatin1Char('/'));
|
||||
pathComponents = QStringView{path}.split(u'/');
|
||||
i = 1;
|
||||
}
|
||||
|
||||
|
@ -411,7 +411,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
|
||||
// with a few modifications to make it cleaner
|
||||
|
||||
QString className = interface;
|
||||
className.replace(QLatin1Char('.'), QLatin1String("::"));
|
||||
className.replace(u'.', QLatin1String("::"));
|
||||
if (className.isEmpty())
|
||||
className = QLatin1String("QDBusInterface");
|
||||
|
||||
@ -589,7 +589,7 @@ void QDBusMetaObjectGenerator::writeWithoutXml(const QString &interface)
|
||||
{
|
||||
// no XML definition
|
||||
QString tmp(interface);
|
||||
tmp.replace(QLatin1Char('.'), QLatin1String("::"));
|
||||
tmp.replace(u'.', QLatin1String("::"));
|
||||
QByteArray name(tmp.toLatin1());
|
||||
|
||||
QDBusMetaObjectPrivate *header = new QDBusMetaObjectPrivate;
|
||||
|
@ -85,7 +85,7 @@ QString qDBusInterfaceFromMetaObject(const QMetaObject *mo)
|
||||
|
||||
if (interface.startsWith(QLatin1String("QDBus"))) {
|
||||
interface.prepend(QLatin1String("org.qtproject.QtDBus."));
|
||||
} else if (interface.startsWith(QLatin1Char('Q')) &&
|
||||
} else if (interface.startsWith(u'Q') &&
|
||||
interface.length() >= 2 && interface.at(1).isUpper()) {
|
||||
// assume it's Qt
|
||||
interface.prepend(QLatin1String("org.qtproject.Qt."));
|
||||
@ -93,9 +93,9 @@ QString qDBusInterfaceFromMetaObject(const QMetaObject *mo)
|
||||
QCoreApplication::instance()->applicationName().isEmpty()) {
|
||||
interface.prepend(QLatin1String("local."));
|
||||
} else {
|
||||
interface.prepend(QLatin1Char('.')).prepend(QCoreApplication::instance()->applicationName());
|
||||
interface.prepend(u'.').prepend(QCoreApplication::instance()->applicationName());
|
||||
const QString organizationDomain = QCoreApplication::instance()->organizationDomain();
|
||||
const auto domainName = QStringView{organizationDomain}.split(QLatin1Char('.'), Qt::SkipEmptyParts);
|
||||
const auto domainName = QStringView{organizationDomain}.split(u'.', Qt::SkipEmptyParts);
|
||||
if (domainName.isEmpty()) {
|
||||
interface.prepend(QLatin1String("local."));
|
||||
} else {
|
||||
@ -104,7 +104,7 @@ QString qDBusInterfaceFromMetaObject(const QMetaObject *mo)
|
||||
// then composedDomain will be equal "com.example."
|
||||
composedDomain.reserve(organizationDomain.size() + 1);
|
||||
for (auto it = domainName.rbegin(), end = domainName.rend(); it != end; ++it)
|
||||
composedDomain += *it + QLatin1Char('.');
|
||||
composedDomain += *it + u'.';
|
||||
|
||||
interface.prepend(composedDomain);
|
||||
}
|
||||
|
@ -83,15 +83,15 @@ static bool variantToString(const QVariant &arg, QString &out)
|
||||
int argType = arg.metaType().id();
|
||||
|
||||
if (argType == QMetaType::QStringList) {
|
||||
out += QLatin1Char('{');
|
||||
out += u'{';
|
||||
const QStringList list = arg.toStringList();
|
||||
for (const QString &item : list)
|
||||
out += QLatin1Char('\"') + item + QLatin1String("\", ");
|
||||
out += u'\"' + item + QLatin1String("\", ");
|
||||
if (!list.isEmpty())
|
||||
out.chop(2);
|
||||
out += QLatin1Char('}');
|
||||
out += u'}';
|
||||
} else if (argType == QMetaType::QByteArray) {
|
||||
out += QLatin1Char('{');
|
||||
out += u'{';
|
||||
QByteArray list = arg.toByteArray();
|
||||
for (int i = 0; i < list.length(); ++i) {
|
||||
out += QString::number(list.at(i));
|
||||
@ -99,9 +99,9 @@ static bool variantToString(const QVariant &arg, QString &out)
|
||||
}
|
||||
if (!list.isEmpty())
|
||||
out.chop(2);
|
||||
out += QLatin1Char('}');
|
||||
out += u'}';
|
||||
} else if (argType == QMetaType::QVariantList) {
|
||||
out += QLatin1Char('{');
|
||||
out += u'{';
|
||||
const QList<QVariant> list = arg.toList();
|
||||
for (const QVariant &item : list) {
|
||||
if (!variantToString(item, out))
|
||||
@ -110,7 +110,7 @@ static bool variantToString(const QVariant &arg, QString &out)
|
||||
}
|
||||
if (!list.isEmpty())
|
||||
out.chop(2);
|
||||
out += QLatin1Char('}');
|
||||
out += u'}';
|
||||
} else if (argType == QMetaType::Char || argType == QMetaType::Short || argType == QMetaType::Int
|
||||
|| argType == QMetaType::Long || argType == QMetaType::LongLong) {
|
||||
out += QString::number(arg.toLongLong());
|
||||
@ -127,14 +127,14 @@ static bool variantToString(const QVariant &arg, QString &out)
|
||||
const QString path = qvariant_cast<QDBusObjectPath>(arg).path();
|
||||
out += QLatin1String("[ObjectPath: ");
|
||||
out += path;
|
||||
out += QLatin1Char(']');
|
||||
out += u']';
|
||||
} else if (argType == qMetaTypeId<QDBusSignature>()) {
|
||||
out += QLatin1String("[Signature: ") + qvariant_cast<QDBusSignature>(arg).signature();
|
||||
out += QLatin1Char(']');
|
||||
out += u']';
|
||||
} else if (argType == qMetaTypeId<QDBusUnixFileDescriptor>()) {
|
||||
out += QLatin1String("[Unix FD: ");
|
||||
out += QLatin1String(qvariant_cast<QDBusUnixFileDescriptor>(arg).isValid() ? "valid" : "not valid");
|
||||
out += QLatin1Char(']');
|
||||
out += u']';
|
||||
} else if (argType == qMetaTypeId<QDBusVariant>()) {
|
||||
const QVariant v = qvariant_cast<QDBusVariant>(arg).variant();
|
||||
out += QLatin1String("[Variant");
|
||||
@ -143,17 +143,17 @@ static bool variantToString(const QVariant &arg, QString &out)
|
||||
&& vUserType != QMetaType::fromType<QDBusSignature>()
|
||||
&& vUserType != QMetaType::fromType<QDBusObjectPath>()
|
||||
&& vUserType != QMetaType::fromType<QDBusArgument>())
|
||||
out += QLatin1Char('(') + QLatin1String(v.typeName()) + QLatin1Char(')');
|
||||
out += u'(' + QLatin1String(v.typeName()) + u')';
|
||||
out += QLatin1String(": ");
|
||||
if (!variantToString(v, out))
|
||||
return false;
|
||||
out += QLatin1Char(']');
|
||||
out += u']';
|
||||
} else if (arg.canConvert<QString>()) {
|
||||
out += QLatin1Char('\"') + arg.toString() + QLatin1Char('\"');
|
||||
out += u'\"' + arg.toString() + u'\"';
|
||||
} else {
|
||||
out += QLatin1Char('[');
|
||||
out += u'[';
|
||||
out += QLatin1String(arg.typeName());
|
||||
out += QLatin1Char(']');
|
||||
out += u']';
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -167,7 +167,7 @@ bool argToString(const QDBusArgument &busArg, QString &out)
|
||||
|
||||
if (elementType != QDBusArgument::BasicType && elementType != QDBusArgument::VariantType
|
||||
&& elementType != QDBusArgument::MapEntryType)
|
||||
out += QLatin1String("[Argument: ") + busSig + QLatin1Char(' ');
|
||||
out += QLatin1String("[Argument: ") + busSig + u' ';
|
||||
|
||||
switch (elementType) {
|
||||
case QDBusArgument::BasicType:
|
||||
@ -181,12 +181,12 @@ bool argToString(const QDBusArgument &busArg, QString &out)
|
||||
break;
|
||||
case QDBusArgument::ArrayType:
|
||||
busArg.beginArray();
|
||||
out += QLatin1Char('{');
|
||||
out += u'{';
|
||||
doIterate = true;
|
||||
break;
|
||||
case QDBusArgument::MapType:
|
||||
busArg.beginMap();
|
||||
out += QLatin1Char('{');
|
||||
out += u'{';
|
||||
doIterate = true;
|
||||
break;
|
||||
case QDBusArgument::MapEntryType:
|
||||
@ -222,18 +222,18 @@ bool argToString(const QDBusArgument &busArg, QString &out)
|
||||
busArg.endStructure();
|
||||
break;
|
||||
case QDBusArgument::ArrayType:
|
||||
out += QLatin1Char('}');
|
||||
out += u'}';
|
||||
busArg.endArray();
|
||||
break;
|
||||
case QDBusArgument::MapType:
|
||||
out += QLatin1Char('}');
|
||||
out += u'}';
|
||||
busArg.endMap();
|
||||
break;
|
||||
}
|
||||
|
||||
if (elementType != QDBusArgument::BasicType && elementType != QDBusArgument::VariantType
|
||||
&& elementType != QDBusArgument::MapEntryType)
|
||||
out += QLatin1Char(']');
|
||||
out += u']';
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -372,7 +372,7 @@ namespace QDBusUtil
|
||||
if (ifaceName.isEmpty() || ifaceName.length() > DBUS_MAXIMUM_NAME_LENGTH)
|
||||
return false;
|
||||
|
||||
const auto parts = QStringView{ifaceName}.split(QLatin1Char('.'));
|
||||
const auto parts = QStringView{ifaceName}.split(u'.');
|
||||
if (parts.count() < 2)
|
||||
return false; // at least two parts
|
||||
|
||||
@ -393,10 +393,10 @@ namespace QDBusUtil
|
||||
bool isValidUniqueConnectionName(QStringView connName)
|
||||
{
|
||||
if (connName.isEmpty() || connName.length() > DBUS_MAXIMUM_NAME_LENGTH ||
|
||||
!connName.startsWith(QLatin1Char(':')))
|
||||
!connName.startsWith(u':'))
|
||||
return false;
|
||||
|
||||
const auto parts = connName.mid(1).split(QLatin1Char('.'));
|
||||
const auto parts = connName.mid(1).split(u'.');
|
||||
if (parts.count() < 1)
|
||||
return false;
|
||||
|
||||
@ -439,10 +439,10 @@ namespace QDBusUtil
|
||||
if (busName.isEmpty() || busName.length() > DBUS_MAXIMUM_NAME_LENGTH)
|
||||
return false;
|
||||
|
||||
if (busName.startsWith(QLatin1Char(':')))
|
||||
if (busName.startsWith(u':'))
|
||||
return isValidUniqueConnectionName(busName);
|
||||
|
||||
const auto parts = QStringView{busName}.split(QLatin1Char('.'));
|
||||
const auto parts = QStringView{busName}.split(u'.');
|
||||
if (parts.count() < 1)
|
||||
return false;
|
||||
|
||||
@ -515,12 +515,12 @@ namespace QDBusUtil
|
||||
if (path == QLatin1String("/"))
|
||||
return true;
|
||||
|
||||
if (!path.startsWith(QLatin1Char('/')) || path.indexOf(QLatin1String("//")) != -1 ||
|
||||
path.endsWith(QLatin1Char('/')))
|
||||
if (!path.startsWith(u'/') || path.indexOf(QLatin1String("//")) != -1 ||
|
||||
path.endsWith(u'/'))
|
||||
return false;
|
||||
|
||||
// it starts with /, so we skip the empty first part
|
||||
const auto parts = QStringView{path}.mid(1).split(QLatin1Char('/'));
|
||||
const auto parts = QStringView{path}.mid(1).split(u'/');
|
||||
for (QStringView part : parts)
|
||||
if (!isValidPartOfObjectPath(part))
|
||||
return false;
|
||||
|
@ -63,11 +63,11 @@ static inline QString typeNameToXml(const char *typeName)
|
||||
QString rich;
|
||||
rich.reserve(int(plain.size() * 1.1));
|
||||
for (int i = 0; i < plain.size(); ++i) {
|
||||
if (plain.at(i) == QLatin1Char('<'))
|
||||
if (plain.at(i) == u'<')
|
||||
rich += QLatin1String("<");
|
||||
else if (plain.at(i) == QLatin1Char('>'))
|
||||
else if (plain.at(i) == u'>')
|
||||
rich += QLatin1String(">");
|
||||
else if (plain.at(i) == QLatin1Char('&'))
|
||||
else if (plain.at(i) == u'&')
|
||||
rich += QLatin1String("&");
|
||||
else
|
||||
rich += plain.at(i);
|
||||
@ -279,7 +279,7 @@ QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo, con
|
||||
|
||||
if (interface.startsWith(QLatin1String("QDBus"))) {
|
||||
interface.prepend(QLatin1String("org.qtproject.QtDBus."));
|
||||
} else if (interface.startsWith(QLatin1Char('Q')) &&
|
||||
} else if (interface.startsWith(u'Q') &&
|
||||
interface.length() >= 2 && interface.at(1).isUpper()) {
|
||||
// assume it's Qt
|
||||
interface.prepend(QLatin1String("org.qtproject.Qt."));
|
||||
@ -287,15 +287,15 @@ QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo, con
|
||||
QCoreApplication::instance()->applicationName().isEmpty()) {
|
||||
interface.prepend(QLatin1String("local."));
|
||||
} else {
|
||||
interface.prepend(QLatin1Char('.')).prepend(QCoreApplication::instance()->applicationName());
|
||||
interface.prepend(u'.').prepend(QCoreApplication::instance()->applicationName());
|
||||
QStringList domainName =
|
||||
QCoreApplication::instance()->organizationDomain().split(QLatin1Char('.'),
|
||||
QCoreApplication::instance()->organizationDomain().split(u'.',
|
||||
Qt::SkipEmptyParts);
|
||||
if (domainName.isEmpty())
|
||||
interface.prepend(QLatin1String("local."));
|
||||
else
|
||||
for (int i = 0; i < domainName.count(); ++i)
|
||||
interface.prepend(QLatin1Char('.')).prepend(domainName.at(i));
|
||||
interface.prepend(u'.').prepend(domainName.at(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -328,9 +328,9 @@ static void readInterface(QXmlStreamReader &xml, QDBusIntrospection::Object *obj
|
||||
static void readNode(const QXmlStreamReader &xml, QDBusIntrospection::Object *objData, int nodeLevel)
|
||||
{
|
||||
const QString objName = xml.attributes().value(QLatin1String("name")).toString();
|
||||
const QString fullName = objData->path.endsWith(QLatin1Char('/'))
|
||||
const QString fullName = objData->path.endsWith(u'/')
|
||||
? (objData->path + objName)
|
||||
: QString(objData->path + QLatin1Char('/') + objName);
|
||||
: QString(objData->path + u'/' + objName);
|
||||
if (!QDBusUtil::isValidObjectPath(fullName)) {
|
||||
qDBusParserError("Invalid D-BUS object path '%s' found while parsing introspection",
|
||||
qPrintable(fullName));
|
||||
|
Loading…
Reference in New Issue
Block a user