diff options
80 files changed, 1825 insertions, 1667 deletions
diff --git a/src/labs/platform/qquicklabsplatformfiledialog.cpp b/src/labs/platform/qquicklabsplatformfiledialog.cpp index da70ff39a0..ccd6182192 100644 --- a/src/labs/platform/qquicklabsplatformfiledialog.cpp +++ b/src/labs/platform/qquicklabsplatformfiledialog.cpp @@ -43,6 +43,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + /*! \qmltype FileDialog \inherits Dialog @@ -556,7 +558,7 @@ QUrl QQuickLabsPlatformFileDialog::addDefaultSuffix(const QUrl &file) const const QString suffix = m_options->defaultSuffix(); // Urls with "content" scheme do not require suffixes. Such schemes are // used on Android. - const bool isContentScheme = url.scheme() == u"content"_qs; + const bool isContentScheme = url.scheme() == u"content"_s; if (!isContentScheme && !suffix.isEmpty() && !path.endsWith(QLatin1Char('/')) && path.lastIndexOf(QLatin1Char('.')) == -1) { url.setPath(path + QLatin1Char('.') + suffix); diff --git a/src/plugins/qmllint/quick/quicklintplugin.cpp b/src/plugins/qmllint/quick/quicklintplugin.cpp index 6e2d1e7382..be098f18bd 100644 --- a/src/plugins/qmllint/quick/quicklintplugin.cpp +++ b/src/plugins/qmllint/quick/quicklintplugin.cpp @@ -28,6 +28,8 @@ #include "quicklintplugin.h" +using namespace Qt::StringLiterals; + ForbiddenChildrenPropertyValidatorPass::ForbiddenChildrenPropertyValidatorPass( QQmlSA::PassManager *manager) : QQmlSA::ElementPass(manager) @@ -160,7 +162,7 @@ ControlsNativeValidatorPass::ControlsNativeValidatorPass(QQmlSA::PassManager *ma ControlElement { "TextField", QStringList { "background" } }, }; - for (const QString &module : { u"QtQuick.Controls.macOS"_qs, u"QtQuick.Controls.Windows"_qs }) { + for (const QString &module : { u"QtQuick.Controls.macOS"_s, u"QtQuick.Controls.Windows"_s }) { if (!manager->hasImportedModule(module)) continue; @@ -228,7 +230,7 @@ AnchorsValidatorPass::AnchorsValidatorPass(QQmlSA::PassManager *manager) bool AnchorsValidatorPass::shouldRun(const QQmlSA::Element &element) { return !m_item.isNull() && element->inherits(m_item) - && element->hasOwnPropertyBindings(u"anchors"_qs); + && element->hasOwnPropertyBindings(u"anchors"_s); } void AnchorsValidatorPass::run(const QQmlSA::Element &element) @@ -236,7 +238,7 @@ void AnchorsValidatorPass::run(const QQmlSA::Element &element) QQmlJS::SourceLocation left, right, hCenter; QQmlJS::SourceLocation top, bottom, vCenter; QQmlJS::SourceLocation baseline; - auto bindings = element->ownPropertyBindings(u"anchors"_qs); + auto bindings = element->ownPropertyBindings(u"anchors"_s); for (auto it = bindings.first; it != bindings.second; it++) { for (const auto &groupBinding : it->groupType()->ownPropertyBindings()) { const QString propertyName = groupBinding.propertyName(); @@ -291,11 +293,11 @@ void QmlLintQuickPlugin::registerPasses(QQmlSA::PassManager *manager, auto forbiddenChildProperty = std::make_unique<ForbiddenChildrenPropertyValidatorPass>(manager); - for (const QString &element : { u"Grid"_qs, u"Flow"_qs }) { - for (const QString &property : { u"anchors"_qs, u"x"_qs, u"y"_qs }) { + for (const QString &element : { u"Grid"_s, u"Flow"_s }) { + for (const QString &property : { u"anchors"_s, u"x"_s, u"y"_s }) { forbiddenChildProperty->addWarning( "QtQuick", element, property, - u"Cannot specify %1 for items inside %2. %2 will not function."_qs.arg( + u"Cannot specify %1 for items inside %2. %2 will not function."_s.arg( property, element)); } } @@ -359,7 +361,7 @@ void QmlLintQuickPlugin::registerPasses(QQmlSA::PassManager *manager, manager->registerElementPass(std::move(attachedPropertyType)); - if (manager->hasImportedModule(u"QtQuick.Controls.macOS"_qs) - || manager->hasImportedModule(u"QtQuick.Controls.Windows"_qs)) + if (manager->hasImportedModule(u"QtQuick.Controls.macOS"_s) + || manager->hasImportedModule(u"QtQuick.Controls.Windows"_s)) manager->registerElementPass(std::make_unique<ControlsNativeValidatorPass>(manager)); } diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 6eb8584f38..bd3e5e7bde 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -54,6 +54,8 @@ QT_USE_NAMESPACE +using namespace Qt::StringLiterals; + static const quint32 emptyStringIndex = 0; using namespace QmlIR; using namespace QQmlJS; @@ -1177,7 +1179,7 @@ void IRBuilder::setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST if (exprStmt) nodeForString = exprStmt->expression; if (asStringRef(nodeForString) == u"undefined") - binding->stringIndex = registerString(u"undefined"_qs); + binding->stringIndex = registerString(u"undefined"_s); else binding->stringIndex = emptyStringIndex; } diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 20685e42f1..9930f3e2a8 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -68,6 +68,8 @@ static const bool disable_lookups = false; QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_LOGGING_CATEGORY(lcQmlCompiler, "qt.qml.compiler"); using namespace QV4; @@ -3187,7 +3189,7 @@ bool Codegen::visit(YieldExpression *ast) Q_ASSERT(innerMostCurentFunctionContext); // yield outside function would have been rejected by parser if (!innerMostCurentFunctionContext->isGenerator) { - throwSyntaxError(ast->firstSourceLocation(), u"Yield is only valid in generator functions"_qs); + throwSyntaxError(ast->firstSourceLocation(), u"Yield is only valid in generator functions"_s); return false; } diff --git a/src/qml/doc/src/cppintegration/interactqmlfromcpp.qdoc b/src/qml/doc/src/cppintegration/interactqmlfromcpp.qdoc index 097e471593..962e17a8a2 100644 --- a/src/qml/doc/src/cppintegration/interactqmlfromcpp.qdoc +++ b/src/qml/doc/src/cppintegration/interactqmlfromcpp.qdoc @@ -181,7 +181,7 @@ You can then initialize your component in the same way as outlined in \l {Loading QML Objects from C++} except using \c {createWithInitialProperties()}: \code - component.createWithInitialProperties(QVariantMap{{u"interface"_qs, QVariant::fromValue<CppInterface *>(new CppInterface)}}); + component.createWithInitialProperties(QVariantMap{{u"interface"_s, QVariant::fromValue<CppInterface *>(new CppInterface)}}); \endcode This method is to be preferred if you know that your interface only needs to be diff --git a/src/qmlcompiler/qqmljscodegenerator.cpp b/src/qmlcompiler/qqmljscodegenerator.cpp index 4fc7631a55..b528f2c4bd 100644 --- a/src/qmlcompiler/qqmljscodegenerator.cpp +++ b/src/qmlcompiler/qqmljscodegenerator.cpp @@ -41,6 +41,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + /*! * \internal * \class QQmlJSCodeGenerator @@ -55,7 +57,7 @@ QT_BEGIN_NAMESPACE #define INJECT_TRACE_INFO(function) \ static const bool injectTraceInfo = true; \ if (injectTraceInfo) { \ - m_body += u"// "_qs + QStringLiteral(#function) + u'\n'; \ + m_body += u"// "_s + QStringLiteral(#function) + u'\n'; \ } QString QQmlJSCodeGenerator::castTargetName(const QQmlJSScope::ConstPtr &type) const @@ -74,27 +76,27 @@ QQmlJSCodeGenerator::QQmlJSCodeGenerator(const QV4::Compiler::Context *compilerC QString QQmlJSCodeGenerator::metaTypeFromType(const QQmlJSScope::ConstPtr &type) const { - return u"QMetaType::fromType<"_qs + type->augmentedInternalName() + u">()"_qs; + return u"QMetaType::fromType<"_s + type->augmentedInternalName() + u">()"_s; } QString QQmlJSCodeGenerator::metaTypeFromName(const QQmlJSScope::ConstPtr &type) const { - return u"[]() { static const auto t = QMetaType::fromName(\""_qs + return u"[]() { static const auto t = QMetaType::fromName(\""_s + QString::fromUtf8(QMetaObject::normalizedType(type->augmentedInternalName().toUtf8())) - + u"\"); return t; }()"_qs; + + u"\"); return t; }()"_s; } QString QQmlJSCodeGenerator::metaObject(const QQmlJSScope::ConstPtr &objectType) { if (!objectType->isComposite()) { - if (objectType->internalName() == u"QObject"_qs - || objectType->internalName() == u"QQmlComponent"_qs) { - return u'&' + objectType->internalName() + u"::staticMetaObject"_qs; + if (objectType->internalName() == u"QObject"_s + || objectType->internalName() == u"QQmlComponent"_s) { + return u'&' + objectType->internalName() + u"::staticMetaObject"_s; } - return metaTypeFromName(objectType) + u".metaObject()"_qs; + return metaTypeFromName(objectType) + u".metaObject()"_s; } - reject(u"retrieving the metaObject of a composite type without using an instance."_qs); + reject(u"retrieving the metaObject of a composite type without using an instance."_s); return QString(); } @@ -126,7 +128,7 @@ QQmlJSAotFunction QQmlJSCodeGenerator::run( auto ¤tRegisterNames = registerNames[registerIndex]; QString &name = currentRegisterNames[m_typeResolver->comparableType(seenType)]; if (name.isEmpty()) - name = u"r%1_%2"_qs.arg(registerIndex).arg(currentRegisterNames.count()); + name = u"r%1_%2"_s.arg(registerIndex).arg(currentRegisterNames.count()); typesForRegisters[seenType] = name; } }; @@ -146,7 +148,7 @@ QT_WARNING_POP // ensure we have m_labels for loops for (const auto loopLabel : m_context->labelInfo) - m_labels.insert(loopLabel, u"label_%1"_qs.arg(m_labels.count())); + m_labels.insert(loopLabel, u"label_%1"_s.arg(m_labels.count())); m_state.State::operator=(initialState(function)); const QByteArray byteCode = function->code; @@ -168,12 +170,12 @@ QT_WARNING_POP result.code += storedType->internalName(); if (storedType->accessSemantics() == QQmlJSScope::AccessSemantics::Reference) - result.code += u" *"_qs; + result.code += u" *"_s; else result.code += u' '; result.code += registerTypeIt.value(); - result.code += u";\n"_qs; + result.code += u";\n"_s; } } @@ -183,7 +185,7 @@ QT_WARNING_POP if (argType.isValid()) { result.argumentTypes.append(argType.storedType()->augmentedInternalName()); } else { - result.argumentTypes.append(u"void"_qs); + result.argumentTypes.append(u"void"_s); } } @@ -192,7 +194,7 @@ QT_WARNING_POP if (function->returnType->accessSemantics() == QQmlJSScope::AccessSemantics::Reference) result.returnType += u'*'; } else { - result.returnType = u"void"_qs; + result.returnType = u"void"_s; } return result; @@ -210,38 +212,38 @@ void QQmlJSCodeGenerator::generate_Ret() INJECT_TRACE_INFO(generate_Ret); if (m_function->returnType) { - const QString signalUndefined = u"aotContext->setReturnValueUndefined();\n"_qs; + const QString signalUndefined = u"aotContext->setReturnValueUndefined();\n"_s; if (!m_state.accumulatorVariableIn.isEmpty()) { const QString in = m_state.accumulatorVariableIn; if (m_typeResolver->registerIsStoredIn( m_state.accumulatorIn(), m_typeResolver->varType())) { - m_body += u"if (!"_qs + in + u".isValid())\n"_qs; - m_body += u" "_qs + signalUndefined; + m_body += u"if (!"_s + in + u".isValid())\n"_s; + m_body += u" "_s + signalUndefined; } else if (m_typeResolver->registerIsStoredIn( m_state.accumulatorIn(), m_typeResolver->jsPrimitiveType())) { - m_body += u"if ("_qs + in - + u".type() == QJSPrimitiveValue::Undefined)\n"_qs; - m_body += u" "_qs + signalUndefined; + m_body += u"if ("_s + in + + u".type() == QJSPrimitiveValue::Undefined)\n"_s; + m_body += u" "_s + signalUndefined; } else if (m_typeResolver->registerIsStoredIn( m_state.accumulatorIn(), m_typeResolver->jsValueType())) { - m_body += u"if ("_qs + in + u".isUndefined())\n"_qs; - m_body += u" "_qs + signalUndefined; + m_body += u"if ("_s + in + u".isUndefined())\n"_s; + m_body += u" "_s + signalUndefined; } - m_body += u"return "_qs + m_body += u"return "_s + conversion(m_state.accumulatorIn().storedType(), m_function->returnType, in); } else { if (m_typeResolver->equals(m_state.accumulatorIn().storedType(), m_typeResolver->voidType())) { m_body += signalUndefined; } - m_body += u"return "_qs + conversion( + m_body += u"return "_s + conversion( m_state.accumulatorIn().storedType(), m_function->returnType, QString()); } } else { - m_body += u"return"_qs; + m_body += u"return"_s; } - m_body += u";\n"_qs; + m_body += u";\n"_s; m_skipUntilNextLabel = true; } @@ -260,13 +262,13 @@ static QString toNumericString(double value) switch (qFpClassify(value)) { case FP_INFINITE: { - const QString inf = u"std::numeric_limits<double>::infinity()"_qs; + const QString inf = u"std::numeric_limits<double>::infinity()"_s; return std::signbit(value) ? (u'-' + inf) : inf; } case FP_NAN: - return u"std::numeric_limits<double>::quiet_NaN()"_qs; + return u"std::numeric_limits<double>::quiet_NaN()"_s; case FP_ZERO: - return std::signbit(value) ? u"-0.0"_qs : u"0"_qs; + return std::signbit(value) ? u"-0.0"_s : u"0"_s; default: break; } @@ -283,11 +285,11 @@ void QQmlJSCodeGenerator::generate_LoadConst(int index) m_body += m_state.accumulatorVariableOut; // ### handle other types? - m_body += u" = "_qs + conversion( + m_body += u" = "_s + conversion( m_typeResolver->intType(), m_state.accumulatorOut().storedType(), toNumericString(value)); - m_body += u";\n"_qs; + m_body += u";\n"_s; generateOutputVariantConversion(m_typeResolver->intType()); } @@ -296,9 +298,9 @@ void QQmlJSCodeGenerator::generate_LoadZero() INJECT_TRACE_INFO(generate_LoadZero); m_body += m_state.accumulatorVariableOut; - m_body += u" = "_qs + conversion( - m_typeResolver->intType(), m_state.accumulatorOut().storedType(), u"0"_qs); - m_body += u";\n"_qs; + m_body += u" = "_s + conversion( + m_typeResolver->intType(), m_state.accumulatorOut().storedType(), u"0"_s); + m_body += u";\n"_s; generateOutputVariantConversion(m_typeResolver->intType()); } @@ -307,9 +309,9 @@ void QQmlJSCodeGenerator::generate_LoadTrue() INJECT_TRACE_INFO(generate_LoadTrue); m_body += m_state.accumulatorVariableOut; - m_body += u" = "_qs + conversion( - m_typeResolver->boolType(), m_state.accumulatorOut().storedType(), u"true"_qs); - m_body += u";\n"_qs; + m_body += u" = "_s + conversion( + m_typeResolver->boolType(), m_state.accumulatorOut().storedType(), u"true"_s); + m_body += u";\n"_s; generateOutputVariantConversion(m_typeResolver->boolType()); } @@ -318,9 +320,9 @@ void QQmlJSCodeGenerator::generate_LoadFalse() INJECT_TRACE_INFO(generate_LoadFalse); m_body += m_state.accumulatorVariableOut; - m_body += u" = "_qs + conversion( - m_typeResolver->boolType(), m_state.accumulatorOut().storedType(), u"false"_qs); - m_body += u";\n"_qs; + m_body += u" = "_s + conversion( + m_typeResolver->boolType(), m_state.accumulatorOut().storedType(), u"false"_s); + m_body += u";\n"_s; generateOutputVariantConversion(m_typeResolver->boolType()); } @@ -328,10 +330,10 @@ void QQmlJSCodeGenerator::generate_LoadNull() { INJECT_TRACE_INFO(generate_LoadNull); - m_body += m_state.accumulatorVariableOut + u" = "_qs; + m_body += m_state.accumulatorVariableOut + u" = "_s; m_body += conversion(m_typeResolver->nullType(), m_state.accumulatorOut().storedType(), - u"nullptr"_qs); - m_body += u";\n"_qs; + u"nullptr"_s); + m_body += u";\n"_s; generateOutputVariantConversion(m_typeResolver->nullType()); } @@ -339,10 +341,10 @@ void QQmlJSCodeGenerator::generate_LoadUndefined() { INJECT_TRACE_INFO(generate_LoadUndefined); - m_body += m_state.accumulatorVariableOut + u" = "_qs; + m_body += m_state.accumulatorVariableOut + u" = "_s; m_body += conversion(m_typeResolver->voidType(), m_state.accumulatorOut().storedType(), QString()); - m_body += u";\n"_qs; + m_body += u";\n"_s; generateOutputVariantConversion(m_typeResolver->voidType()); } @@ -351,10 +353,10 @@ void QQmlJSCodeGenerator::generate_LoadInt(int value) INJECT_TRACE_INFO(generate_LoadInt); m_body += m_state.accumulatorVariableOut; - m_body += u" = "_qs; + m_body += u" = "_s; m_body += conversion(m_typeResolver->intType(), m_state.accumulatorOut().storedType(), QString::number(value)); - m_body += u";\n"_qs; + m_body += u";\n"_s; generateOutputVariantConversion(m_typeResolver->intType()); } @@ -375,14 +377,14 @@ void QQmlJSCodeGenerator::generate_MoveConst(int constIndex, int destTemp) QQmlJSScope::ConstPtr contained; QString input; - m_body += var + u" = "_qs; + m_body += var + u" = "_s; if (v4Value.isNull()) { contained = m_typeResolver->nullType(); } else if (v4Value.isUndefined()) { contained = m_typeResolver->voidType(); } else if (v4Value.isBoolean()) { contained = m_typeResolver->boolType(); - input = v4Value.booleanValue() ? u"true"_qs : u"false"_qs; + input = v4Value.booleanValue() ? u"true"_s : u"false"_s; } else if (v4Value.isInteger()) { contained = m_typeResolver->intType(); input = QString::number(v4Value.int_32()); @@ -390,9 +392,9 @@ void QQmlJSCodeGenerator::generate_MoveConst(int constIndex, int destTemp) contained = m_typeResolver->realType(); input = toNumericString(v4Value.doubleValue()); } else { - reject(u"unknown const type"_qs); + reject(u"unknown const type"_s); } - m_body += conversion(contained, changed, input) + u";\n"_qs; + m_body += conversion(contained, changed, input) + u";\n"_s; generateOutputVariantConversion(contained); } @@ -401,9 +403,9 @@ void QQmlJSCodeGenerator::generate_LoadReg(int reg) INJECT_TRACE_INFO(generate_LoadReg); m_body += m_state.accumulatorVariableOut; - m_body += u" = "_qs; + m_body += u" = "_s; m_body += conversion(registerType(reg), m_state.accumulatorOut(), registerVariable(reg)); - m_body += u";\n"_qs; + m_body += u";\n"_s; } void QQmlJSCodeGenerator::generate_StoreReg(int reg) @@ -416,10 +418,10 @@ void QQmlJSCodeGenerator::generate_StoreReg(int reg) if (var.isEmpty()) return; // don't store "undefined" m_body += var; - m_body += u" = "_qs; + m_body += u" = "_s; m_body += conversion(m_state.accumulatorIn(), m_state.changedRegister(), m_state.accumulatorVariableIn); - m_body += u";\n"_qs; + m_body += u";\n"_s; } void QQmlJSCodeGenerator::generate_MoveReg(int srcReg, int destReg) @@ -431,9 +433,9 @@ void QQmlJSCodeGenerator::generate_MoveReg(int srcReg, int destReg) if (destRegName.isEmpty()) return; // don't store things we cannot store. m_body += destRegName; - m_body += u" = "_qs; + m_body += u" = "_s; m_body += conversion(registerType(srcReg), m_state.changedRegister(), registerVariable(srcReg)); - m_body += u";\n"_qs; + m_body += u";\n"_s; } void QQmlJSCodeGenerator::generate_LoadImport(int index) @@ -445,7 +447,7 @@ void QQmlJSCodeGenerator::generate_LoadImport(int index) void QQmlJSCodeGenerator::generate_LoadLocal(int index) { Q_UNUSED(index); - reject(u"LoadLocal"_qs); + reject(u"LoadLocal"_s); } void QQmlJSCodeGenerator::generate_StoreLocal(int index) @@ -473,10 +475,10 @@ void QQmlJSCodeGenerator::generate_LoadRuntimeString(int stringId) INJECT_TRACE_INFO(generate_LoadRuntimeString); m_body += m_state.accumulatorVariableOut; - m_body += u" = "_qs; + m_body += u" = "_s; m_body += conversion(m_typeResolver->stringType(), m_state.accumulatorOut().storedType(), QQmlJSUtils::toLiteral(m_jsUnitGenerator->stringForIndex(stringId))); - m_body += u";\n"_qs; + m_body += u";\n"_s; generateOutputVariantConversion(m_typeResolver->stringType()); } @@ -497,7 +499,7 @@ void QQmlJSCodeGenerator::generate_LoadClosure(int value) void QQmlJSCodeGenerator::generate_LoadName(int nameIndex) { Q_UNUSED(nameIndex) - reject(u"LoadName"_qs); + reject(u"LoadName"_s); } void QQmlJSCodeGenerator::generate_LoadGlobalLookup(int index) @@ -506,10 +508,10 @@ void QQmlJSCodeGenerator::generate_LoadGlobalLookup(int index) AccumulatorConverter registers(this); - const QString lookup = u"aotContext->loadGlobalLookup("_qs + QString::number(index) - + u", &"_qs + m_state.accumulatorVariableOut + u", "_qs + const QString lookup = u"aotContext->loadGlobalLookup("_s + QString::number(index) + + u", &"_s + m_state.accumulatorVariableOut + u", "_s + metaTypeFromType(m_state.accumulatorOut().storedType()) + u')'; - const QString initialization = u"aotContext->initLoadGlobalLookup("_qs + const QString initialization = u"aotContext->initLoadGlobalLookup("_s + QString::number(index) + u')'; generateLookup(lookup, initialization); } @@ -523,20 +525,20 @@ void QQmlJSCodeGenerator::generate_LoadQmlContextPropertyLookup(int index) const int nameIndex = m_jsUnitGenerator->lookupNameIndex(index); const QString name = m_jsUnitGenerator->stringForIndex(nameIndex); if (m_state.accumulatorOut().variant() == QQmlJSRegisterContent::JavaScriptGlobal) { - m_body += m_state.accumulatorVariableOut + u" = "_qs + m_body += m_state.accumulatorVariableOut + u" = "_s + conversion( m_typeResolver->jsValueType(), m_state.accumulatorOut().storedType(), - u"aotContext->javaScriptGlobalProperty("_qs + QString::number(nameIndex) + u")") - + u";\n"_qs; + u"aotContext->javaScriptGlobalProperty("_s + QString::number(nameIndex) + u")") + + u";\n"_s; return; } const QString indexString = QString::number(index); if (m_state.accumulatorOut().variant() == QQmlJSRegisterContent::ObjectById) { - const QString lookup = u"aotContext->loadContextIdLookup("_qs - + indexString + u", "_qs + const QString lookup = u"aotContext->loadContextIdLookup("_s + + indexString + u", "_s + contentPointer(m_state.accumulatorOut(), m_state.accumulatorVariableOut) + u')'; - const QString initialization = u"aotContext->initLoadContextIdLookup("_qs + const QString initialization = u"aotContext->initLoadContextIdLookup("_s + indexString + u')'; generateLookup(lookup, initialization); return; @@ -548,12 +550,12 @@ void QQmlJSCodeGenerator::generate_LoadQmlContextPropertyLookup(int index) if (isProperty) { const auto lookupType = contentType(m_state.accumulatorOut(), m_state.accumulatorVariableOut); - const QString lookup = u"aotContext->loadScopeObjectPropertyLookup("_qs - + indexString + u", "_qs + const QString lookup = u"aotContext->loadScopeObjectPropertyLookup("_s + + indexString + u", "_s + contentPointer(m_state.accumulatorOut(), m_state.accumulatorVariableOut) + u')'; const QString initialization - = u"aotContext->initLoadScopeObjectPropertyLookup("_qs - + indexString + u", "_qs + = u"aotContext->initLoadScopeObjectPropertyLookup("_s + + indexString + u", "_s + lookupType + u')'; const QString preparation = getLookupPreparation( m_state.accumulatorOut(), m_state.accumulatorVariableOut, index); @@ -562,7 +564,7 @@ void QQmlJSCodeGenerator::generate_LoadQmlContextPropertyLookup(int index) } else if (m_state.accumulatorOut().isType() || m_state.accumulatorOut().isImportNamespace()) { generateTypeLookup(index); } else { - reject(u"lookup of %1"_qs.arg(m_state.accumulatorOut().descriptiveName())); + reject(u"lookup of %1"_s.arg(m_state.accumulatorOut().descriptiveName())); } } @@ -580,28 +582,28 @@ void QQmlJSCodeGenerator::generate_StoreNameSloppy(int nameIndex) case QQmlJSRegisterContent::ScopeProperty: case QQmlJSRegisterContent::ExtensionScopeProperty: { if (!m_typeResolver->registerContains(m_state.accumulatorIn(), type.property().type())) { - m_body += u"{\n"_qs; - m_body += u"auto converted = "_qs + m_body += u"{\n"_s; + m_body += u"auto converted = "_s + conversion(m_state.accumulatorIn(), type, m_state.accumulatorVariableIn) - + u";\n"_qs; - m_body += u"aotContext->storeNameSloppy("_qs + QString::number(nameIndex) - + u", "_qs + contentPointer(type, u"converted"_qs) - + u", "_qs + contentType(type, u"converted"_qs) + u')'; - m_body += u";\n"_qs; - m_body += u"}\n"_qs; + + u";\n"_s; + m_body += u"aotContext->storeNameSloppy("_s + QString::number(nameIndex) + + u", "_s + contentPointer(type, u"converted"_s) + + u", "_s + contentType(type, u"converted"_s) + u')'; + m_body += u";\n"_s; + m_body += u"}\n"_s; } else { - m_body += u"aotContext->storeNameSloppy("_qs + QString::number(nameIndex) - + u", "_qs + m_body += u"aotContext->storeNameSloppy("_s + QString::number(nameIndex) + + u", "_s + contentPointer(m_state.accumulatorIn(), m_state.accumulatorVariableIn) - + u", "_qs + + u", "_s + contentType(m_state.accumulatorIn(), m_state.accumulatorVariableIn) + u')'; - m_body += u";\n"_qs; + m_body += u";\n"_s; } break; } case QQmlJSRegisterContent::ScopeMethod: case QQmlJSRegisterContent::ExtensionScopeMethod: - reject(u"assignment to scope method"_qs); + reject(u"assignment to scope method"_s); break; default: Q_UNREACHABLE(); @@ -621,12 +623,12 @@ void QQmlJSCodeGenerator::generate_LoadElement(int base) const QQmlJSRegisterContent baseType = registerType(base); if (!m_typeResolver->isNumeric(m_state.accumulatorIn()) || !baseType.isList()) { - reject(u"LoadElement with non-list base type or non-numeric arguments"_qs); + reject(u"LoadElement with non-list base type or non-numeric arguments"_s); return; } if (!m_typeResolver->registerIsStoredIn(baseType, m_typeResolver->listPropertyType())) { - reject(u"indirect LoadElement"_qs); + reject(u"indirect LoadElement"_s); return; } @@ -640,16 +642,16 @@ void QQmlJSCodeGenerator::generate_LoadElement(int base) const auto elementType = m_typeResolver->globalType( m_typeResolver->genericType(m_typeResolver->containedType(valueType))); - m_body += u"if ("_qs + indexName + u" >= 0 && "_qs + indexName - + u" < "_qs + baseName + u".count(&"_qs + baseName - + u"))\n"_qs; - m_body += u" "_qs + m_state.accumulatorVariableOut + u" = "_qs + + m_body += u"if ("_s + indexName + u" >= 0 && "_s + indexName + + u" < "_s + baseName + u".count(&"_s + baseName + + u"))\n"_s; + m_body += u" "_s + m_state.accumulatorVariableOut + u" = "_s + conversion(elementType, m_state.accumulatorOut(), - baseName + u".at(&"_qs + baseName + u", "_qs - + indexName + u')') + u";\n"_qs; - m_body += u"else\n"_qs; - m_body += u" "_qs + m_state.accumulatorVariableOut + u" = {}"_qs; - m_body += u";\n"_qs; + baseName + u".at(&"_s + baseName + u", "_s + + indexName + u')') + u";\n"_s; + m_body += u"else\n"_s; + m_body += u" "_s + m_state.accumulatorVariableOut + u" = {}"_s; + m_body += u";\n"_s; } void QQmlJSCodeGenerator::generate_StoreElement(int base, int index) @@ -659,12 +661,12 @@ void QQmlJSCodeGenerator::generate_StoreElement(int base, int index) const QQmlJSRegisterContent baseType = registerType(base); if (!m_typeResolver->isNumeric(registerType(index)) || !baseType.isList()) { - reject(u"StoreElement with non-list base type or non-numeric arguments"_qs); + reject(u"StoreElement with non-list base type or non-numeric arguments"_s); return; } if (!m_typeResolver->registerIsStoredIn(baseType, m_typeResolver->listPropertyType())) { - reject(u"indirect StoreElement"_qs); + reject(u"indirect StoreElement"_s); return; } @@ -675,19 +677,19 @@ void QQmlJSCodeGenerator::generate_StoreElement(int base, int index) const auto elementType = m_typeResolver->globalType(m_typeResolver->genericType( m_typeResolver->containedType(valueType))); - m_body += u"if ("_qs + indexName + u" >= 0 && "_qs + indexName - + u" < "_qs + baseName + u".count(&"_qs + baseName - + u"))\n"_qs; - m_body += u" "_qs + baseName + u".replace(&"_qs + baseName - + u", "_qs + indexName + u", "_qs; + m_body += u"if ("_s + indexName + u" >= 0 && "_s + indexName + + u" < "_s + baseName + u".count(&"_s + baseName + + u"))\n"_s; + m_body += u" "_s + baseName + u".replace(&"_s + baseName + + u", "_s + indexName + u", "_s; m_body += conversion(m_state.accumulatorIn(), elementType, m_state.accumulatorVariableIn) - + u");\n"_qs; + + u");\n"_s; } void QQmlJSCodeGenerator::generate_LoadProperty(int nameIndex) { Q_UNUSED(nameIndex) - reject(u"LoadProperty"_qs); + reject(u"LoadProperty"_s); } void QQmlJSCodeGenerator::generate_LoadOptionalProperty(int name, int offset) @@ -708,9 +710,9 @@ void QQmlJSCodeGenerator::generateEnumLookup(int index) // If the metaenum has the value, just use it and skip all the rest. const QQmlJSMetaEnum metaEnum = m_state.accumulatorOut().enumeration(); if (metaEnum.hasValues()) { - m_body += m_state.accumulatorVariableOut + u" = "_qs + m_body += m_state.accumulatorVariableOut + u" = "_s + QString::number(metaEnum.value(enumMember)); - m_body += u";\n"_qs; + m_body += u";\n"_s; return; } @@ -720,12 +722,12 @@ void QQmlJSCodeGenerator::generateEnumLookup(int index) Q_ASSERT(!scopeType->isComposite()); const QString enumName = metaEnum.isFlag() ? metaEnum.alias() : metaEnum.name(); - const QString lookup = u"aotContext->getEnumLookup("_qs + QString::number(index) - + u", &"_qs + m_state.accumulatorVariableOut + u')'; - const QString initialization = u"aotContext->initGetEnumLookup("_qs - + QString::number(index) + u", "_qs + metaObject(scopeType) - + u", \""_qs + enumName + u"\", \""_qs + enumMember - + u"\")"_qs; + const QString lookup = u"aotContext->getEnumLookup("_s + QString::number(index) + + u", &"_s + m_state.accumulatorVariableOut + u')'; + const QString initialization = u"aotContext->initGetEnumLookup("_s + + QString::number(index) + u", "_s + metaObject(scopeType) + + u", \""_s + enumName + u"\", \""_s + enumMember + + u"\")"_s; generateLookup(lookup, initialization); } @@ -736,43 +738,43 @@ void QQmlJSCodeGenerator::generateTypeLookup(int index) const QString namespaceString = accumulatorIn.isImportNamespace() ? QString::number(accumulatorIn.importNamespace()) - : u"QQmlPrivate::AOTCompiledContext::InvalidStringId"_qs; + : u"QQmlPrivate::AOTCompiledContext::InvalidStringId"_s; switch (m_state.accumulatorOut().variant()) { case QQmlJSRegisterContent::Singleton: { - rejectIfNonQObjectOut(u"non-QObject singleton type"_qs); - const QString lookup = u"aotContext->loadSingletonLookup("_qs + indexString - + u", &"_qs + m_state.accumulatorVariableOut + u')'; - const QString initialization = u"aotContext->initLoadSingletonLookup("_qs + indexString - + u", "_qs + namespaceString + u')'; + rejectIfNonQObjectOut(u"non-QObject singleton type"_s); + const QString lookup = u"aotContext->loadSingletonLookup("_s + indexString + + u", &"_s + m_state.accumulatorVariableOut + u')'; + const QString initialization = u"aotContext->initLoadSingletonLookup("_s + indexString + + u", "_s + namespaceString + u')'; generateLookup(lookup, initialization); break; } case QQmlJSRegisterContent::ScopeModulePrefix: break; case QQmlJSRegisterContent::ScopeAttached: { - rejectIfNonQObjectOut(u"non-QObject attached type"_qs); - const QString lookup = u"aotContext->loadAttachedLookup("_qs + indexString - + u", aotContext->qmlScopeObject, &"_qs + m_state.accumulatorVariableOut + u')'; - const QString initialization = u"aotContext->initLoadAttachedLookup("_qs + indexString - + u", "_qs + namespaceString + u", aotContext->qmlScopeObject)"_qs; + rejectIfNonQObjectOut(u"non-QObject attached type"_s); + const QString lookup = u"aotContext->loadAttachedLookup("_s + indexString + + u", aotContext->qmlScopeObject, &"_s + m_state.accumulatorVariableOut + u')'; + const QString initialization = u"aotContext->initLoadAttachedLookup("_s + indexString + + u", "_s + namespaceString + u", aotContext->qmlScopeObject)"_s; generateLookup(lookup, initialization); break; } case QQmlJSRegisterContent::Script: - reject(u"script lookup"_qs); + reject(u"script lookup"_s); break; case QQmlJSRegisterContent::MetaType: { if (!m_typeResolver->registerIsStoredIn( m_state.accumulatorOut(), m_typeResolver->metaObjectType())) { // TODO: Can we trigger this somehow? // It might be impossible, but we better be safe here. - reject(u"meta-object stored in different type"_qs); + reject(u"meta-object stored in different type"_s); } - const QString lookup = u"aotContext->loadTypeLookup("_qs + indexString - + u", &"_qs + m_state.accumulatorVariableOut + u')'; - const QString initialization = u"aotContext->initLoadTypeLookup("_qs + indexString - + u", "_qs + namespaceString + u")"_qs; + const QString lookup = u"aotContext->loadTypeLookup("_s + indexString + + u", &"_s + m_state.accumulatorVariableOut + u')'; + const QString initialization = u"aotContext->initLoadTypeLookup("_s + indexString + + u", "_s + namespaceString + u")"_s; generateLookup(lookup, initialization); break; } @@ -798,7 +800,7 @@ void QQmlJSCodeGenerator::generateOutputVariantConversion(const QQmlJSScope::Con // If we could store the type directly, we would not wrap it in a QVariant. // Therefore, our best bet here is metaTypeFromName(). - m_body += changedRegisterVariable() + u".convert("_qs + metaTypeFromName(target) + u");\n"_qs; + m_body += changedRegisterVariable() + u".convert("_s + metaTypeFromName(target) + u");\n"_s; } void QQmlJSCodeGenerator::rejectIfNonQObjectOut(const QString &error) @@ -814,7 +816,7 @@ void QQmlJSCodeGenerator::generate_GetLookup(int index) INJECT_TRACE_INFO(generate_GetLookup); if (m_state.accumulatorOut().isMethod()) { - reject(u"lookup of function property."_qs); + reject(u"lookup of function property."_s); return; } @@ -822,10 +824,10 @@ void QQmlJSCodeGenerator::generate_GetLookup(int index) Q_ASSERT(m_state.accumulatorOut().variant() == QQmlJSRegisterContent::ObjectModulePrefix); // If we have an object module prefix, we need to pass through the original object. if (m_state.accumulatorVariableIn != m_state.accumulatorVariableOut) { - m_body += m_state.accumulatorVariableOut + u" = "_qs + m_body += m_state.accumulatorVariableOut + u" = "_s + conversion(m_state.accumulatorIn(), m_state.accumulatorOut(), m_state.accumulatorVariableIn) - + u";\n"_qs; + + u";\n"_s; } return; } @@ -840,7 +842,7 @@ void QQmlJSCodeGenerator::generate_GetLookup(int index) const QString indexString = QString::number(index); const QString namespaceString = m_state.accumulatorIn().isImportNamespace() ? QString::number(m_state.accumulatorIn().importNamespace()) - : u"QQmlPrivate::AOTCompiledContext::InvalidStringId"_qs; + : u"QQmlPrivate::AOTCompiledContext::InvalidStringId"_s; const auto accumulatorIn = m_state.accumulatorIn(); const bool isReferenceType = (accumulatorIn.storedType()->accessSemantics() == QQmlJSScope::AccessSemantics::Reference); @@ -852,15 +854,15 @@ void QQmlJSCodeGenerator::generate_GetLookup(int index) // type must be a QObject, but we cannot construct the inheritance chain. Then we // store it in a generic type. Technically we could even convert it to QObject*, but // that would be expensive. - reject(u"attached object for non-QObject type"_qs); + reject(u"attached object for non-QObject type"_s); } - rejectIfNonQObjectOut(u"non-QObject attached type"_qs); + rejectIfNonQObjectOut(u"non-QObject attached type"_s); - const QString lookup = u"aotContext->loadAttachedLookup("_qs + indexString - + u", "_qs + m_state.accumulatorVariableIn - + u", &"_qs + m_state.accumulatorVariableOut + u')'; - const QString initialization = u"aotContext->initLoadAttachedLookup("_qs - + indexString + u", "_qs + namespaceString + u", "_qs + const QString lookup = u"aotContext->loadAttachedLookup("_s + indexString + + u", "_s + m_state.accumulatorVariableIn + + u", &"_s + m_state.accumulatorVariableOut + u')'; + const QString initialization = u"aotContext->initLoadAttachedLookup("_s + + indexString + u", "_s + namespaceString + u", "_s + m_state.accumulatorVariableIn + u')'; generateLookup(lookup, initialization); return; @@ -878,45 +880,45 @@ void QQmlJSCodeGenerator::generate_GetLookup(int index) Q_ASSERT(m_state.accumulatorOut().isProperty()); if (isReferenceType) { - const QString lookup = u"aotContext->getObjectLookup("_qs + indexString - + u", "_qs + m_state.accumulatorVariableIn + u", "_qs + const QString lookup = u"aotContext->getObjectLookup("_s + indexString + + u", "_s + m_state.accumulatorVariableIn + u", "_s + contentPointer(m_state.accumulatorOut(), m_state.accumulatorVariableOut) + u')'; - const QString initialization = u"aotContext->initGetObjectLookup("_qs - + indexString + u", "_qs + m_state.accumulatorVariableIn - + u", "_qs + contentType(m_state.accumulatorOut(), m_state.accumulatorVariableOut) + const QString initialization = u"aotContext->initGetObjectLookup("_s + + indexString + u", "_s + m_state.accumulatorVariableIn + + u", "_s + contentType(m_state.accumulatorOut(), m_state.accumulatorVariableOut) + u')'; const QString preparation = getLookupPreparation( m_state.accumulatorOut(), m_state.accumulatorVariableOut, index); generateLookup(lookup, initialization, preparation); } else if (m_typeResolver->registerIsStoredIn(accumulatorIn, m_typeResolver->listPropertyType()) - && m_jsUnitGenerator->lookupName(index) == u"length"_qs) { - m_body += m_state.accumulatorVariableOut + u" = "_qs; + && m_jsUnitGenerator->lookupName(index) == u"length"_s) { + m_body += m_state.accumulatorVariableOut + u" = "_s; m_body += conversion( m_typeResolver->globalType(m_typeResolver->intType()), m_state.accumulatorOut(), - m_state.accumulatorVariableIn + u".count("_qs + u'&' + m_state.accumulatorVariableIn + u".count("_s + u'&' + m_state.accumulatorVariableIn + u')'); - m_body += u";\n"_qs; + m_body += u";\n"_s; } else if ((m_typeResolver->registerIsStoredIn(accumulatorIn, m_typeResolver->stringType()) || accumulatorIn.storedType()->accessSemantics() == QQmlJSScope::AccessSemantics::Sequence) - && m_jsUnitGenerator->lookupName(index) == u"length"_qs) { - m_body += m_state.accumulatorVariableOut + u" = "_qs + && m_jsUnitGenerator->lookupName(index) == u"length"_s) { + m_body += m_state.accumulatorVariableOut + u" = "_s + conversion(m_typeResolver->globalType(m_typeResolver->intType()), m_state.accumulatorOut(), - m_state.accumulatorVariableIn + u".length()"_qs) - + u";\n"_qs; + m_state.accumulatorVariableIn + u".length()"_s) + + u";\n"_s; } else if (m_typeResolver->registerIsStoredIn(accumulatorIn, m_typeResolver->jsValueType())) { - reject(u"lookup in QJSValue"_qs); + reject(u"lookup in QJSValue"_s); } else { - const QString lookup = u"aotContext->getValueLookup("_qs + indexString - + u", "_qs + contentPointer(m_state.accumulatorIn(), + const QString lookup = u"aotContext->getValueLookup("_s + indexString + + u", "_s + contentPointer(m_state.accumulatorIn(), m_state.accumulatorVariableIn) - + u", "_qs + contentPointer(m_state.accumulatorOut(), + + u", "_s + contentPointer(m_state.accumulatorOut(), m_state.accumulatorVariableOut) + u')'; - const QString initialization = u"aotContext->initGetValueLookup("_qs - + indexString + u", "_qs - + metaObject(m_state.accumulatorOut().scopeType()) + u", "_qs + const QString initialization = u"aotContext->initGetValueLookup("_s + + indexString + u", "_s + + metaObject(m_state.accumulatorOut().scopeType()) + u", "_s + contentType(m_state.accumulatorOut(), m_state.accumulatorVariableOut) + u')'; const QString preparation = getLookupPreparation( m_state.accumulatorOut(), m_state.accumulatorVariableOut, index); @@ -935,7 +937,7 @@ void QQmlJSCodeGenerator::generate_StoreProperty(int nameIndex, int baseReg) { Q_UNUSED(nameIndex) Q_UNUSED(baseReg) - reject(u"StoreProperty"_qs); + reject(u"StoreProperty"_s); } QString QQmlJSCodeGenerator::setLookupPreparation( @@ -945,9 +947,9 @@ QString QQmlJSCodeGenerator::setLookupPreparation( return QString(); if (m_typeResolver->registerIsStoredIn(content, m_typeResolver->varType())) { - return u"const QMetaType argType = aotContext->lookupResultMetaType("_qs - + QString::number(lookup) + u");\n"_qs - + u"if (argType.isValid())\n "_qs + arg + u".convert(argType)"; + return u"const QMetaType argType = aotContext->lookupResultMetaType("_s + + QString::number(lookup) + u");\n"_s + + u"if (argType.isValid())\n "_s + arg + u".convert(argType)"; } // TODO: We could make sure they're compatible, for example QObject pointers. return QString(); @@ -967,23 +969,23 @@ void QQmlJSCodeGenerator::generate_SetLookup(int index, int baseReg) m_typeResolver->genericType(specific.storedType())); const QString object = registerVariable(baseReg); - m_body += u"{\n"_qs; + m_body += u"{\n"_s; QString variableIn; QString variableInType; QString preparation; QString argType; if (!m_typeResolver->registerContains( m_state.accumulatorIn(), m_typeResolver->containedType(property))) { - m_body += u"auto converted = "_qs + m_body += u"auto converted = "_s + conversion(m_state.accumulatorIn(), property, m_state.accumulatorVariableIn) - + u";\n"_qs; - variableIn = contentPointer(property, u"converted"_qs); - variableInType = contentType(property, u"converted"_qs); - preparation = setLookupPreparation(property, u"converted"_qs, index); + + u";\n"_s; + variableIn = contentPointer(property, u"converted"_s); + variableInType = contentType(property, u"converted"_s); + preparation = setLookupPreparation(property, u"converted"_s, index); if (preparation.isEmpty()) - argType = contentType(property, u"converted"_qs); + argType = contentType(property, u"converted"_s); else - argType = u"argType"_qs; + argType = u"argType"_s; } else { variableIn = contentPointer(property, m_state.accumulatorVariableIn); variableInType = contentType(property, m_state.accumulatorVariableIn); @@ -992,35 +994,35 @@ void QQmlJSCodeGenerator::generate_SetLookup(int index, int baseReg) switch (callBase.storedType()->accessSemantics()) { case QQmlJSScope::AccessSemantics::Reference: { - const QString lookup = u"aotContext->setObjectLookup("_qs + indexString - + u", "_qs + object + u", "_qs + variableIn + u')'; - const QString initialization = u"aotContext->initSetObjectLookup("_qs - + indexString + u", "_qs + object + u", "_qs + argType + u')'; + const QString lookup = u"aotContext->setObjectLookup("_s + indexString + + u", "_s + object + u", "_s + variableIn + u')'; + const QString initialization = u"aotContext->initSetObjectLookup("_s + + indexString + u", "_s + object + u", "_s + argType + u')'; generateLookup(lookup, initialization, preparation); break; } case QQmlJSScope::AccessSemantics::Sequence: { const QString propertyName = m_jsUnitGenerator->lookupName(index); - if (propertyName != u"length"_qs) { - reject(u"setting non-length property on a sequence type"_qs); + if (propertyName != u"length"_s) { + reject(u"setting non-length property on a sequence type"_s); break; } if (!m_typeResolver->registerIsStoredIn(callBase, m_typeResolver->listPropertyType())) { - reject(u"SetLookup on sequence types (because of missing write-back)"_qs); + reject(u"SetLookup on sequence types (because of missing write-back)"_s); break; } // We can resize without write back on a list property because it's actually a reference. - m_body += u"const int begin = "_qs + object + u".count(&" + object + u");\n"_qs; - m_body += u"const int end = "_qs + m_body += u"const int begin = "_s + object + u".count(&" + object + u");\n"_s; + m_body += u"const int end = "_s + (variableIn.startsWith(u'&') ? variableIn.mid(1) : (u'*' + variableIn)) - + u";\n"_qs; - m_body += u"for (int i = begin; i < end; ++i)\n"_qs; - m_body += u" "_qs + object + u".append(&"_qs + object + u", nullptr);\n"_qs; - m_body += u"for (int i = begin; i > end; --i)\n"_qs; - m_body += u" "_qs + object + u".removeLast(&"_qs + object + u')' - + u";\n"_qs; + + u";\n"_s; + m_body += u"for (int i = begin; i < end; ++i)\n"_s; + m_body += u" "_s + object + u".append(&"_s + object + u", nullptr);\n"_s; + m_body += u"for (int i = begin; i > end; --i)\n"_s; + m_body += u" "_s + object + u".removeLast(&"_s + object + u')' + + u";\n"_s; break; } case QQmlJSScope::AccessSemantics::Value: { @@ -1030,15 +1032,15 @@ void QQmlJSCodeGenerator::generate_SetLookup(int index, int baseReg) const QQmlJSRegisterContent property = specific.storedIn( m_typeResolver->genericType(specific.storedType())); - const QString lookup = u"aotContext->setValueLookup("_qs + indexString - + u", "_qs + contentPointer(registerType(baseReg), object) - + u", "_qs + variableIn + u')'; - const QString initialization = u"aotContext->initSetValueLookup("_qs - + indexString + u", "_qs + metaObject(property.scopeType()) - + u", "_qs + contentType(registerType(baseReg), object) + u')'; + const QString lookup = u"aotContext->setValueLookup("_s + indexString + + u", "_s + contentPointer(registerType(baseReg), object) + + u", "_s + variableIn + u')'; + const QString initialization = u"aotContext->initSetValueLookup("_s + + indexString + u", "_s + metaObject(property.scopeType()) + + u", "_s + contentType(registerType(baseReg), object) + u')'; generateLookup(lookup, initialization, preparation); - reject(u"SetLookup on value types (because of missing write-back)"_qs); + reject(u"SetLookup on value types (because of missing write-back)"_s); break; } case QQmlJSScope::AccessSemantics::None: @@ -1046,7 +1048,7 @@ void QQmlJSCodeGenerator::generate_SetLookup(int index, int baseReg) break; } - m_body += u"}\n"_qs; + m_body += u"}\n"_s; } void QQmlJSCodeGenerator::generate_LoadSuperProperty(int property) @@ -1085,14 +1087,14 @@ QString QQmlJSCodeGenerator::argumentsList(int argc, int argv, QString *outVar) if (m_state.changedRegisterIndex() == InvalidRegister || m_typeResolver->registerContains( m_state.accumulatorOut(), m_typeResolver->voidType())) { - types = u"QMetaType()"_qs; - args = u"nullptr"_qs; + types = u"QMetaType()"_s; + args = u"nullptr"_s; } else { - *outVar = u"callResult"_qs; + *outVar = u"callResult"_s; const QQmlJSScope::ConstPtr outType = m_state.accumulatorOut().storedType(); m_body += outType->internalName(); if (outType->accessSemantics() == QQmlJSScope::AccessSemantics::Reference) - m_body += u" *"_qs; + m_body += u" *"_s; else m_body += u' '; m_body += *outVar + u";\n"; @@ -1105,22 +1107,22 @@ QString QQmlJSCodeGenerator::argumentsList(int argc, int argv, QString *outVar) const QQmlJSRegisterContent content = registerType(argv + i); const QString var = registerVariable(argv + i); if (m_typeResolver->registerIsStoredIn(content, m_typeResolver->jsPrimitiveType())) { - QString argName = u"arg"_qs + QString::number(i); - conversions += u"QVariant "_qs + argName + u" = "_qs - + conversion(content.storedType(), m_typeResolver->varType(), var) + u";\n"_qs; - args += u", "_qs + argName + u".data()"_qs; - types += u", "_qs + argName + u".metaType()"_qs; + QString argName = u"arg"_s + QString::number(i); + conversions += u"QVariant "_s + argName + u" = "_s + + conversion(content.storedType(), m_typeResolver->varType(), var) + u";\n"_s; + args += u", "_s + argName + u".data()"_s; + types += u", "_s + argName + u".metaType()"_s; } else if (m_typeResolver->registerIsStoredIn(content, m_typeResolver->varType())) { - args += u", "_qs + var + u".data()"_qs; - types += u", "_qs + var + u".metaType()"_qs; + args += u", "_s + var + u".data()"_s; + types += u", "_s + var + u".metaType()"_s; } else { - args += u", &"_qs + var; - types += u", "_qs + metaTypeFromType(content.storedType()); + args += u", &"_s + var; + types += u", "_s + metaTypeFromType(content.storedType()); } } return conversions - + u"void *args[] = { "_qs + args + u" };\n"_qs - + u"const QMetaType types[] = { "_qs + types + u" };\n"_qs; + + u"void *args[] = { "_s + args + u" };\n"_s + + u"const QMetaType types[] = { "_s + types + u" };\n"_s; } void QQmlJSCodeGenerator::generateMoveOutVar(const QString &outVar) @@ -1128,7 +1130,7 @@ void QQmlJSCodeGenerator::generateMoveOutVar(const QString &outVar) if (m_state.accumulatorVariableOut.isEmpty() || outVar.isEmpty()) return; - m_body += m_state.accumulatorVariableOut + u" = "_qs; + m_body += m_state.accumulatorVariableOut + u" = "_s; m_body += u"std::move(" + outVar + u");\n"; } @@ -1155,126 +1157,126 @@ void QQmlJSCodeGenerator::generate_CallProperty(int nameIndex, int baseReg, int Q_UNUSED(baseReg); Q_UNUSED(argc); Q_UNUSED(argv); - reject(u"CallProperty"_qs); + reject(u"CallProperty"_s); } bool QQmlJSCodeGenerator::inlineMathMethod(const QString &name, int argc, int argv) { - addInclude(u"cmath"_qs); - addInclude(u"limits"_qs); - addInclude(u"qalgorithms.h"_qs); - addInclude(u"qrandom.h"_qs); + addInclude(u"cmath"_s); + addInclude(u"limits"_s); + addInclude(u"qalgorithms.h"_s); + addInclude(u"qrandom.h"_s); // If the result is not stored, we don't need to generate any code. All the math methods are // conceptually pure functions. if (m_state.changedRegisterIndex() != Accumulator) return true; - m_body += u"{\n"_qs; + m_body += u"{\n"_s; for (int i = 0; i < argc; ++i) { - m_body += u"const double arg%1 = "_qs.arg(i + 1) + conversion( + m_body += u"const double arg%1 = "_s.arg(i + 1) + conversion( registerType(argv + i).storedType(), m_typeResolver->realType(), registerVariable(argv + i)) - + u";\n"_qs; + + u";\n"_s; } - const QString qNaN = u"std::numeric_limits<double>::quiet_NaN()"_qs; - const QString inf = u"std::numeric_limits<double>::infinity()"_qs; - m_body += m_state.accumulatorVariableOut + u" = "_qs; + const QString qNaN = u"std::numeric_limits<double>::quiet_NaN()"_s; + const QString inf = u"std::numeric_limits<double>::infinity()"_s; + m_body += m_state.accumulatorVariableOut + u" = "_s; QString expression; if (name == u"abs" && argc == 1) { - expression = u"(qIsNull(arg1) ? 0 : (arg1 < 0.0 ? -arg1 : arg1))"_qs; - } else if (name == u"acos"_qs && argc == 1) { - expression = u"arg1 > 1.0 ? %1 : std::acos(arg1)"_qs.arg(qNaN); - } else if (name == u"acosh"_qs && argc == 1) { - expression = u"arg1 < 1.0 ? %1 : std::acosh(arg1)"_qs.arg(qNaN); - } else if (name == u"asin"_qs && argc == 1) { - expression = u"arg1 > 1.0 ? %1 : std::asin(arg1)"_qs.arg(qNaN); - } else if (name == u"asinh"_qs && argc == 1) { - expression = u"qIsNull(arg1) ? arg1 : std::asinh(arg1)"_qs; - } else if (name == u"atan"_qs && argc == 1) { - expression = u"qIsNull(arg1) ? arg1 : std::atan(arg1)"_qs; - } else if (name == u"atanh"_qs && argc == 1) { - expression = u"qIsNull(arg1) ? arg1 : std::atanh(arg1)"_qs; - } else if (name == u"atan2"_qs) { + expression = u"(qIsNull(arg1) ? 0 : (arg1 < 0.0 ? -arg1 : arg1))"_s; + } else if (name == u"acos"_s && argc == 1) { + expression = u"arg1 > 1.0 ? %1 : std::acos(arg1)"_s.arg(qNaN); + } else if (name == u"acosh"_s && argc == 1) { + expression = u"arg1 < 1.0 ? %1 : std::acosh(arg1)"_s.arg(qNaN); + } else if (name == u"asin"_s && argc == 1) { + expression = u"arg1 > 1.0 ? %1 : std::asin(arg1)"_s.arg(qNaN); + } else if (name == u"asinh"_s && argc == 1) { + expression = u"qIsNull(arg1) ? arg1 : std::asinh(arg1)"_s; + } else if (name == u"atan"_s && argc == 1) { + expression = u"qIsNull(arg1) ? arg1 : std::atan(arg1)"_s; + } else if (name == u"atanh"_s && argc == 1) { + expression = u"qIsNull(arg1) ? arg1 : std::atanh(arg1)"_s; + } else if (name == u"atan2"_s) { // TODO: complicated return false; - } else if (name == u"cbrt"_qs && argc == 1) { - expression = u"std::cbrt(arg1)"_qs; - } else if (name == u"ceil"_qs && argc == 1) { - expression = u"(arg1 < 0.0 && arg1 > -1.0) ? std::copysign(0.0, -1.0) : std::ceil(arg1)"_qs; - } else if (name == u"clz32"_qs && argc == 1) { - expression = u"qint32(qCountLeadingZeroBits(quint32(QJSNumberCoercion::toInteger(arg1))))"_qs; - } else if (name == u"cos"_qs && argc == 1) { - expression = u"std::cos(arg1)"_qs; - } else if (name == u"cosh"_qs && argc == 1) { - expression = u"std::cosh(arg1)"_qs; - } else if (name == u"exp"_qs && argc == 1) { + } else if (name == u"cbrt"_s && argc == 1) { + expression = u"std::cbrt(arg1)"_s; + } else if (name == u"ceil"_s && argc == 1) { + expression = u"(arg1 < 0.0 && arg1 > -1.0) ? std::copysign(0.0, -1.0) : std::ceil(arg1)"_s; + } else if (name == u"clz32"_s && argc == 1) { + expression = u"qint32(qCountLeadingZeroBits(quint32(QJSNumberCoercion::toInteger(arg1))))"_s; + } else if (name == u"cos"_s && argc == 1) { + expression = u"std::cos(arg1)"_s; + } else if (name == u"cosh"_s && argc == 1) { + expression = u"std::cosh(arg1)"_s; + } else if (name == u"exp"_s && argc == 1) { expression = u"std::isinf(arg1) " "? (std::copysign(1.0, arg1) == -1 ? 0.0 : %1) " - ": std::exp(arg1)"_qs.arg(inf); - } else if (name == u"expm1"_qs) { + ": std::exp(arg1)"_s.arg(inf); + } else if (name == u"expm1"_s) { // TODO: complicated return false; - } else if (name == u"floor"_qs && argc == 1) { - expression = u"std::floor(arg1)"_qs; - } else if (name == u"fround"_qs && argc == 1) { + } else if (name == u"floor"_s && argc == 1) { + expression = u"std::floor(arg1)"_s; + } else if (name == u"fround"_s && argc == 1) { expression = u"(std::isnan(arg1) || std::isinf(arg1) || qIsNull(arg1)) " "? arg1 " - ": double(float(arg1))"_qs; - } else if (name == u"hypot"_qs) { + ": double(float(arg1))"_s; + } else if (name == u"hypot"_s) { // TODO: complicated return false; - } else if (name == u"imul"_qs && argc == 2) { + } else if (name == u"imul"_s && argc == 2) { expression = u"qint32(quint32(QJSNumberCoercion::toInteger(arg1)) " - "* quint32(QJSNumberCoercion::toInteger(arg2)))"_qs; - } else if (name == u"log"_qs && argc == 1) { - expression = u"arg1 < 0.0 ? %1 : std::log(arg1)"_qs.arg(qNaN); - } else if (name == u"log10"_qs && argc == 1) { - expression = u"arg1 < 0.0 ? %1 : std::log10(arg1)"_qs.arg(qNaN); - } else if (name == u"log1p"_qs && argc == 1) { - expression = u"arg1 < -1.0 ? %1 : std::log1p(arg1)"_qs.arg(qNaN); - } else if (name == u"log2"_qs && argc == 1) { - expression = u"arg1 < -0.0 ? %1 : std::log2(arg1)"_qs.arg(qNaN); - } else if (name == u"max"_qs && argc == 2) { + "* quint32(QJSNumberCoercion::toInteger(arg2)))"_s; + } else if (name == u"log"_s && argc == 1) { + expression = u"arg1 < 0.0 ? %1 : std::log(arg1)"_s.arg(qNaN); + } else if (name == u"log10"_s && argc == 1) { + expression = u"arg1 < 0.0 ? %1 : std::log10(arg1)"_s.arg(qNaN); + } else if (name == u"log1p"_s && argc == 1) { + expression = u"arg1 < -1.0 ? %1 : std::log1p(arg1)"_s.arg(qNaN); + } else if (name == u"log2"_s && argc == 1) { + expression = u"arg1 < -0.0 ? %1 : std::log2(arg1)"_s.arg(qNaN); + } else if (name == u"max"_s && argc == 2) { expression = u"(qIsNull(arg2) && qIsNull(arg1) && std::copysign(1.0, arg2) == 1) " "? arg2 " - ": ((arg2 > arg1 || std::isnan(arg2)) ? arg2 : arg1)"_qs; - } else if (name == u"min"_qs && argc == 2) { + ": ((arg2 > arg1 || std::isnan(arg2)) ? arg2 : arg1)"_s; + } else if (name == u"min"_s && argc == 2) { expression = u"(qIsNull(arg2) && qIsNull(arg1) && std::copysign(1.0, arg2) == -1) " "? arg2 " - ": ((arg2 < arg1 || std::isnan(arg2)) ? arg2 : arg1)"_qs; - } else if (name == u"pow"_qs) { + ": ((arg2 < arg1 || std::isnan(arg2)) ? arg2 : arg1)"_s; + } else if (name == u"pow"_s) { // TODO: complicated return false; - } else if (name == u"random"_qs && argc == 0) { - expression = u"QRandomGenerator::global()->generateDouble()"_qs; - } else if (name == u"round"_qs && argc == 1) { + } else if (name == u"random"_s && argc == 0) { + expression = u"QRandomGenerator::global()->generateDouble()"_s; + } else if (name == u"round"_s && argc == 1) { expression = u"std::isfinite(arg1) " "? ((arg1 < 0.5 && arg1 >= -0.5) " "? std::copysign(0.0, arg1) " ": std::floor(arg1 + 0.5)) " - ": arg1"_qs; - } else if (name == u"sign"_qs && argc == 1) { + ": arg1"_s; + } else if (name == u"sign"_s && argc == 1) { expression = u"std::isnan(arg1) " "? %1 " ": (qIsNull(arg1) " "? arg1 " - ": (std::signbit(arg1) ? -1.0 : 1.0))"_qs.arg(qNaN); - } else if (name == u"sin"_qs && argc == 1) { - expression = u"qIsNull(arg1) ? arg1 : std::sin(arg1)"_qs; - } else if (name == u"sinh"_qs && argc == 1) { - expression = u"qIsNull(arg1) ? arg1 : std::sinh(arg1)"_qs; - } else if (name == u"sqrt"_qs && argc == 1) { - expression = u"std::sqrt(arg1)"_qs; - } else if (name == u"tan"_qs && argc == 1) { - expression = u"qIsNull(arg1) ? arg1 : std::tan(arg1)"_qs; - } else if (name == u"tanh"_qs && argc == 1) { - expression = u"qIsNull(arg1) ? arg1 : std::tanh(arg1)"_qs; - } else if (name == u"trunc"_qs && argc == 1) { - expression = u"std::trunc(arg1)"_qs; + ": (std::signbit(arg1) ? -1.0 : 1.0))"_s.arg(qNaN); + } else if (name == u"sin"_s && argc == 1) { + expression = u"qIsNull(arg1) ? arg1 : std::sin(arg1)"_s; + } else if (name == u"sinh"_s && argc == 1) { + expression = u"qIsNull(arg1) ? arg1 : std::sinh(arg1)"_s; + } else if (name == u"sqrt"_s && argc == 1) { + expression = u"std::sqrt(arg1)"_s; + } else if (name == u"tan"_s && argc == 1) { + expression = u"qIsNull(arg1) ? arg1 : std::tan(arg1)"_s; + } else if (name == u"tanh"_s && argc == 1) { + expression = u"qIsNull(arg1) ? arg1 : std::tanh(arg1)"_s; + } else if (name == u"trunc"_s && argc == 1) { + expression = u"std::trunc(arg1)"_s; } else { return false; } @@ -1282,8 +1284,8 @@ bool QQmlJSCodeGenerator::inlineMathMethod(const QString &name, int argc, int ar m_body += conversion( m_typeResolver->realType(), m_state.accumulatorOut().storedType(), expression); - m_body += u";\n"_qs; - m_body += u"}\n"_qs; + m_body += u";\n"_s; + m_body += u"}\n"_s; return true; } @@ -1292,7 +1294,7 @@ void QQmlJSCodeGenerator::generate_CallPropertyLookup(int index, int base, int a INJECT_TRACE_INFO(generate_CallPropertyLookup); if (m_state.accumulatorOut().variant() == QQmlJSRegisterContent::JavaScriptReturnValue) - reject(u"call to untyped JavaScript function"_qs); + reject(u"call to untyped JavaScript function"_s); AccumulatorConverter registers(this); @@ -1305,24 +1307,24 @@ void QQmlJSCodeGenerator::generate_CallPropertyLookup(int index, int base, int a return; } - reject(u"call to property '%1' of %2"_qs.arg(name, baseType.descriptiveName())); + reject(u"call to property '%1' of %2"_s.arg(name, baseType.descriptiveName())); } const QString indexString = QString::number(index); - m_body += u"{\n"_qs; + m_body += u"{\n"_s; QString outVar; m_body += argumentsList(argc, argv, &outVar); - const QString lookup = u"aotContext->callObjectPropertyLookup("_qs + indexString - + u", "_qs + registerVariable(base) - + u", args, types, "_qs + QString::number(argc) + u')'; - const QString initialization = u"aotContext->initCallObjectPropertyLookup("_qs + const QString lookup = u"aotContext->callObjectPropertyLookup("_s + indexString + + u", "_s + registerVariable(base) + + u", args, types, "_s + QString::number(argc) + u')'; + const QString initialization = u"aotContext->initCallObjectPropertyLookup("_s + indexString + u')'; generateLookup(lookup, initialization); generateMoveOutVar(outVar); - m_body += u"}\n"_qs; + m_body += u"}\n"_s; } void QQmlJSCodeGenerator::generate_CallElement(int base, int index, int argc, int argv) @@ -1339,7 +1341,7 @@ void QQmlJSCodeGenerator::generate_CallName(int name, int argc, int argv) Q_UNUSED(name); Q_UNUSED(argc); Q_UNUSED(argv); - reject(u"CallName"_qs); + reject(u"CallName"_s); } void QQmlJSCodeGenerator::generate_CallPossiblyDirectEval(int argc, int argv) @@ -1354,7 +1356,7 @@ void QQmlJSCodeGenerator::generate_CallGlobalLookup(int index, int argc, int arg Q_UNUSED(index); Q_UNUSED(argc); Q_UNUSED(argv); - reject(u"CallGlobalLookup"_qs); + reject(u"CallGlobalLookup"_s); } void QQmlJSCodeGenerator::generate_CallQmlContextPropertyLookup(int index, int argc, int argv) @@ -1362,23 +1364,23 @@ void QQmlJSCodeGenerator::generate_CallQmlContextPropertyLookup(int index, int a INJECT_TRACE_INFO(generate_CallQmlContextPropertyLookup); if (m_state.accumulatorOut().variant() == QQmlJSRegisterContent::JavaScriptReturnValue) - reject(u"call to untyped JavaScript function"_qs); + reject(u"call to untyped JavaScript function"_s); AccumulatorConverter registers(this); const QString indexString = QString::number(index); - m_body += u"{\n"_qs; + m_body += u"{\n"_s; QString outVar; m_body += argumentsList(argc, argv, &outVar); - const QString lookup = u"aotContext->callQmlContextPropertyLookup("_qs + indexString - + u", args, types, "_qs + QString::number(argc) + u')'; - const QString initialization = u"aotContext->initCallQmlContextPropertyLookup("_qs + const QString lookup = u"aotContext->callQmlContextPropertyLookup("_s + indexString + + u", args, types, "_s + QString::number(argc) + u')'; + const QString initialization = u"aotContext->initCallQmlContextPropertyLookup("_s + indexString + u')'; generateLookup(lookup, initialization); generateMoveOutVar(outVar); - m_body += u"}\n"_qs; + m_body += u"}\n"_s; } void QQmlJSCodeGenerator::generate_CallWithSpread(int func, int thisObject, int argc, int argv) @@ -1404,7 +1406,7 @@ void QQmlJSCodeGenerator::generate_Construct(int func, int argc, int argv) Q_UNUSED(func); Q_UNUSED(argc); Q_UNUSED(argv); - reject(u"Construct"_qs); + reject(u"Construct"_s); } void QQmlJSCodeGenerator::generate_ConstructWithSpread(int func, int argc, int argv) @@ -1418,12 +1420,12 @@ void QQmlJSCodeGenerator::generate_ConstructWithSpread(int func, int argc, int a void QQmlJSCodeGenerator::generate_SetUnwindHandler(int offset) { Q_UNUSED(offset) - reject(u"SetUnwindHandlerh"_qs); + reject(u"SetUnwindHandlerh"_s); } void QQmlJSCodeGenerator::generate_UnwindDispatch() { - reject(u"UnwindDispatch"_qs); + reject(u"UnwindDispatch"_s); } void QQmlJSCodeGenerator::generate_UnwindToLabel(int level, int offset) @@ -1444,11 +1446,11 @@ void QQmlJSCodeGenerator::generate_ThrowException() INJECT_TRACE_INFO(generate_ThrowException); generateSetInstructionPointer(); - m_body += u"aotContext->engine->throwError("_qs + m_body += u"aotContext->engine->throwError("_s + conversion(m_state.accumulatorIn(), m_typeResolver->globalType( m_typeResolver->jsValueType()), - m_state.accumulatorVariableIn) + u");\n"_qs; - m_body += u"return "_qs + errorReturnValue() + u";\n"_qs; + m_state.accumulatorVariableIn) + u");\n"_s; + m_body += u"return "_s + errorReturnValue() + u";\n"_s; } void QQmlJSCodeGenerator::generate_GetException() @@ -1465,14 +1467,14 @@ void QQmlJSCodeGenerator::generate_CreateCallContext() { INJECT_TRACE_INFO(generate_CreateCallContext); - m_body += u"{\n"_qs; + m_body += u"{\n"_s; } void QQmlJSCodeGenerator::generate_PushCatchContext(int index, int nameIndex) { Q_UNUSED(index) Q_UNUSED(nameIndex) - reject(u"PushCatchContext"_qs); + reject(u"PushCatchContext"_s); } void QQmlJSCodeGenerator::generate_PushWithContext() @@ -1507,7 +1509,7 @@ void QQmlJSCodeGenerator::generate_PopContext() INJECT_TRACE_INFO(generate_PopContext); // Add a semicolon before the closing brace, in case there was a bare label before it. - m_body += u";}\n"_qs; + m_body += u";}\n"_s; } void QQmlJSCodeGenerator::generate_GetIterator(int iterator) @@ -1557,12 +1559,12 @@ void QQmlJSCodeGenerator::generate_DeleteName(int name) void QQmlJSCodeGenerator::generate_TypeofName(int name) { Q_UNUSED(name); - reject(u"TypeofName"_qs); + reject(u"TypeofName"_s); } void QQmlJSCodeGenerator::generate_TypeofValue() { - reject(u"TypeofValue"_qs); + reject(u"TypeofValue"_s); } void QQmlJSCodeGenerator::generate_DeclareVar(int varName, int isDeletable) @@ -1579,9 +1581,9 @@ void QQmlJSCodeGenerator::generate_DefineArray(int argc, int args) const QQmlJSScope::ConstPtr stored = m_state.accumulatorOut().storedType(); if (argc == 0) { - m_body += m_state.accumulatorVariableOut + u" = "_qs; + m_body += m_state.accumulatorVariableOut + u" = "_s; m_body += conversion(m_typeResolver->emptyListType(), stored, QString()); - m_body += u";\n"_qs; + m_body += u";\n"_s; generateOutputVariantConversion(m_typeResolver->emptyListType()); return; } @@ -1589,7 +1591,7 @@ void QQmlJSCodeGenerator::generate_DefineArray(int argc, int args) if (stored->accessSemantics() != QQmlJSScope::AccessSemantics::Sequence) { // This rejects any attempt to store the list into a QVariant. // Therefore, we don't have to adjust the contained type below. - reject(u"storing an array in a non-sequence type"_qs); + reject(u"storing an array in a non-sequence type"_s); return; } @@ -1602,8 +1604,8 @@ void QQmlJSCodeGenerator::generate_DefineArray(int argc, int args) registerVariable(args + i)); } - m_body += m_state.accumulatorVariableOut + u" = "_qs + stored->internalName() + u'{'; - m_body += initializer.join(u", "_qs); + m_body += m_state.accumulatorVariableOut + u" = "_s + stored->internalName() + u'{'; + m_body += initializer.join(u", "_s); m_body += u"};\n"; } @@ -1612,7 +1614,7 @@ void QQmlJSCodeGenerator::generate_DefineObjectLiteral(int internalClassId, int Q_UNUSED(internalClassId) Q_UNUSED(argc) Q_UNUSED(args) - reject(u"DefineObjectLiteral"_qs); + reject(u"DefineObjectLiteral"_s); } void QQmlJSCodeGenerator::generate_CreateClass(int classIndex, int heritage, int computedNames) @@ -1659,7 +1661,7 @@ void QQmlJSCodeGenerator::generate_Jump(int offset) INJECT_TRACE_INFO(generate_Jump); generateJumpCodeWithTypeConversions(offset); - m_body += u";\n"_qs; + m_body += u";\n"_s; m_skipUntilNextLabel = true; } @@ -1667,33 +1669,33 @@ void QQmlJSCodeGenerator::generate_JumpTrue(int offset) { INJECT_TRACE_INFO(generate_JumpTrue); - m_body += u"if ("_qs; + m_body += u"if ("_s; m_body += conversion(m_state.accumulatorIn().storedType(), m_typeResolver->boolType(), m_state.accumulatorVariableIn); - m_body += u") "_qs; + m_body += u") "_s; generateJumpCodeWithTypeConversions(offset); - m_body += u";\n"_qs; + m_body += u";\n"_s; } void QQmlJSCodeGenerator::generate_JumpFalse(int offset) { INJECT_TRACE_INFO(generate_JumpFalse); - m_body += u"if (!"_qs; + m_body += u"if (!"_s; m_body += conversion(m_state.accumulatorIn().storedType(), m_typeResolver->boolType(), m_state.accumulatorVariableIn); - m_body += u") "_qs; + m_body += u") "_s; generateJumpCodeWithTypeConversions(offset); - m_body += u";\n"_qs; + m_body += u";\n"_s; } void QQmlJSCodeGenerator::generate_JumpNoException(int offset) { INJECT_TRACE_INFO(generate_JumpNoException); - m_body += u"if (!context->engine->hasException()) "_qs; + m_body += u"if (!context->engine->hasException()) "_s; generateJumpCodeWithTypeConversions(offset); - m_body += u";\n"_qs; + m_body += u";\n"_s; } void QQmlJSCodeGenerator::generate_JumpNotUndefined(int offset) @@ -1713,14 +1715,14 @@ void QQmlJSCodeGenerator::generate_CmpEqNull() { INJECT_TRACE_INFO(generate_CmlEqNull); - m_body += m_state.accumulatorVariableOut + u" = "_qs; + m_body += m_state.accumulatorVariableOut + u" = "_s; m_body += conversion( m_typeResolver->boolType(), m_state.accumulatorOut().storedType(), - u"QJSPrimitiveValue(QJSPrimitiveNull()).equals("_qs + u"QJSPrimitiveValue(QJSPrimitiveNull()).equals("_s + conversion( m_state.accumulatorIn().storedType(), m_typeResolver->jsPrimitiveType(), m_state.accumulatorVariableIn) + u')'); - m_body += u";\n"_qs; + m_body += u";\n"_s; generateOutputVariantConversion(m_typeResolver->boolType()); } @@ -1728,31 +1730,31 @@ void QQmlJSCodeGenerator::generate_CmpNeNull() { INJECT_TRACE_INFO(generate_CmlNeNull); - m_body += m_state.accumulatorVariableOut + u" = "_qs; + m_body += m_state.accumulatorVariableOut + u" = "_s; m_body += conversion( m_typeResolver->boolType(), m_state.accumulatorOut().storedType(), - u"!QJSPrimitiveValue(QJSPrimitiveNull()).equals("_qs + u"!QJSPrimitiveValue(QJSPrimitiveNull()).equals("_s + conversion( m_state.accumulatorIn().storedType(), m_typeResolver->jsPrimitiveType(), m_state.accumulatorVariableIn) + u')'); - m_body += u";\n"_qs; + m_body += u";\n"_s; generateOutputVariantConversion(m_typeResolver->boolType()); } QString QQmlJSCodeGenerator::eqIntExpression(int lhsConst) { if (m_typeResolver->registerIsStoredIn(m_state.accumulatorIn(), m_typeResolver->intType())) - return QString::number(lhsConst) + u" == "_qs + m_state.accumulatorVariableIn; + return QString::number(lhsConst) + u" == "_s + m_state.accumulatorVariableIn; if (m_typeResolver->registerIsStoredIn(m_state.accumulatorIn(), m_typeResolver->boolType())) { - return QString::number(lhsConst) + u" == "_qs + return QString::number(lhsConst) + u" == "_s + conversion(m_state.accumulatorIn().storedType(), m_typeResolver->intType(), m_state.accumulatorVariableIn); } if (m_typeResolver->isNumeric(m_state.accumulatorIn())) { return conversion(m_typeResolver->intType(), m_typeResolver->realType(), - QString::number(lhsConst)) + u" == "_qs + QString::number(lhsConst)) + u" == "_s + conversion(m_state.accumulatorIn().storedType(), m_typeResolver->realType(), m_state.accumulatorVariableIn); } @@ -1760,7 +1762,7 @@ QString QQmlJSCodeGenerator::eqIntExpression(int lhsConst) QString result; result += conversion(m_typeResolver->intType(), m_typeResolver->jsPrimitiveType(), QString::number(lhsConst)); - result += u".equals("_qs; + result += u".equals("_s; result += conversion(m_state.accumulatorIn().storedType(), m_typeResolver->jsPrimitiveType(), m_state.accumulatorVariableIn); result += u')'; @@ -1774,8 +1776,8 @@ QString QQmlJSCodeGenerator::getLookupPreparation( return QString(); if (m_typeResolver->registerIsStoredIn(content, m_typeResolver->varType())) { - return var + u" = QVariant(aotContext->lookupResultMetaType("_qs - + QString::number(lookup) + u"))"_qs; + return var + u" = QVariant(aotContext->lookupResultMetaType("_s + + QString::number(lookup) + u"))"_s; } // TODO: We could make sure they're compatible, for example QObject pointers. return QString(); @@ -1787,11 +1789,11 @@ QString QQmlJSCodeGenerator::contentPointer(const QQmlJSRegisterContent &content if (m_typeResolver->registerContains(content, stored)) return u'&' + var; else if (m_typeResolver->registerIsStoredIn(content, m_typeResolver->varType())) - return var + u".data()"_qs; + return var + u".data()"_s; else if (stored->accessSemantics() == QQmlJSScope::AccessSemantics::Reference) return u'&' + var; else - reject(u"content pointer of non-QVariant wrapper type "_qs + content.descriptiveName()); + reject(u"content pointer of non-QVariant wrapper type "_s + content.descriptiveName()); return QString(); } @@ -1803,11 +1805,11 @@ QString QQmlJSCodeGenerator::contentType(const QQmlJSRegisterContent &content, c if (m_typeResolver->equals(contained, stored)) return metaTypeFromType(stored); else if (m_typeResolver->equals(stored, m_typeResolver->varType())) - return var + u".metaType()"_qs; // We expect the QVariant to be initialized + return var + u".metaType()"_s; // We expect the QVariant to be initialized else if (stored->accessSemantics() == QQmlJSScope::AccessSemantics::Reference) return metaTypeFromName(contained); else - reject(u"content type of non-QVariant wrapper type "_qs + content.descriptiveName()); + reject(u"content type of non-QVariant wrapper type "_s + content.descriptiveName()); return QString(); } @@ -1815,9 +1817,9 @@ void QQmlJSCodeGenerator::generate_CmpEqInt(int lhsConst) { INJECT_TRACE_INFO(generate_CmpEqInt); - m_body += m_state.accumulatorVariableOut + u" = "_qs; + m_body += m_state.accumulatorVariableOut + u" = "_s; m_body += conversion(m_typeResolver->boolType(), m_state.accumulatorOut().storedType(), - eqIntExpression(lhsConst)) + u";\n"_qs; + eqIntExpression(lhsConst)) + u";\n"_s; generateOutputVariantConversion(m_typeResolver->boolType()); } @@ -1825,64 +1827,64 @@ void QQmlJSCodeGenerator::generate_CmpNeInt(int lhsConst) { INJECT_TRACE_INFO(generate_CmpNeInt); - m_body += m_state.accumulatorVariableOut + u" = "_qs; + m_body += m_state.accumulatorVariableOut + u" = "_s; m_body += conversion(m_typeResolver->boolType(), m_state.accumulatorOut().storedType(), - u"!("_qs + eqIntExpression(lhsConst) + u')') + u";\n"_qs; + u"!("_s + eqIntExpression(lhsConst) + u')') + u";\n"_s; generateOutputVariantConversion(m_typeResolver->boolType()); } void QQmlJSCodeGenerator::generate_CmpEq(int lhs) { INJECT_TRACE_INFO(generate_CmpEq); - generateEqualityOperation(lhs, u"equals"_qs, false); + generateEqualityOperation(lhs, u"equals"_s, false); } void QQmlJSCodeGenerator::generate_CmpNe(int lhs) { INJECT_TRACE_INFO(generate_CmpNe); - generateEqualityOperation(lhs, u"equals"_qs, true); + generateEqualityOperation(lhs, u"equals"_s, true); } void QQmlJSCodeGenerator::generate_CmpGt(int lhs) { INJECT_TRACE_INFO(generate_CmpGt); - generateCompareOperation(lhs, u">"_qs); + generateCompareOperation(lhs, u">"_s); } void QQmlJSCodeGenerator::generate_CmpGe(int lhs) { INJECT_TRACE_INFO(generate_CmpGe); - generateCompareOperation(lhs, u">="_qs); + generateCompareOperation(lhs, u">="_s); } void QQmlJSCodeGenerator::generate_CmpLt(int lhs) { INJECT_TRACE_INFO(generate_CmpLt); - generateCompareOperation(lhs, u"<"_qs); + generateCompareOperation(lhs, u"<"_s); } void QQmlJSCodeGenerator::generate_CmpLe(int lhs) { INJECT_TRACE_INFO(generate_CmpLe); - generateCompareOperation(lhs, u"<="_qs); + generateCompareOperation(lhs, u"<="_s); } void QQmlJSCodeGenerator::generate_CmpStrictEqual(int lhs) { INJECT_TRACE_INFO(generate_CmpStrictEqual); - generateEqualityOperation(lhs, u"strictlyEquals"_qs, false); + generateEqualityOperation(lhs, u"strictlyEquals"_s, false); } void QQmlJSCodeGenerator::generate_CmpStrictNotEqual(int lhs) { INJECT_TRACE_INFO(generate_CmpStrictNotEqual); - generateEqualityOperation(lhs, u"strictlyEquals"_qs, true); + generateEqualityOperation(lhs, u"strictlyEquals"_s, true); } void QQmlJSCodeGenerator::generate_CmpIn(int lhs) { Q_UNUSED(lhs) - reject(u"CmpIn"_qs); + reject(u"CmpIn"_s); } void QQmlJSCodeGenerator::generate_CmpInstanceOf(int lhs) @@ -1899,37 +1901,37 @@ void QQmlJSCodeGenerator::generate_As(int lhs) const QQmlJSScope::ConstPtr contained = m_typeResolver->containedType(m_state.readRegister(lhs)); - m_body += m_state.accumulatorVariableOut + u" = "_qs; + m_body += m_state.accumulatorVariableOut + u" = "_s; if (m_typeResolver->equals( m_state.accumulatorIn().storedType(), m_typeResolver->metaObjectType()) && contained->isComposite()) { m_body += conversion( m_typeResolver->genericType(contained), m_state.accumulatorOut().storedType(), - m_state.accumulatorVariableIn + u"->cast("_qs + input + u')'); + m_state.accumulatorVariableIn + u"->cast("_s + input + u')'); } else { m_body += conversion( m_typeResolver->genericType(contained), m_state.accumulatorOut().storedType(), - u'(' + metaObject(contained) + u")->cast("_qs + input + u')'); + u'(' + metaObject(contained) + u")->cast("_s + input + u')'); } - m_body += u";\n"_qs; + m_body += u";\n"_s; } void QQmlJSCodeGenerator::generate_UNot() { INJECT_TRACE_INFO(generate_UNot); - generateUnaryOperation(u"!"_qs); + generateUnaryOperation(u"!"_s); } void QQmlJSCodeGenerator::generate_UPlus() { INJECT_TRACE_INFO(generate_UPlus); - generateUnaryOperation(u"+"_qs); + generateUnaryOperation(u"+"_s); } void QQmlJSCodeGenerator::generate_UMinus() { INJECT_TRACE_INFO(generate_UMinus); - generateUnaryOperation(u"-"_qs); + generateUnaryOperation(u"-"_s); } void QQmlJSCodeGenerator::generate_UCompl() @@ -1940,19 +1942,19 @@ void QQmlJSCodeGenerator::generate_UCompl() void QQmlJSCodeGenerator::generate_Increment() { INJECT_TRACE_INFO(generate_Increment); - generateInPlaceOperation(u"++"_qs); + generateInPlaceOperation(u"++"_s); } void QQmlJSCodeGenerator::generate_Decrement() { INJECT_TRACE_INFO(generate_Decrement); - generateInPlaceOperation(u"--"_qs); + generateInPlaceOperation(u"--"_s); } void QQmlJSCodeGenerator::generate_Add(int lhs) { INJECT_TRACE_INFO(generate_Add); - generateArithmeticOperation(lhs, u"+"_qs); + generateArithmeticOperation(lhs, u"+"_s); } void QQmlJSCodeGenerator::generate_BitAnd(int lhs) @@ -1982,13 +1984,13 @@ void QQmlJSCodeGenerator::generate_UShr(int lhs) void QQmlJSCodeGenerator::generate_Shr(int lhs) { Q_UNUSED(lhs); - reject(u"Shr"_qs); + reject(u"Shr"_s); } void QQmlJSCodeGenerator::generate_Shl(int lhs) { Q_UNUSED(lhs); - reject(u"Shl"_qs); + reject(u"Shl"_s); } void QQmlJSCodeGenerator::generate_BitAndConst(int rhs) @@ -2018,13 +2020,13 @@ void QQmlJSCodeGenerator::generate_UShrConst(int rhs) void QQmlJSCodeGenerator::generate_ShrConst(int value) { Q_UNUSED(value); - reject(u"ShrConst"_qs); + reject(u"ShrConst"_s); } void QQmlJSCodeGenerator::generate_ShlConst(int value) { Q_UNUSED(value); - reject(u"ShlConst"_qs); + reject(u"ShlConst"_s); } void QQmlJSCodeGenerator::generate_Exp(int lhs) @@ -2036,13 +2038,13 @@ void QQmlJSCodeGenerator::generate_Exp(int lhs) void QQmlJSCodeGenerator::generate_Mul(int lhs) { INJECT_TRACE_INFO(generate_Mul); - generateArithmeticOperation(lhs, u"*"_qs); + generateArithmeticOperation(lhs, u"*"_s); } void QQmlJSCodeGenerator::generate_Div(int lhs) { INJECT_TRACE_INFO(generate_Div); - generateArithmeticOperation(lhs, u"/"_qs); + generateArithmeticOperation(lhs, u"/"_s); } void QQmlJSCodeGenerator::generate_Mod(int lhs) @@ -2059,10 +2061,10 @@ void QQmlJSCodeGenerator::generate_Mod(int lhs) Q_ASSERT(!rhsVar.isEmpty()); m_body += m_state.accumulatorVariableOut; - m_body += u" = "_qs; + m_body += u" = "_s; m_body += conversion(m_typeResolver->jsPrimitiveType(), m_state.accumulatorOut().storedType(), - u'(' + lhsVar + u" % "_qs + rhsVar + u')'); - m_body += u";\n"_qs; + u'(' + lhsVar + u" % "_s + rhsVar + u')'); + m_body += u";\n"_s; generateOutputVariantConversion(m_typeResolver->jsPrimitiveType()); } @@ -2070,7 +2072,7 @@ void QQmlJSCodeGenerator::generate_Mod(int lhs) void QQmlJSCodeGenerator::generate_Sub(int lhs) { INJECT_TRACE_INFO(generate_Sub); - generateArithmeticOperation(lhs, u"-"_qs); + generateArithmeticOperation(lhs, u"-"_s); } void QQmlJSCodeGenerator::generate_InitializeBlockDeadTemporalZone(int firstReg, int count) @@ -2132,7 +2134,7 @@ QV4::Moth::ByteCodeHandler::Verdict QQmlJSCodeGenerator::startInstruction( auto labelIt = m_labels.constFind(currentInstructionOffset()); if (labelIt != m_labels.constEnd()) { - m_body += *labelIt + u":;\n"_qs; + m_body += *labelIt + u":;\n"_s; m_skipUntilNextLabel = false; } else if (m_skipUntilNextLabel && !instructionManipulatesContext(type)) { return SkipInstruction; @@ -2155,7 +2157,7 @@ QV4::Moth::ByteCodeHandler::Verdict QQmlJSCodeGenerator::startInstruction( if (currentLine != m_lastLineNumberUsed) { const int nextLine = nextJSLine(currentLine); for (auto line = currentLine - 1; line < nextLine - 1; ++line) { - m_body += u"// "_qs; + m_body += u"// "_s; m_body += m_sourceCodeLines.value(line).trimmed(); m_body += u'\n'; } @@ -2177,14 +2179,14 @@ void QQmlJSCodeGenerator::endInstruction(QV4::Moth::Instr::Type) void QQmlJSCodeGenerator::generateSetInstructionPointer() { - m_body += u"aotContext->setInstructionPointer("_qs - + QString::number(nextInstructionOffset()) + u");\n"_qs; + m_body += u"aotContext->setInstructionPointer("_s + + QString::number(nextInstructionOffset()) + u");\n"_s; } void QQmlJSCodeGenerator::generateExceptionCheck() { - m_body += u"if (aotContext->engine->hasError())\n"_qs; - m_body += u" return "_qs + errorReturnValue() + u";\n"_qs; + m_body += u"if (aotContext->engine->hasError())\n"_s; + m_body += u" return "_s + errorReturnValue() + u";\n"_s; } void QQmlJSCodeGenerator::generateEqualityOperation(int lhs, const QString &function, bool invert) @@ -2203,37 +2205,37 @@ void QQmlJSCodeGenerator::generateEqualityOperation(int lhs, const QString &func }; if (!isComparable()) { - reject(u"equality comparison on non-primitive types %1 and %2"_qs.arg( + reject(u"equality comparison on non-primitive types %1 and %2"_s.arg( m_state.accumulatorIn().descriptiveName(), lhsContent.descriptiveName())); } const QQmlJSScope::ConstPtr lhsType = lhsContent.storedType(); const QQmlJSScope::ConstPtr rhsType = m_state.accumulatorIn().storedType(); - m_body += m_state.accumulatorVariableOut + u" = "_qs; + m_body += m_state.accumulatorVariableOut + u" = "_s; const auto primitive = m_typeResolver->jsPrimitiveType(); if (m_typeResolver->equals(lhsType, rhsType) && !m_typeResolver->equals(lhsType, primitive)) { m_body += conversion(m_typeResolver->boolType(), m_state.accumulatorOut().storedType(), - registerVariable(lhs) + (invert ? u" != "_qs : u" == "_qs) + registerVariable(lhs) + (invert ? u" != "_s : u" == "_s) + m_state.accumulatorVariableIn); } else { m_body += conversion( m_typeResolver->boolType(), m_state.accumulatorOut().storedType(), - (invert ? u"!"_qs : QString()) + (invert ? u"!"_s : QString()) + conversion(registerType(lhs).storedType(), primitive, registerVariable(lhs)) + u'.' + function + u'(' + conversion( m_state.accumulatorIn().storedType(), primitive, m_state.accumulatorVariableIn) + u')'); } - m_body += u";\n"_qs; + m_body += u";\n"_s; generateOutputVariantConversion(m_typeResolver->boolType()); } void QQmlJSCodeGenerator::generateCompareOperation(int lhs, const QString &cppOperator) { - m_body += m_state.accumulatorVariableOut + u" = "_qs; + m_body += m_state.accumulatorVariableOut + u" = "_s; const auto lhsType = registerType(lhs); const QQmlJSScope::ConstPtr compareType = @@ -2247,7 +2249,7 @@ void QQmlJSCodeGenerator::generateCompareOperation(int lhs, const QString &cppOp + u' ' + cppOperator + u' ' + conversion(m_state.accumulatorIn().storedType(), compareType, m_state.accumulatorVariableIn)); - m_body += u";\n"_qs; + m_body += u";\n"_s; generateOutputVariantConversion(m_typeResolver->boolType()); } @@ -2262,11 +2264,11 @@ void QQmlJSCodeGenerator::generateArithmeticOperation(int lhs, const QString &cp const QQmlJSRegisterContent originalOut = m_typeResolver->original(m_state.accumulatorOut()); m_body += m_state.accumulatorVariableOut; - m_body += u" = "_qs; + m_body += u" = "_s; m_body += conversion( originalOut, m_state.accumulatorOut(), u'(' + lhsVar + u' ' + cppOperator + u' ' + rhsVar + u')'); - m_body += u";\n"_qs; + m_body += u";\n"_s; generateOutputVariantConversion(m_typeResolver->containedType(originalOut)); } @@ -2276,21 +2278,21 @@ void QQmlJSCodeGenerator::generateUnaryOperation(const QString &cppOperator) m_state.accumulatorVariableIn); if (var == m_state.accumulatorVariableOut) { - m_body += m_state.accumulatorVariableOut + u" = "_qs + cppOperator + var + u";\n"_qs; + m_body += m_state.accumulatorVariableOut + u" = "_s + cppOperator + var + u";\n"_s; return; } const auto original = m_typeResolver->original(m_state.accumulatorOut()); if (m_state.accumulatorOut() == original) { - m_body += m_state.accumulatorVariableOut + u" = "_qs + var + u";\n"_qs; - m_body += m_state.accumulatorVariableOut + u" = "_qs - + cppOperator + m_state.accumulatorVariableOut + u";\n"_qs; + m_body += m_state.accumulatorVariableOut + u" = "_s + var + u";\n"_s; + m_body += m_state.accumulatorVariableOut + u" = "_s + + cppOperator + m_state.accumulatorVariableOut + u";\n"_s; return; } - m_body += m_state.accumulatorVariableOut + u" = "_qs + conversion( + m_body += m_state.accumulatorVariableOut + u" = "_s + conversion( m_typeResolver->original(m_state.accumulatorOut()), - m_state.accumulatorOut(), cppOperator + var) + u";\n"_qs; + m_state.accumulatorOut(), cppOperator + var) + u";\n"_s; generateOutputVariantConversion(m_typeResolver->containedType(original)); } @@ -2301,23 +2303,23 @@ void QQmlJSCodeGenerator::generateInPlaceOperation(const QString &cppOperator) m_state.accumulatorVariableIn); if (var == m_state.accumulatorVariableOut) { - m_body += cppOperator + var + u";\n"_qs; + m_body += cppOperator + var + u";\n"_s; return; } const auto original = m_typeResolver->original(m_state.accumulatorOut()); if (m_state.accumulatorOut() == original) { - m_body += m_state.accumulatorVariableOut + u" = "_qs + var + u";\n"_qs; - m_body += cppOperator + m_state.accumulatorVariableOut + u";\n"_qs; + m_body += m_state.accumulatorVariableOut + u" = "_s + var + u";\n"_s; + m_body += cppOperator + m_state.accumulatorVariableOut + u";\n"_s; return; } - m_body += u"{\n"_qs; - m_body += u"auto converted = "_qs + var + u";\n"_qs; - m_body += m_state.accumulatorVariableOut + u" = "_qs + conversion( + m_body += u"{\n"_s; + m_body += u"auto converted = "_s + var + u";\n"_s; + m_body += m_state.accumulatorVariableOut + u" = "_s + conversion( m_typeResolver->original(m_state.accumulatorOut()), - m_state.accumulatorOut(), cppOperator + u"converted"_qs) + u";\n"_qs; - m_body += u"}\n"_qs; + m_state.accumulatorOut(), cppOperator + u"converted"_s) + u";\n"_s; + m_body += u"}\n"_s; generateOutputVariantConversion(m_typeResolver->containedType(original)); } @@ -2325,14 +2327,14 @@ void QQmlJSCodeGenerator::generateLookup(const QString &lookup, const QString &i const QString &resultPreparation) { if (!resultPreparation.isEmpty()) - m_body += resultPreparation + u";\n"_qs; - m_body += u"while (!"_qs + lookup + u") {\n"_qs; + m_body += resultPreparation + u";\n"_s; + m_body += u"while (!"_s + lookup + u") {\n"_s; generateSetInstructionPointer(); - m_body += initialization + u";\n"_qs; + m_body += initialization + u";\n"_s; generateExceptionCheck(); if (!resultPreparation.isEmpty()) - m_body += resultPreparation + u";\n"_qs; - m_body += u"}\n"_qs; + m_body += resultPreparation + u";\n"_s; + m_body += u"}\n"_s; } void QQmlJSCodeGenerator::generateJumpCodeWithTypeConversions(int relativeOffset) @@ -2376,30 +2378,30 @@ void QQmlJSCodeGenerator::generateJumpCodeWithTypeConversions(int relativeOffset continue; conversionCode += *variable; - conversionCode += u" = "_qs; + conversionCode += u" = "_s; conversionCode += conversion(currentType, targetType, currentVariable); - conversionCode += u";\n"_qs; + conversionCode += u";\n"_s; } } if (relativeOffset) { auto labelIt = m_labels.find(absoluteOffset); if (labelIt == m_labels.end()) - labelIt = m_labels.insert(absoluteOffset, u"label_%1"_qs.arg(m_labels.count())); - conversionCode += u" goto "_qs + *labelIt + u";\n"_qs; + labelIt = m_labels.insert(absoluteOffset, u"label_%1"_s.arg(m_labels.count())); + conversionCode += u" goto "_s + *labelIt + u";\n"_s; } if (!conversionCode.isEmpty()) - m_body += u"{\n"_qs + conversionCode + u"}\n"_qs; + m_body += u"{\n"_s + conversionCode + u"}\n"_s; } QString QQmlJSCodeGenerator::registerVariable(int index) const { if (index >= QV4::CallData::OffsetCount && index < firstRegisterIndex()) { const int argumentIndex = index - QV4::CallData::OffsetCount; - return u"*static_cast<"_qs + return u"*static_cast<"_s + castTargetName(m_function->argumentTypes[argumentIndex].storedType()) - + u"*>(argumentsPtr["_qs + QString::number(argumentIndex) + u"])"_qs; + + u"*>(argumentsPtr["_s + QString::number(argumentIndex) + u"])"_s; } return m_registerVariables.value(index).value(registerType(index).storedType()); } @@ -2432,57 +2434,57 @@ QString QQmlJSCodeGenerator::conversion(const QQmlJSScope::ConstPtr &from, auto zeroBoolOrNumeric = [&](const QQmlJSScope::ConstPtr &to) { if (m_typeResolver->equals(to, boolType)) - return u"false"_qs; + return u"false"_s; if (m_typeResolver->equals(to, m_typeResolver->intType())) - return u"0"_qs; + return u"0"_s; if (m_typeResolver->equals(to, m_typeResolver->floatType())) - return u"0.0f"_qs; + return u"0.0f"_s; if (m_typeResolver->equals(to, m_typeResolver->realType())) - return u"0.0"_qs; + return u"0.0"_s; return QString(); }; if (m_typeResolver->equals(from, m_typeResolver->voidType())) { if (to->accessSemantics() == QQmlJSScope::AccessSemantics::Reference) - return u"static_cast<"_qs + to->internalName() + u" *>(nullptr)"_qs; + return u"static_cast<"_s + to->internalName() + u" *>(nullptr)"_s; const QString zero = zeroBoolOrNumeric(to); if (!zero.isEmpty()) return zero; if (m_typeResolver->equals(to, m_typeResolver->stringType())) - return QQmlJSUtils::toLiteral(u"undefined"_qs); + return QQmlJSUtils::toLiteral(u"undefined"_s); if (m_typeResolver->equals(from, to)) return QString(); // Anything else is just the default constructed type. - return to->augmentedInternalName() + u"()"_qs; + return to->augmentedInternalName() + u"()"_s; } if (m_typeResolver->equals(from, m_typeResolver->nullType())) { if (to->accessSemantics() == QQmlJSScope::AccessSemantics::Reference) - return u"static_cast<"_qs + to->internalName() + u" *>(nullptr)"_qs; + return u"static_cast<"_s + to->internalName() + u" *>(nullptr)"_s; if (m_typeResolver->equals(to, jsValueType)) - return u"QJSValue(QJSValue::NullValue)"_qs; + return u"QJSValue(QJSValue::NullValue)"_s; if (m_typeResolver->equals(to, jsPrimitiveType)) - return u"QJSPrimitiveValue(QJSPrimitiveNull())"_qs; + return u"QJSPrimitiveValue(QJSPrimitiveNull())"_s; if (m_typeResolver->equals(to, varType)) - return u"QVariant::fromValue<std::nullptr_t>(nullptr)"_qs; + return u"QVariant::fromValue<std::nullptr_t>(nullptr)"_s; const QString zero = zeroBoolOrNumeric(to); if (!zero.isEmpty()) return zero; if (m_typeResolver->equals(to, m_typeResolver->stringType())) - return QQmlJSUtils::toLiteral(u"null"_qs); + return QQmlJSUtils::toLiteral(u"null"_s); if (m_typeResolver->equals(from, to)) return QString(); - reject(u"Conversion from null to %1"_qs.arg(to->internalName())); + reject(u"Conversion from null to %1"_s.arg(to->internalName())); } if (m_typeResolver->equals(from, m_typeResolver->emptyListType())) { if (to->accessSemantics() == QQmlJSScope::AccessSemantics::Sequence) - return castTargetName(to) + u"()"_qs; + return castTargetName(to) + u"()"_s; if (m_typeResolver->equals(to, m_typeResolver->varType())) - return u"QVariant(QVariantList())"_qs; + return u"QVariant(QVariantList())"_s; if (m_typeResolver->equals(from, to)) return QString(); - reject(u"Conversion from empty list to %1"_qs.arg(to->internalName())); + reject(u"Conversion from empty list to %1"_s.arg(to->internalName())); } if (m_typeResolver->equals(from, to)) @@ -2497,14 +2499,14 @@ QString QQmlJSCodeGenerator::conversion(const QQmlJSScope::ConstPtr &from, for (QQmlJSScope::ConstPtr base = from; base; base = base->baseType()) { // We still have to cast as other execution paths may result in different types. if (base->internalName() == to->internalName()) - return u"static_cast<"_qs + to->internalName() + u" *>("_qs + variable + u')'; + return u"static_cast<"_s + to->internalName() + u" *>("_s + variable + u')'; } for (QQmlJSScope::ConstPtr base = to; base; base = base->baseType()) { if (base->internalName() == from->internalName()) - return u"static_cast<"_qs + to->internalName() + u" *>("_qs + variable + u')'; + return u"static_cast<"_s + to->internalName() + u" *>("_s + variable + u')'; } } else if (m_typeResolver->equals(to, m_typeResolver->boolType())) { - return u'(' + variable + u" != nullptr)"_qs; + return u'(' + variable + u" != nullptr)"_s; } } @@ -2523,7 +2525,7 @@ QString QQmlJSCodeGenerator::conversion(const QQmlJSScope::ConstPtr &from, if (m_typeResolver->equals(from, m_typeResolver->realType()) && m_typeResolver->equals(to, m_typeResolver->intType())) { - return u"QJSNumberCoercion::toInteger("_qs + variable + u')'; + return u"QJSNumberCoercion::toInteger("_s + variable + u')'; } if (isBoolOrNumber(from) && isBoolOrNumber(to)) @@ -2532,65 +2534,65 @@ QString QQmlJSCodeGenerator::conversion(const QQmlJSScope::ConstPtr &from, if (m_typeResolver->equals(from, jsPrimitiveType)) { if (m_typeResolver->equals(to, m_typeResolver->realType())) - return variable + u".toDouble()"_qs; + return variable + u".toDouble()"_s; if (m_typeResolver->equals(to, boolType)) - return variable + u".toBoolean()"_qs; + return variable + u".toBoolean()"_s; if (m_typeResolver->equals(to, m_typeResolver->intType())) - return variable + u".toInteger()"_qs; + return variable + u".toInteger()"_s; if (m_typeResolver->equals(to, m_typeResolver->stringType())) - return variable + u".toString()"_qs; + return variable + u".toString()"_s; if (m_typeResolver->equals(to, jsValueType)) - return u"QJSValue(QJSPrimitiveValue("_qs + variable + u"))"_qs; + return u"QJSValue(QJSPrimitiveValue("_s + variable + u"))"_s; if (m_typeResolver->equals(to, varType)) - return variable + u".toVariant()"_qs; + return variable + u".toVariant()"_s; if (to->accessSemantics() == QQmlJSScope::AccessSemantics::Reference) - return u"static_cast<"_qs + to->internalName() + u" *>(nullptr)"_qs; + return u"static_cast<"_s + to->internalName() + u" *>(nullptr)"_s; } if (isJsValue(from)) { if (m_typeResolver->equals(to, jsPrimitiveType)) - return variable + u".toPrimitive()"_qs; + return variable + u".toPrimitive()"_s; if (m_typeResolver->equals(to, varType)) - return variable + u".toVariant(QJSValue::RetainJSObjects)"_qs; - return u"qjsvalue_cast<"_qs + castTargetName(to) + u">("_qs + variable + u')'; + return variable + u".toVariant(QJSValue::RetainJSObjects)"_s; + return u"qjsvalue_cast<"_s + castTargetName(to) + u">("_s + variable + u')'; } if (m_typeResolver->equals(to, jsPrimitiveType)) - return u"QJSPrimitiveValue("_qs + variable + u')'; + return u"QJSPrimitiveValue("_s + variable + u')'; if (m_typeResolver->equals(to, jsValueType)) - return u"aotContext->engine->toScriptValue("_qs + variable + u')'; + return u"aotContext->engine->toScriptValue("_s + variable + u')'; if (m_typeResolver->equals(from, varType)) { if (m_typeResolver->equals(to, m_typeResolver->listPropertyType())) - return u"QQmlListReference("_qs + variable + u", aotContext->qmlEngine())"_qs; - return u"aotContext->engine->fromVariant<"_qs + castTargetName(to) + u">("_qs + return u"QQmlListReference("_s + variable + u", aotContext->qmlEngine())"_s; + return u"aotContext->engine->fromVariant<"_s + castTargetName(to) + u">("_s + variable + u')'; } if (m_typeResolver->equals(to, varType)) - return u"QVariant::fromValue("_qs + variable + u')'; + return u"QVariant::fromValue("_s + variable + u')'; if (m_typeResolver->equals(from, m_typeResolver->urlType()) && m_typeResolver->equals(to, m_typeResolver->stringType())) { - return variable + u".toString()"_qs; + return variable + u".toString()"_s; } if (m_typeResolver->equals(from, m_typeResolver->stringType()) && m_typeResolver->equals(to, m_typeResolver->urlType())) { - return u"QUrl("_qs + variable + u')'; + return u"QUrl("_s + variable + u')'; } const auto retrieveFromPrimitive = [&](const QQmlJSScope::ConstPtr &type) { if (m_typeResolver->equals(type, m_typeResolver->boolType())) - return u".toBoolean()"_qs; + return u".toBoolean()"_s; if (m_typeResolver->equals(type, m_typeResolver->intType())) - return u".toInteger()"_qs; + return u".toInteger()"_s; if (m_typeResolver->equals(type, m_typeResolver->realType())) - return u".toDouble()"_qs; + return u".toDouble()"_s; if (m_typeResolver->equals(type, m_typeResolver->stringType())) - return u".toString()"_qs; + return u".toString()"_s; return QString(); }; @@ -2603,13 +2605,13 @@ QString QQmlJSCodeGenerator::conversion(const QQmlJSScope::ConstPtr &from, if (fitsIntoPrimitive(from)) { const QString retrieve = retrieveFromPrimitive(to); if (!retrieve.isEmpty()) - return u"QJSPrimitiveValue("_qs + variable + u')' + retrieve; + return u"QJSPrimitiveValue("_s + variable + u')' + retrieve; } // TODO: more efficient string conversions, possibly others - return u"aotContext->engine->fromScriptValue<"_qs + castTargetName(to) - + u">(aotContext->engine->toScriptValue("_qs + variable + u"))"_qs; + return u"aotContext->engine->fromScriptValue<"_s + castTargetName(to) + + u">(aotContext->engine->toScriptValue("_s + variable + u"))"_s; } int QQmlJSCodeGenerator::nextJSLine(uint line) const @@ -2629,7 +2631,7 @@ int QQmlJSCodeGenerator::nextJSLine(uint line) const void QQmlJSCodeGenerator::reject(const QString &thing) { - setError(u"Cannot generate efficient code for %1"_qs.arg(thing)); + setError(u"Cannot generate efficient code for %1"_s.arg(thing)); } QQmlJSCodeGenerator::AccumulatorConverter::AccumulatorConverter(QQmlJSCodeGenerator *generator) @@ -2647,9 +2649,9 @@ QQmlJSCodeGenerator::AccumulatorConverter::AccumulatorConverter(QQmlJSCodeGenera if (!resolver->equals(origContained, resolver->containedType(accumulatorOut)) || !resolver->equals(origStored, accumulatorOut.storedType())) { - generator->m_state.accumulatorVariableOut = u"retrieved"_qs; + generator->m_state.accumulatorVariableOut = u"retrieved"_s; generator->m_state.setRegister(Accumulator, resolver->original(accumulatorOut)); - generator->m_body += u"{\n"_qs; + generator->m_body += u"{\n"_s; generator->m_body += origStored->augmentedInternalName() + u' ' + generator->m_state.accumulatorVariableOut + u";\n"; } else if (generator->m_state.accumulatorVariableIn == generator->m_state.accumulatorVariableOut @@ -2660,27 +2662,27 @@ QQmlJSCodeGenerator::AccumulatorConverter::AccumulatorConverter(QQmlJSCodeGenera // prepare the output QVariant, and afterwards use the input variant. Therefore we need to // move the input out of the way first. generator->m_state.accumulatorVariableIn - = generator->m_state.accumulatorVariableIn + u"_moved"_qs; - generator->m_body += u"{\n"_qs; - generator->m_body += u"QVariant "_qs + generator->m_state.accumulatorVariableIn - + u" = std::move("_qs + generator->m_state.accumulatorVariableOut + u");\n"_qs; + = generator->m_state.accumulatorVariableIn + u"_moved"_s; + generator->m_body += u"{\n"_s; + generator->m_body += u"QVariant "_s + generator->m_state.accumulatorVariableIn + + u" = std::move("_s + generator->m_state.accumulatorVariableOut + u");\n"_s; } } QQmlJSCodeGenerator::AccumulatorConverter::~AccumulatorConverter() { if (accumulatorVariableOut != generator->m_state.accumulatorVariableOut) { - generator->m_body += accumulatorVariableOut + u" = "_qs + generator->conversion( + generator->m_body += accumulatorVariableOut + u" = "_s + generator->conversion( generator->m_state.accumulatorOut(), accumulatorOut, - generator->m_state.accumulatorVariableOut) + u";\n"_qs; + generator->m_state.accumulatorVariableOut) + u";\n"_s; const auto contained = generator->m_typeResolver->containedType( generator->m_state.accumulatorOut()); - generator->m_body += u"}\n"_qs; + generator->m_body += u"}\n"_s; generator->m_state.setRegister(Accumulator, accumulatorOut); generator->m_state.accumulatorVariableOut = accumulatorVariableOut; generator->generateOutputVariantConversion(contained); } else if (accumulatorVariableIn != generator->m_state.accumulatorVariableIn) { - generator->m_body += u"}\n"_qs; + generator->m_body += u"}\n"_s; generator->m_state.accumulatorVariableIn = accumulatorVariableIn; } } diff --git a/src/qmlcompiler/qqmljscodegenerator_p.h b/src/qmlcompiler/qqmljscodegenerator_p.h index e7ed70e43a..b08183c343 100644 --- a/src/qmlcompiler/qqmljscodegenerator_p.h +++ b/src/qmlcompiler/qqmljscodegenerator_p.h @@ -289,7 +289,8 @@ private: bool inlineMathMethod(const QString &name, int argc, int argv); QQmlJSScope::ConstPtr mathObject() const { - return m_typeResolver->jsGlobalObject()->property(u"Math"_qs).type(); + using namespace Qt::StringLiterals; + return m_typeResolver->jsGlobalObject()->property(u"Math"_s).type(); } int firstRegisterIndex() const diff --git a/src/qmlcompiler/qqmljscompiler.cpp b/src/qmlcompiler/qqmljscompiler.cpp index 14811c2aa2..f272cbbd80 100644 --- a/src/qmlcompiler/qqmljscompiler.cpp +++ b/src/qmlcompiler/qqmljscompiler.cpp @@ -48,6 +48,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_LOGGING_CATEGORY(lcAotCompiler, "qt.qml.compiler.aot", QtFatalMsg); static const int FileScopeCodeIndex = -1; @@ -735,21 +737,21 @@ QQmlJSAotFunction QQmlJSAotCompiler::globalCode() const { QQmlJSAotFunction global; global.includes = { - u"QtQml/qjsengine.h"_qs, - u"QtQml/qjsprimitivevalue.h"_qs, - u"QtQml/qjsvalue.h"_qs, - u"QtQml/qqmlcomponent.h"_qs, - u"QtQml/qqmlcontext.h"_qs, - u"QtQml/qqmlengine.h"_qs, - - u"QtCore/qdatetime.h"_qs, - u"QtCore/qobject.h"_qs, - u"QtCore/qstring.h"_qs, - u"QtCore/qstringlist.h"_qs, - u"QtCore/qurl.h"_qs, - u"QtCore/qvariant.h"_qs, - - u"type_traits"_qs + u"QtQml/qjsengine.h"_s, + u"QtQml/qjsprimitivevalue.h"_s, + u"QtQml/qjsvalue.h"_s, + u"QtQml/qqmlcomponent.h"_s, + u"QtQml/qqmlcontext.h"_s, + u"QtQml/qqmlengine.h"_s, + + u"QtCore/qdatetime.h"_s, + u"QtCore/qobject.h"_s, + u"QtCore/qstring.h"_s, + u"QtCore/qstringlist.h"_s, + u"QtCore/qurl.h"_s, + u"QtCore/qvariant.h"_s, + + u"type_traits"_s }; return global; } diff --git a/src/qmlcompiler/qqmljsfunctioninitializer.cpp b/src/qmlcompiler/qqmljsfunctioninitializer.cpp index ce8df3148f..56a2be53b7 100644 --- a/src/qmlcompiler/qqmljsfunctioninitializer.cpp +++ b/src/qmlcompiler/qqmljsfunctioninitializer.cpp @@ -35,6 +35,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + /*! * \internal * \class QQmlJSFunctionInitializer @@ -48,30 +50,30 @@ static QString bindingTypeDescription(QmlIR::Binding::ValueType type) { switch (type) { case QmlIR::Binding::Type_Invalid: - return u"invalid"_qs; + return u"invalid"_s; case QmlIR::Binding::Type_Boolean: - return u"a boolean"_qs; + return u"a boolean"_s; case QmlIR::Binding::Type_Number: - return u"a number"_qs; + return u"a number"_s; case QmlIR::Binding::Type_String: - return u"a string"_qs; + return u"a string"_s; case QmlIR::Binding::Type_Null: - return u"null"_qs; + return u"null"_s; case QmlIR::Binding::Type_Translation: - return u"a translation"_qs; + return u"a translation"_s; case QmlIR::Binding::Type_TranslationById: - return u"a translation by id"_qs; + return u"a translation by id"_s; case QmlIR::Binding::Type_Script: - return u"a script"_qs; + return u"a script"_s; case QmlIR::Binding::Type_Object: - return u"an object"_qs; + return u"an object"_s; case QmlIR::Binding::Type_AttachedProperty: - return u"an attached property"_qs; + return u"an attached property"_s; case QmlIR::Binding::Type_GroupProperty: - return u"a grouped property"_qs; + return u"a grouped property"_s; } - return u"nothing"_qs; + return u"nothing"_s; } void QQmlJSFunctionInitializer::populateSignature( @@ -99,14 +101,14 @@ void QQmlJSFunctionInitializer::populateSignature( function->argumentTypes.append( m_typeResolver->tracked( m_typeResolver->globalType(m_typeResolver->varType()))); - signatureError(u"Cannot resolve the argument type %1."_qs + signatureError(u"Cannot resolve the argument type %1."_s .arg(argument.typeAnnotation->type->toString())); } } else { function->argumentTypes.append( m_typeResolver->tracked( m_typeResolver->globalType(m_typeResolver->varType()))); - signatureError(u"Functions without type annotations won't be compiled"_qs); + signatureError(u"Functions without type annotations won't be compiled"_s); } } } @@ -115,7 +117,7 @@ void QQmlJSFunctionInitializer::populateSignature( if (ast->typeAnnotation) { function->returnType = m_typeResolver->typeFromAST(ast->typeAnnotation->type); if (!function->returnType) - signatureError(u"Cannot resolve return type %1"_qs.arg( + signatureError(u"Cannot resolve return type %1"_s.arg( QmlIR::IRBuilder::asString(ast->typeAnnotation->type->typeId))); } } @@ -149,7 +151,7 @@ QQmlJSCompilePass::Function QQmlJSFunctionInitializer::run( function.qmlScope = m_scopeType; if (irBinding.type != QmlIR::Binding::Type_Script) { - diagnose(u"Binding is not a script binding, but %1."_qs.arg( + diagnose(u"Binding is not a script binding, but %1."_s.arg( bindingTypeDescription(QmlIR::Binding::ValueType(quint32(irBinding.type)))), QtDebugMsg, bindingLocation, error); } @@ -158,7 +160,7 @@ QQmlJSCompilePass::Function QQmlJSFunctionInitializer::run( if (!isProperty && QmlIR::IRBuilder::isSignalPropertyName(propertyName)) { const QString signalName = QmlIR::IRBuilder::signalNameFromSignalPropertyName(propertyName); - if (signalName.endsWith(u"Changed"_qs) + if (signalName.endsWith(u"Changed"_s) && m_objectType->hasProperty(signalName.chopped(strlen("Changed")))) { function.isSignalHandler = true; } else { @@ -172,7 +174,7 @@ QQmlJSCompilePass::Function QQmlJSFunctionInitializer::run( } if (!function.isSignalHandler) { - diagnose(u"Could not compile signal handler for %1: The signal does not exist"_qs.arg( + diagnose(u"Could not compile signal handler for %1: The signal does not exist"_s.arg( signalName), QtWarningMsg, bindingLocation, error); } @@ -181,7 +183,7 @@ QQmlJSCompilePass::Function QQmlJSFunctionInitializer::run( if (!function.isSignalHandler) { if (!isProperty) { - diagnose(u"Could not compile binding for %1: The property does not exist"_qs.arg( + diagnose(u"Could not compile binding for %1: The property does not exist"_s.arg( propertyName), QtWarningMsg, bindingLocation, error); } @@ -193,7 +195,7 @@ QQmlJSCompilePass::Function QQmlJSFunctionInitializer::run( if (!function.returnType) { - diagnose(u"Cannot resolve property type %1 for binding on %2"_qs.arg( + diagnose(u"Cannot resolve property type %1 for binding on %2"_s.arg( property.typeName(), propertyName), QtWarningMsg, bindingLocation, error); } @@ -216,7 +218,7 @@ QQmlJSCompilePass::Function QQmlJSFunctionInitializer::run( auto body = new (&pool) QQmlJS::AST::StatementList(stmt); body = body->finish(); - QString name = u"binding for "_qs; // #### + QString name = u"binding for "_s; // #### ast = new (&pool) QQmlJS::AST::FunctionDeclaration( pool.newString(name), /*formals*/ nullptr, body); ast->lbraceToken = astNode->firstSourceLocation(); diff --git a/src/qmlcompiler/qqmljsimporter.cpp b/src/qmlcompiler/qqmljsimporter.cpp index 0ac4f490fc..5f99a3c1da 100644 --- a/src/qmlcompiler/qqmljsimporter.cpp +++ b/src/qmlcompiler/qqmljsimporter.cpp @@ -37,6 +37,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static const QLatin1String SlashQmldir = QLatin1String("/qmldir"); static const QLatin1String SlashPluginsDotQmltypes = QLatin1String("/plugins.qmltypes"); @@ -295,7 +297,7 @@ void QQmlJSImporter::importDependencies(const QQmlJSImporter::Import &import, if (hasOptionalImports && !m_useOptionalImports) { m_warnings.append( - { u"%1 uses optional imports which are not supported. Some types might not be found."_qs + { u"%1 uses optional imports which are not supported. Some types might not be found."_s .arg(import.name), QtCriticalMsg, QQmlJS::SourceLocation() }); } @@ -467,7 +469,7 @@ void QQmlJSImporter::processImport(const QQmlJSScope::Import &importDescription, // only happen when enumerations are involved, thus the strategy is to // resolve enumerations (which can potentially create new child scopes) // before resolving the type fully - const QQmlJSScope::ConstPtr intType = tempTypes.cppNames.value(u"int"_qs).scope; + const QQmlJSScope::ConstPtr intType = tempTypes.cppNames.value(u"int"_s).scope; for (auto it = import.objects.begin(); it != import.objects.end(); ++it) { if (!it->scope.factory()) QQmlJSScope::resolveEnums(it->scope, intType); @@ -532,12 +534,12 @@ QQmlJSImporter::AvailableTypes QQmlJSImporter::builtinImportHelper() importBuiltins(m_importPaths); if (!qmltypesFiles.isEmpty()) { const QString pathsString = - m_importPaths.isEmpty() ? u"<empty>"_qs : m_importPaths.join(u"\n\t"); + m_importPaths.isEmpty() ? u"<empty>"_s : m_importPaths.join(u"\n\t"); m_warnings.append({ QStringLiteral("Failed to find the following builtins: %1 (so will use " "qrc). Import paths used:\n\t%2") .arg(qmltypesFiles.join(u", "), pathsString), QtWarningMsg, QQmlJS::SourceLocation() }); - importBuiltins({ u":/qt-project.org/qml/builtins"_qs }); // use qrc as a "last resort" + importBuiltins({ u":/qt-project.org/qml/builtins"_s }); // use qrc as a "last resort" } Q_ASSERT(qmltypesFiles.isEmpty()); // since qrc must cover it in all the bad cases @@ -654,7 +656,7 @@ bool QQmlJSImporter::importHelper(const QString &module, AvailableTypes *types, // The QML module only contains builtins and is not registered declaratively, so ignore requests // for importing it - if (module == u"QML"_qs) + if (module == u"QML"_s) return true; if (getTypesFromCache()) @@ -792,7 +794,7 @@ void QQmlJSImporter::setImportPaths(const QStringList &importPaths) QQmlJSScope::ConstPtr QQmlJSImporter::jsGlobalObject() const { - return m_builtins.cppNames[u"GlobalObject"_qs].scope; + return m_builtins.cppNames[u"GlobalObject"_s].scope; } QT_END_NAMESPACE diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp index 246362c693..fd927c67d4 100644 --- a/src/qmlcompiler/qqmljsimportvisitor.cpp +++ b/src/qmlcompiler/qqmljsimportvisitor.cpp @@ -46,6 +46,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + using namespace QQmlJS::AST; /*! @@ -102,7 +104,7 @@ QQmlJSImportVisitor::QQmlJSImportVisitor( m_globalScope = m_currentScope; m_currentScope->setIsComposite(true); - m_currentScope->setInternalName(u"global"_qs); + m_currentScope->setInternalName(u"global"_s); QLatin1String jsGlobVars[] = { /* Not listed on the MDN page; browser and QML extensions: */ // console/debug api @@ -369,7 +371,7 @@ void QQmlJSImportVisitor::importBaseModules() // Pulling in the modules and neighboring qml files of the qmltypes we're trying to lint is not // something we need to do. - if (!m_logger->fileName().endsWith(u".qmltypes"_qs)) { + if (!m_logger->fileName().endsWith(u".qmltypes"_s)) { m_rootScopeImports.insert(m_importer->importDirectory(m_implicitImportDirectory)); QQmlJSResourceFileMapper *mapper = m_importer->resourceFileMapper(); @@ -802,11 +804,11 @@ void QQmlJSImportVisitor::checkRequiredProperties() const QString propertyScopeName = !propertyScope.isNull() ? getScopeName(propertyScope, QQmlJSScope::QMLScope) - : u"here"_qs; + : u"here"_s; const QString requiredScopeName = prevRequiredScope ? getScopeName(prevRequiredScope, QQmlJSScope::QMLScope) - : u"here"_qs; + : u"here"_s; std::optional<FixSuggestion> suggestion; @@ -819,7 +821,7 @@ void QQmlJSImportVisitor::checkRequiredProperties() if (!prevRequiredScope.isNull()) { auto sourceScope = prevRequiredScope->baseType(); suggestion = FixSuggestion { - { { u"%1:%2:%3: Property marked as required in %4"_qs + { { u"%1:%2:%3: Property marked as required in %4"_s .arg(sourceScope->filePath()) .arg(sourceScope->sourceLocation().startLine) .arg(sourceScope->sourceLocation().startColumn) @@ -1285,7 +1287,7 @@ void QQmlJSImportVisitor::populateRuntimeFunctionIndicesForDocument() const bool QQmlJSImportVisitor::visit(QQmlJS::AST::ExpressionStatement *ast) { if (m_pendingSignalHandler.isValid()) { - enterEnvironment(QQmlJSScope::JSFunctionScope, u"signalhandler"_qs, + enterEnvironment(QQmlJSScope::JSFunctionScope, u"signalhandler"_s, ast->firstSourceLocation()); flushPendingSignalParameters(); } @@ -1295,7 +1297,7 @@ bool QQmlJSImportVisitor::visit(QQmlJS::AST::ExpressionStatement *ast) void QQmlJSImportVisitor::endVisit(QQmlJS::AST::ExpressionStatement *) { if (m_currentScope->scopeType() == QQmlJSScope::JSFunctionScope - && m_currentScope->baseTypeName() == u"signalhandler"_qs) { + && m_currentScope->baseTypeName() == u"signalhandler"_s) { leaveEnvironment(); } } @@ -1331,7 +1333,7 @@ bool QQmlJSImportVisitor::visit(QQmlJS::AST::StringLiteral *sl) templateString += c; } - const FixSuggestion suggestion = { { { u"Use a template literal instead"_qs, + const FixSuggestion suggestion = { { { u"Use a template literal instead"_s, sl->literalToken, u"`" % templateString % u"`", QString(), false } } }; m_logger->log(QStringLiteral("String contains unescaped line terminator which is " @@ -1393,7 +1395,7 @@ void QQmlJSImportVisitor::endVisit(UiObjectDefinition *) bool QQmlJSImportVisitor::visit(UiInlineComponent *component) { if (!m_inlineComponentName.isNull()) { - m_logger->log(u"Nested inline components are not supported"_qs, Log_Syntax, + m_logger->log(u"Nested inline components are not supported"_s, Log_Syntax, component->firstSourceLocation()); return true; } @@ -1427,7 +1429,7 @@ bool QQmlJSImportVisitor::visit(UiPublicMember *publicMember) case UiPublicMember::Property: { QString typeName = buildName(publicMember->memberType); QString aliasExpr; - const bool isAlias = (typeName == u"alias"_qs); + const bool isAlias = (typeName == u"alias"_s); if (isAlias) { typeName.clear(); // type name is useless for alias here, so keep it empty const auto expression = cast<ExpressionStatement *>(publicMember->statement); @@ -1617,7 +1619,7 @@ bool QQmlJSImportVisitor::visit(QQmlJS::AST::UiSourceElement *srcElement) bool QQmlJSImportVisitor::visit(QQmlJS::AST::FunctionDeclaration *fdecl) { - m_logger->log(u"Declared function \"%1\""_qs.arg(fdecl->name), Log_ControlsSanity, + m_logger->log(u"Declared function \"%1\""_s.arg(fdecl->name), Log_ControlsSanity, fdecl->firstSourceLocation()); incrementInnerFunctionCount(); visitFunctionExpressionHelper(fdecl); @@ -1760,11 +1762,11 @@ void QQmlJSImportVisitor::handleIdDeclaration(QQmlJS::AST::UiScriptBinding *scri if (const auto *idExpression = cast<IdentifierExpression *>(statement->expression)) return idExpression->name.toString(); else if (const auto *idString = cast<StringLiteral *>(statement->expression)) { - m_logger->log(u"ids do not need quotation marks"_qs, Log_SyntaxIdQuotation, + m_logger->log(u"ids do not need quotation marks"_s, Log_SyntaxIdQuotation, idString->firstSourceLocation()); return idString->value.toString(); } - m_logger->log(u"Failed to parse id"_qs, Log_Syntax, + m_logger->log(u"Failed to parse id"_s, Log_Syntax, statement->expression->firstSourceLocation()); return QString(); @@ -1777,7 +1779,7 @@ void QQmlJSImportVisitor::handleIdDeclaration(QQmlJS::AST::UiScriptBinding *scri auto otherLocation = otherScopeWithID->sourceLocation(); // critical because subsequent analysis cannot cope with messed up ids // and the file is invalid - m_logger->log(u"Found a duplicated id. id %1 was first declared at %2:%3"_qs.arg( + m_logger->log(u"Found a duplicated id. id %1 was first declared at %2:%3"_s.arg( name, QString::number(otherLocation.startLine), QString::number(otherLocation.startColumn)), Log_Syntax, // ?? @@ -1854,7 +1856,7 @@ bool QQmlJSImportVisitor::visit(UiScriptBinding *scriptBinding) auto name = group->name; if (id && id->name.toString() == u"anchors") - m_logger->log(u"Using anchors here"_qs, Log_ControlsSanity, + m_logger->log(u"Using anchors here"_s, Log_ControlsSanity, scriptBinding->firstSourceLocation()); const auto signal = QQmlJSUtils::signalName(name); @@ -1875,7 +1877,7 @@ bool QQmlJSImportVisitor::visit(UiScriptBinding *scriptBinding) } } - m_logger->log(u"Declared signal handler \"%1\""_qs.arg(name), Log_ControlsSanity, + m_logger->log(u"Declared signal handler \"%1\""_s.arg(name), Log_ControlsSanity, scriptBinding->firstSourceLocation()); m_signals[m_currentScope].append({ m_savedBindingOuterScope, group->firstSourceLocation(), @@ -2080,7 +2082,7 @@ bool QQmlJSImportVisitor::visit(QQmlJS::AST::UiPragma *pragma) // If a file uses pragma Strict, it expects to be compiled, so automatically // enable compiler warnings unless the level is set explicitly already (e.g. // by the user). - if (pragma->name == u"Strict"_qs && !m_logger->wasCategoryChanged(Log_Compiler)) { + if (pragma->name == u"Strict"_s && !m_logger->wasCategoryChanged(Log_Compiler)) { // TODO: the logic here is rather complicated and may be buggy m_logger->setCategoryLevel(Log_Compiler, QtWarningMsg); m_logger->setCategoryIgnored(Log_Compiler, false); @@ -2308,7 +2310,7 @@ void QQmlJSImportVisitor::endVisit(QQmlJS::AST::UiObjectBinding *uiob) if (foundIds) { m_logger->log( - u"Cannot defer property assignment to \"%1\". Assigning an id to an object or one of its sub-objects bound to a deferred property will make the assignment immediate."_qs + u"Cannot defer property assignment to \"%1\". Assigning an id to an object or one of its sub-objects bound to a deferred property will make the assignment immediate."_s .arg(propertyName), Log_DeferredPropertyId, uiob->firstSourceLocation()); } @@ -2324,10 +2326,10 @@ void QQmlJSImportVisitor::endVisit(QQmlJS::AST::UiObjectBinding *uiob) QQmlJSMetaPropertyBinding binding(uiob->firstSourceLocation(), propertyName); if (uiob->hasOnToken) { - if (childScope->hasInterface(u"QQmlPropertyValueInterceptor"_qs)) { + if (childScope->hasInterface(u"QQmlPropertyValueInterceptor"_s)) { binding.setInterceptor(getScopeName(childScope, QQmlJSScope::QMLScope), QQmlJSScope::ConstPtr(childScope)); - } else { // if (childScope->hasInterface(u"QQmlPropertyValueSource"_qs)) + } else { // if (childScope->hasInterface(u"QQmlPropertyValueSource"_s)) binding.setValueSource(getScopeName(childScope, QQmlJSScope::QMLScope), QQmlJSScope::ConstPtr(childScope)); } diff --git a/src/qmlcompiler/qqmljslinter.cpp b/src/qmlcompiler/qqmljslinter.cpp index 44d4c4a38c..42ade39e3d 100644 --- a/src/qmlcompiler/qqmljslinter.cpp +++ b/src/qmlcompiler/qqmljslinter.cpp @@ -59,6 +59,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + class CodegenWarningInterface final : public QV4::Compiler::CodegenWarningInterface { public: @@ -70,7 +72,7 @@ public: { Q_UNUSED(fileName) m_logger->log( - u"Variable \"%1\" is used here before its declaration. The declaration is at %2:%3."_qs + u"Variable \"%1\" is used here before its declaration. The declaration is at %2:%3."_s .arg(name) .arg(declarationLocation.startLine) .arg(declarationLocation.startColumn), @@ -133,7 +135,7 @@ QQmlJSLinter::Plugin::Plugin(QString path) QQmlJSLinter::Plugin::Plugin(const QStaticPlugin &staticPlugin) { - if (!parseMetaData(staticPlugin.metaData(), u"built-in"_qs)) + if (!parseMetaData(staticPlugin.metaData(), u"built-in"_s)) return; m_instance = qobject_cast<QQmlSA::LintPlugin *>(staticPlugin.instance()); @@ -162,7 +164,7 @@ bool QQmlJSLinter::Plugin::parseMetaData(const QJsonObject &metaData, QString pl QJsonObject pluginMetaData = metaData[u"MetaData"].toObject(); - for (const QString &requiredKey : { u"name"_qs, u"version"_qs, u"author"_qs }) { + for (const QString &requiredKey : { u"name"_s, u"version"_s, u"author"_s }) { if (!pluginMetaData.contains(requiredKey)) { qWarning() << pluginName << "is missing the required " << requiredKey << "metadata, skipping"; @@ -173,7 +175,7 @@ bool QQmlJSLinter::Plugin::parseMetaData(const QJsonObject &metaData, QString pl m_name = pluginMetaData[u"name"].toString(); m_author = pluginMetaData[u"author"].toString(); m_version = pluginMetaData[u"version"].toString(); - m_description = pluginMetaData[u"description"].toString(u"-/-"_qs); + m_description = pluginMetaData[u"description"].toString(u"-/-"_s); return true; } @@ -258,7 +260,7 @@ void QQmlJSLinter::parseComments(QQmlJSLogger *logger, if (option != logger->options().constEnd()) categories << option->m_category; else - logger->log(u"qmllint directive on unknown category \"%1\""_qs.arg(category), + logger->log(u"qmllint directive on unknown category \"%1\""_s.arg(category), Log_Syntax, loc); } @@ -267,7 +269,7 @@ void QQmlJSLinter::parseComments(QQmlJSLogger *logger, categories << option.m_category; } - if (command == u"disable"_qs) { + if (command == u"disable"_s) { const QString line = lines[loc.startLine - 1]; const QString preComment = line.left(line.indexOf(comment) - 2); @@ -283,10 +285,10 @@ void QQmlJSLinter::parseComments(QQmlJSLogger *logger, oneLineDisablesPerLine[loc.startLine] |= categories; else disablesPerLine[loc.startLine] |= categories; - } else if (command == u"enable"_qs) { + } else if (command == u"enable"_s) { enablesPerLine[loc.startLine + 1] |= categories; } else { - logger->log(u"Invalid qmllint directive \"%1\" provided"_qs.arg(command), Log_Syntax, + logger->log(u"Invalid qmllint directive \"%1\" provided"_s.arg(command), Log_Syntax, loc); } } @@ -326,7 +328,7 @@ QQmlJSLinter::LintResult QQmlJSLinter::lintFile(const QString &filename, if (!json) return; - result[u"filename"_qs] = QFileInfo(filename).absoluteFilePath(); + result[u"filename"_s] = QFileInfo(filename).absoluteFilePath(); result[u"warnings"] = warnings; result[u"success"] = success; @@ -340,46 +342,46 @@ QQmlJSLinter::LintResult QQmlJSLinter::lintFile(const QString &filename, QString type; switch (message.type) { case QtDebugMsg: - type = u"debug"_qs; + type = u"debug"_s; break; case QtWarningMsg: - type = u"warning"_qs; + type = u"warning"_s; break; case QtCriticalMsg: - type = u"critical"_qs; + type = u"critical"_s; break; case QtFatalMsg: - type = u"fatal"_qs; + type = u"fatal"_s; break; case QtInfoMsg: - type = u"info"_qs; + type = u"info"_s; break; default: - type = u"unknown"_qs; + type = u"unknown"_s; break; } - jsonMessage[u"type"_qs] = type; + jsonMessage[u"type"_s] = type; if (message.loc.isValid()) { - jsonMessage[u"line"_qs] = static_cast<int>(message.loc.startLine); - jsonMessage[u"column"_qs] = static_cast<int>(message.loc.startColumn); - jsonMessage[u"charOffset"_qs] = static_cast<int>(message.loc.offset); - jsonMessage[u"length"_qs] = static_cast<int>(message.loc.length); + jsonMessage[u"line"_s] = static_cast<int>(message.loc.startLine); + jsonMessage[u"column"_s] = static_cast<int>(message.loc.startColumn); + jsonMessage[u"charOffset"_s] = static_cast<int>(message.loc.offset); + jsonMessage[u"length"_s] = static_cast<int>(message.loc.length); } - jsonMessage[u"message"_qs] = message.message; + jsonMessage[u"message"_s] = message.message; QJsonArray suggestions; if (suggestion.has_value()) { for (const auto &fix : suggestion->fixes) { QJsonObject jsonFix; jsonFix[u"message"] = fix.message; - jsonFix[u"line"_qs] = static_cast<int>(fix.cutLocation.startLine); - jsonFix[u"column"_qs] = static_cast<int>(fix.cutLocation.startColumn); - jsonFix[u"charOffset"_qs] = static_cast<int>(fix.cutLocation.offset); - jsonFix[u"length"_qs] = static_cast<int>(fix.cutLocation.length); - jsonFix[u"replacement"_qs] = fix.replacementString; + jsonFix[u"line"_s] = static_cast<int>(fix.cutLocation.startLine); + jsonFix[u"column"_s] = static_cast<int>(fix.cutLocation.startColumn); + jsonFix[u"charOffset"_s] = static_cast<int>(fix.cutLocation.offset); + jsonFix[u"length"_s] = static_cast<int>(fix.cutLocation.length); + jsonFix[u"replacement"_s] = fix.replacementString; jsonFix[u"isHint"] = fix.isHint; if (!fix.fileName.isEmpty()) jsonFix[u"fileName"] = fix.fileName; @@ -537,7 +539,7 @@ QQmlJSLinter::LintResult QQmlJSLinter::lintFile(const QString &filename, QQmlJSCompileError error; - QLoggingCategory::setFilterRules(u"qt.qml.compiler=false"_qs); + QLoggingCategory::setFilterRules(u"qt.qml.compiler=false"_s); CodegenWarningInterface interface(m_logger.get()); qCompileQmlFile(filename, saveFunction, &codegen, &error, true, &interface, diff --git a/src/qmlcompiler/qqmljslintercodegen.cpp b/src/qmlcompiler/qqmljslintercodegen.cpp index db9b94a253..fd22e95ef9 100644 --- a/src/qmlcompiler/qqmljslintercodegen.cpp +++ b/src/qmlcompiler/qqmljslintercodegen.cpp @@ -38,6 +38,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + QQmlJSLinterCodegen::QQmlJSLinterCodegen(QQmlJSImporter *importer, const QString &fileName, const QStringList &qmldirFiles, QQmlJSLogger *logger, QQmlJSTypeInfo *typeInfo) @@ -71,7 +73,7 @@ QQmlJSLinterCodegen::compileBinding(const QV4::Compiler::Context *context, if (!analyzeFunction(context, &function, &analyzeError)) { // If it's a signal and the function just returns a closure, it's harmless. // Otherwise promote the message to warning level. - return diagnose(u"Could not compile binding for %1: %2"_qs.arg(name, analyzeError.message), + return diagnose(u"Could not compile binding for %1: %2"_s.arg(name, analyzeError.message), (function.isSignalHandler && analyzeError.type == QtDebugMsg) ? QtDebugMsg : QtWarningMsg, @@ -95,7 +97,7 @@ QQmlJSLinterCodegen::compileFunction(const QV4::Compiler::Context *context, QQmlJS::DiagnosticMessage analyzeError; if (!analyzeFunction(context, &function, &analyzeError)) { - return diagnose(u"Could not compile function %1: %2"_qs.arg(name, analyzeError.message), + return diagnose(u"Could not compile function %1: %2"_s.arg(name, analyzeError.message), QtWarningMsg, analyzeError.loc); } diff --git a/src/qmlcompiler/qqmljsliteralbindingcheck.cpp b/src/qmlcompiler/qqmljsliteralbindingcheck.cpp index ec0c3380ec..20e29649d0 100644 --- a/src/qmlcompiler/qqmljsliteralbindingcheck.cpp +++ b/src/qmlcompiler/qqmljsliteralbindingcheck.cpp @@ -34,6 +34,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + void QQmlJSLiteralBindingCheck::run(QQmlJSImportVisitor *visitor, QQmlJSTypeResolver *resolver) { QQmlJSLogger *logger = visitor->logger(); @@ -52,13 +54,13 @@ void QQmlJSLiteralBindingCheck::run(QQmlJSImportVisitor *visitor, QQmlJSTypeReso // If the property is defined in the same scope where it is set, // we are in fact allowed to set it, even if it's not writable. if (!property.isWritable() && !scope->hasOwnProperty(propertyName)) { - logger->log(u"Cannot assign to read-only property %1"_qs.arg(propertyName), + logger->log(u"Cannot assign to read-only property %1"_s.arg(propertyName), Log_Type, binding.sourceLocation()); continue; } if (!resolver->canConvertFromTo(binding.literalType(resolver), property.type())) { - logger->log(u"Cannot assign binding of type %1 to %2"_qs.arg( + logger->log(u"Cannot assign binding of type %1 to %2"_s.arg( QQmlJSScope::prettyName(binding.literalTypeName()), QQmlJSScope::prettyName(property.typeName())), Log_Type, binding.sourceLocation()); @@ -67,7 +69,7 @@ void QQmlJSLiteralBindingCheck::run(QQmlJSImportVisitor *visitor, QQmlJSTypeReso if (resolver->equals(property.type(), resolver->stringType()) && resolver->isNumeric(binding.literalType(resolver))) { - logger->log(u"Cannot assign a numeric constant to a string property"_qs, + logger->log(u"Cannot assign a numeric constant to a string property"_s, Log_Type, binding.sourceLocation()); } } diff --git a/src/qmlcompiler/qqmljslogger.cpp b/src/qmlcompiler/qqmljslogger.cpp index c03f8d07d4..7763aecab9 100644 --- a/src/qmlcompiler/qqmljslogger.cpp +++ b/src/qmlcompiler/qqmljslogger.cpp @@ -33,6 +33,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + const QMap<QString, QQmlJSLogger::Option> &QQmlJSLogger::options() { static QMap<QString, QQmlJSLogger::Option> optionsMap = { { QStringLiteral("required"), @@ -289,10 +291,10 @@ void QQmlJSLogger::printFix(const FixSuggestion &fix) if (replacementString.contains(u'\n')) continue; - m_output.write(u" "_qs.repeated( + m_output.write(u" "_s.repeated( issueLocationWithContext.beforeText().length() - tabCount) - + u"\t"_qs.repeated(tabCount) - + u"^"_qs.repeated(fixItem.replacementString.length()) + u'\n'); + + u"\t"_s.repeated(tabCount) + + u"^"_s.repeated(fixItem.replacementString.length()) + u'\n'); } } diff --git a/src/qmlcompiler/qqmljsregistercontent.cpp b/src/qmlcompiler/qqmljsregistercontent.cpp index c6ab1ffbd7..1bad8111e0 100644 --- a/src/qmlcompiler/qqmljsregistercontent.cpp +++ b/src/qmlcompiler/qqmljsregistercontent.cpp @@ -31,21 +31,23 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + QString QQmlJSRegisterContent::descriptiveName() const { if (m_storedType.isNull()) - return u"(invalid type)"_qs; + return u"(invalid type)"_s; - QString result = m_storedType->internalName() + u" of "_qs; + QString result = m_storedType->internalName() + u" of "_s; const auto scope = [this]() -> QString { if (m_scope.isNull()) - return u"(invalid type)::"_qs; + return u"(invalid type)::"_s; return (m_scope->internalName().isEmpty() ? (m_scope->filePath().isEmpty() - ? u"??"_qs - : (u"(component in "_qs + m_scope->filePath() + u")"_qs)) + ? u"??"_s + : (u"(component in "_s + m_scope->filePath() + u")"_s)) : m_scope->internalName()) - + u"::"_qs; + + u"::"_s; }; switch (m_content.index()) { @@ -53,32 +55,32 @@ QString QQmlJSRegisterContent::descriptiveName() const return result + std::get<QQmlJSScope::ConstPtr>(m_content)->internalName(); case Property: { const QQmlJSMetaProperty prop = std::get<QQmlJSMetaProperty>(m_content); - return result + scope() + prop.propertyName() + u" with type "_qs + prop.typeName(); + return result + scope() + prop.propertyName() + u" with type "_s + prop.typeName(); } case Method: { const auto methods = std::get<QList<QQmlJSMetaMethod>>(m_content); if (methods.isEmpty()) - return result + scope() + u"(unknown method)"_qs; + return result + scope() + u"(unknown method)"_s; else - return result + scope() + methods[0].methodName() + u"(...)"_qs; + return result + scope() + methods[0].methodName() + u"(...)"_s; } case Enum: { const auto e = std::get<std::pair<QQmlJSMetaEnum, QString>>(m_content); if (e.second.isEmpty()) return result + scope() + e.first.name(); else - return result + scope() + e.first.name() + u"::"_qs + e.second; + return result + scope() + e.first.name() + u"::"_s + e.second; } case ImportNamespace: { - return u"import namespace %1"_qs.arg(std::get<uint>(m_content)); + return u"import namespace %1"_s.arg(std::get<uint>(m_content)); } case Conversion: { - return u"conversion to %1"_qs.arg( + return u"conversion to %1"_s.arg( std::get<ConvertedTypes>(m_content).result->internalName()); } } Q_UNREACHABLE(); - return result + u"wat?"_qs; + return result + u"wat?"_s; } bool QQmlJSRegisterContent::isList() const diff --git a/src/qmlcompiler/qqmljsscope.cpp b/src/qmlcompiler/qqmljsscope.cpp index ded18e8163..f419757592 100644 --- a/src/qmlcompiler/qqmljsscope.cpp +++ b/src/qmlcompiler/qqmljsscope.cpp @@ -132,7 +132,7 @@ void QQmlJSScope::insertJSIdentifier(const QString &name, const JavaScriptIdenti void QQmlJSScope::insertPropertyIdentifier(const QQmlJSMetaProperty &property) { addOwnProperty(property); - QQmlJSMetaMethod method(property.propertyName() + u"Changed"_qs, u"void"_qs); + QQmlJSMetaMethod method(property.propertyName() + u"Changed"_s, u"void"_s); method.setMethodType(QQmlJSMetaMethod::Signal); method.setIsImplicitQmlPropertyChangeSignal(true); addOwnMethod(method); @@ -512,7 +512,7 @@ QTypeRevision QQmlJSScope::resolveTypes( const auto resolveAll = [](const QQmlJSScope::Ptr &self, const QQmlJSScope::ContextualTypes &contextualTypes, QSet<QString> *usedTypes) { - resolveEnums(self, findType(u"int"_qs, contextualTypes, usedTypes).scope); + resolveEnums(self, findType(u"int"_s, contextualTypes, usedTypes).scope); return resolveType(self, contextualTypes, usedTypes); }; return resolveTypesInternal(resolveAll, updateChildScope, self, contextualTypes, usedTypes); @@ -919,7 +919,7 @@ void QDeferredFactory<QQmlJSScope>::populate(const QSharedPointer<QQmlJSScope> & typeReader(scope); m_importer->m_globalWarnings.append(typeReader.errors()); scope->setInternalName(internalName()); - QQmlJSScope::resolveEnums(scope, m_importer->builtinInternalNames().value(u"int"_qs).scope); + QQmlJSScope::resolveEnums(scope, m_importer->builtinInternalNames().value(u"int"_s).scope); if (m_isSingleton && !scope->isSingleton()) { m_importer->m_globalWarnings.append( @@ -967,11 +967,11 @@ bool QQmlJSScope::canAssign(const QQmlJSScope::ConstPtr &derived) const scope = scope->baseType()) { if (isSameType(scope)) return true; - if (isBaseComponent && scope->internalName() == u"QObject"_qs) + if (isBaseComponent && scope->internalName() == u"QObject"_s) return true; } - return internalName() == u"QVariant"_qs || internalName() == u"QJSValue"_qs; + return internalName() == u"QVariant"_s || internalName() == u"QJSValue"_s; } bool QQmlJSScope::isInCustomParserParent() const diff --git a/src/qmlcompiler/qqmljsscope_p.h b/src/qmlcompiler/qqmljsscope_p.h index 4609b18fb6..e62d6aef36 100644 --- a/src/qmlcompiler/qqmljsscope_p.h +++ b/src/qmlcompiler/qqmljsscope_p.h @@ -300,9 +300,11 @@ public: void setInternalName(const QString &internalName) { m_internalName = internalName; } QString augmentedInternalName() const { + using namespace Qt::StringLiterals; + QString suffix; if (m_semantics == AccessSemantics::Reference) - suffix = u" *"_qs; + suffix = u" *"_s; return m_internalName + suffix; } diff --git a/src/qmlcompiler/qqmljsshadowcheck.cpp b/src/qmlcompiler/qqmljsshadowcheck.cpp index d56f19c105..743ed61abf 100644 --- a/src/qmlcompiler/qqmljsshadowcheck.cpp +++ b/src/qmlcompiler/qqmljsshadowcheck.cpp @@ -30,6 +30,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + /*! * \internal * \class QQmlJSShadowCheck @@ -127,7 +129,7 @@ void QQmlJSShadowCheck::checkShadowing( return; // Only properties and methods can be shadowed } - setError(u"Member %1 of %2 can be shadowed"_qs + setError(u"Member %1 of %2 can be shadowed"_s .arg(memberName, m_state.accumulatorIn().descriptiveName())); return; } diff --git a/src/qmlcompiler/qqmljstypepropagator.cpp b/src/qmlcompiler/qqmljstypepropagator.cpp index 86bed50390..e5e0bb367c 100644 --- a/src/qmlcompiler/qqmljstypepropagator.cpp +++ b/src/qmlcompiler/qqmljstypepropagator.cpp @@ -34,6 +34,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + /*! * \internal * \class QQmlJSTypePropagator @@ -80,12 +82,12 @@ QQmlJSCompilePass::InstructionAnnotations QQmlJSTypePropagator::run( } #define INSTR_PROLOGUE_NOT_IMPLEMENTED() \ - setError(u"Instruction \"%1\" not implemented"_qs \ + setError(u"Instruction \"%1\" not implemented"_s \ .arg(QString::fromUtf8(__func__))); \ return; #define INSTR_PROLOGUE_NOT_IMPLEMENTED_IGNORE() \ - m_logger->log(u"Instruction \"%1\" not implemented"_qs.arg(QString::fromUtf8(__func__)), \ + m_logger->log(u"Instruction \"%1\" not implemented"_s.arg(QString::fromUtf8(__func__)), \ Log_Compiler, QQmlJS::SourceLocation()); \ return; @@ -96,15 +98,15 @@ void QQmlJSTypePropagator::generate_Ret() } else if (!m_returnType.isValid() && m_state.accumulatorIn().isValid() && !m_typeResolver->registerContains( m_state.accumulatorIn(), m_typeResolver->voidType())) { - setError(u"function without type annotation returns %1"_qs + setError(u"function without type annotation returns %1"_s .arg(m_state.accumulatorIn().descriptiveName())); return; } else if (!canConvertFromTo(m_state.accumulatorIn(), m_returnType)) { - setError(u"cannot convert from %1 to %2"_qs + setError(u"cannot convert from %1 to %2"_s .arg(m_state.accumulatorIn().descriptiveName(), m_returnType.descriptiveName())); - m_logger->log(u"Cannot assign binding of type %1 to %2"_qs.arg( + m_logger->log(u"Cannot assign binding of type %1 to %2"_s.arg( m_typeResolver->containedTypeName(m_state.accumulatorIn(), true), m_typeResolver->containedTypeName(m_returnType, true)), Log_Type, getCurrentBindingSourceLocation()); @@ -254,7 +256,7 @@ void QQmlJSTypePropagator::generate_LoadName(int nameIndex) const QString name = m_jsUnitGenerator->stringForIndex(nameIndex); setAccumulator(m_typeResolver->scopedType(m_function->qmlScope, name)); if (!m_state.accumulatorOut().isValid()) - setError(u"Cannot find name "_qs + name); + setError(u"Cannot find name "_s + name); } void QQmlJSTypePropagator::generate_LoadGlobalLookup(int index) @@ -291,7 +293,7 @@ void QQmlJSTypePropagator::handleUnqualifiedAccess(const QString &name, bool isM if (m_function->qmlScope->isInCustomParserParent()) { // Only ignore custom parser based elements if it's not Connections. if (m_function->qmlScope->baseType().isNull() - || m_function->qmlScope->baseType()->internalName() != u"QQmlConnections"_qs) + || m_function->qmlScope->baseType()->internalName() != u"QQmlConnections"_s) return; } @@ -328,15 +330,15 @@ void QQmlJSTypePropagator::handleUnqualifiedAccess(const QString &name, bool isM const auto handler = m_typeResolver->signalHandlers()[id.location]; - QString fixString = handler.isMultiline ? u"function("_qs : u"("_qs; + QString fixString = handler.isMultiline ? u"function("_s : u"("_s; const auto parameters = handler.signalParameters; for (int numParams = parameters.size(); numParams > 0; --numParams) { fixString += parameters.at(parameters.size() - numParams); if (numParams > 1) - fixString += u", "_qs; + fixString += u", "_s; } - fixString += handler.isMultiline ? u") "_qs : u") => "_qs; + fixString += handler.isMultiline ? u") "_s : u") => "_s; suggestion->fixes << FixSuggestion::Fix { name @@ -365,12 +367,12 @@ void QQmlJSTypePropagator::handleUnqualifiedAccess(const QString &name, bool isM name + QLatin1String(" is a member of a parent element\n") + QLatin1String(" You can qualify the access with its id " "to avoid this warning:\n"), - fixLocation, (id.isEmpty() ? u"<id>."_qs : (id + u'.')), QString(), id.isEmpty() + fixLocation, (id.isEmpty() ? u"<id>."_s : (id + u'.')), QString(), id.isEmpty() }; if (id.isEmpty()) { suggestion->fixes << FixSuggestion::Fix { - u"You first have to give the element an id"_qs, QQmlJS::SourceLocation {}, {} + u"You first have to give the element an id"_s, QQmlJS::SourceLocation {}, {} }; } } @@ -427,10 +429,10 @@ void QQmlJSTypePropagator::checkDeprecated(QQmlJSScope::ConstPtr scope, const QS QString descriptor = name; if (isMethod) - descriptor += u'(' + method.parameterNames().join(u", "_qs) + u')'; + descriptor += u'(' + method.parameterNames().join(u", "_s) + u')'; QString message = QStringLiteral("%1 \"%2\" is deprecated") - .arg(isMethod ? u"Method"_qs : u"Property"_qs) + .arg(isMethod ? u"Method"_s : u"Property"_s) .arg(descriptor); if (!deprecation.reason.isEmpty()) @@ -448,16 +450,16 @@ bool QQmlJSTypePropagator::isRestricted(const QString &propertyName) const return false; if (accumulatorIn.value().isList() && propertyName != u"length") { - restrictedKind = u"a list"_qs; + restrictedKind = u"a list"_s; } else if (accumulatorIn.value().isEnumeration() && !accumulatorIn.value().enumeration().hasKey(propertyName)) { - restrictedKind = u"an enum"_qs; + restrictedKind = u"an enum"_s; } else if (accumulatorIn.value().isMethod()) { - restrictedKind = u"a method"_qs; + restrictedKind = u"a method"_s; } if (!restrictedKind.isEmpty()) - m_logger->log(u"Type is %1. You cannot access \"%2\" from here."_qs.arg(restrictedKind, + m_logger->log(u"Type is %1. You cannot access \"%2\" from here."_s.arg(restrictedKind, propertyName), Log_Type, getCurrentSourceLocation()); @@ -474,14 +476,14 @@ bool QQmlJSTypePropagator::isMissingPropertyType(QQmlJSScope::ConstPtr scope, QString errorType; if (property.type().isNull()) - errorType = u"found"_qs; + errorType = u"found"_s; else if (!property.type()->isFullyResolved()) - errorType = u"fully resolved"_qs; + errorType = u"fully resolved"_s; Q_ASSERT(!errorType.isEmpty()); m_logger->log( - u"Type \"%1\" of property \"%2\" not %3. This is likely due to a missing dependency entry or a type not being exposed declaratively."_qs + u"Type \"%1\" of property \"%2\" not %3. This is likely due to a missing dependency entry or a type not being exposed declaratively."_s .arg(property.typeName(), propertyName, errorType), Log_Type, getCurrentSourceLocation()); @@ -494,35 +496,35 @@ bool QQmlJSTypePropagator::isCallingProperty(QQmlJSScope::ConstPtr scope, const if (!property.isValid()) return false; - QString propertyType = u"Property"_qs; + QString propertyType = u"Property"_s; auto methods = scope->methods(name); QString errorType; if (!methods.isEmpty()) { - errorType = u"shadowed by a property."_qs; + errorType = u"shadowed by a property."_s; switch (methods.first().methodType()) { case QQmlJSMetaMethod::Signal: - propertyType = u"Signal"_qs; + propertyType = u"Signal"_s; break; case QQmlJSMetaMethod::Slot: - propertyType = u"Slot"_qs; + propertyType = u"Slot"_s; break; case QQmlJSMetaMethod::Method: - propertyType = u"Method"_qs; + propertyType = u"Method"_s; break; } } else if (m_typeResolver->equals(property.type(), m_typeResolver->varType())) { errorType = - u"a variant property. It may or may not be a method. Use a regular function instead."_qs; + u"a variant property. It may or may not be a method. Use a regular function instead."_s; } else if (m_typeResolver->equals(property.type(), m_typeResolver->jsValueType())) { errorType = - u"a QJSValue property. It may or may not be a method. Use a regular Q_INVOKABLE instead."_qs; + u"a QJSValue property. It may or may not be a method. Use a regular Q_INVOKABLE instead."_s; } else { - errorType = u"not a method"_qs; + errorType = u"not a method"_s; } - m_logger->log(u"%1 \"%2\" is %3"_qs.arg(propertyType, name, errorType), Log_Type, + m_logger->log(u"%1 \"%2\" is %3"_s.arg(propertyType, name, errorType), Log_Type, getCurrentSourceLocation(), true, true, {}); return true; @@ -549,12 +551,12 @@ void QQmlJSTypePropagator::generate_LoadQmlContextPropertyLookup(int index) checkDeprecated(m_function->qmlScope, name, false); if (!m_state.accumulatorOut().isValid()) { - setError(u"Cannot access value for name "_qs + name); + setError(u"Cannot access value for name "_s + name); handleUnqualifiedAccess(name, false); } else if (m_typeResolver->genericType(m_state.accumulatorOut().storedType()).isNull()) { // It should really be valid. // We get the generic type from aotContext->loadQmlContextPropertyIdLookup(). - setError(u"Cannot determine generic type for "_qs + name); + setError(u"Cannot determine generic type for "_s + name); } } @@ -564,26 +566,26 @@ void QQmlJSTypePropagator::generate_StoreNameSloppy(int nameIndex) const QQmlJSRegisterContent type = m_typeResolver->scopedType(m_function->qmlScope, name); if (!type.isValid()) { - setError(u"Cannot find name "_qs + name); + setError(u"Cannot find name "_s + name); return; } if (!type.isProperty()) { - setError(u"Cannot assign to non-property "_qs + name); + setError(u"Cannot assign to non-property "_s + name); return; } if (!type.isWritable() && !m_function->qmlScope->hasOwnProperty(name)) { - setError(u"Can't assign to read-only property %1"_qs.arg(name)); + setError(u"Can't assign to read-only property %1"_s.arg(name)); - m_logger->log(u"Cannot assign to read-only property %1"_qs.arg(name), Log_Property, + m_logger->log(u"Cannot assign to read-only property %1"_s.arg(name), Log_Property, getCurrentSourceLocation()); return; } if (!canConvertFromTo(m_state.accumulatorIn(), type)) { - setError(u"cannot convert from %1 to %2"_qs + setError(u"cannot convert from %1 to %2"_s .arg(m_state.accumulatorIn().descriptiveName(), type.descriptiveName())); } @@ -680,9 +682,9 @@ void QQmlJSTypePropagator::propagatePropertyLookup(const QString &propertyName) QQmlJS::SourceLocation fixLocation = getCurrentSourceLocation(); fixLocation.length = 0; - suggestion.fixes << FixSuggestion::Fix { u"Reference it by id instead:"_qs, + suggestion.fixes << FixSuggestion::Fix { u"Reference it by id instead:"_s, fixLocation, - id.isEmpty() ? u"<id>."_qs : (id + u'.'), + id.isEmpty() ? u"<id>."_s : (id + u'.'), QString(), id.isEmpty() }; fixLocation = scope->sourceLocation(); @@ -690,13 +692,13 @@ void QQmlJSTypePropagator::propagatePropertyLookup(const QString &propertyName) if (id.isEmpty()) { suggestion.fixes - << FixSuggestion::Fix { u"You first have to give the element an id"_qs, + << FixSuggestion::Fix { u"You first have to give the element an id"_s, QQmlJS::SourceLocation {}, {} }; } m_logger->log( - u"Using attached type %1 already initialized in a parent scope."_qs.arg( + u"Using attached type %1 already initialized in a parent scope."_s.arg( m_state.accumulatorIn().scopeType()->internalName()), Log_AttachedPropertyReuse, getCurrentSourceLocation(), true, true, suggestion); @@ -717,10 +719,10 @@ void QQmlJSTypePropagator::propagatePropertyLookup(const QString &propertyName) return; } if (m_state.accumulatorIn().isImportNamespace()) - m_logger->log(u"Type not found in namespace"_qs, Log_Type, getCurrentSourceLocation()); + m_logger->log(u"Type not found in namespace"_s, Log_Type, getCurrentSourceLocation()); } else if (m_state.accumulatorOut().variant() == QQmlJSRegisterContent::Singleton && m_state.accumulatorIn().variant() == QQmlJSRegisterContent::ObjectModulePrefix) { - m_logger->log(u"Cannot load singleton as property of object"_qs, Log_Type, + m_logger->log(u"Cannot load singleton as property of object"_s, Log_Type, getCurrentSourceLocation()); setAccumulator(QQmlJSRegisterContent()); } @@ -728,7 +730,7 @@ void QQmlJSTypePropagator::propagatePropertyLookup(const QString &propertyName) const bool isRestrictedProperty = isRestricted(propertyName); if (!m_state.accumulatorOut().isValid()) { - setError(u"Cannot load property %1 from %2."_qs + setError(u"Cannot load property %1 from %2."_s .arg(propertyName, m_state.accumulatorIn().descriptiveName())); if (isRestrictedProperty) @@ -770,20 +772,20 @@ void QQmlJSTypePropagator::propagatePropertyLookup(const QString &propertyName) } m_logger->log( - u"Property \"%1\" not found on type \"%2\""_qs.arg(propertyName).arg(typeName), + u"Property \"%1\" not found on type \"%2\""_s.arg(propertyName).arg(typeName), Log_Type, getCurrentSourceLocation(), true, true, fixSuggestion); return; } if (m_state.accumulatorOut().isMethod() && m_state.accumulatorOut().method().length() != 1) { - setError(u"Cannot determine overloaded method on loadProperty"_qs); + setError(u"Cannot determine overloaded method on loadProperty"_s); return; } if (m_state.accumulatorOut().isProperty()) { if (m_typeResolver->registerContains( m_state.accumulatorOut(), m_typeResolver->voidType())) { - setError(u"Type %1 does not have a property %2 for reading"_qs + setError(u"Type %1 does not have a property %2 for reading"_s .arg(m_state.accumulatorIn().descriptiveName(), propertyName)); return; } @@ -841,22 +843,22 @@ void QQmlJSTypePropagator::generate_StoreProperty(int nameIndex, int base) QQmlJSRegisterContent property = m_typeResolver->memberType(callBase, propertyName); if (!property.isProperty()) { - setError(u"Type %1 does not have a property %2 for writing"_qs + setError(u"Type %1 does not have a property %2 for writing"_s .arg(callBase.descriptiveName(), propertyName)); return; } if (!property.isWritable()) { - setError(u"Can't assign to read-only property %1"_qs.arg(propertyName)); + setError(u"Can't assign to read-only property %1"_s.arg(propertyName)); - m_logger->log(u"Cannot assign to read-only property %1"_qs.arg(propertyName), Log_Property, + m_logger->log(u"Cannot assign to read-only property %1"_s.arg(propertyName), Log_Property, getCurrentSourceLocation()); return; } if (!canConvertFromTo(m_state.accumulatorIn(), property)) { - setError(u"cannot convert from %1 to %2"_qs + setError(u"cannot convert from %1 to %2"_s .arg(m_state.accumulatorIn().descriptiveName(), property.descriptiveName())); return; } @@ -924,7 +926,7 @@ void QQmlJSTypePropagator::generate_CallProperty(int nameIndex, int base, int ar const QString propertyName = m_jsUnitGenerator->stringForIndex(nameIndex); if (m_typeResolver->registerContains( - callBase, m_typeResolver->jsGlobalObject()->property(u"Math"_qs).type())) { + callBase, m_typeResolver->jsGlobalObject()->property(u"Math"_s).type())) { // If we call a method on the Math object we don't need the actual Math object. We do need // to transfer the type information to the code generator so that it knows that this is the @@ -953,7 +955,7 @@ void QQmlJSTypePropagator::generate_CallProperty(int nameIndex, int base, int ar const auto member = m_typeResolver->memberType(callBase, propertyName); if (!member.isMethod()) { - setError(u"Type %1 does not have a property %2 for calling"_qs + setError(u"Type %1 does not have a property %2 for calling"_s .arg(callBase.descriptiveName(), propertyName)); if (callBase.isType() && isCallingProperty(callBase.type(), propertyName)) @@ -972,7 +974,7 @@ void QQmlJSTypePropagator::generate_CallProperty(int nameIndex, int base, int ar fixSuggestion = suggestion; } - m_logger->log(u"Property \"%1\" not found on type \"%2\""_qs.arg( + m_logger->log(u"Property \"%1\" not found on type \"%2\""_s.arg( propertyName, m_typeResolver->containedTypeName(callBase, true)), Log_Type, getCurrentSourceLocation(), true, true, fixSuggestion); return; @@ -995,14 +997,14 @@ QQmlJSMetaMethod QQmlJSTypePropagator::bestMatchForCall(const QList<QQmlJSMetaMe javascriptFunction = method; if (method.returnType().isNull() && !method.returnTypeName().isEmpty()) { - errors->append(u"return type %1 cannot be resolved"_qs + errors->append(u"return type %1 cannot be resolved"_s .arg(method.returnTypeName())); continue; } const auto argumentTypes = method.parameterTypes(); if (argc != argumentTypes.size()) { - errors->append(u"Function expects %1 arguments, but %2 were provided"_qs + errors->append(u"Function expects %1 arguments, but %2 were provided"_s .arg(argumentTypes.size()) .arg(argc)); continue; @@ -1012,7 +1014,7 @@ QQmlJSMetaMethod QQmlJSTypePropagator::bestMatchForCall(const QList<QQmlJSMetaMe for (int i = 0; i < argc; ++i) { const auto argumentType = argumentTypes[i]; if (argumentType.isNull()) { - errors->append(u"type %1 for argument %2 cannot be resolved"_qs + errors->append(u"type %1 for argument %2 cannot be resolved"_s .arg(method.parameterTypeNames().at(i)) .arg(i)); matches = false; @@ -1025,7 +1027,7 @@ QQmlJSMetaMethod QQmlJSTypePropagator::bestMatchForCall(const QList<QQmlJSMetaMe } errors->append( - u"argument %1 contains %2 but is expected to contain the type %3"_qs.arg(i).arg( + u"argument %1 contains %2 but is expected to contain the type %3"_s.arg(i).arg( m_state.registers[argv + i].descriptiveName(), method.parameterTypeNames().at(i))); matches = false; @@ -1113,7 +1115,7 @@ void QQmlJSTypePropagator::propagateCall(const QList<QQmlJSMetaMethod> &methods, if (methods.length() == 1) setError(errors.first()); else - setError(u"No matching override found. Candidates:\n"_qs + errors.join(u'\n')); + setError(u"No matching override found. Candidates:\n"_s + errors.join(u'\n')); return; } @@ -1125,7 +1127,7 @@ void QQmlJSTypePropagator::propagateCall(const QList<QQmlJSMetaMethod> &methods, match.isJavaScriptFunction() ? QQmlJSRegisterContent::JavaScriptReturnValue : QQmlJSRegisterContent::MethodReturnValue)); if (!m_state.accumulatorOut().isValid()) - setError(u"Cannot store return type of method %1()."_qs.arg(match.methodName())); + setError(u"Cannot store return type of method %1()."_s.arg(match.methodName())); m_state.setHasSideEffects(true); const auto types = match.parameterTypes(); @@ -1184,10 +1186,10 @@ void QQmlJSTypePropagator::propagateScopeLookupCall(const QString &functionName, } } - setError(u"method %1 cannot be resolved."_qs.arg(functionName)); + setError(u"method %1 cannot be resolved."_s.arg(functionName)); setAccumulator(m_typeResolver->globalType(m_typeResolver->jsValueType())); - setError(u"Cannot find function '%1'"_qs.arg(functionName)); + setError(u"Cannot find function '%1'"_s.arg(functionName)); handleUnqualifiedAccess(functionName, true); } @@ -1474,7 +1476,7 @@ void QQmlJSTypePropagator::generate_JumpTrue(int offset) { if (!canConvertFromTo(m_state.accumulatorIn(), m_typeResolver->globalType(m_typeResolver->boolType()))) { - setError(u"cannot convert from %1 to boolean"_qs + setError(u"cannot convert from %1 to boolean"_s .arg(m_state.accumulatorIn().descriptiveName())); return; } @@ -1487,7 +1489,7 @@ void QQmlJSTypePropagator::generate_JumpFalse(int offset) { if (!canConvertFromTo(m_state.accumulatorIn(), m_typeResolver->globalType(m_typeResolver->boolType()))) { - setError(u"cannot convert from %1 to boolean"_qs + setError(u"cannot convert from %1 to boolean"_s .arg(m_state.accumulatorIn().descriptiveName())); return; } @@ -1711,7 +1713,7 @@ void QQmlJSTypePropagator::generate_As(int lhs) if (m_typeResolver->containedType(input)->accessSemantics() != QQmlJSScope::AccessSemantics::Reference || contained->accessSemantics() != QQmlJSScope::AccessSemantics::Reference) { - setError(u"invalid cast from %1 to %2. You can only cast object types."_qs + setError(u"invalid cast from %1 to %2. You can only cast object types."_s .arg(input.descriptiveName(), m_state.accumulatorIn().descriptiveName())); } else { setAccumulator(m_typeResolver->globalType(contained)); @@ -1722,7 +1724,7 @@ void QQmlJSTypePropagator::generate_UNot() { if (!canConvertFromTo(m_state.accumulatorIn(), m_typeResolver->globalType(m_typeResolver->boolType()))) { - setError(u"cannot convert from %1 to boolean"_qs + setError(u"cannot convert from %1 to boolean"_s .arg(m_state.accumulatorIn().descriptiveName())); return; } @@ -1984,7 +1986,7 @@ QQmlJSTypePropagator::startInstruction(QV4::Moth::Instr::Type type) auto newType = registerIt.value(); if (!newType.isValid()) { - setError(u"When reached from offset %1, %2 is undefined"_qs + setError(u"When reached from offset %1, %2 is undefined"_s .arg(stateToMerge.originatingOffset) .arg(registerName(registerIndex))); return SkipInstruction; @@ -2042,7 +2044,7 @@ void QQmlJSTypePropagator::endInstruction(QV4::Moth::Instr::Type instr) case QV4::Moth::Instr::Type::PushCatchContext: case QV4::Moth::Instr::Type::UnwindDispatch: if (m_state.changedRegisterIndex() == Accumulator && !m_error->isValid()) { - setError(u"Instruction is not expected to populate the accumulator"_qs); + setError(u"Instruction is not expected to populate the accumulator"_s); return; } break; @@ -2051,7 +2053,7 @@ void QQmlJSTypePropagator::endInstruction(QV4::Moth::Instr::Type instr) // for the next instruction. if ((!m_state.changedRegister().isValid() || m_state.changedRegisterIndex() != Accumulator) && !m_error->isValid()) { - setError(u"Instruction is expected to populate the accumulator"_qs); + setError(u"Instruction is expected to populate the accumulator"_s); return; } } @@ -2110,13 +2112,13 @@ void QQmlJSTypePropagator::saveRegisterStateForJump(int offset) QString QQmlJSTypePropagator::registerName(int registerIndex) const { if (registerIndex == Accumulator) - return u"accumulator"_qs; + return u"accumulator"_s; if (registerIndex >= FirstArgument && registerIndex < FirstArgument + m_function->argumentTypes.count()) { - return u"argument %1"_qs.arg(registerIndex - FirstArgument); + return u"argument %1"_s.arg(registerIndex - FirstArgument); } - return u"temporary register %1"_qs.arg( + return u"temporary register %1"_s.arg( registerIndex - FirstArgument - m_function->argumentTypes.count()); } @@ -2124,7 +2126,7 @@ QQmlJSRegisterContent QQmlJSTypePropagator::checkedInputRegister(int reg) { const auto regIt = m_state.registers.find(reg); if (regIt == m_state.registers.end()) { - setError(u"Type error: could not infer the type of an expression"_qs); + setError(u"Type error: could not infer the type of an expression"_s); return {}; } return regIt.value(); diff --git a/src/qmlcompiler/qqmljstyperesolver.cpp b/src/qmlcompiler/qqmljstyperesolver.cpp index ab9d5f81e1..6c901ac2ce 100644 --- a/src/qmlcompiler/qqmljstyperesolver.cpp +++ b/src/qmlcompiler/qqmljstyperesolver.cpp @@ -39,6 +39,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_LOGGING_CATEGORY(lcTypeResolver, "qt.qml.compiler.typeresolver", QtInfoMsg); template<typename Action> @@ -67,51 +69,51 @@ QQmlJSTypeResolver::QQmlJSTypeResolver(QQmlJSImporter *importer) : m_typeTracker(std::make_unique<TypeTracker>()) { const QQmlJSImporter::ImportedTypes builtinTypes = importer->builtinInternalNames(); - m_voidType = builtinTypes[u"void"_qs].scope; - m_nullType = builtinTypes[u"std::nullptr_t"_qs].scope; - m_realType = builtinTypes[u"double"_qs].scope; - m_floatType = builtinTypes[u"float"_qs].scope; - m_intType = builtinTypes[u"int"_qs].scope; - m_boolType = builtinTypes[u"bool"_qs].scope; - m_stringType = builtinTypes[u"QString"_qs].scope; - m_stringListType = builtinTypes[u"QStringList"_qs].scope; - m_urlType = builtinTypes[u"QUrl"_qs].scope; - m_dateTimeType = builtinTypes[u"QDateTime"_qs].scope; - m_variantListType = builtinTypes[u"QVariantList"_qs].scope; - m_varType = builtinTypes[u"QVariant"_qs].scope; - m_jsValueType = builtinTypes[u"QJSValue"_qs].scope; + m_voidType = builtinTypes[u"void"_s].scope; + m_nullType = builtinTypes[u"std::nullptr_t"_s].scope; + m_realType = builtinTypes[u"double"_s].scope; + m_floatType = builtinTypes[u"float"_s].scope; + m_intType = builtinTypes[u"int"_s].scope; + m_boolType = builtinTypes[u"bool"_s].scope; + m_stringType = builtinTypes[u"QString"_s].scope; + m_stringListType = builtinTypes[u"QStringList"_s].scope; + m_urlType = builtinTypes[u"QUrl"_s].scope; + m_dateTimeType = builtinTypes[u"QDateTime"_s].scope; + m_variantListType = builtinTypes[u"QVariantList"_s].scope; + m_varType = builtinTypes[u"QVariant"_s].scope; + m_jsValueType = builtinTypes[u"QJSValue"_s].scope; QQmlJSScope::Ptr emptyListType = QQmlJSScope::create(); - emptyListType->setInternalName(u"void*"_qs); + emptyListType->setInternalName(u"void*"_s); emptyListType->setAccessSemantics(QQmlJSScope::AccessSemantics::Sequence); m_emptyListType = emptyListType; QQmlJSScope::Ptr jsPrimitiveType = QQmlJSScope::create(); - jsPrimitiveType->setInternalName(u"QJSPrimitiveValue"_qs); - jsPrimitiveType->setFilePath(u"qjsprimitivevalue.h"_qs); + jsPrimitiveType->setInternalName(u"QJSPrimitiveValue"_s); + jsPrimitiveType->setFilePath(u"qjsprimitivevalue.h"_s); jsPrimitiveType->setAccessSemantics(QQmlJSScope::AccessSemantics::Value); m_jsPrimitiveType = jsPrimitiveType; QQmlJSScope::Ptr listPropertyType = QQmlJSScope::create(); - listPropertyType->setInternalName(u"QQmlListProperty<QObject>"_qs); - listPropertyType->setFilePath(u"qqmllist.h"_qs); + listPropertyType->setInternalName(u"QQmlListProperty<QObject>"_s); + listPropertyType->setFilePath(u"qqmllist.h"_s); listPropertyType->setAccessSemantics(QQmlJSScope::AccessSemantics::Sequence); - listPropertyType->setValueTypeName(u"QObject"_qs); + listPropertyType->setValueTypeName(u"QObject"_s); QQmlJSScope::resolveTypes(listPropertyType, builtinTypes); m_listPropertyType = listPropertyType; QQmlJSScope::Ptr metaObjectType = QQmlJSScope::create(); - metaObjectType->setInternalName(u"const QMetaObject"_qs); - metaObjectType->setFilePath(u"qmetaobject.h"_qs); + metaObjectType->setInternalName(u"const QMetaObject"_s); + metaObjectType->setFilePath(u"qmetaobject.h"_s); metaObjectType->setAccessSemantics(QQmlJSScope::AccessSemantics::Reference); m_metaObjectType = metaObjectType; m_jsGlobalObject = importer->jsGlobalObject(); - auto numberMethods = m_jsGlobalObject->methods(u"Number"_qs); + auto numberMethods = m_jsGlobalObject->methods(u"Number"_s); Q_ASSERT(numberMethods.length() == 1); m_numberPrototype = numberMethods[0].returnType()->baseType(); Q_ASSERT(m_numberPrototype); - Q_ASSERT(m_numberPrototype->internalName() == u"NumberPrototype"_qs); + Q_ASSERT(m_numberPrototype->internalName() == u"NumberPrototype"_s); } /*! @@ -162,14 +164,14 @@ QQmlJSScope::ConstPtr QQmlJSTypeResolver::listType( case QQmlJSScope::AccessSemantics::Reference: if (mode == UseListReference) return m_listPropertyType; - if (elementType->internalName() != u"QObject"_qs) + if (elementType->internalName() != u"QObject"_s) return listType(genericType(elementType), mode); Q_FALLTHROUGH(); case QQmlJSScope::AccessSemantics::Value: { QQmlJSScope::Ptr listType = QQmlJSScope::create(); listType->setAccessSemantics(QQmlJSScope::AccessSemantics::Sequence); listType->setValueTypeName(elementType->internalName()); - listType->setInternalName(u"QList<%1>"_qs.arg(elementType->augmentedInternalName())); + listType->setInternalName(u"QList<%1>"_s.arg(elementType->augmentedInternalName())); listType->setFilePath(elementType->filePath()); const QQmlJSImportedScope element = {elementType, QTypeRevision()}; QQmlJSScope::resolveTypes(listType, {{elementType->internalName(), element}}); @@ -521,11 +523,11 @@ bool QQmlJSTypeResolver::canConvertFromTo(const QQmlJSScope::ConstPtr &from, // in QQmlJSCodeGenerator::conversion(). if (equals(from, m_stringType) && !to.isNull()) { const QString toTypeName = to->internalName(); - if (toTypeName == u"QTime"_qs || toTypeName == u"QDate"_qs - || toTypeName == u"QPoint"_qs || toTypeName == u"QPointF"_qs - || toTypeName == u"QSize"_qs || toTypeName == u"QSizeF"_qs - || toTypeName == u"QRect"_qs || toTypeName == u"QRectF"_qs - || toTypeName == u"QColor"_qs) { + if (toTypeName == u"QTime"_s || toTypeName == u"QDate"_s + || toTypeName == u"QPoint"_s || toTypeName == u"QPointF"_s + || toTypeName == u"QSize"_s || toTypeName == u"QSizeF"_s + || toTypeName == u"QRect"_s || toTypeName == u"QRectF"_s + || toTypeName == u"QColor"_s) { return true; } } @@ -665,15 +667,15 @@ QQmlJSScope::ConstPtr QQmlJSTypeResolver::genericType(const QQmlJSScope::ConstPt // As QQmlComponent is derived from QObject, we can restrict ourselves to the latter. // This results in less if'ery when retrieving a QObject* from somewhere and deciding // what it is. - if (base->internalName() == u"QObject"_qs) { + if (base->internalName() == u"QObject"_s) { return base; } else if (allowComponent == ComponentIsGeneric::Yes - && base->internalName() == u"QQmlComponent"_qs) { + && base->internalName() == u"QQmlComponent"_s) { return base; } } - m_logger->log(u"Object type %1 is not derived from QObject or QQmlComponent"_qs.arg( + m_logger->log(u"Object type %1 is not derived from QObject or QQmlComponent"_s.arg( type->internalName()), Log_Compiler, type->sourceLocation()); @@ -844,12 +846,12 @@ QQmlJSRegisterContent QQmlJSTypeResolver::scopedType(const QQmlJSScope::ConstPtr if (const auto attached = type->attachedType()) { if (!genericType(attached)) { - m_logger->log(u"Cannot resolve generic base of attached %1"_qs.arg( + m_logger->log(u"Cannot resolve generic base of attached %1"_s.arg( attached->internalName()), Log_Compiler, attached->sourceLocation()); return {}; } else if (type->accessSemantics() != QQmlJSScope::AccessSemantics::Reference) { - m_logger->log(u"Cannot retrieve attached object for non-reference type %1"_qs.arg( + m_logger->log(u"Cannot retrieve attached object for non-reference type %1"_s.arg( type->internalName()), Log_Compiler, type->sourceLocation()); return {}; @@ -985,8 +987,8 @@ QQmlJSRegisterContent QQmlJSTypeResolver::lengthProperty( bool isWritable, const QQmlJSScope::ConstPtr &scope) const { QQmlJSMetaProperty prop; - prop.setPropertyName(u"length"_qs); - prop.setTypeName(u"int"_qs); + prop.setPropertyName(u"length"_s); + prop.setTypeName(u"int"_s); prop.setType(intType()); prop.setIsWritable(isWritable); return QQmlJSRegisterContent::create(intType(), prop, QQmlJSRegisterContent::Builtin, scope); @@ -1000,7 +1002,7 @@ QQmlJSRegisterContent QQmlJSTypeResolver::memberType(const QQmlJSScope::ConstPtr if (equals(type, jsValueType())) { QQmlJSMetaProperty prop; prop.setPropertyName(name); - prop.setTypeName(u"QJSValue"_qs); + prop.setTypeName(u"QJSValue"_s); prop.setType(jsValueType()); prop.setIsWritable(true); return QQmlJSRegisterContent::create(jsValueType(), prop, @@ -1009,7 +1011,7 @@ QQmlJSRegisterContent QQmlJSTypeResolver::memberType(const QQmlJSScope::ConstPtr if ((equals(type, stringType()) || type->accessSemantics() == QQmlJSScope::AccessSemantics::Sequence) - && name == u"length"_qs) { + && name == u"length"_s) { return lengthProperty(!equals(type, stringType()), type); } @@ -1039,7 +1041,7 @@ QQmlJSRegisterContent QQmlJSTypeResolver::memberType(const QQmlJSScope::ConstPtr identifier.has_value()) { QQmlJSMetaProperty prop; prop.setPropertyName(name); - prop.setTypeName(u"QJSValue"_qs); + prop.setTypeName(u"QJSValue"_s); prop.setType(jsValueType()); prop.setIsWritable(!identifier->isConst); @@ -1057,12 +1059,12 @@ QQmlJSRegisterContent QQmlJSTypeResolver::memberType(const QQmlJSScope::ConstPtr if (QQmlJSScope::ConstPtr attachedBase = typeForName(name)) { if (QQmlJSScope::ConstPtr attached = attachedBase->attachedType()) { if (!genericType(attached)) { - m_logger->log(u"Cannot resolve generic base of attached %1"_qs.arg( + m_logger->log(u"Cannot resolve generic base of attached %1"_s.arg( attached->internalName()), Log_Compiler, attached->sourceLocation()); return {}; } else if (type->accessSemantics() != QQmlJSScope::AccessSemantics::Reference) { - m_logger->log(u"Cannot retrieve attached object for non-reference type %1"_qs.arg( + m_logger->log(u"Cannot retrieve attached object for non-reference type %1"_s.arg( type->internalName()), Log_Compiler, type->sourceLocation()); return {}; @@ -1107,7 +1109,7 @@ QQmlJSRegisterContent QQmlJSTypeResolver::memberType(const QQmlJSRegisterContent } if (type.isProperty()) { const auto prop = type.property(); - if (prop.isList() && name == u"length"_qs) + if (prop.isList() && name == u"length"_s) return lengthProperty(true, listPropertyType()); return memberType(prop.type(), name); } @@ -1120,7 +1122,7 @@ QQmlJSRegisterContent QQmlJSTypeResolver::memberType(const QQmlJSRegisterContent } if (type.isMethod()) { QQmlJSMetaProperty prop; - prop.setTypeName(u"QJSValue"_qs); + prop.setTypeName(u"QJSValue"_s); prop.setPropertyName(name); prop.setType(jsValueType()); prop.setIsWritable(true); @@ -1131,7 +1133,7 @@ QQmlJSRegisterContent QQmlJSTypeResolver::memberType(const QQmlJSRegisterContent if (type.isImportNamespace()) { if (type.scopeType()->accessSemantics() != QQmlJSScope::AccessSemantics::Reference) { m_logger->log( - u"Cannot use non-reference type %1 as base of namespaced attached type"_qs.arg( + u"Cannot use non-reference type %1 as base of namespaced attached type"_s.arg( type.scopeType()->internalName()), Log_Type, type.scopeType()->sourceLocation()); return {}; @@ -1202,7 +1204,7 @@ QQmlJSRegisterContent QQmlJSTypeResolver::valueType(const QQmlJSRegisterContent return {}; QQmlJSMetaProperty property; - property.setPropertyName(u"[]"_qs); + property.setPropertyName(u"[]"_s); property.setTypeName(value->internalName()); property.setType(value); diff --git a/src/qmlcompiler/qqmljsutils.cpp b/src/qmlcompiler/qqmljsutils.cpp index b593b02b9a..41a3000803 100644 --- a/src/qmlcompiler/qqmljsutils.cpp +++ b/src/qmlcompiler/qqmljsutils.cpp @@ -30,6 +30,8 @@ #include <algorithm> +using namespace Qt::StringLiterals; + std::optional<FixSuggestion> QQmlJSUtils::didYouMean(const QString &userInput, QStringList candidates, QQmlJS::SourceLocation location) @@ -79,7 +81,7 @@ std::optional<FixSuggestion> QQmlJSUtils::didYouMean(const QString &userInput, if (shortestDistance < std::min(std::max(userInput.length() / 2, qsizetype(3)), userInput.length())) { return FixSuggestion { { FixSuggestion::Fix { - u"Did you mean \"%1\"?"_qs.arg(shortestDistanceWord), location, + u"Did you mean \"%1\"?"_s.arg(shortestDistanceWord), location, shortestDistanceWord } } }; } else { return {}; diff --git a/src/qmlcompiler/qqmljsutils_p.h b/src/qmlcompiler/qqmljsutils_p.h index a910e887ef..d6cb148500 100644 --- a/src/qmlcompiler/qqmljsutils_p.h +++ b/src/qmlcompiler/qqmljsutils_p.h @@ -57,7 +57,8 @@ struct QQmlJSUtils */ static QString escapeString(QString s) { - return s.replace(u'\\', u"\\\\"_qs).replace(u'"', u"\\\""_qs).replace(u'\n', u"\\n"_qs); + using namespace Qt::StringLiterals; + return s.replace(u'\\', u"\\\\"_s).replace(u'"', u"\\\""_s).replace(u'\n', u"\\n"_s); } /*! \internal diff --git a/src/qmlcompiler/qqmlsa.cpp b/src/qmlcompiler/qqmlsa.cpp index 013d81855e..f86b3f0704 100644 --- a/src/qmlcompiler/qqmlsa.cpp +++ b/src/qmlcompiler/qqmlsa.cpp @@ -37,6 +37,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace QQmlSA { class GenericPassPrivate { @@ -129,12 +131,12 @@ bool PassManager::hasImportedModule(QAnyStringView module) const void DebugElementPass::run(const Element &element) { emitWarning(u"Type: " + element->baseTypeName()); - if (auto bindings = element->propertyBindings(u"objectName"_qs); !bindings.isEmpty()) { + if (auto bindings = element->propertyBindings(u"objectName"_s); !bindings.isEmpty()) { emitWarning(u"is named: " + bindings.first().stringValue()); } if (auto defPropName = element->defaultPropertyName(); !defPropName.isEmpty()) { emitWarning(u"binding " + QString::number(element->propertyBindings(defPropName).size()) - + u" elements to property "_qs + defPropName); + + u" elements to property "_s + defPropName); } } diff --git a/src/qmldom/qqmldomelements.cpp b/src/qmldom/qqmldomelements.cpp index 14cf0fcf52..9f29873536 100644 --- a/src/qmldom/qqmldomelements.cpp +++ b/src/qmldom/qqmldomelements.cpp @@ -72,6 +72,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace QQmlJS { namespace Dom { @@ -1954,8 +1956,8 @@ QmlUri QmlUri::fromString(const QString &str) { if (str.startsWith(u'"')) return fromDirectoryString(str.mid(1, str.length() - 2) - .replace(u"\\\""_qs, u"\""_qs) - .replace(u"\\\\"_qs, u"\\"_qs)); + .replace(u"\\\""_s, u"\""_s) + .replace(u"\\\\"_s, u"\\"_s)); else return fromUriString(str); } @@ -2083,8 +2085,8 @@ QString QmlUri::toString() const case Kind::DirectoryUrl: case Kind::RelativePath: case Kind::AbsolutePath: - return u"\""_qs + directoryString().replace(u'\\', u"\\\\"_qs).replace(u'"', u"\\\""_qs) - + u"\""_qs; + return u"\""_s + directoryString().replace(u'\\', u"\\\\"_s).replace(u'"', u"\\\""_s) + + u"\""_s; } return QString(); } diff --git a/src/qmldom/qqmldomelements_p.h b/src/qmldom/qqmldomelements_p.h index b5ca5bed55..cc25e4df2a 100644 --- a/src/qmldom/qqmldomelements_p.h +++ b/src/qmldom/qqmldomelements_p.h @@ -583,7 +583,7 @@ public: { return QStringLiteral(u"QtObject{\n %1: ").arg(n.split(u'.').last()); } - static QString postCodeForName(QStringView) { return u"\n}\n"_qs; } + static QString postCodeForName(QStringView) { return QStringLiteral(u"\n}\n"); } QString preCode() const { return preCodeForName(m_name); } QString postCode() const { return postCodeForName(m_name); } diff --git a/src/qmldom/qqmldomexternalitems.cpp b/src/qmldom/qqmldomexternalitems.cpp index 8e550485cb..bbcceeb54d 100644 --- a/src/qmldom/qqmldomexternalitems.cpp +++ b/src/qmldom/qqmldomexternalitems.cpp @@ -58,6 +58,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace QQmlJS { namespace Dom { @@ -464,7 +466,7 @@ bool QmlDirectory::iterateDirectSubpaths(DomItem &self, DirectVisitor visitor) auto keys = m_qmlFiles.keys(); return QSet<QString>(keys.begin(), keys.end()); }, - u"List<Reference>"_qs)); + u"List<Reference>"_s)); }); return cont; } diff --git a/src/qmldom/qqmldomtop.cpp b/src/qmldom/qqmldomtop.cpp index 0d262c13f5..25c9e6d98f 100644 --- a/src/qmldom/qqmldomtop.cpp +++ b/src/qmldom/qqmldomtop.cpp @@ -67,6 +67,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace QQmlJS { namespace Dom { @@ -2245,8 +2247,8 @@ QString DomEnvironment::globalScopeName() const QList<Import> DomEnvironment::defaultImplicitImports() { - return QList<Import>({ Import::fromUriString(u"QML"_qs, Version(1, 0)), - Import(QmlUri::fromUriString(u"QtQml"_qs), Version(6, 0)) }); + return QList<Import>({ Import::fromUriString(u"QML"_s, Version(1, 0)), + Import(QmlUri::fromUriString(u"QtQml"_s), Version(6, 0)) }); } QList<Import> DomEnvironment::implicitImports() const diff --git a/src/qmltest/quicktestutil.cpp b/src/qmltest/quicktestutil.cpp index 87abaeb177..132c172eea 100644 --- a/src/qmltest/quicktestutil.cpp +++ b/src/qmltest/quicktestutil.cpp @@ -53,6 +53,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + bool QuickTestUtil::printAvailableFunctions() const { return QTest::printAvailableFunctions; @@ -67,7 +69,7 @@ void QuickTestUtil::populateClipboardText(int lineCount) { #if QT_CONFIG(clipboard) QString fmt(u"%1 bottles of beer on the wall, %1 bottles of beer; " - "take one down, pass it around, %2 bottles of beer on the wall."_qs); + "take one down, pass it around, %2 bottles of beer on the wall."_s); QStringList lines; for (int i = lineCount; i > 0; --i) lines << fmt.arg(i).arg(i - 1); diff --git a/src/qmltyperegistrar/metatypesjsonprocessor.cpp b/src/qmltyperegistrar/metatypesjsonprocessor.cpp index e25c0e3f67..f86bc74a3a 100644 --- a/src/qmltyperegistrar/metatypesjsonprocessor.cpp +++ b/src/qmltyperegistrar/metatypesjsonprocessor.cpp @@ -33,6 +33,7 @@ #include <QtCore/qjsondocument.h> #include <QtCore/qqueue.h> +using namespace Qt::StringLiterals; bool MetaTypesJsonProcessor::processTypes(const QStringList &files) { @@ -150,9 +151,9 @@ QString MetaTypesJsonProcessor::extractRegisteredTypes() const const auto value = entry[u"value"].toString(); if (name == u"QML.Element") { if (value == u"auto") { - qmlElement = u"QML_NAMED_ELEMENT("_qs + className + u")"_qs; + qmlElement = u"QML_NAMED_ELEMENT("_s + className + u")"_s; } else if (value == u"anonymous") { - qmlElement = u"QML_ANONYMOUS"_qs; + qmlElement = u"QML_ANONYMOUS"_s; } else { qmlElement = u"QML_NAMED_ELEMENT(" + value + u")"; } @@ -161,19 +162,19 @@ QString MetaTypesJsonProcessor::extractRegisteredTypes() const } else if (name == u"QML.UncreatableReason") { qmlUncreatable = u"QML_UNCREATABLE(\"" + value + u"\")"; } else if (name == u"QML.Attached") { - qmlAttached = u"QML_ATTACHED("_qs + value + u")"; + qmlAttached = u"QML_ATTACHED("_s + value + u")"; } else if (name == u"QML.Singleton") { isSingleton = true; } } if (qmlElement.isEmpty()) continue; // no relevant entries found - const QString spaces = u" "_qs; - registrationHelper += u"\nstruct "_qs + foreignClassName + u"{\n Q_GADGET\n"_qs; - registrationHelper += spaces + u"QML_FOREIGN(" + className + u")\n"_qs; - registrationHelper += spaces + qmlElement + u"\n"_qs; + const QString spaces = u" "_s; + registrationHelper += u"\nstruct "_s + foreignClassName + u"{\n Q_GADGET\n"_s; + registrationHelper += spaces + u"QML_FOREIGN(" + className + u")\n"_s; + registrationHelper += spaces + qmlElement + u"\n"_s; if (isSingleton) - registrationHelper += spaces + u"QML_SINGLETON\n"_qs; + registrationHelper += spaces + u"QML_SINGLETON\n"_s; if (isExplicitlyUncreatable) { if (qmlUncreatable.isEmpty()) registrationHelper += spaces + uR"(QML_UNCREATABLE(""))" + u"n"; diff --git a/src/qmltyperegistrar/qmltyperegistrar.cpp b/src/qmltyperegistrar/qmltyperegistrar.cpp index e5d1bb95d6..35d4508cd6 100644 --- a/src/qmltyperegistrar/qmltyperegistrar.cpp +++ b/src/qmltyperegistrar/qmltyperegistrar.cpp @@ -42,6 +42,8 @@ #include <cstdlib> +using namespace Qt::StringLiterals; + struct ScopedPointerFileCloser { static inline void cleanup(FILE *handle) { if (handle) fclose(handle); } @@ -94,7 +96,7 @@ static int runExtract(const QString & baseName, const MetaTypesJsonProcessor &pr "#include <QtQml/qqmlmoduleregistration.h>\n").arg(baseName.toUpper()); const QStringList includes = processor.includes(); for (const QString &include: includes) - prefix += u"\n#include <%1>"_qs.arg(include); + prefix += u"\n#include <%1>"_s.arg(include); headerFile.write((prefix + processor.extractRegisteredTypes()).toUtf8() + "\n#endif"); QFile sourceFile(baseName + u".cpp"); @@ -104,8 +106,8 @@ static int runExtract(const QString & baseName, const MetaTypesJsonProcessor &pr return EXIT_FAILURE; } // the string split is necessaury because cmake's automoc scanner would otherwise pick up the include - QString code = u"#include \"%1.h\"\n#include "_qs.arg(baseName); - code += uR"("moc_%1.cpp")"_qs.arg(baseName); + QString code = u"#include \"%1.h\"\n#include "_s.arg(baseName); + code += uR"("moc_%1.cpp")"_s.arg(baseName); sourceFile.write(code.toUtf8()); return EXIT_SUCCESS; } @@ -185,8 +187,8 @@ int main(int argc, char **argv) "want to follow Qt's versioning scheme.")); parser.addOption(followForeignVersioningOption); - QCommandLineOption extract(u"extract"_qs); - extract.setDescription(u"Extract QML types from a module and use QML_FOREIGN to register them"_qs); + QCommandLineOption extract(u"extract"_s); + extract.setDescription(u"Extract QML types from a module and use QML_FOREIGN to register them"_s); parser.addOption(extract); parser.addPositionalArgument(QStringLiteral("[MOC generated json file]"), diff --git a/src/qmltyperegistrar/qmltypescreator.cpp b/src/qmltyperegistrar/qmltypescreator.cpp index fdb6a220df..98251add1d 100644 --- a/src/qmltyperegistrar/qmltypescreator.cpp +++ b/src/qmltyperegistrar/qmltypescreator.cpp @@ -36,6 +36,8 @@ #include <QtCore/qjsondocument.h> #include <QtCore/qversionnumber.h> +using namespace Qt::StringLiterals; + static QString enquote(const QString &string) { QString s = string; @@ -49,7 +51,7 @@ static QString convertPrivateClassToUsableForm(QString s) // ClassName is a non-private class name. we don't need "::d_func()" piece // so that could be removed, but we need "Private" so that ClassName becomes // ClassNamePrivate (at present, simply consider this correct) - s.replace(u"::d_func()"_qs, u"Private"_qs); + s.replace(u"::d_func()"_s, u"Private"_s); return s; } diff --git a/src/quick/designer/qquickdesignercustomobjectdata.cpp b/src/quick/designer/qquickdesignercustomobjectdata.cpp index cb22c597ad..1cafe6bc1c 100644 --- a/src/quick/designer/qquickdesignercustomobjectdata.cpp +++ b/src/quick/designer/qquickdesignercustomobjectdata.cpp @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + typedef QHash<QObject*, QQuickDesignerCustomObjectData*> CustomObjectDataHash; Q_GLOBAL_STATIC(CustomObjectDataHash, s_designerObjectToDataHash) @@ -262,7 +264,7 @@ void QQuickDesignerCustomObjectData::setPropertyBinding(QQmlContext *context, return; if (property.isProperty()) { - QString url = u"@designer"_qs; + QString url = u"@designer"_s; int lineNumber = 0; QQmlAnyBinding binding = QQmlAnyBinding::createFromCodeString(property, expression, object(), QQmlContextData::get(context), url, lineNumber); diff --git a/src/quick/util/qquickstategroup.cpp b/src/quick/util/qquickstategroup.cpp index 57491aa7f2..e9a21b7c60 100644 --- a/src/quick/util/qquickstategroup.cpp +++ b/src/quick/util/qquickstategroup.cpp @@ -53,6 +53,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_DECLARE_LOGGING_CATEGORY(lcStates) class QQuickStateGroupPrivate : public QObjectPrivate @@ -377,7 +379,7 @@ bool QQuickStateGroupPrivate::updateAutoState() if (state->isWhenKnown()) { if (state->isNamed()) { bool whenValue = state->when(); - const QQmlProperty whenProp(state, u"when"_qs); + const QQmlProperty whenProp(state, u"when"_s); const auto potentialWhenBinding = QQmlAnyBinding::ofProperty(whenProp); Q_ASSERT(!potentialWhenBinding.isUntypedPropertyBinding()); diff --git a/src/quickdialogs2/quickdialogs2/qquickfiledialog.cpp b/src/quickdialogs2/quickdialogs2/qquickfiledialog.cpp index 8390026dd6..bf149527c1 100644 --- a/src/quickdialogs2/quickdialogs2/qquickfiledialog.cpp +++ b/src/quickdialogs2/quickdialogs2/qquickfiledialog.cpp @@ -47,6 +47,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_DECLARE_LOGGING_CATEGORY(lcDialogs) Q_LOGGING_CATEGORY(lcFileDialog, "qt.quick.dialogs.filedialog") @@ -579,7 +581,7 @@ QUrl QQuickFileDialog::addDefaultSuffix(const QUrl &file) const const QString suffix = m_options->defaultSuffix(); // Urls with "content" scheme do not require suffixes. Such schemes are // used on Android. - const bool isContentScheme = url.scheme() == u"content"_qs; + const bool isContentScheme = url.scheme() == u"content"_s; if (!isContentScheme && !suffix.isEmpty() && !path.endsWith(QLatin1Char('/')) && path.lastIndexOf(QLatin1Char('.')) == -1) { url.setPath(path + QLatin1Char('.') + suffix); diff --git a/src/quicktestutils/quick/visualtestutils_p.h b/src/quicktestutils/quick/visualtestutils_p.h index a4b558d4e6..a2cd2c0290 100644 --- a/src/quicktestutils/quick/visualtestutils_p.h +++ b/src/quicktestutils/quick/visualtestutils_p.h @@ -70,6 +70,8 @@ namespace QQuickVisualTestUtils template<typename T> T *findItem(QQuickItem *parent, const QString &objectName, int index = -1) { + using namespace Qt::StringLiterals; + const QMetaObject &mo = T::staticMetaObject; for (int i = 0; i < parent->childItems().count(); ++i) { QQuickItem *item = qobject_cast<QQuickItem*>(parent->childItems().at(i)); @@ -77,7 +79,7 @@ namespace QQuickVisualTestUtils continue; if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { if (index != -1) { - QQmlExpression e(qmlContext(item), item, u"index"_qs); + QQmlExpression e(qmlContext(item), item, u"index"_s); if (e.evaluate().toInt() == index) return static_cast<T*>(item); } else { diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index 9dc109b713..49fd064311 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -49,6 +49,8 @@ #define NO_INLINE __attribute__((noinline)) #endif +using namespace Qt::StringLiterals; + Q_DECLARE_METATYPE(QList<int>) Q_DECLARE_METATYPE(QObjectList) @@ -5226,11 +5228,11 @@ void tst_QJSEngine::concatAfterUnshift() test = test.concat([]) return test })() - )"_qs); + )"_s); QVERIFY2(!value.isError(), qPrintable(value.toString())); QVERIFY(value.isArray()); - QCOMPARE(value.property(0).toString(), u"val1"_qs); - QCOMPARE(value.property(1).toString(), u"val2"_qs); + QCOMPARE(value.property(0).toString(), u"val1"_s); + QCOMPARE(value.property(1).toString(), u"val2"_s); } void tst_QJSEngine::sortSparseArray() diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp index 648099e050..0ab0a81258 100644 --- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp +++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp @@ -45,6 +45,8 @@ #include <QtQuickTestUtils/private/qmlutils_p.h> #include "scriptstringprops.h" +using namespace Qt::StringLiterals; + class tst_qmlcachegen: public QQmlDataTest { Q_OBJECT @@ -822,7 +824,7 @@ void tst_qmlcachegen::scriptStringCachegenInteraction() QVERIFY(scripty->m_undef.isUndefinedLiteral()); QVERIFY(scripty->m_nul.isNullLiteral()); - QCOMPARE(scripty->m_str.stringLiteral(), u"hello"_qs); + QCOMPARE(scripty->m_str.stringLiteral(), u"hello"_s); QCOMPARE(scripty->m_num.numberLiteral(&ok), 42); ok = false; scripty->m_bol.booleanLiteral(&ok); diff --git a/tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h b/tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h index f56b82539c..45354decf0 100644 --- a/tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h +++ b/tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h @@ -65,14 +65,14 @@ class OverriddenObjectName : public ObjectWithMethod public: OverriddenObjectName(QObject *parent = nullptr) : ObjectWithMethod(parent) { - m_objectName = u"borschtsch"_qs; + m_objectName = QStringLiteral("borschtsch"); nothing = 77; } QString objectName() const { return m_objectName.value(); } void setObjectName(const QString &objectName) { m_objectName.setValue(objectName); } QBindable<QString> objectNameBindable() { return QBindable<QString>(&m_objectName); } - Q_INVOKABLE QString doThing() const { return u"7"_qs; } + Q_INVOKABLE QString doThing() const { return QStringLiteral("7"); } int fff() const { return nothing.value(); } QBindable<int> nothingBindable() { return QBindable<int>(¬hing); } diff --git a/tests/auto/qml/qmlcppcodegen/data/person.cpp b/tests/auto/qml/qmlcppcodegen/data/person.cpp index e05e7b371a..e9dbbf071b 100644 --- a/tests/auto/qml/qmlcppcodegen/data/person.cpp +++ b/tests/auto/qml/qmlcppcodegen/data/person.cpp @@ -28,10 +28,12 @@ #include "person.h" +using namespace Qt::StringLiterals; + Person::Person(QObject *parent) - : QObject(parent), m_name(u"Bart"_qs), m_shoeSize(0) + : QObject(parent), m_name(u"Bart"_s), m_shoeSize(0) { - m_things.append(u"thing"_qs); + m_things.append(u"thing"_s); m_things.append(30); } @@ -50,7 +52,7 @@ void Person::setName(const QString &n) void Person::resetName() { - setName(u"Bart"_qs); + setName(u"Bart"_s); } int Person::shoeSize() const diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 696e579d87..cd528a2970 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -33,6 +33,8 @@ #include <QtCore/qprocess.h> #endif +using namespace Qt::StringLiterals; + Q_IMPORT_QML_PLUGIN(TestTypesPlugin) class tst_QmlCppCodegen : public QObject @@ -137,7 +139,7 @@ private slots: void tst_QmlCppCodegen::simpleBinding() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/Test.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/Test.qml"_s)); QScopedPointer<QObject> object(component.create()); QVERIFY2(!object.isNull(), component.errorString().toUtf8().constData()); QCOMPARE(object->property("foo").toInt(), int(3)); @@ -158,7 +160,7 @@ void tst_QmlCppCodegen::simpleBinding() void tst_QmlCppCodegen::anchorsFill() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/anchorsFill.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/anchorsFill.qml"_s)); QScopedPointer<QObject> object(component.create()); QVERIFY2(!object.isNull(), component.errorString().toUtf8().constData()); @@ -180,21 +182,21 @@ void tst_QmlCppCodegen::anchorsFill() void tst_QmlCppCodegen::signalHandler() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/signal.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/signal.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); QCOMPARE(object->objectName(), QString()); QCOMPARE(object->property("ff").toInt(), 4); - object->setObjectName(u"foo"_qs); + object->setObjectName(u"foo"_s); QCOMPARE(object->property("ff").toInt(), 12); } void tst_QmlCppCodegen::idAccess() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/idAccess.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/idAccess.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -210,7 +212,7 @@ void tst_QmlCppCodegen::idAccess() object->setProperty("z", 14); QCOMPARE(object->property("y").toInt(), 48); - QObject *ttt = qmlContext(object.data())->objectForName(u"ttt"_qs); + QObject *ttt = qmlContext(object.data())->objectForName(u"ttt"_s); QFont f = qvariant_cast<QFont>(ttt->property("font")); QCOMPARE(f.pointSize(), 22); } @@ -226,7 +228,7 @@ void tst_QmlCppCodegen::globals() QQmlEngine engine; int exitCode = -1; QObject::connect(&engine, &QQmlEngine::exit, [&](int code) { exitCode = code; }); - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/globals.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/globals.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); const QByteArray message = QByteArray("Start 2 ") + arg1(); @@ -239,29 +241,29 @@ void tst_QmlCppCodegen::globals() QObject *application = qvariant_cast<QObject *>(object->property("application")); QVERIFY(application); QCOMPARE(QString::fromUtf8(application->metaObject()->className()), - u"QQuickApplication"_qs); + u"QQuickApplication"_s); QTest::ignoreMessage(QtDebugMsg, "End"); QMetaObject::invokeMethod(application, "aboutToQuit"); const QVariant somewhere = object->property("somewhere"); QCOMPARE(somewhere.userType(), QMetaType::QUrl); - QCOMPARE(qvariant_cast<QUrl>(somewhere).toString(), u"qrc:/somewhere/else.qml"_qs); + QCOMPARE(qvariant_cast<QUrl>(somewhere).toString(), u"qrc:/somewhere/else.qml"_s); const QVariant somewhereString = object->property("somewhereString"); QCOMPARE(somewhereString.userType(), QMetaType::QString); - QCOMPARE(somewhereString.toString(), u"qrc:/somewhere/else.qml"_qs); + QCOMPARE(somewhereString.toString(), u"qrc:/somewhere/else.qml"_s); const QVariant plain = object->property("plain"); QCOMPARE(plain.userType(), QMetaType::QUrl); - QCOMPARE(qvariant_cast<QUrl>(plain).toString(), u"/not/here.qml"_qs); + QCOMPARE(qvariant_cast<QUrl>(plain).toString(), u"/not/here.qml"_s); } void tst_QmlCppCodegen::multiLookup() { // Multiple lookups of singletons (Qt in this case) don't clash with one another. QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/immediateQuit.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/immediateQuit.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); const QByteArray message = QByteArray("End: ") + arg1(); @@ -277,7 +279,7 @@ void tst_QmlCppCodegen::enums() { QQmlEngine engine; { - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/Enums.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/Enums.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QTest::ignoreMessage(QtWarningMsg, "qrc:/TestTypes/Enums.qml:4:1: " @@ -288,11 +290,11 @@ void tst_QmlCppCodegen::enums() bool ok = false; QCOMPARE(object->property("appState").toInt(&ok), 2); QVERIFY(ok); - QCOMPARE(object->property("color").toString(), u"blue"_qs); + QCOMPARE(object->property("color").toString(), u"blue"_s); QTRY_COMPARE(object->property("appState").toInt(&ok), 1); QVERIFY(ok); - QCOMPARE(object->property("color").toString(), u"green"_qs); + QCOMPARE(object->property("color").toString(), u"green"_s); const auto func = qmlAttachedPropertiesFunction( object.data(), QMetaType::fromName("QQuickLayout*").metaObject()); @@ -306,19 +308,19 @@ void tst_QmlCppCodegen::enums() QCOMPARE(qvariant_cast<Qt::Alignment>(prop), Qt::AlignCenter); } { - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/enumsInOtherObject.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/enumsInOtherObject.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); - QCOMPARE(object->property("color").toString(), u"blue"_qs); - QTRY_COMPARE(object->property("color").toString(), u"green"_qs); + QCOMPARE(object->property("color").toString(), u"blue"_s); + QTRY_COMPARE(object->property("color").toString(), u"green"_s); } } void tst_QmlCppCodegen::funcWithParams() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/funcWithParams.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/funcWithParams.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -328,7 +330,7 @@ void tst_QmlCppCodegen::funcWithParams() void tst_QmlCppCodegen::intOverflow() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/intOverflow.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/intOverflow.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -339,7 +341,7 @@ void tst_QmlCppCodegen::intOverflow() void tst_QmlCppCodegen::stringLength() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/stringLength.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/stringLength.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -349,17 +351,17 @@ void tst_QmlCppCodegen::stringLength() void tst_QmlCppCodegen::scopeVsObject() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/scopeVsObject.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/scopeVsObject.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); - QCOMPARE(object->property("objectName").toString(), u"foobar"_qs); + QCOMPARE(object->property("objectName").toString(), u"foobar"_s); } void tst_QmlCppCodegen::compositeTypeMethod() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/compositeTypeMethod.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/compositeTypeMethod.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -370,7 +372,7 @@ void tst_QmlCppCodegen::compositeTypeMethod() void tst_QmlCppCodegen::excessiveParameters() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/excessiveParameters.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/excessiveParameters.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -381,7 +383,7 @@ void tst_QmlCppCodegen::excessiveParameters() void tst_QmlCppCodegen::jsImport() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/jsimport.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/jsimport.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -391,7 +393,7 @@ void tst_QmlCppCodegen::jsImport() void tst_QmlCppCodegen::jsmoduleImport() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/jsmoduleimport.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/jsmoduleimport.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -407,11 +409,11 @@ void tst_QmlCppCodegen::jsmoduleImport() void tst_QmlCppCodegen::methods() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/methods.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/methods.qml"_s)); QVERIFY(component.isReady()); QTest::ignoreMessage(QtDebugMsg, "The Bar"); - QTest::ignoreMessage(QtWarningMsg, QRegularExpression(u"TypeError: .* is not a function"_qs)); + QTest::ignoreMessage(QtWarningMsg, QRegularExpression(u"TypeError: .* is not a function"_s)); QScopedPointer<QObject> obj(component.create()); QVERIFY(obj); BirthdayParty *party(qobject_cast<BirthdayParty *>(obj.data())); @@ -422,30 +424,30 @@ void tst_QmlCppCodegen::methods() bool foundGreen = false; bool foundFoo = false; for (int ii = 0; ii < party->guestCount(); ++ii) { - if (party->guest(ii)->name() == u"William Green"_qs) + if (party->guest(ii)->name() == u"William Green"_s) foundGreen = true; - if (party->guest(ii)->name() == u"The Foo"_qs) + if (party->guest(ii)->name() == u"The Foo"_s) foundFoo = true; } QVERIFY(foundGreen); QVERIFY(foundFoo); - QCOMPARE(obj->property("n1").toString(), u"onGurk"_qs); - QCOMPARE(obj->property("n2").toString(), u"onSemmeln"_qs); + QCOMPARE(obj->property("n1").toString(), u"onGurk"_s); + QCOMPARE(obj->property("n2").toString(), u"onSemmeln"_s); QCOMPARE(obj->property("n3"), QVariant()); { QVariant ret; obj->metaObject()->invokeMethod(obj.data(), "retrieveVar", Q_RETURN_ARG(QVariant, ret)); QCOMPARE(ret.typeId(), QMetaType::QString); - QCOMPARE(ret.toString(), u"Jack Smith"_qs); + QCOMPARE(ret.toString(), u"Jack Smith"_s); } { QString ret; obj->metaObject()->invokeMethod(obj.data(), "retrieveString", Q_RETURN_ARG(QString, ret)); - QCOMPARE(ret, u"Jack Smith"_qs); + QCOMPARE(ret, u"Jack Smith"_s); } QCOMPARE(party->host()->shoeSize(), 12); @@ -466,7 +468,7 @@ void tst_QmlCppCodegen::methods() void tst_QmlCppCodegen::math() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/math.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/math.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -477,7 +479,7 @@ void tst_QmlCppCodegen::math() void tst_QmlCppCodegen::unknownParameter() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/unknownParameter.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/unknownParameter.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -487,26 +489,26 @@ void tst_QmlCppCodegen::unknownParameter() void tst_QmlCppCodegen::array() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/array.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/array.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); const QJSValue value1 = object->property("values1").value<QJSValue>(); QVERIFY(value1.isArray()); - QCOMPARE(value1.property(u"length"_qs).toInt(), 3); + QCOMPARE(value1.property(u"length"_s).toInt(), 3); QCOMPARE(value1.property(0).toInt(), 1); QCOMPARE(value1.property(1).toInt(), 2); QCOMPARE(value1.property(2).toInt(), 3); const QJSValue value2 = object->property("values2").value<QJSValue>(); QVERIFY(value2.isArray()); - QCOMPARE(value2.property(u"length"_qs).toInt(), 0); + QCOMPARE(value2.property(u"length"_s).toInt(), 0); } void tst_QmlCppCodegen::equalsUndefined() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/equalsUndefined.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/equalsUndefined.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -518,7 +520,7 @@ void tst_QmlCppCodegen::equalsUndefined() void tst_QmlCppCodegen::conversions() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/conversions.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/conversions.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QTest::ignoreMessage(QtWarningMsg, "qrc:/TestTypes/conversions.qml:42: TypeError: Type error"); @@ -544,17 +546,17 @@ void tst_QmlCppCodegen::conversions() QCOMPARE(object->property("cmpEqInt").toInt(), 17); - QCOMPARE(object->property("undefinedType").toString(), u"undefined"_qs); - QCOMPARE(object->property("booleanType").toString(), u"boolean"_qs); - QCOMPARE(object->property("numberType").toString(), u"number"_qs); - QCOMPARE(object->property("stringType").toString(), u"string"_qs); - QCOMPARE(object->property("objectType").toString(), u"object"_qs); - QCOMPARE(object->property("symbolType").toString(), u"symbol"_qs); + QCOMPARE(object->property("undefinedType").toString(), u"undefined"_s); + QCOMPARE(object->property("booleanType").toString(), u"boolean"_s); + QCOMPARE(object->property("numberType").toString(), u"number"_s); + QCOMPARE(object->property("stringType").toString(), u"string"_s); + QCOMPARE(object->property("objectType").toString(), u"object"_s); + QCOMPARE(object->property("symbolType").toString(), u"symbol"_s); QJSManagedValue obj = engine.toManagedValue(object->property("anObject")); - QCOMPARE(obj.property(u"a"_qs).toInt(), 12); - QCOMPARE(obj.property(u"b"_qs).toInt(), 14); - QCOMPARE(obj.property(u"c"_qs).toString(), u"somestring"_qs); + QCOMPARE(obj.property(u"a"_s).toInt(), 12); + QCOMPARE(obj.property(u"b"_s).toInt(), 14); + QCOMPARE(obj.property(u"c"_s).toString(), u"somestring"_s); QVERIFY(object->property("aInObject").toBool()); QVERIFY(object->property("lengthInArray").toBool()); @@ -569,7 +571,7 @@ void tst_QmlCppCodegen::conversions() const QVariant stringPlusString = object->property("stringPlusString"); QCOMPARE(stringPlusString.typeId(), QMetaType::QString); - QCOMPARE(stringPlusString.toString(), u"1220"_qs); + QCOMPARE(stringPlusString.toString(), u"1220"_s); const QVariant stringMinusString = object->property("stringMinusString"); QCOMPARE(stringMinusString.typeId(), QMetaType::Double); @@ -584,7 +586,7 @@ void tst_QmlCppCodegen::conversions() QCOMPARE(stringDivString.toDouble(), 0.6); QCOMPARE(object->property("uglyString").toString(), - u"with\nnewlinewith\"quotwith\\slashes"_qs); + u"with\nnewlinewith\"quotwith\\slashes"_s); QCOMPARE(qvariant_cast<QObject *>(object->property("nullObject1")), nullptr); QCOMPARE(qvariant_cast<QObject *>(object->property("nullObject2")), object.data()); @@ -650,19 +652,19 @@ void tst_QmlCppCodegen::interestingFiles_data() QTest::addColumn<QString>("file"); QTest::addColumn<bool>("isValid"); - QTest::addRow("conversions2") << u"conversions2.qml"_qs << true; - QTest::addRow("TestCase") << u"TestCase.qml"_qs << true; - QTest::addRow("layouts") << u"layouts.qml"_qs << true; - QTest::addRow("interactive") << u"interactive.qml"_qs << true; - QTest::addRow("Panel") << u"Panel.qml"_qs << true; - QTest::addRow("ProgressBar") << u"ProgressBar/ProgressBar.ui.qml"_qs << true; - QTest::addRow("Root") << u"ProgressBar/Root.qml"_qs << true; - QTest::addRow("noscope") << u"noscope.qml"_qs << true; - QTest::addRow("dynamicscene") << u"dynamicscene.qml"_qs << true; - QTest::addRow("curlygrouped") << u"curlygrouped.qml"_qs << true; - QTest::addRow("cycleHead") << u"cycleHead.qml"_qs << false; - QTest::addRow("deadStoreLoop") << u"deadStoreLoop.qml"_qs << true; - QTest::addRow("moveRegVoid") << u"moveRegVoid.qml"_qs << true; + QTest::addRow("conversions2") << u"conversions2.qml"_s << true; + QTest::addRow("TestCase") << u"TestCase.qml"_s << true; + QTest::addRow("layouts") << u"layouts.qml"_s << true; + QTest::addRow("interactive") << u"interactive.qml"_s << true; + QTest::addRow("Panel") << u"Panel.qml"_s << true; + QTest::addRow("ProgressBar") << u"ProgressBar/ProgressBar.ui.qml"_s << true; + QTest::addRow("Root") << u"ProgressBar/Root.qml"_s << true; + QTest::addRow("noscope") << u"noscope.qml"_s << true; + QTest::addRow("dynamicscene") << u"dynamicscene.qml"_s << true; + QTest::addRow("curlygrouped") << u"curlygrouped.qml"_s << true; + QTest::addRow("cycleHead") << u"cycleHead.qml"_s << false; + QTest::addRow("deadStoreLoop") << u"deadStoreLoop.qml"_s << true; + QTest::addRow("moveRegVoid") << u"moveRegVoid.qml"_s << true; } void tst_QmlCppCodegen::interestingFiles() @@ -671,7 +673,7 @@ void tst_QmlCppCodegen::interestingFiles() QFETCH(bool, isValid); QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/%1"_qs.arg(file))); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/%1"_s.arg(file))); if (isValid) { QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> object(component.create()); @@ -684,7 +686,7 @@ void tst_QmlCppCodegen::interestingFiles() void tst_QmlCppCodegen::extendedTypes() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/extendedTypes.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/extendedTypes.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QTest::ignoreMessage(QtDebugMsg, "6 QSizeF(10, 20) 30"); @@ -694,7 +696,7 @@ void tst_QmlCppCodegen::extendedTypes() QCOMPARE(object->property("a").toInt(), 6); QCOMPARE(qvariant_cast<QSizeF>(object->property("b")), QSizeF(10, 20)); QCOMPARE(object->property("c").toInt(), 30); - QCOMPARE(object->property("d").toString(), u"QSizeF(10, 20)"_qs); + QCOMPARE(object->property("d").toString(), u"QSizeF(10, 20)"_s); QCOMPARE(object->property("e").toInt(), 2); } @@ -702,14 +704,14 @@ void tst_QmlCppCodegen::extendedTypes() void tst_QmlCppCodegen::construct() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/construct.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/construct.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); const QJSManagedValue v = engine.toManagedValue(object->property("foo")); QVERIFY(v.isError()); - QCOMPARE(v.toString(), u"Error: bar"_qs); + QCOMPARE(v.toString(), u"Error: bar"_s); QCOMPARE(object->property("aaa").toInt(), 12); QTest::ignoreMessage(QtWarningMsg, "qrc:/TestTypes/construct.qml:9: Error: ouch"); @@ -725,10 +727,10 @@ void tst_QmlCppCodegen::contextParam() QQmlEngine engine; QVariantMap m; - m.insert(u"foo"_qs, 10); - engine.rootContext()->setContextProperty(u"contextParam"_qs, m); + m.insert(u"foo"_s, 10); + engine.rootContext()->setContextProperty(u"contextParam"_s, m); - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/contextParam.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/contextParam.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -739,7 +741,7 @@ void tst_QmlCppCodegen::contextParam() void tst_QmlCppCodegen::attachedType() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/text.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/text.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -756,7 +758,7 @@ void tst_QmlCppCodegen::attachedType() void tst_QmlCppCodegen::componentReturnType() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/componentReturnType.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/componentReturnType.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); @@ -767,7 +769,7 @@ void tst_QmlCppCodegen::componentReturnType() void tst_QmlCppCodegen::onAssignment() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/pressAndHoldButton.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/pressAndHoldButton.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); @@ -801,7 +803,7 @@ void tst_QmlCppCodegen::failures() void tst_QmlCppCodegen::enumScope() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/enumScope.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/enumScope.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QCOMPARE(object->property("flow").toInt(), 1); @@ -810,7 +812,7 @@ void tst_QmlCppCodegen::enumScope() void tst_QmlCppCodegen::unusedAttached() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/unusedAttached.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/unusedAttached.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); @@ -828,7 +830,7 @@ void tst_QmlCppCodegen::unusedAttached() void tst_QmlCppCodegen::attachedBaseEnum() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/attachedBaseEnum.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/attachedBaseEnum.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); @@ -844,7 +846,7 @@ void tst_QmlCppCodegen::attachedBaseEnum() void tst_QmlCppCodegen::nullAccess() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/nullAccess.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/nullAccess.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QTest::ignoreMessage(QtWarningMsg, @@ -865,7 +867,7 @@ void tst_QmlCppCodegen::nullAccess() void tst_QmlCppCodegen::interceptor() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/interceptor.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/interceptor.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -886,7 +888,7 @@ void tst_QmlCppCodegen::interceptor() void tst_QmlCppCodegen::nonNotifyable() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/nonNotifyable.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/nonNotifyable.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -900,32 +902,32 @@ void tst_QmlCppCodegen::nonNotifyable() void tst_QmlCppCodegen::importsFromImportPath() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/importsFromImportPath.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/importsFromImportPath.qml"_s)); // We might propagate the import path, eventually, but for now instantiating is not important. // If the compiler accepts the file, it's probably fine. QVERIFY(component.isError()); QCOMPARE(component.errorString(), - u"qrc:/TestTypes/importsFromImportPath.qml:1 module \"Module\" is not installed\n"_qs); + u"qrc:/TestTypes/importsFromImportPath.qml:1 module \"Module\" is not installed\n"_s); } void tst_QmlCppCodegen::aliasLookup() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/aliasLookup.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/aliasLookup.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); const QVariant t = object->property("t"); QCOMPARE(t.metaType(), QMetaType::fromType<QString>()); - QCOMPARE(t.toString(), u"12"_qs); + QCOMPARE(t.toString(), u"12"_s); } void tst_QmlCppCodegen::outOfBoundsArray() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/outOfBounds.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/outOfBounds.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QTest::ignoreMessage(QtDebugMsg, "oob undefined"); @@ -938,8 +940,8 @@ void tst_QmlCppCodegen::outOfBoundsArray() void tst_QmlCppCodegen::compositeSingleton() { QQmlEngine engine; - engine.addImportPath(u":/TestTypes/imports/"_qs); - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/compositesingleton.qml"_qs)); + engine.addImportPath(u":/TestTypes/imports/"_s); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/compositesingleton.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> o(component.create()); QCOMPARE(o->property("x").toDouble(), 4.5); @@ -950,7 +952,7 @@ void tst_QmlCppCodegen::compositeSingleton() void tst_QmlCppCodegen::lotsOfRegisters() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/page.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/page.qml"_s)); QVERIFY2(!component.isError(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -986,7 +988,7 @@ void tst_QmlCppCodegen::lotsOfRegisters() void tst_QmlCppCodegen::inPlaceDecrement() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/dialog.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/dialog.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -1012,7 +1014,7 @@ void tst_QmlCppCodegen::inPlaceDecrement() void tst_QmlCppCodegen::shifts() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/shifts.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/shifts.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -1027,25 +1029,25 @@ void tst_QmlCppCodegen::shifts() void tst_QmlCppCodegen::valueTypeProperty() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/valueTypeProperty.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/valueTypeProperty.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QFont font = qvariant_cast<QFont>(object->property("font")); QCOMPARE(object->property("foo").toString(), font.family()); - font.setFamily(u"Bar"_qs); + font.setFamily(u"Bar"_s); object->setProperty("font", QVariant::fromValue(font)); - QCOMPARE(object->property("foo").toString(), u"Bar"_qs); + QCOMPARE(object->property("foo").toString(), u"Bar"_s); } void tst_QmlCppCodegen::propertyOfParent() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/RootWithoutId.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/RootWithoutId.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); - QObject *child = qmlContext(object.data())->objectForName(u"item"_qs); + QObject *child = qmlContext(object.data())->objectForName(u"item"_s); bool expected = false; @@ -1070,7 +1072,7 @@ void tst_QmlCppCodegen::propertyOfParent() void tst_QmlCppCodegen::accessModelMethodFromOutSide() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/AccessModelMethodsFromOutside.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/AccessModelMethodsFromOutside.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QTest::ignoreMessage(QtDebugMsg, "3"); @@ -1078,15 +1080,15 @@ void tst_QmlCppCodegen::accessModelMethodFromOutSide() QScopedPointer<QObject> object(component.create()); QCOMPARE(object->property("cost1").toDouble(), 3); - QCOMPARE(object->property("name1").toString(), u"Orange"_qs); + QCOMPARE(object->property("name1").toString(), u"Orange"_s); QCOMPARE(object->property("cost2").toDouble(), 1.95); - QCOMPARE(object->property("name2").toString(), u"Banana"_qs); + QCOMPARE(object->property("name2").toString(), u"Banana"_s); } void tst_QmlCppCodegen::functionArguments() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/Dummy.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/Dummy.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); @@ -1106,23 +1108,23 @@ void tst_QmlCppCodegen::functionArguments() Q_ARG(double, d), Q_ARG(int, e)); QCOMPARE(result, 42); - QString astr = u"foo"_qs; - QString bstr = u"bar"_qs; + QString astr = u"foo"_s; + QString bstr = u"bar"_s; QString concatenated; metaObject->invokeMethod( object.data(), "concat", Q_RETURN_ARG(QString, concatenated), Q_ARG(QString, astr), Q_ARG(QString, bstr)); - QCOMPARE(concatenated, u"foobar"_qs); + QCOMPARE(concatenated, u"foobar"_s); } void tst_QmlCppCodegen::bindingExpression() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/BindingExpression.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/BindingExpression.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); - QObject *child = qmlContext(object.data())->objectForName(u"child"_qs); + QObject *child = qmlContext(object.data())->objectForName(u"child"_s); double width = 200; double y = 10; @@ -1133,7 +1135,7 @@ void tst_QmlCppCodegen::bindingExpression() const double childY = y + (width - 100) / 2; QCOMPARE(child->property("y").toDouble(), childY); - QCOMPARE(object->property("mass"), childY > 100 ? u"heavy"_qs : u"light"_qs); + QCOMPARE(object->property("mass"), childY > 100 ? u"heavy"_s : u"light"_s); QCOMPARE(object->property("test_division").toDouble(), width / 1000 + 50); QCOMPARE(object->property("test_ternary").toDouble(), 2.2); @@ -1160,28 +1162,28 @@ void tst_QmlCppCodegen::bindingExpression() void tst_QmlCppCodegen::voidFunction() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/voidfunction.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/voidfunction.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); QVERIFY(object->objectName().isEmpty()); object->metaObject()->invokeMethod(object.data(), "doesNotReturnValue"); - QCOMPARE(object->objectName(), u"barbar"_qs); + QCOMPARE(object->objectName(), u"barbar"_s); } void tst_QmlCppCodegen::overriddenProperty() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/childobject.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/childobject.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); - QCOMPARE(object->objectName(), u"kraut"_qs); + QCOMPARE(object->objectName(), u"kraut"_s); QCOMPARE(object->property("doneThing").toInt(), 5); QCOMPARE(object->property("usingFinal").toInt(), 5); auto checkAssignment = [&]() { - const QString newName = u"worscht"_qs; + const QString newName = u"worscht"_s; QMetaObject::invokeMethod(object.data(), "setChildObjectName", Q_ARG(QString, newName)); QCOMPARE(object->objectName(), newName); }; @@ -1189,9 +1191,9 @@ void tst_QmlCppCodegen::overriddenProperty() ObjectWithMethod *benign = new ObjectWithMethod(object.data()); benign->theThing = 10; - benign->setObjectName(u"cabbage"_qs); + benign->setObjectName(u"cabbage"_s); object->setProperty("child", QVariant::fromValue(benign)); - QCOMPARE(object->objectName(), u"cabbage"_qs); + QCOMPARE(object->objectName(), u"cabbage"_s); checkAssignment(); QCOMPARE(object->property("doneThing").toInt(), 10); QCOMPARE(object->property("usingFinal").toInt(), 10); @@ -1202,7 +1204,7 @@ void tst_QmlCppCodegen::overriddenProperty() "The override won't be used."); object->setProperty("child", QVariant::fromValue(evil)); - QCOMPARE(object->objectName(), u"borschtsch"_qs); + QCOMPARE(object->objectName(), u"borschtsch"_s); checkAssignment(); QCOMPARE(object->property("doneThing").toInt(), 7); @@ -1212,7 +1214,7 @@ void tst_QmlCppCodegen::overriddenProperty() void tst_QmlCppCodegen::listLength() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/listlength.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/listlength.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -1222,7 +1224,7 @@ void tst_QmlCppCodegen::listLength() void tst_QmlCppCodegen::parentProperty() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/parentProp.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/parentProp.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -1233,9 +1235,9 @@ void tst_QmlCppCodegen::parentProperty() object->setProperty("implicitWidth", QVariant::fromValue(14)); QCOMPARE(object->property("i").toInt(), 26); - QObject *child = qmlContext(object.data())->objectForName(u"child"_qs); - QObject *sibling = qmlContext(object.data())->objectForName(u"sibling"_qs); - QObject *evil = qmlContext(object.data())->objectForName(u"evil"_qs); + QObject *child = qmlContext(object.data())->objectForName(u"child"_s); + QObject *sibling = qmlContext(object.data())->objectForName(u"sibling"_s); + QObject *evil = qmlContext(object.data())->objectForName(u"evil"_s); child->setProperty("parent", QVariant::fromValue(sibling)); @@ -1252,7 +1254,7 @@ void tst_QmlCppCodegen::parentProperty() QCOMPARE(object->property("i").toInt(), 886); { - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/specificParent.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/specificParent.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> rootObject(component.create()); @@ -1265,7 +1267,7 @@ void tst_QmlCppCodegen::parentProperty() void tst_QmlCppCodegen::registerElimination() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/registerelimination.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/registerelimination.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> object(component.create()); QVERIFY(!object.isNull()); @@ -1283,16 +1285,16 @@ void tst_QmlCppCodegen::registerElimination() void tst_QmlCppCodegen::asCast() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/asCast.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/asCast.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QScopedPointer<QObject> root(component.create()); QVERIFY(!root.isNull()); QQmlContext *context = qmlContext(root.data()); - const QObject *object = context->objectForName(u"object"_qs); - const QObject *item = context->objectForName(u"item"_qs); - const QObject *rectangle = context->objectForName(u"rectangle"_qs); - const QObject *dummy = context->objectForName(u"dummy"_qs); + const QObject *object = context->objectForName(u"object"_s); + const QObject *item = context->objectForName(u"item"_s); + const QObject *rectangle = context->objectForName(u"rectangle"_s); + const QObject *dummy = context->objectForName(u"dummy"_s); QCOMPARE(qvariant_cast<QObject *>(root->property("objectAsObject")), object); QCOMPARE(qvariant_cast<QObject *>(root->property("objectAsItem")), nullptr); @@ -1318,7 +1320,7 @@ void tst_QmlCppCodegen::asCast() void tst_QmlCppCodegen::noQQmlData() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/noQQmlData.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/noQQmlData.qml"_s)); QVERIFY2(component.isReady(), component.errorString().toUtf8()); QTest::ignoreMessage(QtWarningMsg, "qrc:/TestTypes/noQQmlData.qml:7: TypeError: " @@ -1334,9 +1336,9 @@ void tst_QmlCppCodegen::noQQmlData() Person *host1 = new Person(party); party->setHost(host1); - QCOMPARE(party->property("n").toString(), u"Bart in da house!"_qs); - host1->setName(u"Marge"_qs); - QCOMPARE(party->property("n").toString(), u"Marge in da house!"_qs); + QCOMPARE(party->property("n").toString(), u"Bart in da house!"_s); + host1->setName(u"Marge"_s); + QCOMPARE(party->property("n").toString(), u"Marge in da house!"_s); QTest::ignoreMessage(QtWarningMsg, "qrc:/TestTypes/noQQmlData.qml:7: TypeError: " "Cannot read property 'name' of null"); @@ -1347,26 +1349,26 @@ void tst_QmlCppCodegen::noQQmlData() // Lookups are initialized now, and we introduce an object without QQmlData Person *host2 = new Person(party); party->setHost(host2); - QCOMPARE(party->property("n").toString(), u"Bart in da house!"_qs); - host2->setName(u"Homer"_qs); - QCOMPARE(party->property("n").toString(), u"Homer in da house!"_qs); + QCOMPARE(party->property("n").toString(), u"Bart in da house!"_s); + host2->setName(u"Homer"_s); + QCOMPARE(party->property("n").toString(), u"Homer in da house!"_s); QMetaObject::invokeMethod(party, "burn"); engine.collectGarbage(); // Does not crash - party->setProperty("inDaHouse", u" burns!"_qs); + party->setProperty("inDaHouse", u" burns!"_s); // Mr Burns may or may not burn, depending on whether we use lookups. // If using lookups, the binding is aborted when we find the isQueuedForDeletion flag. // If reading the property directly, we don't have to care about it. - QVERIFY(party->property("n").toString().startsWith(u"Mr Burns"_qs)); + QVERIFY(party->property("n").toString().startsWith(u"Mr Burns"_s)); } void tst_QmlCppCodegen::scopeObjectDestruction() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/fileDialog.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/fileDialog.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> rootObject(component.create()); @@ -1413,21 +1415,21 @@ static void checkColorProperties(QQmlComponent *component) void tst_QmlCppCodegen::colorAsVariant() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/colorAsVariant.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/colorAsVariant.qml"_s)); checkColorProperties(&component); } void tst_QmlCppCodegen::bindToValueType() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/bindToValueType.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/bindToValueType.qml"_s)); checkColorProperties(&component); } void tst_QmlCppCodegen::undefinedResets() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/undefinedResets.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/undefinedResets.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> rootObject(component.create()); @@ -1436,34 +1438,34 @@ void tst_QmlCppCodegen::undefinedResets() Person *person = qobject_cast<Person *>(rootObject.data()); QVERIFY(person); QCOMPARE(person->shoeSize(), 0); - QCOMPARE(person->name(), u"Marge"_qs); + QCOMPARE(person->name(), u"Marge"_s); person->setShoeSize(11); QCOMPARE(person->shoeSize(), 11); - QCOMPARE(person->name(), u"Bart"_qs); + QCOMPARE(person->name(), u"Bart"_s); person->setShoeSize(10); QCOMPARE(person->shoeSize(), 10); - QCOMPARE(person->name(), u"Marge"_qs); + QCOMPARE(person->name(), u"Marge"_s); } void tst_QmlCppCodegen::innerObjectNonShadowable() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/ownProperty.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/ownProperty.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> rootObject(component.create()); QVERIFY(rootObject); - QCOMPARE(rootObject->objectName(), u"foo"_qs); + QCOMPARE(rootObject->objectName(), u"foo"_s); } void tst_QmlCppCodegen::ownPropertiesNonShadowable() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/overriddenMember.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/overriddenMember.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> rootObject(component.create()); @@ -1477,7 +1479,7 @@ void tst_QmlCppCodegen::ownPropertiesNonShadowable() void tst_QmlCppCodegen::modulePrefix() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/modulePrefix.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/modulePrefix.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> rootObject(component.create()); @@ -1491,7 +1493,7 @@ void tst_QmlCppCodegen::modulePrefix() void tst_QmlCppCodegen::colorString() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/colorString.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/colorString.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> rootObject(component.create()); @@ -1505,22 +1507,22 @@ void tst_QmlCppCodegen::colorString() void tst_QmlCppCodegen::urlString() { QQmlEngine engine; - QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/urlString.qml"_qs)); + QQmlComponent component(&engine, QUrl(u"qrc:/TestTypes/urlString.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> rootObject(component.create()); QVERIFY(rootObject); - QCOMPARE(qvariant_cast<QUrl>(rootObject->property("c")), QUrl(u"http://dddddd.com"_qs)); - QCOMPARE(qvariant_cast<QUrl>(rootObject->property("d")), QUrl(u"http://aaaaaa.com"_qs)); - QCOMPARE(qvariant_cast<QUrl>(rootObject->property("e")), QUrl(u"http://a112233.de"_qs)); + QCOMPARE(qvariant_cast<QUrl>(rootObject->property("c")), QUrl(u"http://dddddd.com"_s)); + QCOMPARE(qvariant_cast<QUrl>(rootObject->property("d")), QUrl(u"http://aaaaaa.com"_s)); + QCOMPARE(qvariant_cast<QUrl>(rootObject->property("e")), QUrl(u"http://a112233.de"_s)); } void tst_QmlCppCodegen::callContextPropertyLookupResult() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/callContextPropertyLookupResult.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/callContextPropertyLookupResult.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1531,7 +1533,7 @@ void tst_QmlCppCodegen::callContextPropertyLookupResult() void tst_QmlCppCodegen::deadShoeSize() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/deadShoeSize.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/deadShoeSize.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QTest::ignoreMessage(QtWarningMsg, "qrc:/TestTypes/deadShoeSize.qml:5: Error: ouch"); QScopedPointer<QObject> o(c.create()); @@ -1542,7 +1544,7 @@ void tst_QmlCppCodegen::deadShoeSize() void tst_QmlCppCodegen::listIndices() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/listIndices.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/listIndices.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1557,7 +1559,7 @@ void tst_QmlCppCodegen::listIndices() void tst_QmlCppCodegen::jsMathObject() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/jsMathObject.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/jsMathObject.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1613,7 +1615,7 @@ void tst_QmlCppCodegen::intEnumCompare() { QQmlEngine engine; { - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/intEnumCompare.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/intEnumCompare.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1625,7 +1627,7 @@ void tst_QmlCppCodegen::intEnumCompare() { // We cannot use Qt.red in QML because it's lower case. - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/enumInvalid.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/enumInvalid.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1637,7 +1639,7 @@ void tst_QmlCppCodegen::intEnumCompare() void tst_QmlCppCodegen::attachedSelf() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/SelectionRectangle.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/SelectionRectangle.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1650,7 +1652,7 @@ void tst_QmlCppCodegen::attachedSelf() void tst_QmlCppCodegen::functionReturningVoid() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/functionReturningVoid.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/functionReturningVoid.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1667,7 +1669,7 @@ void tst_QmlCppCodegen::functionCallOnNamespaced() { QQmlEngine engine; { - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/themergood.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/themergood.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1675,7 +1677,7 @@ void tst_QmlCppCodegen::functionCallOnNamespaced() } { - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/themerbad.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/themerbad.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1686,7 +1688,7 @@ void tst_QmlCppCodegen::functionCallOnNamespaced() void tst_QmlCppCodegen::flushBeforeCapture() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/noBindingLoop.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/noBindingLoop.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1699,45 +1701,45 @@ void tst_QmlCppCodegen::flushBeforeCapture() void tst_QmlCppCodegen::unknownAttached() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/unknownAttached.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/unknownAttached.qml"_s)); QVERIFY(c.isError()); } void tst_QmlCppCodegen::variantlist() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/variantlist.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/variantlist.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); const QVariantList things = qvariant_cast<QVariantList>(o->property("things")); QCOMPARE(things.length(), 2); - QCOMPARE(things[0].toString(), u"thing"_qs); + QCOMPARE(things[0].toString(), u"thing"_s); QCOMPARE(things[1].toInt(), 30); } void tst_QmlCppCodegen::popContextAfterRet() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/popContextAfterRet.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/popContextAfterRet.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); QCOMPARE(o->objectName(), QString()); o->setProperty("stackViewDepth", 1); - QCOMPARE(o->objectName(), u"backgroundImage"_qs); + QCOMPARE(o->objectName(), u"backgroundImage"_s); o->setProperty("stackViewDepth", 2); - QCOMPARE(o->objectName(), u"backgroundBlur"_qs); + QCOMPARE(o->objectName(), u"backgroundBlur"_s); o->setProperty("stackViewDepth", 1); - QCOMPARE(o->objectName(), u"backgroundImage"_qs); + QCOMPARE(o->objectName(), u"backgroundImage"_s); } void tst_QmlCppCodegen::revisions() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/revisions.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/revisions.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1749,7 +1751,7 @@ void tst_QmlCppCodegen::revisions() void tst_QmlCppCodegen::invisibleBase() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/invisibleBase.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/invisibleBase.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1759,21 +1761,21 @@ void tst_QmlCppCodegen::invisibleBase() void tst_QmlCppCodegen::notEqualsInt() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/notEqualsInt.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/notEqualsInt.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); - QObject *t = qmlContext(o.data())->objectForName(u"t"_qs); + QObject *t = qmlContext(o.data())->objectForName(u"t"_s); QVERIFY(t); - QCOMPARE(t->property("text").toString(), u"Foo"_qs); + QCOMPARE(t->property("text").toString(), u"Foo"_s); QMetaObject::invokeMethod(o.data(), "foo"); - QCOMPARE(t->property("text").toString(), u"Bar"_qs); + QCOMPARE(t->property("text").toString(), u"Bar"_s); } void tst_QmlCppCodegen::infinities() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/infinities.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/infinities.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1795,7 +1797,7 @@ void tst_QmlCppCodegen::infinities() void tst_QmlCppCodegen::blockComments() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/blockComments.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/blockComments.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1805,7 +1807,7 @@ void tst_QmlCppCodegen::blockComments() void tst_QmlCppCodegen::functionLookup() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/functionLookup.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/functionLookup.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1821,7 +1823,7 @@ void tst_QmlCppCodegen::functionLookup() void tst_QmlCppCodegen::objectInVar() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/objectInVar.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/objectInVar.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(o); @@ -1839,7 +1841,7 @@ void tst_QmlCppCodegen::objectInVar() void tst_QmlCppCodegen::functionTakingVar() { QQmlEngine engine; - const QUrl document(u"qrc:/TestTypes/functionTakingVar.qml"_qs); + const QUrl document(u"qrc:/TestTypes/functionTakingVar.qml"_s); QQmlComponent c(&engine, document); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); @@ -1859,7 +1861,7 @@ void tst_QmlCppCodegen::functionTakingVar() void tst_QmlCppCodegen::testIsnan() { QQmlEngine engine; - const QUrl document(u"qrc:/TestTypes/isnan.qml"_qs); + const QUrl document(u"qrc:/TestTypes/isnan.qml"_s); QQmlComponent c(&engine, document); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); @@ -1880,7 +1882,7 @@ void tst_QmlCppCodegen::testIsnan() void tst_QmlCppCodegen::fallbackLookups() { QQmlEngine engine; - const QUrl document(u"qrc:/TestTypes/fallbacklookups.qml"_qs); + const QUrl document(u"qrc:/TestTypes/fallbacklookups.qml"_s); QQmlComponent c(&engine, document); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); @@ -1913,7 +1915,7 @@ void tst_QmlCppCodegen::fallbackLookups() void tst_QmlCppCodegen::typedArray() { QQmlEngine engine; - const QUrl document(u"qrc:/TestTypes/typedArray.qml"_qs); + const QUrl document(u"qrc:/TestTypes/typedArray.qml"_s); QQmlComponent c(&engine, document); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); @@ -1945,9 +1947,9 @@ void tst_QmlCppCodegen::prefixedType() // We need to add an import path here because we cannot namespace the implicit import. // The implicit import is what we use for all the other tests, even if we explicitly // import TestTypes. That is because the TestTypes module is in a subdirectory "data". - engine.addImportPath(u":/"_qs); + engine.addImportPath(u":/"_s); - const QUrl document(u"qrc:/TestTypes/prefixedMetaType.qml"_qs); + const QUrl document(u"qrc:/TestTypes/prefixedMetaType.qml"_s); QQmlComponent c(&engine, document); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); @@ -1976,15 +1978,15 @@ void tst_QmlCppCodegen::evadingAmbiguity() // We need to add an import path here because we cannot namespace the implicit import. // The implicit import is what we use for all the other tests, even if we explicitly // import TestTypes. That is because the TestTypes module is in a subdirectory "data". - engine.addImportPath(u":/"_qs); + engine.addImportPath(u":/"_s); - QQmlComponent c1(&engine, QUrl(u"qrc:/TestTypes/ambiguous1/Ambiguous.qml"_qs)); + QQmlComponent c1(&engine, QUrl(u"qrc:/TestTypes/ambiguous1/Ambiguous.qml"_s)); QVERIFY2(c1.isReady(), qPrintable(c1.errorString())); QScopedPointer<QObject> o1(c1.create()); QCOMPARE(o1->objectName(), QStringLiteral("Ambiguous")); QCOMPARE(o1->property("i").toString(), QStringLiteral("Ambiguous1")); - QQmlComponent c2(&engine, QUrl(u"qrc:/TestTypes/ambiguous2/Ambiguous.qml"_qs)); + QQmlComponent c2(&engine, QUrl(u"qrc:/TestTypes/ambiguous2/Ambiguous.qml"_s)); QVERIFY2(c2.isReady(), qPrintable(c2.errorString())); QScopedPointer<QObject> o2(c2.create()); QCOMPARE(o2->objectName(), QStringLiteral("Ambiguous")); @@ -1994,7 +1996,7 @@ void tst_QmlCppCodegen::evadingAmbiguity() void tst_QmlCppCodegen::fromBoolValue() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/fromBoolValue.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/fromBoolValue.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QCOMPARE(o->property("a").toBool(), true); @@ -2009,7 +2011,7 @@ void tst_QmlCppCodegen::fromBoolValue() QCOMPARE(o->property("width").toInt(), 100); QCOMPARE(o->property("b").toBool(), false); - o->setProperty("state", QVariant::fromValue(u"foo"_qs)); + o->setProperty("state", QVariant::fromValue(u"foo"_s)); QCOMPARE(o->property("width").toInt(), 0); QCOMPARE(o->property("b").toBool(), false); } @@ -2017,7 +2019,7 @@ void tst_QmlCppCodegen::fromBoolValue() void tst_QmlCppCodegen::invisibleTypes() { QQmlEngine engine; - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/invisibleTypes.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/invisibleTypes.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); @@ -2068,20 +2070,20 @@ void tst_QmlCppCodegen::invalidPropertyType() qmlRegisterType<MyCppType>("App", 1, 0, "MyCppType"); QQmlEngine engine; - QQmlComponent okComponent(&engine, QUrl(u"qrc:/TestTypes/OkType.qml"_qs)); + QQmlComponent okComponent(&engine, QUrl(u"qrc:/TestTypes/OkType.qml"_s)); QVERIFY2(okComponent.isReady(), qPrintable(okComponent.errorString())); QScopedPointer<QObject> picker(okComponent.create()); QVERIFY2(!picker.isNull(), qPrintable(okComponent.errorString())); - QObject *inner = qmlContext(picker.data())->objectForName(u"inner"_qs); + QObject *inner = qmlContext(picker.data())->objectForName(u"inner"_s); QVERIFY(inner); MyCppType *myCppType = qobject_cast<MyCppType *>(inner); QVERIFY(myCppType); QVERIFY(!myCppType->useListDelegate()); - QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/BadType.qml"_qs)); + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/BadType.qml"_s)); QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.createWithInitialProperties( - QVariantMap {{u"picker"_qs, QVariant::fromValue(picker.data())}})); + QVariantMap {{u"picker"_s, QVariant::fromValue(picker.data())}})); QVERIFY2(!o.isNull(), qPrintable(c.errorString())); QVERIFY(!myCppType->useListDelegate()); @@ -2102,7 +2104,7 @@ void tst_QmlCppCodegen::runInterpreted() QProcess process; process.setProgram(QCoreApplication::applicationFilePath()); process.setEnvironment(QProcess::systemEnvironment() - + QStringList(u"QV4_FORCE_INTERPRETER=1"_qs)); + + QStringList(u"QV4_FORCE_INTERPRETER=1"_s)); process.start(); QVERIFY(process.waitForFinished()); QCOMPARE(process.exitStatus(), QProcess::NormalExit); diff --git a/tests/auto/qml/qmlimportscanner/tst_qmlimportscanner.cpp b/tests/auto/qml/qmlimportscanner/tst_qmlimportscanner.cpp index 1212cd3c82..11f4425f61 100644 --- a/tests/auto/qml/qmlimportscanner/tst_qmlimportscanner.cpp +++ b/tests/auto/qml/qmlimportscanner/tst_qmlimportscanner.cpp @@ -31,6 +31,8 @@ #include <QString> #include <QtQuickTestUtils/private/qmlutils_p.h> +using namespace Qt::StringLiterals; + class TestQmlimportscanner: public QQmlDataTest { Q_OBJECT @@ -127,9 +129,9 @@ void TestQmlimportscanner::modules() void TestQmlimportscanner::qmldirPreference() { // ### - QStringList with {u"-importPath"_qs, testFile("With")}; - QStringList withOut {u"-importPath"_qs, testFile("WithOut")}; - QStringList genericArgs {u"-qmlFiles"_qs, testFile("qmldirpref.qml"), u"-importPath"_qs, + QStringList with {u"-importPath"_s, testFile("With")}; + QStringList withOut {u"-importPath"_s, testFile("WithOut")}; + QStringList genericArgs {u"-qmlFiles"_s, testFile("qmldirpref.qml"), u"-importPath"_s, QLibraryInfo::path(QLibraryInfo::QmlImportsPath)}; diff --git a/tests/auto/qml/qmllint/lintplugin.cpp b/tests/auto/qml/qmllint/lintplugin.cpp index 9fe0789f41..91f3f41749 100644 --- a/tests/auto/qml/qmllint/lintplugin.cpp +++ b/tests/auto/qml/qmllint/lintplugin.cpp @@ -28,6 +28,8 @@ #include "lintplugin.h" +using namespace Qt::StringLiterals; + class ElementTest : public QQmlSA::ElementPass { public: @@ -43,13 +45,13 @@ public: void run(const QQmlSA::Element &element) override { - auto property = element->property(u"radius"_qs); - if (!property.isValid() || element->property(u"radius"_qs).typeName() != u"double") { + auto property = element->property(u"radius"_s); + if (!property.isValid() || element->property(u"radius"_s).typeName() != u"double") { emitWarning(u"Failed to verify radius property", element->sourceLocation()); return; } - auto bindings = element->propertyBindings(u"radius"_qs); + auto bindings = element->propertyBindings(u"radius"_s); if (bindings.isEmpty() || bindings.constFirst().numberValue() != 5) { emitWarning(u"Failed to verify radius property binding", element->sourceLocation()); return; diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index 492ec95350..4fc5357177 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -236,7 +236,7 @@ void TestQmllint::testUnqualified_data() 33 } // builtin property }, {}, - { { Message { u"root."_qs, 9, 16 } }, { Message { u"root."_qs, 13, 33 } } } + { { Message { u"root."_s, 9, 16 } }, { Message { u"root."_s, 13, 33 } } } }; // access injected name from signal QTest::newRow("SignalHandler") @@ -264,7 +264,7 @@ void TestQmllint::testUnqualified_data() Message { QStringLiteral("Unqualified access"), 6, 25 }, }, {}, - { { Message { u"<id>."_qs, 6, 25 } } } }; + { { Message { u"<id>."_s, 6, 25 } } } }; QTest::newRow("crashConnections") << QStringLiteral("crashConnections.qml") @@ -1215,7 +1215,7 @@ void TestQmllint::compilerWarnings() auto options = QQmlJSLogger::options(); if (enableCompilerWarnings) - options[u"compiler"_qs].setLevel(u"warning"_qs); + options[u"compiler"_s].setLevel(u"warning"_s); runTest(filename, result, {}, {}, {}, UseDefaultImports, &options); } @@ -1242,7 +1242,7 @@ void TestQmllint::controlsSanity() QJsonArray warnings; auto options = QQmlJSLogger::options(); - options[u"controls-sanity"_qs].setLevel(u"warning"_qs); + options[u"controls-sanity"_s].setLevel(u"warning"_s); runTest(filename, result, {}, {}, {}, UseDefaultImports, &options); } @@ -1354,7 +1354,7 @@ void TestQmllint::callQmllint(const QString &fileToLint, bool shouldSucceed, QJs if (warnings) { QVERIFY2(jsonOutput.size() == 1, QJsonDocument(jsonOutput).toJson()); - *warnings = jsonOutput.at(0)[u"warnings"_qs].toArray(); + *warnings = jsonOutput.at(0)[u"warnings"_s].toArray(); } QCOMPARE(success, shouldSucceed); @@ -1377,15 +1377,15 @@ void TestQmllint::callQmllint(const QString &fileToLint, bool shouldSucceed, QJs callQmllint(QFileInfo(file).absoluteFilePath(), true, nullptr, importPaths, qmldirFiles, resources, defaultImports, options, false); - const QString fixedPath = testFile(info.baseName() + u".fixed.qml"_qs); + const QString fixedPath = testFile(info.baseName() + u".fixed.qml"_s); if (QFileInfo(fixedPath).exists()) { QFile fixedFile(fixedPath); fixedFile.open(QFile::ReadOnly); QString fixedFileContents = QString::fromUtf8(fixedFile.readAll()); #ifdef Q_OS_WIN - fixedCode = fixedCode.replace(u"\r\n"_qs, u"\n"_qs); - fixedFileContents = fixedFileContents.replace(u"\r\n"_qs, u"\n"_qs); + fixedCode = fixedCode.replace(u"\r\n"_s, u"\n"_s); + fixedFileContents = fixedFileContents.replace(u"\r\n"_s, u"\n"_s); #endif QCOMPARE(fixedCode, fixedFileContents); @@ -1493,7 +1493,7 @@ void TestQmllint::searchWarnings(const QJsonArray &warnings, const QString &subs #ifdef Q_OS_WIN // Replacements can contain native line endings // but we need them to be uniform in order for them to conform to our test data - replacement = replacement.replace(u"\r\n"_qs, u"\n"_qs); + replacement = replacement.replace(u"\r\n"_s, u"\n"_s); #endif if (replacement.contains(substring)) { @@ -1582,7 +1582,7 @@ void TestQmllint::attachedPropertyReuse() { auto options = QQmlJSLogger::options(); - options[u"multiple-attached-objects"_qs].setLevel(u"warning"_qs); + options[u"multiple-attached-objects"_s].setLevel(u"warning"_s); runTest("attachedPropNotReused.qml", Result { { Message { QStringLiteral("Using attached type QQuickKeyNavigationAttached " "already initialized in a parent " @@ -1607,7 +1607,7 @@ void TestQmllint::missingBuiltinsNoCrash() QVERIFY2(!success, QJsonDocument(jsonOutput).toJson()); QVERIFY2(jsonOutput.size() == 1, QJsonDocument(jsonOutput).toJson()); - warnings = jsonOutput.at(0)[u"warnings"_qs].toArray(); + warnings = jsonOutput.at(0)[u"warnings"_s].toArray(); checkResult(warnings, Result { { Message { QStringLiteral("Failed to find the following builtins: " @@ -1636,20 +1636,20 @@ void TestQmllint::testPlugin() for (const QQmlJSLinter::Plugin &plugin : m_linter.plugins()) { if (plugin.name() == "testPlugin") { pluginFound = true; - QCOMPARE(plugin.author(), u"Qt"_qs); - QCOMPARE(plugin.description(), u"A test plugin for tst_qmllint"_qs); - QCOMPARE(plugin.version(), u"1.0"_qs); + QCOMPARE(plugin.author(), u"Qt"_s); + QCOMPARE(plugin.description(), u"A test plugin for tst_qmllint"_s); + QCOMPARE(plugin.version(), u"1.0"_s); break; } } QVERIFY(pluginFound); - runTest("elementpass_pluginTest.qml", Result { { Message { u"ElementTest OK"_qs, 4, 5 } } }); - runTest("propertypass_pluginTest.qml", Result { { Message { u"OK"_qs } } }); + runTest("elementpass_pluginTest.qml", Result { { Message { u"ElementTest OK"_s, 4, 5 } } }); + runTest("propertypass_pluginTest.qml", Result { { Message { u"OK"_s } } }); runTest("controlsWithQuick_pluginTest.qml", - Result { { Message { u"QtQuick.Controls, QtQuick and QtQuick.Window present"_qs } } }); + Result { { Message { u"QtQuick.Controls, QtQuick and QtQuick.Window present"_s } } }); runTest("controlsWithoutQuick_pluginTest.qml", - Result { { Message { u"QtQuick.Controls and NO QtQuick present"_qs } } }); + Result { { Message { u"QtQuick.Controls and NO QtQuick present"_s } } }); // Verify that none of the passes do anything when they're not supposed to runTest("nothing_pluginTest.qml", Result::clean()); } @@ -1667,50 +1667,50 @@ void TestQmllint::quickPlugin() runTest("pluginQuick_anchors.qml", Result{ { Message{ - u"Cannot specify left, right, and horizontalCenter anchors at the same time."_qs }, + u"Cannot specify left, right, and horizontalCenter anchors at the same time."_s }, Message { - u"Cannot specify top, bottom, and verticalCenter anchors at the same time."_qs }, + u"Cannot specify top, bottom, and verticalCenter anchors at the same time."_s }, Message{ - u"Baseline anchor cannot be used in conjunction with top, bottom, or verticalCenter anchors."_qs }, + u"Baseline anchor cannot be used in conjunction with top, bottom, or verticalCenter anchors."_s }, Message{ u"Cannot assign binding of type null to QQuickAnchorLine"_s, 5, 35 }, Message{ u"Cannot assign binding of type null to QQuickAnchorLine"_s, 8, 33 } } }); runTest("pluginQuick_layoutChildren.qml", Result { { Message { - u"Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead."_qs }, + u"Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead."_s }, Message { - u"Detected x on an item that is managed by a layout. This is undefined behavior; use Layout.leftMargin or Layout.rightMargin instead."_qs }, + u"Detected x on an item that is managed by a layout. This is undefined behavior; use Layout.leftMargin or Layout.rightMargin instead."_s }, Message { - u"Detected y on an item that is managed by a layout. This is undefined behavior; use Layout.topMargin or Layout.bottomMargin instead."_qs }, + u"Detected y on an item that is managed by a layout. This is undefined behavior; use Layout.topMargin or Layout.bottomMargin instead."_s }, Message { - u"Detected height on an item that is managed by a layout. This is undefined behavior; use implictHeight or Layout.preferredHeight instead."_qs }, + u"Detected height on an item that is managed by a layout. This is undefined behavior; use implictHeight or Layout.preferredHeight instead."_s }, Message { - u"Detected width on an item that is managed by a layout. This is undefined behavior; use implicitWidth or Layout.preferredWidth instead."_qs }, + u"Detected width on an item that is managed by a layout. This is undefined behavior; use implicitWidth or Layout.preferredWidth instead."_s }, Message { - u"Cannot specify anchors for items inside Grid. Grid will not function."_qs }, + u"Cannot specify anchors for items inside Grid. Grid will not function."_s }, Message { - u"Cannot specify x for items inside Grid. Grid will not function."_qs }, + u"Cannot specify x for items inside Grid. Grid will not function."_s }, Message { - u"Cannot specify y for items inside Grid. Grid will not function."_qs }, + u"Cannot specify y for items inside Grid. Grid will not function."_s }, Message { - u"Cannot specify anchors for items inside Flow. Flow will not function."_qs }, + u"Cannot specify anchors for items inside Flow. Flow will not function."_s }, Message { - u"Cannot specify x for items inside Flow. Flow will not function."_qs }, + u"Cannot specify x for items inside Flow. Flow will not function."_s }, Message { - u"Cannot specify y for items inside Flow. Flow will not function."_qs } } }); + u"Cannot specify y for items inside Flow. Flow will not function."_s } } }); runTest("pluginQuick_attached.qml", Result { - { Message { u"ToolTip must be attached to an Item"_qs }, - Message { u"SplitView attached property only works with Items"_qs }, - Message { u"ScrollIndicator must be attached to a Flickable"_qs }, - Message { u"ScrollBar must be attached to a Flickable or ScrollView"_qs }, - Message { u"Accessible must be attached to an Item"_qs }, - Message { u"EnterKey attached property only works with Items"_qs }, + { Message { u"ToolTip must be attached to an Item"_s }, + Message { u"SplitView attached property only works with Items"_s }, + Message { u"ScrollIndicator must be attached to a Flickable"_s }, + Message { u"ScrollBar must be attached to a Flickable or ScrollView"_s }, + Message { u"Accessible must be attached to an Item"_s }, + Message { u"EnterKey attached property only works with Items"_s }, Message { - u"LayoutDirection attached property only works with Items and Windows"_qs }, - Message { u"Layout must be attached to Item elements"_qs }, - Message { u"StackView attached property only works with Items"_qs } } }); + u"LayoutDirection attached property only works with Items and Windows"_s }, + Message { u"Layout must be attached to Item elements"_s }, + Message { u"StackView attached property only works with Items"_s } } }); } #endif diff --git a/tests/auto/qml/qmltc/data/cpptypes/typewithproperties.cpp b/tests/auto/qml/qmltc/data/cpptypes/typewithproperties.cpp index d0ea6c4c9f..322211b44d 100644 --- a/tests/auto/qml/qmltc/data/cpptypes/typewithproperties.cpp +++ b/tests/auto/qml/qmltc/data/cpptypes/typewithproperties.cpp @@ -28,6 +28,8 @@ #include "typewithproperties.h" +using namespace Qt::StringLiterals; + double TypeWithProperties::a() const { return m_a; @@ -72,7 +74,7 @@ void TypeWithProperties::setD(int d_) { if (m_d != d_) { m_d = d_; - Q_EMIT dSignal(u"d changed"_qs, d_); + Q_EMIT dSignal(u"d changed"_s, d_); } } void TypeWithProperties::setJsValue(const QJSValue &value) diff --git a/tests/auto/qml/qmltc/tst_qmltc.cpp b/tests/auto/qml/qmltc/tst_qmltc.cpp index 955911e52a..7ea496fd17 100644 --- a/tests/auto/qml/qmltc/tst_qmltc.cpp +++ b/tests/auto/qml/qmltc/tst_qmltc.cpp @@ -112,6 +112,8 @@ #define PREPEND_NAMESPACE(name) ::QmltcTest::name // silent contract that the namespace is QmltcTest +using namespace Qt::StringLiterals; + tst_qmltc::tst_qmltc() { #if defined(QMLTC_TESTS_DISABLE_CACHE) && QMLTC_TESTS_DISABLE_CACHE @@ -187,7 +189,7 @@ void tst_qmltc::initTestCase() QQmlComponent component(&e); for (const auto &url : urls) { component.loadUrl(url); - QVERIFY2(!component.isError(), qPrintable(u"Bad QML file. "_qs + component.errorString())); + QVERIFY2(!component.isError(), qPrintable(u"Bad QML file. "_s + component.errorString())); } } @@ -362,16 +364,16 @@ void tst_qmltc::properties() QCOMPARE(created.doubleP(), 0.5); QCOMPARE(created.intP(), 42); QCOMPARE(created.realP(), 2.32); - QCOMPARE(created.stringP(), u"hello, world"_qs); - QCOMPARE(created.urlP(), u"https://www.qt.io/"_qs); + QCOMPARE(created.stringP(), u"hello, world"_s); + QCOMPARE(created.urlP(), u"https://www.qt.io/"_s); QCOMPARE(created.varP(), 42.42); QCOMPARE(created.boolP(), true); QCOMPARE(created.boolP(), true); - QCOMPARE(created.colorP(), QColor(u"blue"_qs)); + QCOMPARE(created.colorP(), QColor(u"blue"_s)); - QCOMPARE(created.readonlyStringP(), u"foobar"_qs); + QCOMPARE(created.readonlyStringP(), u"foobar"_s); // object bindinds: const auto objectCtx = e.contextForObject(&created); @@ -380,12 +382,12 @@ void tst_qmltc::properties() { QQuickText *child0 = qobject_cast<QQuickText *>(listQtObj.at(0)); QVERIFY(child0); - QCOMPARE(child0->text(), u"child0"_qs); + QCOMPARE(child0->text(), u"child0"_s); QCOMPARE(objectCtx->objectForName("listQtObjP_child_0"), child0); QObject *child1 = listQtObj.at(1); QVERIFY(child1); - QCOMPARE(child1->property("what").toString(), u"child1"_qs); + QCOMPARE(child1->property("what").toString(), u"child1"_s); QQuickItem *child2 = qobject_cast<QQuickItem *>(listQtObj.at(2)); QVERIFY(child2); @@ -417,17 +419,17 @@ void tst_qmltc::properties() QScopedPointer<QObject> beforeDelegateObject(beforeDelegate->create()); QVERIFY(beforeDelegateObject); QVERIFY(qobject_cast<QQuickText *>(beforeDelegateObject.get())); - QCOMPARE(beforeDelegateObject->property("text").toString(), u"beforeDelegate"_qs); + QCOMPARE(beforeDelegateObject->property("text").toString(), u"beforeDelegate"_s); QScopedPointer<QObject> delegateObject(delegate->create()); QVERIFY(delegateObject); QVERIFY(qobject_cast<QQuickText *>(delegateObject.get())); - QCOMPARE(delegateObject->property("text").toString(), u"delegate"_qs); + QCOMPARE(delegateObject->property("text").toString(), u"delegate"_s); QScopedPointer<QObject> afterDelegateObject(afterDelegate->create()); QVERIFY(afterDelegateObject); QVERIFY(qobject_cast<QQuickText *>(afterDelegateObject.get())); - QCOMPARE(afterDelegateObject->property("text").toString(), u"afterDelegate"_qs); + QCOMPARE(afterDelegateObject->property("text").toString(), u"afterDelegate"_s); } QQmlComponent *explicitComp = qobject_cast<QQmlComponent *>(created.explicitCompP()); @@ -435,11 +437,11 @@ void tst_qmltc::properties() QScopedPointer<QObject> explicitCompObject(explicitComp->create()); QVERIFY(explicitCompObject); QVERIFY(qobject_cast<QQuickText *>(explicitCompObject.get())); - QCOMPARE(explicitCompObject->property("text").toString(), u"not a delegate"_qs); + QCOMPARE(explicitCompObject->property("text").toString(), u"not a delegate"_s); QObject *sentinelForComponent = created.sentinelForComponent(); QVERIFY(sentinelForComponent); - QCOMPARE(sentinelForComponent->property("text").toString(), u"should be correctly created"_qs); + QCOMPARE(sentinelForComponent->property("text").toString(), u"should be correctly created"_s); } void tst_qmltc::ids() @@ -474,15 +476,15 @@ void tst_qmltc::ids() return object->objectName(); }; - QCOMPARE(objectNameById("rectangle"), u"rectangle"_qs); - QCOMPARE(objectNameById("row"), u"row"_qs); - QCOMPARE(objectNameById("textInRectangle"), u"textInRectangle"_qs); - QCOMPARE(objectNameById("itemInList"), u"itemInList"_qs); - QCOMPARE(objectNameById("objectInList"), u"objectInList"_qs); - QCOMPARE(objectNameById("item"), u"item"_qs); - QCOMPARE(objectNameById("gridView"), u"gridView"_qs); - QCOMPARE(objectNameById("tableView"), u"tableView"_qs); - QCOMPARE(objectNameById("sentinel"), u"sentinel"_qs); + QCOMPARE(objectNameById("rectangle"), u"rectangle"_s); + QCOMPARE(objectNameById("row"), u"row"_s); + QCOMPARE(objectNameById("textInRectangle"), u"textInRectangle"_s); + QCOMPARE(objectNameById("itemInList"), u"itemInList"_s); + QCOMPARE(objectNameById("objectInList"), u"objectInList"_s); + QCOMPARE(objectNameById("item"), u"item"_s); + QCOMPARE(objectNameById("gridView"), u"gridView"_s); + QCOMPARE(objectNameById("tableView"), u"tableView"_s); + QCOMPARE(objectNameById("sentinel"), u"sentinel"_s); const auto verifyComponent = [&](QQmlComponent *component, const QString &componentId, const QString &objectId) { @@ -499,22 +501,22 @@ void tst_qmltc::ids() }; auto explicitComponent = qobject_cast<QQmlComponent *>(created.explicitCompProperty()); - verifyComponent(explicitComponent, u"explicitComponent"_qs, u"explicitText"_qs); + verifyComponent(explicitComponent, u"explicitComponent"_s, u"explicitText"_s); QQmlListReference children(&created, "data"); QCOMPARE(children.size(), 2); QQuickTableView *table = qobject_cast<QQuickTableView *>(children.at(1)); QVERIFY(table); - QCOMPARE(ctx->objectForName(u"tableView"_qs), table); - QCOMPARE(table->objectName(), u"tableView"_qs); + QCOMPARE(ctx->objectForName(u"tableView"_s), table); + QCOMPARE(table->objectName(), u"tableView"_s); auto before = qvariant_cast<QQmlComponent *>(table->property("before")); - verifyComponent(before, u"beforeDelegate"_qs, u"beforeDelegateText"_qs); + verifyComponent(before, u"beforeDelegate"_s, u"beforeDelegateText"_s); auto after = qvariant_cast<QQmlComponent *>(table->property("after")); - verifyComponent(after, u"afterDelegate"_qs, u"afterDelegateText"_qs); + verifyComponent(after, u"afterDelegate"_s, u"afterDelegateText"_s); auto delegate = table->delegate(); - verifyComponent(delegate, /* implicit component */ QString(), u"delegateRect"_qs); + verifyComponent(delegate, /* implicit component */ QString(), u"delegateRect"_s); // TableView is really special when you add Component to a default // property. see QQuickFlickablePrivate::data_append @@ -527,15 +529,15 @@ void tst_qmltc::ids() if (!comp) continue; // this is bad, but there doesn't seem to be any better choice - if (ctx->objectForName(u"beforeDelegateDefaultProperty"_qs) == comp) + if (ctx->objectForName(u"beforeDelegateDefaultProperty"_s) == comp) beforeChild = comp; - else if (ctx->objectForName(u"afterDelegateDefaultProperty"_qs) == comp) + else if (ctx->objectForName(u"afterDelegateDefaultProperty"_s) == comp) afterChild = comp; } // we just used ctx->objectForName() to find these components, so // there's no point in checking the same condition in verifyComponent() - verifyComponent(beforeChild, QString(), u"beforeDelegateDefaultPropertyText"_qs); - verifyComponent(afterChild, QString(), u"afterDelegateDefaultPropertyText"_qs); + verifyComponent(beforeChild, QString(), u"beforeDelegateDefaultPropertyText"_s); + verifyComponent(afterChild, QString(), u"afterDelegateDefaultPropertyText"_s); } } @@ -543,7 +545,7 @@ void tst_qmltc::importNamespace() { QQmlEngine e; PREPEND_NAMESPACE(importNamespace) created(&e); // compilation of this type shouldn't crash - QCOMPARE(created.text(), u"hello, world"_qs); + QCOMPARE(created.text(), u"hello, world"_s); } void tst_qmltc::componentTypes() @@ -556,7 +558,7 @@ void tst_qmltc::componentTypes() QScopedPointer<QObject> enclosed(created.create()); QVERIFY(enclosed); - QCOMPARE(enclosed->objectName(), u"enclosed"_qs); + QCOMPARE(enclosed->objectName(), u"enclosed"_s); } { @@ -564,18 +566,18 @@ void tst_qmltc::componentTypes() PREPEND_NAMESPACE(componentTypes) created(&e); QQmlContext *ctx = e.contextForObject(&created); - QObject *normal = ctx->objectForName(u"normal"_qs); + QObject *normal = ctx->objectForName(u"normal"_s); QVERIFY(normal); - QCOMPARE(normal->property("text").toString(), u"indirect component"_qs); + QCOMPARE(normal->property("text").toString(), u"indirect component"_s); - QVERIFY(ctx->objectForName(u"accessibleNormal"_qs)); - QVERIFY(!ctx->objectForName(u"inaccessibleNormal"_qs)); - QVERIFY(ctx->objectForName(u"accessible"_qs)); - QVERIFY(!ctx->objectForName(u"inaccessible"_qs)); - QVERIFY(ctx->objectForName(u"accessibleDelegate"_qs)); - QVERIFY(!ctx->objectForName(u"inaccessibleDelegate"_qs)); + QVERIFY(ctx->objectForName(u"accessibleNormal"_s)); + QVERIFY(!ctx->objectForName(u"inaccessibleNormal"_s)); + QVERIFY(ctx->objectForName(u"accessible"_s)); + QVERIFY(!ctx->objectForName(u"inaccessible"_s)); + QVERIFY(ctx->objectForName(u"accessibleDelegate"_s)); + QVERIFY(!ctx->objectForName(u"inaccessibleDelegate"_s)); - QCOMPARE(created.p2()->property("text").toString(), u"foo"_qs); + QCOMPARE(created.p2()->property("text").toString(), u"foo"_s); QVERIFY(created.p3()->property("text").toString().isEmpty()); // ComponentType still subclasses QQmlComponent, so create() works: @@ -583,16 +585,16 @@ void tst_qmltc::componentTypes() QVERIFY(normalComponent); QScopedPointer<QObject> enclosed(normalComponent->create()); QVERIFY(enclosed); - QCOMPARE(enclosed->objectName(), u"enclosed"_qs); + QCOMPARE(enclosed->objectName(), u"enclosed"_s); QQmlListReference children(&created, "data"); QCOMPARE(children.size(), 4); - QCOMPARE(ctx->objectForName(u"normal"_qs), children.at(0)); - QCOMPARE(ctx->objectForName(u"accessibleNormal"_qs), children.at(1)); - QCOMPARE(ctx->objectForName(u"accessible"_qs), created.p2()); + QCOMPARE(ctx->objectForName(u"normal"_s), children.at(0)); + QCOMPARE(ctx->objectForName(u"accessibleNormal"_s), children.at(1)); + QCOMPARE(ctx->objectForName(u"accessible"_s), created.p2()); QQuickTableView *table = qobject_cast<QQuickTableView *>(children.at(3)); QVERIFY(table); - QCOMPARE(ctx->objectForName(u"accessibleDelegate"_qs), table->delegate()); + QCOMPARE(ctx->objectForName(u"accessibleDelegate"_s), table->delegate()); } } @@ -622,7 +624,7 @@ void tst_qmltc::deferredProperties() { QQmlEngine e; PREPEND_NAMESPACE(deferredProperties_group) created(&e); - QCOMPARE(created.getGroup()->getStr(), u"foobar"_qs); + QCOMPARE(created.getGroup()->getStr(), u"foobar"_s); QCOMPARE(created.getGroup()->getDeferred(), 0); // Note: we can't easily evaluate a deferred binding for a // `group.deferred` here, so just accept the fact the the value is not @@ -647,7 +649,7 @@ void tst_qmltc::deferredProperties() // `group` binding is not deferred as per current behavior outside of // PropertyChanges and friends. we defer `group.deferred` binding though - QCOMPARE(created.getGroup()->getStr(), u"still immediate"_qs); + QCOMPARE(created.getGroup()->getStr(), u"still immediate"_s); QCOMPARE(created.getGroup()->getDeferred(), 0); QVERIFY(!qmlAttachedPropertiesObject<DeferredAttached>(&created, false)); @@ -1034,11 +1036,11 @@ void tst_qmltc::complexAliases() QCOMPARE(created.aliasToPrivatePalette(), QQuickItemPrivate::get(theRect)->palette()); QSignalSpy paletteChangedSpy(&created, &PREPEND_NAMESPACE(complexAliases)::aliasToPrivatePaletteChanged); QQuickPalette *newPalette = new QQuickPalette(&created); - newPalette->fromQPalette(QPalette(QColor(u"cyan"_qs))); - QCOMPARE(newPalette->button(), QColor(u"cyan"_qs)); + newPalette->fromQPalette(QPalette(QColor(u"cyan"_s))); + QCOMPARE(newPalette->button(), QColor(u"cyan"_s)); created.setAliasToPrivatePalette(newPalette); QCOMPARE(paletteChangedSpy.count(), 1); - QCOMPARE(QQuickItemPrivate::get(theRect)->palette()->button(), QColor(u"cyan"_qs)); + QCOMPARE(QQuickItemPrivate::get(theRect)->palette()->button(), QColor(u"cyan"_s)); QCOMPARE(created.aliasToPrivatePalette(), QQuickItemPrivate::get(theRect)->palette()); // aliasToAnchors: @@ -1340,7 +1342,7 @@ void tst_qmltc::groupedProperty_qquicktext() QCOMPARE(anchors->bottomMargin(), qreal(42)); QFont font = created.font(); - QCOMPARE(font.family(), u"Helvetica"_qs); + QCOMPARE(font.family(), u"Helvetica"_s); QCOMPARE(font.pointSize(), 4); QQmlListReference ref(&created, "data"); @@ -1850,13 +1852,13 @@ void tst_qmltc::privateProperties() { QQmlEngine e; PREPEND_NAMESPACE(privatePropertySubclass) created(&e); - QCOMPARE(created.dummy(), u"bar"_qs); - QCOMPARE(created.strAlias(), u"foobar"_qs); + QCOMPARE(created.dummy(), u"bar"_s); + QCOMPARE(created.strAlias(), u"foobar"_s); QCOMPARE(created.smthAlias(), 42); auto privateCreated = static_cast<PrivatePropertyTypePrivate *>(QObjectPrivate::get(&created)); QVERIFY(privateCreated); - QCOMPARE(privateCreated->foo(), u"Smth is: 42"_qs); + QCOMPARE(privateCreated->foo(), u"Smth is: 42"_s); ValueTypeGroup vt = privateCreated->vt(); QCOMPARE(vt.count(), 11); @@ -1890,7 +1892,7 @@ void tst_qmltc::calqlatrBits() // sanity QVERIFY(anim); QCOMPARE(anim->target(), textItem); - QCOMPARE(anim->property(), u"scale"_qs); + QCOMPARE(anim->property(), u"scale"_s); QCOMPARE(anim->duration(), 50); QCOMPARE(anim->from(), 1); QCOMPARE(anim->to(), 0.5); @@ -1947,7 +1949,7 @@ void tst_qmltc::trickyPropertyChangeAndSignalHandlers() QCOMPARE(created.cChangedCount3(), 42); three->setD(10); QCOMPARE(created.dChangedCount3(), 10); - QCOMPARE(created.dChangedStr3(), u"d changed"_qs); + QCOMPARE(created.dChangedStr3(), u"d changed"_s); four->setC(1.5); QCOMPARE(created.cChangedCount4(), 2); // cChangedCount4 is int, so 0.5 is truncated four->setD(84); @@ -1956,7 +1958,7 @@ void tst_qmltc::trickyPropertyChangeAndSignalHandlers() // this test, it would mean that we get proper dChanged*4 values intead of // `undefined` junk QCOMPARE(created.dChangedCount4(), 42); - QCOMPARE(created.dChangedStr4(), u"d changed!"_qs); + QCOMPARE(created.dChangedStr4(), u"d changed!"_s); created.changeProperties1(); QCOMPARE(created.aChangedCount1(), 2); diff --git a/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp b/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp index 09c77ce37a..50871eb5b2 100644 --- a/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp +++ b/tests/auto/qml/qmltc_qprocess/tst_qmltc_qprocess.cpp @@ -42,6 +42,8 @@ #include <functional> +using namespace Qt::StringLiterals; + class tst_qmltc_qprocess : public QQmlDataTest { Q_OBJECT @@ -55,7 +57,7 @@ class tst_qmltc_qprocess : public QQmlDataTest QString runQmltc(const QString &inputFile, bool shouldSucceed, const QStringList &extraArgs = {}); - QString modifiedPath(const QString &path) { return path + u".orig"_qs; } + QString modifiedPath(const QString &path) { return path + u".orig"_s; } public: tst_qmltc_qprocess() : QQmlDataTest(QT_QMLTEST_DATADIR) { } @@ -79,20 +81,20 @@ private slots: void tst_qmltc_qprocess::initTestCase() { QQmlDataTest::initTestCase(); - m_qmltcPath = QLibraryInfo::path(QLibraryInfo::BinariesPath) + u"/qmltc"_qs; + m_qmltcPath = QLibraryInfo::path(QLibraryInfo::BinariesPath) + u"/qmltc"_s; #ifdef Q_OS_WIN - m_qmltcPath += u".exe"_qs; + m_qmltcPath += u".exe"_s; #endif if (!QFileInfo(m_qmltcPath).exists()) { - const QString message = u"qmltc executable not found (looked for %0)"_qs.arg(m_qmltcPath); + const QString message = u"qmltc executable not found (looked for %0)"_s.arg(m_qmltcPath); QFAIL(qPrintable(message)); } - m_tmpPath = QDir::tempPath() + u"/tst_qmltc_qprocess_artifacts"_qs; + m_tmpPath = QDir::tempPath() + u"/tst_qmltc_qprocess_artifacts"_s; QVERIFY(QDir(m_tmpPath).removeRecursively()); // in case it's already there QVERIFY(QDir().mkpath(m_tmpPath)); - m_resources = QStringLiteral(TST_QMLTC_QPROCESS_RESOURCES).split(u"_::_"_qs); + m_resources = QStringLiteral(TST_QMLTC_QPROCESS_RESOURCES).split(u"_::_"_s); } void tst_qmltc_qprocess::cleanupTestCase() @@ -108,9 +110,9 @@ QString tst_qmltc_qprocess::runQmltc(const QString &inputFile, args << (QFileInfo(inputFile).isAbsolute() ? inputFile : testFile(inputFile)); for (const QString &resource : m_resources) - args << u"--resource"_qs << resource; - args << u"--header"_qs << (m_tmpPath + u"/"_qs + QFileInfo(inputFile).baseName() + u".h"_qs); - args << u"--impl"_qs << (m_tmpPath + u"/"_qs + QFileInfo(inputFile).baseName() + u".cpp"_qs); + args << u"--resource"_s << resource; + args << u"--header"_s << (m_tmpPath + u"/"_s + QFileInfo(inputFile).baseName() + u".h"_s); + args << u"--impl"_s << (m_tmpPath + u"/"_s + QFileInfo(inputFile).baseName() + u".cpp"_s); args << extraArgs; QString errors; @@ -150,7 +152,7 @@ QString tst_qmltc_qprocess::runQmltc(const QString &inputFile, bool shouldSuccee void tst_qmltc_qprocess::sanity() { - const auto output = runQmltc(u"dummy.qml"_qs, true); + const auto output = runQmltc(u"dummy.qml"_s, true); QVERIFY2(output.isEmpty(), qPrintable(output)); } @@ -163,8 +165,8 @@ void tst_qmltc_qprocess::noBuiltins() QVERIFY(file.rename(original)); }; - for (QString builtin : { u"builtins.qmltypes"_qs, u"jsroot.qmltypes"_qs }) { - const auto path = QLibraryInfo::path(QLibraryInfo::QmlImportsPath) + u"/"_qs + builtin; + for (QString builtin : { u"builtins.qmltypes"_s, u"jsroot.qmltypes"_s }) { + const auto path = QLibraryInfo::path(QLibraryInfo::QmlImportsPath) + u"/"_s + builtin; QScopeGuard scope(std::bind(renameBack, path)); QFile file(path); @@ -172,8 +174,8 @@ void tst_qmltc_qprocess::noBuiltins() QVERIFY(file.rename(modifiedPath(path))); // test that qmltc exits gracefully - const auto errors = runQmltc(u"dummy.qml"_qs, false); - QVERIFY(errors.contains(u"Failed to find the following builtins: %1"_qs.arg(builtin))); + const auto errors = runQmltc(u"dummy.qml"_s, false); + QVERIFY(errors.contains(u"Failed to find the following builtins: %1"_s.arg(builtin))); } } @@ -185,34 +187,34 @@ void tst_qmltc_qprocess::noQtQml() QVERIFY(QDir().rename(current, original)); }; - const auto modulePath = QLibraryInfo::path(QLibraryInfo::QmlImportsPath) + u"/QtQml"_qs; + const auto modulePath = QLibraryInfo::path(QLibraryInfo::QmlImportsPath) + u"/QtQml"_s; QScopeGuard scope(std::bind(renameBack, modulePath)); QVERIFY(QDir(modulePath).exists()); QVERIFY(QDir().rename(modulePath, modifiedPath(modulePath))); // test that qmltc exits gracefully - const auto errors = runQmltc(u"dummy.qml"_qs, false); - QVERIFY(errors.contains(u"Failed to import QtQml. Are your import paths set up properly?"_qs)); + const auto errors = runQmltc(u"dummy.qml"_s, false); + QVERIFY(errors.contains(u"Failed to import QtQml. Are your import paths set up properly?"_s)); } void tst_qmltc_qprocess::inlineComponent() { - const auto errors = runQmltc(u"inlineComponent.qml"_qs, false); + const auto errors = runQmltc(u"inlineComponent.qml"_s, false); QEXPECT_FAIL("", "qmltc does not support inline components at the moment", Continue); - QVERIFY(!errors.contains(u"Inline components are not supported"_qs)); + QVERIFY(!errors.contains(u"Inline components are not supported"_s)); } void tst_qmltc_qprocess::singleton() { - const auto errors = runQmltc(u"SingletonThing.qml"_qs, false); + const auto errors = runQmltc(u"SingletonThing.qml"_s, false); QEXPECT_FAIL("", "qmltc does not support singletons at the moment", Continue); - QVERIFY(!errors.contains(u"Singleton types are not supported"_qs)); + QVERIFY(!errors.contains(u"Singleton types are not supported"_s)); } void tst_qmltc_qprocess::warningsAsErrors() { - const auto errors = runQmltc(u"erroneousFile.qml"_qs, false); - QVERIFY2(errors.contains(u"Error:"_qs), qPrintable(errors)); // Note: not a warning! + const auto errors = runQmltc(u"erroneousFile.qml"_s, false); + QVERIFY2(errors.contains(u"Error:"_s), qPrintable(errors)); // Note: not a warning! } QTEST_MAIN(tst_qmltc_qprocess) diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index b760c34a53..68b80f8b53 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -47,6 +47,8 @@ #include <algorithm> +using namespace Qt::StringLiterals; + class WithQJSValue : public QObject { Q_OBJECT @@ -1096,7 +1098,7 @@ void tst_qqmlcomponent::initJSValueProp() QQmlComponent component(&engine); component.setData("import ComponentTest\nWithQJSValue {}", QUrl()); QVERIFY2(component.isReady(), qPrintable(component.errorString())); - QScopedPointer<QObject> o(component.createWithInitialProperties({{ u"v"_qs, 5}})); + QScopedPointer<QObject> o(component.createWithInitialProperties({{ u"v"_s, 5}})); QVERIFY(!o.isNull()); WithQJSValue *withQJSValue = qobject_cast<WithQJSValue *>(o.data()); QVERIFY(withQJSValue); @@ -1141,7 +1143,7 @@ void tst_qqmlcomponent::componentTypes() QVERIFY(oComponent); QScopedPointer<QObject> enclosed(oComponent->create()); QVERIFY(!enclosed.isNull()); - QCOMPARE(enclosed->objectName(), u"enclosed"_qs); + QCOMPARE(enclosed->objectName(), u"enclosed"_s); } { @@ -1153,20 +1155,20 @@ void tst_qqmlcomponent::componentTypes() QQmlContext *ctx = engine.contextForObject(o.get()); - QObject *normal = ctx->objectForName(u"normal"_qs); + QObject *normal = ctx->objectForName(u"normal"_s); QVERIFY(normal); - QCOMPARE(normal->property("text").toString(), u"indirect component"_qs); + QCOMPARE(normal->property("text").toString(), u"indirect component"_s); // check (and thus "document" in code) various ways of how ids work - QVERIFY(ctx->objectForName(u"accessibleNormal"_qs)); - QVERIFY(!ctx->objectForName(u"inaccessibleNormal"_qs)); - QVERIFY(ctx->objectForName(u"accessible"_qs)); - QVERIFY(!ctx->objectForName(u"inaccessible"_qs)); - QVERIFY(ctx->objectForName(u"accessibleDelegate"_qs)); - QVERIFY(!ctx->objectForName(u"inaccessibleDelegate"_qs)); + QVERIFY(ctx->objectForName(u"accessibleNormal"_s)); + QVERIFY(!ctx->objectForName(u"inaccessibleNormal"_s)); + QVERIFY(ctx->objectForName(u"accessible"_s)); + QVERIFY(!ctx->objectForName(u"inaccessible"_s)); + QVERIFY(ctx->objectForName(u"accessibleDelegate"_s)); + QVERIFY(!ctx->objectForName(u"inaccessibleDelegate"_s)); QCOMPARE(qvariant_cast<QObject *>(o->property("p2"))->property("text").toString(), - u"foo"_qs); + u"foo"_s); auto p3Object = qvariant_cast<QObject *>(o->property("p3")); QVERIFY(p3Object); QVERIFY(p3Object->property("text").toString().isEmpty()); @@ -1175,7 +1177,7 @@ void tst_qqmlcomponent::componentTypes() QVERIFY(normalComponent); QScopedPointer<QObject> enclosed(normalComponent->create()); QVERIFY(enclosed); - QCOMPARE(enclosed->objectName(), u"enclosed"_qs); + QCOMPARE(enclosed->objectName(), u"enclosed"_s); } } diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 2ff9a28ee0..153b2b3c85 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -68,6 +68,8 @@ QML. This does not include static QML language issues. Static QML language issues are covered in qmllanguage */ +using namespace Qt::StringLiterals; + class tst_qqmlecmascript : public QQmlDataTest { Q_OBJECT @@ -7738,7 +7740,7 @@ void tst_qqmlecmascript::qpropertyBindingReplacement() QQmlComponent c(&engine, testFileUrl("qpropertyBindingReplacement.qml")); QScopedPointer<QObject> root(c.create()); QVERIFY(root); - QCOMPARE(root->objectName(), u"overwritten"_qs); + QCOMPARE(root->objectName(), u"overwritten"_s); } void tst_qqmlecmascript::deleteRootObjectInCreation() diff --git a/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp b/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp index d6d56c52e0..66025ad361 100644 --- a/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp +++ b/tests/auto/qml/qqmljsscope/tst_qqmljsscope.cpp @@ -49,6 +49,8 @@ #include <QtQml/private/qqmljslexer_p.h> #include <QtQml/private/qqmljsparser_p.h> +using namespace Qt::StringLiterals; + class tst_qqmljsscope : public QQmlDataTest { Q_OBJECT @@ -141,7 +143,7 @@ void tst_qqmljsscope::initTestCase() QDirIterator it(dataDirectory(), QDirIterator::FollowSymlinks | QDirIterator::Subdirectories); while (it.hasNext()) { const QString url = it.next(); - if (!url.endsWith(u".qml"_qs)) // not interesting + if (!url.endsWith(u".qml"_s)) // not interesting continue; const QFileInfo fi(url); QVERIFY(fi.exists()); @@ -152,36 +154,36 @@ void tst_qqmljsscope::initTestCase() void tst_qqmljsscope::orderedBindings() { - QQmlJSScope::ConstPtr root = run(u"orderedBindings.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"orderedBindings.qml"_s); QVERIFY(root); - auto [pBindingsBegin, pBindingsEnd] = root->ownPropertyBindings(u"p"_qs); + auto [pBindingsBegin, pBindingsEnd] = root->ownPropertyBindings(u"p"_s); QVERIFY(std::distance(pBindingsBegin, pBindingsEnd) == 2); // check that the bindings are properly ordered QCOMPARE(pBindingsBegin->bindingType(), QQmlJSMetaPropertyBinding::Object); QCOMPARE(std::next(pBindingsBegin)->bindingType(), QQmlJSMetaPropertyBinding::Interceptor); - auto [itemsBindingsBegin, itemsBindingsEnd] = root->ownPropertyBindings(u"items"_qs); + auto [itemsBindingsBegin, itemsBindingsEnd] = root->ownPropertyBindings(u"items"_s); QVERIFY(std::distance(itemsBindingsBegin, itemsBindingsEnd) == 2); QCOMPARE(itemsBindingsBegin->bindingType(), QQmlJSMetaPropertyBinding::Object); QCOMPARE(std::next(itemsBindingsBegin)->bindingType(), QQmlJSMetaPropertyBinding::Object); - QCOMPARE(itemsBindingsBegin->objectType()->baseTypeName(), u"Item"_qs); - QCOMPARE(std::next(itemsBindingsBegin)->objectType()->baseTypeName(), u"Text"_qs); + QCOMPARE(itemsBindingsBegin->objectType()->baseTypeName(), u"Item"_s); + QCOMPARE(std::next(itemsBindingsBegin)->objectType()->baseTypeName(), u"Text"_s); } void tst_qqmljsscope::signalCreationDifferences() { - QQmlJSScope::ConstPtr root = run(u"signalCreationDifferences.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"signalCreationDifferences.qml"_s); QVERIFY(root); - QVERIFY(root->hasOwnProperty(u"myProperty"_qs)); - QVERIFY(root->hasOwnProperty(u"conflictingProperty"_qs)); - QCOMPARE(root->ownMethods(u"mySignal"_qs).size(), 1); + QVERIFY(root->hasOwnProperty(u"myProperty"_s)); + QVERIFY(root->hasOwnProperty(u"conflictingProperty"_s)); + QCOMPARE(root->ownMethods(u"mySignal"_s).size(), 1); - const auto conflicting = root->ownMethods(u"conflictingPropertyChanged"_qs); + const auto conflicting = root->ownMethods(u"conflictingPropertyChanged"_s); QCOMPARE(conflicting.size(), 2); QCOMPARE(conflicting[0].methodType(), QQmlJSMetaMethod::Signal); QCOMPARE(conflicting[1].methodType(), QQmlJSMetaMethod::Signal); @@ -191,7 +193,7 @@ void tst_qqmljsscope::signalCreationDifferences() explicitMethod = &conflicting[1]; else explicitMethod = &conflicting[0]; - QCOMPARE(explicitMethod->parameterNames(), QStringList({ u"a"_qs, u"c"_qs })); + QCOMPARE(explicitMethod->parameterNames(), QStringList({ u"a"_s, u"c"_s })); } void tst_qqmljsscope::allTypesAvailable() @@ -202,40 +204,40 @@ void tst_qqmljsscope::allTypesAvailable() }; QQmlJSImporter importer { importPaths, /* resource file mapper */ nullptr }; - const auto types = importer.importModule(u"QtQml"_qs); - QVERIFY(types.contains(u"$internal$.QObject"_qs)); - QVERIFY(types.contains(u"QtObject"_qs)); - QCOMPARE(types[u"$internal$.QObject"_qs].scope, types[u"QtObject"_qs].scope); + const auto types = importer.importModule(u"QtQml"_s); + QVERIFY(types.contains(u"$internal$.QObject"_s)); + QVERIFY(types.contains(u"QtObject"_s)); + QCOMPARE(types[u"$internal$.QObject"_s].scope, types[u"QtObject"_s].scope); } void tst_qqmljsscope::shadowing() { - QQmlJSScope::ConstPtr root = run(u"shadowing.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"shadowing.qml"_s); QVERIFY(root); QVERIFY(root->baseType()); // Check whether properties are properly shadowed const auto properties = root->properties(); - QVERIFY(properties.contains(u"property_not_shadowed"_qs)); - QVERIFY(properties.contains(u"property_shadowed"_qs)); + QVERIFY(properties.contains(u"property_not_shadowed"_s)); + QVERIFY(properties.contains(u"property_shadowed"_s)); - QCOMPARE(properties[u"property_not_shadowed"_qs].typeName(), u"QString"_qs); - QCOMPARE(properties[u"property_shadowed"_qs].typeName(), u"int"_qs); + QCOMPARE(properties[u"property_not_shadowed"_s].typeName(), u"QString"_s); + QCOMPARE(properties[u"property_shadowed"_s].typeName(), u"int"_s); // Check whether methods are properly shadowed const auto methods = root->methods(); - QCOMPARE(methods.count(u"method_not_shadowed"_qs), 1); - QCOMPARE(methods.count(u"method_shadowed"_qs), 1); + QCOMPARE(methods.count(u"method_not_shadowed"_s), 1); + QCOMPARE(methods.count(u"method_shadowed"_s), 1); - QCOMPARE(methods[u"method_not_shadowed"_qs].parameterNames().size(), 1); - QCOMPARE(methods[u"method_shadowed"_qs].parameterNames().size(), 0); + QCOMPARE(methods[u"method_not_shadowed"_s].parameterNames().size(), 1); + QCOMPARE(methods[u"method_shadowed"_s].parameterNames().size(), 0); } #ifdef LABS_QML_MODELS_PRESENT void tst_qqmljsscope::componentWrappedObjects() { - QQmlJSScope::ConstPtr root = run(u"componentWrappedObjects.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"componentWrappedObjects.qml"_s); QVERIFY(root); auto children = root->childScopes(); @@ -247,15 +249,15 @@ void tst_qqmljsscope::componentWrappedObjects() && type->isWrappedInImplicitComponent() == isWrapped; }; - QVERIFY(isGoodType(children[0], u"nonWrapped1"_qs, false)); - QVERIFY(isGoodType(children[1], u"nonWrapped2"_qs, false)); - QVERIFY(isGoodType(children[2], u"nonWrapped3"_qs, false)); - QVERIFY(isGoodType(children[3], u"wrapped"_qs, true)); + QVERIFY(isGoodType(children[0], u"nonWrapped1"_s, false)); + QVERIFY(isGoodType(children[1], u"nonWrapped2"_s, false)); + QVERIFY(isGoodType(children[2], u"nonWrapped3"_s, false)); + QVERIFY(isGoodType(children[3], u"wrapped"_s, true)); } void tst_qqmljsscope::labsQmlModelsSanity() { - QQmlJSScope::ConstPtr root = run(u"labsQmlModelsSanity.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"labsQmlModelsSanity.qml"_s); QVERIFY(root); auto children = root->childScopes(); QCOMPARE(children.size(), 1); @@ -266,26 +268,26 @@ void tst_qqmljsscope::labsQmlModelsSanity() // the QmlModels dependency is lost, we don't "see" that DelegateChooser // inherits QQmlComponent - and so has no properties from it, hence, we can // test exactly that: - QVERIFY(children[0]->hasProperty(u"progress"_qs)); - QVERIFY(children[0]->hasProperty(u"status"_qs)); - QVERIFY(children[0]->hasProperty(u"url"_qs)); + QVERIFY(children[0]->hasProperty(u"progress"_s)); + QVERIFY(children[0]->hasProperty(u"status"_s)); + QVERIFY(children[0]->hasProperty(u"url"_s)); } #endif void tst_qqmljsscope::unknownCppBase() { - QQmlJSScope::ConstPtr root = run(u"unknownCppBaseAssigningToVar.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"unknownCppBaseAssigningToVar.qml"_s); QVERIFY(root); // we should not crash here, then it is a success } void tst_qqmljsscope::groupedProperties() { - QQmlJSScope::ConstPtr root = run(u"groupProperties.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"groupProperties.qml"_s); QVERIFY(root); - QVERIFY(root->hasProperty(u"anchors"_qs)); - const auto anchorBindings = root->propertyBindings(u"anchors"_qs); + QVERIFY(root->hasProperty(u"anchors"_s)); + const auto anchorBindings = root->propertyBindings(u"anchors"_s); QVERIFY(!anchorBindings.isEmpty()); QCOMPARE(anchorBindings.size(), 2); // from type itself and from the base type @@ -306,29 +308,29 @@ void tst_qqmljsscope::groupedProperties() QMultiHash<QString, QQmlJSMetaPropertyBinding> bindingsOfType; getBindingsWithinGroup(&bindingsOfType, 0); QCOMPARE(bindingsOfType.size(), 2); - QCOMPARE(value(bindingsOfType, u"left"_qs).bindingType(), QQmlJSMetaPropertyBinding::Script); - QCOMPARE(value(bindingsOfType, u"leftMargin"_qs).bindingType(), + QCOMPARE(value(bindingsOfType, u"left"_s).bindingType(), QQmlJSMetaPropertyBinding::Script); + QCOMPARE(value(bindingsOfType, u"leftMargin"_s).bindingType(), QQmlJSMetaPropertyBinding::NumberLiteral); QMultiHash<QString, QQmlJSMetaPropertyBinding> bindingsOfBaseType; getBindingsWithinGroup(&bindingsOfBaseType, 1); QCOMPARE(bindingsOfBaseType.size(), 1); - QCOMPARE(value(bindingsOfBaseType, u"top"_qs).bindingType(), QQmlJSMetaPropertyBinding::Script); + QCOMPARE(value(bindingsOfBaseType, u"top"_s).bindingType(), QQmlJSMetaPropertyBinding::Script); } void tst_qqmljsscope::descriptiveNameOfNull() { QQmlJSRegisterContent nullContent; - QCOMPARE(nullContent.descriptiveName(), u"(invalid type)"_qs); + QCOMPARE(nullContent.descriptiveName(), u"(invalid type)"_s); QQmlJSScope::Ptr stored = QQmlJSScope::create(); - stored->setInternalName(u"bar"_qs); + stored->setInternalName(u"bar"_s); QQmlJSMetaProperty property; - property.setPropertyName(u"foo"_qs); - property.setTypeName(u"baz"_qs); + property.setPropertyName(u"foo"_s); + property.setTypeName(u"baz"_s); QQmlJSRegisterContent unscoped = QQmlJSRegisterContent::create( stored, property, QQmlJSRegisterContent::ScopeProperty, QQmlJSScope::ConstPtr()); - QCOMPARE(unscoped.descriptiveName(), u"bar of (invalid type)::foo with type baz"_qs); + QCOMPARE(unscoped.descriptiveName(), u"bar of (invalid type)::foo with type baz"_s); } void tst_qqmljsscope::groupedPropertiesConsistency() @@ -336,7 +338,7 @@ void tst_qqmljsscope::groupedPropertiesConsistency() { QQmlEngine engine; QQmlComponent component(&engine); - component.loadUrl(testFileUrl(u"groupPropertiesConsistency.qml"_qs)); + component.loadUrl(testFileUrl(u"groupPropertiesConsistency.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> root(component.create()); QVERIFY2(root, qPrintable(component.errorString())); @@ -345,10 +347,10 @@ void tst_qqmljsscope::groupedPropertiesConsistency() } { - QQmlJSScope::ConstPtr root = run(u"groupPropertiesConsistency.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"groupPropertiesConsistency.qml"_s); QVERIFY(root); - const auto fontBindings = root->propertyBindings(u"font"_qs); + const auto fontBindings = root->propertyBindings(u"font"_s); QCOMPARE(fontBindings.size(), 2); // The binding order in QQmlJSScope case is "reversed": first come @@ -360,10 +362,10 @@ void tst_qqmljsscope::groupedPropertiesConsistency() void tst_qqmljsscope::groupedPropertySyntax() { - QQmlJSScope::ConstPtr root = run(u"groupPropertySyntax.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"groupPropertySyntax.qml"_s); QVERIFY(root); - const auto fontBindings = root->propertyBindings(u"font"_qs); + const auto fontBindings = root->propertyBindings(u"font"_s); QCOMPARE(fontBindings.size(), 1); // The binding order in QQmlJSScope case is "reversed": first come @@ -379,17 +381,17 @@ void tst_qqmljsscope::groupedPropertySyntax() return bindings.value(key, QQmlJSMetaPropertyBinding(QQmlJS::SourceLocation {})); }; - QCOMPARE(value(subbindings, u"pixelSize"_qs).bindingType(), + QCOMPARE(value(subbindings, u"pixelSize"_s).bindingType(), QQmlJSMetaPropertyBinding::NumberLiteral); - QCOMPARE(value(subbindings, u"bold"_qs).bindingType(), QQmlJSMetaPropertyBinding::BoolLiteral); + QCOMPARE(value(subbindings, u"bold"_s).bindingType(), QQmlJSMetaPropertyBinding::BoolLiteral); } void tst_qqmljsscope::attachedProperties() { - QQmlJSScope::ConstPtr root = run(u"attachedProperties.qml"_qs); + QQmlJSScope::ConstPtr root = run(u"attachedProperties.qml"_s); QVERIFY(root); - const auto keysBindings = root->propertyBindings(u"Keys"_qs); + const auto keysBindings = root->propertyBindings(u"Keys"_s); QVERIFY(!keysBindings.isEmpty()); QCOMPARE(keysBindings.size(), 2); // from type itself and from the base type @@ -410,15 +412,15 @@ void tst_qqmljsscope::attachedProperties() QMultiHash<QString, QQmlJSMetaPropertyBinding> bindingsOfType; getBindingsWithinAttached(&bindingsOfType, 0); QCOMPARE(bindingsOfType.size(), 2); - QCOMPARE(value(bindingsOfType, u"enabled"_qs).bindingType(), + QCOMPARE(value(bindingsOfType, u"enabled"_s).bindingType(), QQmlJSMetaPropertyBinding::BoolLiteral); - QCOMPARE(value(bindingsOfType, u"forwardTo"_qs).bindingType(), + QCOMPARE(value(bindingsOfType, u"forwardTo"_s).bindingType(), QQmlJSMetaPropertyBinding::Script); QMultiHash<QString, QQmlJSMetaPropertyBinding> bindingsOfBaseType; getBindingsWithinAttached(&bindingsOfBaseType, 1); QCOMPARE(bindingsOfBaseType.size(), 1); - QCOMPARE(value(bindingsOfBaseType, u"priority"_qs).bindingType(), + QCOMPARE(value(bindingsOfBaseType, u"priority"_s).bindingType(), QQmlJSMetaPropertyBinding::Script); } @@ -436,14 +438,14 @@ void tst_qqmljsscope::scriptIndices() { QQmlEngine engine; QQmlComponent component(&engine); - component.loadUrl(testFileUrl(u"functionAndBindingIndices.qml"_qs)); + component.loadUrl(testFileUrl(u"functionAndBindingIndices.qml"_s)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> root(component.create()); QVERIFY2(root, qPrintable(component.errorString())); } QmlIR::Document document(false); // we need QmlIR information here - QQmlJSScope::ConstPtr root = run(u"functionAndBindingIndices.qml"_qs, &document); + QQmlJSScope::ConstPtr root = run(u"functionAndBindingIndices.qml"_s, &document); QVERIFY(root); QVERIFY(document.javaScriptCompilationUnit.unitData()); diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 3aad47c4aa..e844cd3d63 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -64,6 +64,8 @@ #include <unistd.h> #endif +using namespace Qt::StringLiterals; + DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES) static inline bool isCaseSensitiveFileSystem(const QString &path) { @@ -2692,10 +2694,10 @@ void tst_qqmllanguage::defaultPropertyWithInitializer_data() QTest::addColumn<QUrl>("file"); QTest::addColumn<QString>("objectName"); - QTest::newRow("base") << testFileUrl("DefaultPropertyWithInitializer.qml") << u"default"_qs; - QTest::newRow("user") << testFileUrl("DefaultPropertyWithInitializerUser.qml") << u"changed"_qs; - QTest::newRow("list base") << testFileUrl("DefaultPropertyWithListInitializer.qml") << u"1"_qs; - QTest::newRow("list user") << testFileUrl("DefaultPropertyWithListInitializerUser.qml") << u"2"_qs; + QTest::newRow("base") << testFileUrl("DefaultPropertyWithInitializer.qml") << u"default"_s; + QTest::newRow("user") << testFileUrl("DefaultPropertyWithInitializerUser.qml") << u"changed"_s; + QTest::newRow("list base") << testFileUrl("DefaultPropertyWithListInitializer.qml") << u"1"_s; + QTest::newRow("list user") << testFileUrl("DefaultPropertyWithListInitializerUser.qml") << u"2"_s; } void tst_qqmllanguage::defaultPropertyWithInitializer() diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index 09949dd610..830b7228f7 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -41,6 +41,8 @@ #include <QtQuickTestUtils/private/qmlutils_p.h> +using namespace Qt::StringLiterals; + Q_DECLARE_METATYPE(QList<int>) Q_DECLARE_METATYPE(QList<QVariantHash>) @@ -1777,7 +1779,7 @@ void tst_qqmllistmodel::objectDestroyed() std::unique_ptr<QObject> obj = std::make_unique<QObject>(); connect(obj.get(), &QObject::destroyed, [&]() { obj.release(); }); - engine.rootContext()->setContextProperty(u"contextObject"_qs, obj.get()); + engine.rootContext()->setContextProperty(u"contextObject"_s, obj.get()); engine.setObjectOwnership(obj.get(), QJSEngine::JavaScriptOwnership); delete component.create(); @@ -1785,7 +1787,7 @@ void tst_qqmllistmodel::objectDestroyed() engine.collectGarbage(); QTest::qSleep(250); QVERIFY(obj); - engine.evaluate(u"model.clear();"_qs); + engine.evaluate(u"model.clear();"_s); engine.collectGarbage(); QTRY_VERIFY(!obj); } @@ -1803,7 +1805,7 @@ void tst_qqmllistmodel::destroyObject() QUrl()); QVERIFY2(component.isReady(), qPrintable(component.errorString())); QScopedPointer<QObject> element(new QObject); - engine.rootContext()->setContextProperty(u"contextObject"_qs, element.data()); + engine.rootContext()->setContextProperty(u"contextObject"_s, element.data()); QScopedPointer<QObject> o(component.create()); QVERIFY(!o.isNull()); diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index 497478b095..7bcfc6c3ac 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -39,6 +39,8 @@ #include <private/qqmlanybinding_p.h> #include <QtQuickTestUtils/private/qmlutils_p.h> +using namespace Qt::StringLiterals; + class tst_qqmlmetatype : public QQmlDataTest { Q_OBJECT @@ -380,7 +382,7 @@ void tst_qqmlmetatype::interceptorAPI() QVERIFY(interceptor->interceptedWrite); QQmlProperty objectName(obj.get(), "objectName"); - QProperty<QString> hello(u"Hello, World!"_qs); + QProperty<QString> hello(u"Hello, World!"_s); QQmlAnyBinding binding; binding = Qt::makePropertyBinding(hello); interceptor->interceptedBindable = false; diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index 402a68afae..e2cd13e18f 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -48,6 +48,8 @@ #include "qobject.h" #include <QtQml/QQmlPropertyMap> +using namespace Qt::StringLiterals; + #include <QDebug> class MyQmlObject : public QObject { @@ -2356,18 +2358,18 @@ void tst_qqmlproperty::dontRemoveQPropertyBinding() QVERIFY(object.bindableObjectName().hasBinding()); // A write with DontRemoveBinding preserves the binding - QQmlPropertyPrivate::write(objectName, u"goodbye"_qs, QQmlPropertyData::DontRemoveBinding); + QQmlPropertyPrivate::write(objectName, u"goodbye"_s, QQmlPropertyData::DontRemoveBinding); QVERIFY(object.bindableObjectName().hasBinding()); // but changes the value - QCOMPARE(object.objectName(), u"goodbye"_qs); + QCOMPARE(object.objectName(), u"goodbye"_s); // subsequent binding evaluations change the value again - name = u"hello, again"_qs; + name = u"hello, again"_s; QCOMPARE(object.objectName(), name.value()); // The binding is only preserved by the write which had DontRemoveBinding set // any further write will remove the binding - QQmlPropertyPrivate::write(objectName, u"goodbye"_qs, QQmlPropertyData::WriteFlags{}); - QCOMPARE(object.objectName(), u"goodbye"_qs); + QQmlPropertyPrivate::write(objectName, u"goodbye"_s, QQmlPropertyData::WriteFlags{}); + QCOMPARE(object.objectName(), u"goodbye"_s); QVERIFY(!object.bindableObjectName().hasBinding()); } @@ -2401,7 +2403,7 @@ void tst_qqmlproperty::compatResolveUrls() QProcess process; process.setProgram(QCoreApplication::applicationFilePath()); process.setEnvironment(QProcess::systemEnvironment() - + QStringList(u"QML_COMPAT_RESOLVE_URLS_ON_ASSIGNMENT=1"_qs)); + + QStringList(u"QML_COMPAT_RESOLVE_URLS_ON_ASSIGNMENT=1"_s)); process.setArguments({QStringLiteral("compatResolveUrls")}); process.start(); QVERIFY(process.waitForFinished()); diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp index 944a7c8762..4194272153 100644 --- a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp +++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp @@ -35,6 +35,8 @@ #include <QSignalSpy> #include <QDebug> +using namespace Qt::StringLiterals; + class tst_QQmlPropertyMap : public QQmlDataTest { Q_OBJECT @@ -604,10 +606,10 @@ public: Map(QObject *parent = nullptr) : QQmlPropertyMap(this, parent) { - insert( "a", u"yayayaya"_qs ); - insert( "b", u"yayayayb"_qs); - insert( "c", u"yayayayc"_qs); - insert( "d", u"yayayayd"_qs); + insert( "a", u"yayayaya"_s ); + insert( "b", u"yayayayb"_s); + insert( "c", u"yayayayc"_s); + insert( "d", u"yayayayd"_s); freeze(); } @@ -623,18 +625,18 @@ void tst_QQmlPropertyMap::cachedSignals() QVERIFY2(c.isReady(), qPrintable(c.errorString())); QScopedPointer<QObject> o(c.create()); QVERIFY(!o.isNull()); - QCOMPARE(o->property("text").toString(), u"yayayayc"_qs); - foo.setProperty("c", u"something"_qs); - QCOMPARE(o->property("text").toString(), u"something"_qs); - foo.insert("c", u"other"_qs); - QCOMPARE(o->property("text").toString(), u"other"_qs); + QCOMPARE(o->property("text").toString(), u"yayayayc"_s); + foo.setProperty("c", u"something"_s); + QCOMPARE(o->property("text").toString(), u"something"_s); + foo.insert("c", u"other"_s); + QCOMPARE(o->property("text").toString(), u"other"_s); QTest::ignoreMessage( QtWarningMsg, - qPrintable(url.toString() + u":4:5: Unable to assign [undefined] to QString"_qs)); + qPrintable(url.toString() + u":4:5: Unable to assign [undefined] to QString"_s)); foo.clear("c"); - QCOMPARE(o->property("text").toString(), u"other"_qs); - foo.insert("c", u"final"_qs); - QCOMPARE(o->property("text").toString(), u"final"_qs); + QCOMPARE(o->property("text").toString(), u"other"_s); + foo.insert("c", u"final"_s); + QCOMPARE(o->property("text").toString(), u"final"_s); } class NastyMap: public QQmlPropertyMap diff --git a/tests/auto/qmldom/domitem/tst_qmldomitem.h b/tests/auto/qmldom/domitem/tst_qmldomitem.h index f28e4ff6b5..8539617bb0 100644 --- a/tests/auto/qmldom/domitem/tst_qmldomitem.h +++ b/tests/auto/qmldom/domitem/tst_qmldomitem.h @@ -53,6 +53,7 @@ #include <memory> QT_BEGIN_NAMESPACE + namespace QQmlJS { namespace Dom { @@ -543,10 +544,12 @@ private slots: QVERIFY(obj1); { + using namespace Qt::StringLiterals; + QList<DomItem> rect = - obj1.lookup(u"Rectangle"_qs, LookupType::Type, LookupOption::Normal); + obj1.lookup(u"Rectangle"_s, LookupType::Type, LookupOption::Normal); QList<DomItem> rect2 = - obj1.lookup(u"Rectangle"_qs, LookupType::Symbol, LookupOption::Normal); + obj1.lookup(u"Rectangle"_s, LookupType::Symbol, LookupOption::Normal); QVERIFY(rect.length() == 1); QVERIFY(rect2.length() == 1); QCOMPARE(rect.first().internalKind(), DomType::Export); @@ -555,7 +558,7 @@ private slots: QCOMPARE(rect3.internalKind(), DomType::QmlObject); QList<DomItem> rects; obj1.resolve( - Path::Current(PathCurrent::Lookup).field(Fields::type).key(u"Rectangle"_qs), + Path::Current(PathCurrent::Lookup).field(Fields::type).key(u"Rectangle"_s), [&rects](Path, DomItem &el) { rects.append(el); return true; @@ -580,6 +583,8 @@ private slots: #ifdef Q_OS_ANDROID QSKIP("Test uncompatible with Android (QTBUG-100171)"); #endif + using namespace Qt::StringLiterals; + QString testFile1 = baseDir + QLatin1String("/TestImports.qml"); DomItem env = DomEnvironment::create( QStringList(), @@ -601,22 +606,22 @@ private slots: importedModules.append(importPtr->uri); } } - QCOMPARE(importedModules.at(0).moduleUri(), u"QtQuick"_qs); - QCOMPARE(importedModules.at(0).directoryString(), u""_qs); - QCOMPARE(importedModules.at(1).directoryString(), u"../.."_qs); - QCOMPARE(importedModules.at(1).localPath(), u"../.."_qs); + QCOMPARE(importedModules.at(0).moduleUri(), u"QtQuick"_s); + QCOMPARE(importedModules.at(0).directoryString(), u""_s); + QCOMPARE(importedModules.at(1).directoryString(), u"../.."_s); + QCOMPARE(importedModules.at(1).localPath(), u"../.."_s); QCOMPARE(importedModules.at(1).absoluteLocalPath(), QString()); - QCOMPARE(importedModules.at(1).absoluteLocalPath(u"/bla/bla"_qs), u"/bla/bla/../.."); - QCOMPARE(importedModules.at(2).directoryString(), u"../dommerging"_qs); - QCOMPARE(importedModules.at(2).localPath(), u"../dommerging"_qs); + QCOMPARE(importedModules.at(1).absoluteLocalPath(u"/bla/bla"_s), u"/bla/bla/../.."); + QCOMPARE(importedModules.at(2).directoryString(), u"../dommerging"_s); + QCOMPARE(importedModules.at(2).localPath(), u"../dommerging"_s); QCOMPARE(importedModules.at(2).absoluteLocalPath(), QString()); - QCOMPARE(importedModules.at(2).absoluteLocalPath(u"/bla/bla"_qs), + QCOMPARE(importedModules.at(2).absoluteLocalPath(u"/bla/bla"_s), u"/bla/bla/../dommerging"); - QCOMPARE(importedModules.at(3).directoryString(), u"C:/some/path"_qs); - QCOMPARE(importedModules.at(3).localPath(), u"C:/some/path"_qs); - QCOMPARE(importedModules.at(4).directoryString(), u"http://bla.com/"_qs); - QCOMPARE(importedModules.at(4).directoryUrl().toString(), u"http://bla.com/"_qs); - QCOMPARE(importedModules.at(5).absoluteLocalPath(), u"/absolute/path"_qs); + QCOMPARE(importedModules.at(3).directoryString(), u"C:/some/path"_s); + QCOMPARE(importedModules.at(3).localPath(), u"C:/some/path"_s); + QCOMPARE(importedModules.at(4).directoryString(), u"http://bla.com/"_s); + QCOMPARE(importedModules.at(4).directoryUrl().toString(), u"http://bla.com/"_s); + QCOMPARE(importedModules.at(5).absoluteLocalPath(), u"/absolute/path"_s); QVERIFY(QmlUri::fromDirectoryString("QtQuick") != importedModules.at(0)); QCOMPARE(QmlUri::fromUriString("QtQuick"), importedModules.at(0)); } @@ -674,6 +679,8 @@ private slots: static void checkAliases(DomItem &qmlObj) { + using namespace Qt::StringLiterals; + if (const QmlObject *qmlObjPtr = qmlObj.as<QmlObject>()) { auto pDefs = qmlObjPtr->propertyDefs(); auto i = pDefs.constBegin(); @@ -688,34 +695,34 @@ private slots: switch (propName.last(1).at(0).unicode()) { case u'i': QCOMPARE(rAlias.status, LocallyResolvedAlias::Status::ResolvedProperty); - QCOMPARE(rAlias.typeName, u"int"_qs); + QCOMPARE(rAlias.typeName, u"int"_s); QVERIFY(rAlias.accessedPath.isEmpty()); QCOMPARE(rAlias.localPropertyDef.internalKind(), DomType::PropertyDefinition); break; case u'r': QCOMPARE(rAlias.status, LocallyResolvedAlias::Status::ResolvedProperty); - QCOMPARE(rAlias.typeName, u"real"_qs); + QCOMPARE(rAlias.typeName, u"real"_s); QVERIFY(rAlias.accessedPath.isEmpty()); QCOMPARE(rAlias.localPropertyDef.internalKind(), DomType::PropertyDefinition); break; case u'I': QCOMPARE(rAlias.status, LocallyResolvedAlias::Status::ResolvedObject); - QCOMPARE(rAlias.typeName, u"Item"_qs); - QCOMPARE(rAlias.accessedPath, QStringList { u"objectName"_qs }); + QCOMPARE(rAlias.typeName, u"Item"_s); + QCOMPARE(rAlias.accessedPath, QStringList { u"objectName"_s }); QVERIFY(!rAlias.localPropertyDef); break; case u'q': QCOMPARE(rAlias.status, LocallyResolvedAlias::Status::ResolvedObject); - QCOMPARE(rAlias.typeName, u"QtObject"_qs); - QCOMPARE(rAlias.accessedPath, QStringList { u"objectName"_qs }); + QCOMPARE(rAlias.typeName, u"QtObject"_s); + QCOMPARE(rAlias.accessedPath, QStringList { u"objectName"_s }); QVERIFY(!rAlias.localPropertyDef); break; case u'Q': QCOMPARE(rAlias.status, LocallyResolvedAlias::Status::ResolvedObject); - QCOMPARE(rAlias.typeName, u"QtObject"_qs); - QCOMPARE(rAlias.accessedPath, QStringList { u"objectName"_qs }); + QCOMPARE(rAlias.typeName, u"QtObject"_s); + QCOMPARE(rAlias.accessedPath, QStringList { u"objectName"_s }); QVERIFY(rAlias.localPropertyDef); break; default: @@ -751,8 +758,10 @@ private slots: } void testAliasResolve() { + using namespace Qt::StringLiterals; + QFETCH(QString, inFile); - QString testFile1 = baseDir + u"/"_qs + inFile; + QString testFile1 = baseDir + u"/"_s + inFile; DomItem env = DomEnvironment::create( QStringList(), QQmlJS::Dom::DomEnvironment::Option::SingleThreaded diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp index 8f2ba0021c..499e418395 100644 --- a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp +++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp @@ -50,6 +50,8 @@ #include <QQmlComponent> +using namespace Qt::StringLiterals; + #define EXPECT(cond) \ do { \ if (!errorAt && !(cond)) { \ @@ -126,7 +128,7 @@ void tst_QQuickAccessible::cleanup() for (int i = 0; i < list.count(); ++i) { auto object = list.at(i)->object(); QString objectInfo = object ? QDebug::toString(object) - : u"[deleted object]"_qs; + : u"[deleted object]"_s; qWarning().noquote() << " " << (i + 1) << objectInfo << "Event: '" << qAccessibleEventString(list.at(i)->type()) << "' Child: " << list.at(i)->child(); diff --git a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp index 020097b9ef..3ac4aecd5a 100644 --- a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp +++ b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp @@ -39,6 +39,8 @@ #include <QtQuickTestUtils/private/qmlutils_p.h> #include <QFont> +using namespace Qt::StringLiterals; + class tst_qquickapplication : public QQmlDataTest { Q_OBJECT @@ -75,7 +77,7 @@ void tst_qquickapplication::cleanup() void tst_qquickapplication::active() { - for (const QString &app : { u"Qt.application"_qs, u"Application"_qs }) { + for (const QString &app : { u"Qt.application"_s, u"Application"_s }) { QQmlComponent component(&engine); component.setData(u"import QtQuick 2.0; " "Item { " @@ -85,7 +87,7 @@ void tst_qquickapplication::active() " target: %1; " " function onActiveChanged(active) { active2 = %1.active; }" " } " - "}"_qs.arg(app) + "}"_s.arg(app) .toUtf8(), QUrl::fromLocalFile("")); QQuickItem *item = qobject_cast<QQuickItem *>(component.create()); @@ -131,7 +133,7 @@ void tst_qquickapplication::active() void tst_qquickapplication::state() { - for (const QString &app : { u"Qt.application"_qs, u"Application"_qs }) { + for (const QString &app : { u"Qt.application"_s, u"Application"_s }) { QQmlComponent component(&engine); component.setData(u"import QtQuick 2.0; " "Item { " @@ -142,7 +144,7 @@ void tst_qquickapplication::state() " function onStateChanged(state) { state2 = %1.state; }" " } " " Component.onCompleted: state2 = %1.state; " - "}"_qs.arg(app) + "}"_s.arg(app) .toUtf8(), QUrl::fromLocalFile("")); QQuickItem *item = qobject_cast<QQuickItem *>(component.create()); @@ -206,10 +208,10 @@ void tst_qquickapplication::state() void tst_qquickapplication::layoutDirection() { - for (const QString &app : { u"Qt.application"_qs, u"Application"_qs }) { + for (const QString &app : { u"Qt.application"_s, u"Application"_s }) { QQmlComponent component(&engine); component.setData( - u"import QtQuick 2.0; Item { property bool layoutDirection: %1.layoutDirection }"_qs + u"import QtQuick 2.0; Item { property bool layoutDirection: %1.layoutDirection }"_s .arg(app) .toUtf8(), QUrl::fromLocalFile("")); @@ -233,10 +235,10 @@ void tst_qquickapplication::layoutDirection() void tst_qquickapplication::font() { - for (const QString &app : { u"Qt.application"_qs, u"Application"_qs }) { + for (const QString &app : { u"Qt.application"_s, u"Application"_s }) { QQmlComponent component(&engine); component.setData( - u"import QtQuick 2.0; Item { property font defaultFont: %1.font }"_qs.arg(app) + u"import QtQuick 2.0; Item { property font defaultFont: %1.font }"_s.arg(app) .toUtf8(), QUrl::fromLocalFile("")); QQuickItem *item = qobject_cast<QQuickItem *>(component.create()); diff --git a/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp index b7a7010a57..9c3598b186 100644 --- a/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp +++ b/tests/auto/quick/qquickdroparea/tst_qquickdroparea.cpp @@ -41,6 +41,8 @@ #include <QtQuickTestUtils/private/qmlutils_p.h> #include <QtQuickTestUtils/private/viewtestutils_p.h> +using namespace Qt::StringLiterals; + template <typename T> static T evaluate(QObject *scope, const QString &expression) { QQmlExpression expr(qmlContext(scope), scope, expression); @@ -1338,7 +1340,7 @@ void tst_QQuickDropArea::signalOrder() const QList<QVariant> eventOrder = item->property("eventOrder").toList(); QCOMPARE(eventOrder, - QList<QVariant>({ u"entered1"_qs, u"exited1"_qs, u"entered2"_qs, u"exited2"_qs })); + QList<QVariant>({ u"entered1"_s, u"exited1"_s, u"entered2"_s, u"exited2"_s })); } QTEST_MAIN(tst_QQuickDropArea) diff --git a/tests/auto/quickcontrols2/qquickdrawer/tst_qquickdrawer.cpp b/tests/auto/quickcontrols2/qquickdrawer/tst_qquickdrawer.cpp index b5b6212be5..6f2a299c80 100644 --- a/tests/auto/quickcontrols2/qquickdrawer/tst_qquickdrawer.cpp +++ b/tests/auto/quickcontrols2/qquickdrawer/tst_qquickdrawer.cpp @@ -50,6 +50,7 @@ //using namespace QQuickVisualTestUtils; using namespace QQuickControlsTestUtils; +using namespace Qt::StringLiterals; class tst_QQuickDrawer : public QQmlDataTest { @@ -547,7 +548,7 @@ void tst_QQuickDrawer::header() void tst_QQuickDrawer::dragHandlerInteraction() { - QQuickControlsApplicationHelper helper(this, u"dragHandlerInteraction.qml"_qs); + QQuickControlsApplicationHelper helper(this, u"dragHandlerInteraction.qml"_s); QVERIFY2(helper.ready, helper.failureMessage()); auto window = helper.appWindow;; diff --git a/tests/auto/quickcontrols2/sanity/tst_sanity.cpp b/tests/auto/quickcontrols2/sanity/tst_sanity.cpp index 6c85bf42ed..fa1d0ecd83 100644 --- a/tests/auto/quickcontrols2/sanity/tst_sanity.cpp +++ b/tests/auto/quickcontrols2/sanity/tst_sanity.cpp @@ -44,6 +44,7 @@ using namespace QQuickVisualTestUtils; using namespace QQuickControlsTestUtils; +using namespace Qt::StringLiterals; class tst_Sanity : public QObject { @@ -76,11 +77,11 @@ tst_Sanity::tst_Sanity() // Mainly because a lot of false positives are generated because we are linting files from // different modules directly without their generated qmldirs. for (const QString &key : m_options.keys()) - m_options[key].setLevel(u"disable"_qs); + m_options[key].setLevel(u"disable"_s); - m_options[u"deferred-property-id"_qs].setLevel(u"warning"_qs); - m_options[u"controls-sanity"_qs].setLevel(u"warning"_qs); - m_options[u"multiple-attached-objects"_qs].setLevel(u"warning"_qs); + m_options[u"deferred-property-id"_s].setLevel(u"warning"_s); + m_options[u"controls-sanity"_s].setLevel(u"warning"_s); + m_options[u"multiple-attached-objects"_s].setLevel(u"warning"_s); } void tst_Sanity::initTestCase() diff --git a/tests/benchmarks/qml/javascript/tst_javascript.cpp b/tests/benchmarks/qml/javascript/tst_javascript.cpp index 7eda96b77f..6a3eb3d29d 100644 --- a/tests/benchmarks/qml/javascript/tst_javascript.cpp +++ b/tests/benchmarks/qml/javascript/tst_javascript.cpp @@ -34,6 +34,8 @@ #include "testtypes.h" +using namespace Qt::StringLiterals; + class tst_javascript : public QObject { Q_OBJECT @@ -52,7 +54,7 @@ private: void tst_javascript::run_data() { QTest::addColumn<QString>("file"); - QDirIterator listing(SRCDIR "/data", QStringList{u"*.qml"_qs}, + QDirIterator listing(SRCDIR "/data", QStringList{u"*.qml"_s}, QDir::Files | QDir::NoDotAndDotDot); while (listing.hasNext()) { auto info = listing.nextFileInfo(); diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp index 24490e1198..bdce49cad0 100644 --- a/tools/qmlimportscanner/main.cpp +++ b/tools/qmlimportscanner/main.cpp @@ -54,6 +54,8 @@ QT_USE_NAMESPACE +using namespace Qt::StringLiterals; + namespace { QStringList g_qmlImportPaths; @@ -288,7 +290,7 @@ QPair<QString, QString> resolveImportPath(const QString &uri, const QString &ver const QDir candidateDir(candidatePath); if (candidateDir.exists()) { const auto newCandidate = qMakePair(candidatePath, relativePath); // import found - if (candidateDir.exists(u"qmldir"_qs)) // if it has a qmldir, we are fine + if (candidateDir.exists(u"qmldir"_s)) // if it has a qmldir, we are fine return newCandidate; else if (candidate.first.isEmpty()) candidate = newCandidate; @@ -304,7 +306,7 @@ QPair<QString, QString> resolveImportPath(const QString &uri, const QString &ver const QDir candidateDir(candidatePath); if (candidateDir.exists()) { const auto newCandidate = qMakePair(candidatePath, relativePath); // import found - if (candidateDir.exists(u"qmldir"_qs)) + if (candidateDir.exists(u"qmldir"_s)) return newCandidate; else if (candidate.first.isEmpty()) candidate = newCandidate; diff --git a/tools/qmllint/main.cpp b/tools/qmllint/main.cpp index f6c29c19b6..04d0e322b8 100644 --- a/tools/qmllint/main.cpp +++ b/tools/qmllint/main.cpp @@ -50,6 +50,8 @@ #include <cstdio> +using namespace Qt::StringLiterals; + constexpr int JSON_LOGGING_FORMAT_REVISION = 3; int main(int argv, char *argc[]) @@ -366,7 +368,7 @@ All warnings can be set to three levels: continue; } - const QString backupFile = filename + u".bak"_qs; + const QString backupFile = filename + u".bak"_s; if (QFile::exists(backupFile) && !QFile::remove(backupFile)) { if (!silent) { qWarning().nospace() << "Failed to remove old backup file " << backupFile @@ -414,8 +416,8 @@ All warnings can be set to three levels: if (useJson) { QJsonObject result; - result[u"revision"_qs] = JSON_LOGGING_FORMAT_REVISION; - result[u"files"_qs] = jsonFiles; + result[u"revision"_s] = JSON_LOGGING_FORMAT_REVISION; + result[u"files"_s] = jsonFiles; QString fileName = parser.value(jsonOption); diff --git a/tools/qmlls/qlanguageserver.cpp b/tools/qmlls/qlanguageserver.cpp index 898d1b0666..be0145112e 100644 --- a/tools/qmlls/qlanguageserver.cpp +++ b/tools/qmlls/qlanguageserver.cpp @@ -32,6 +32,7 @@ QT_BEGIN_NAMESPACE using namespace QLspSpecification; +using namespace Qt::StringLiterals; Q_LOGGING_CATEGORY(lspServerLog, "qt.languageserver.server") @@ -196,13 +197,13 @@ void QLanguageServer::registerMethods(QJsonRpc::TypedRpc &typedRpc) if (rState == RunStatus::NotSetup || rState == RunStatus::DidSetup) responder(QJsonRpcProtocol::MessageHandler::error( int(QLspSpecification::ErrorCodes::ServerNotInitialized), - u"Request on non initialized Language Server (runStatus %1): %2"_qs + u"Request on non initialized Language Server (runStatus %1): %2"_s .arg(int(rState)) .arg(QString::fromUtf8(doc.toJson())))); else responder(QJsonRpcProtocol::MessageHandler::error( int(QLspSpecification::ErrorCodes::InvalidRequest), - u"Method called on stopping Language Server (runStatus %1)"_qs.arg( + u"Method called on stopping Language Server (runStatus %1)"_s.arg( int(rState)))); return QJsonRpcProtocol::Processing::Stop; }); @@ -284,12 +285,12 @@ void QLanguageServer::registerHandlers(QLanguageServerProtocol *protocol) if (rStatus == RunStatus::NotSetup || rStatus == RunStatus::SettingUp) response.sendErrorResponse( int(QLspSpecification::ErrorCodes::InvalidRequest), - u"Initialization request received on non setup language server"_qs + u"Initialization request received on non setup language server"_s .toUtf8()); else response.sendErrorResponse( int(QLspSpecification::ErrorCodes::InvalidRequest), - u"Received multiple initialization requests"_qs.toUtf8()); + u"Received multiple initialization requests"_s.toUtf8()); emit lifecycleError(); return; } diff --git a/tools/qmlls/qmllintsuggestions.cpp b/tools/qmlls/qmllintsuggestions.cpp index c26f154a47..75ada742b7 100644 --- a/tools/qmlls/qmllintsuggestions.cpp +++ b/tools/qmlls/qmllintsuggestions.cpp @@ -35,6 +35,7 @@ using namespace QLspSpecification; using namespace QQmlJS::Dom; +using namespace Qt::StringLiterals; Q_LOGGING_CATEGORY(lintLog, "qt.languageserver.lint") @@ -94,7 +95,7 @@ static void codeActionHandler( edit.documentChanges = edits; CodeAction action; - action.kind = u"refactor.rewrite"_qs.toUtf8(); + action.kind = u"refactor.rewrite"_s.toUtf8(); action.edit = edit; action.title = message.toUtf8(); diff --git a/tools/qmlls/qqmlcodemodel.cpp b/tools/qmlls/qqmlcodemodel.cpp index 2a45a4d98e..01a1719094 100644 --- a/tools/qmlls/qqmlcodemodel.cpp +++ b/tools/qmlls/qqmlcodemodel.cpp @@ -42,6 +42,7 @@ namespace QmlLsp { Q_LOGGING_CATEGORY(codeModelLog, "qt.languageserver.codemodel") using namespace QQmlJS::Dom; +using namespace Qt::StringLiterals; /*! \internal @@ -547,29 +548,29 @@ QDebug OpenDocumentSnapshot::dump(QDebug dbg, DumpOptions options) { dbg.noquote().nospace() << "{"; dbg << " uri:" << QString::fromUtf8(uri) << "\n"; - dbg << " docVersion:" << (docVersion ? QString::number(*docVersion) : u"*none*"_qs) << "\n"; + dbg << " docVersion:" << (docVersion ? QString::number(*docVersion) : u"*none*"_s) << "\n"; if (options & DumpOption::LatestCode) { dbg << " doc: ------------\n" << doc.field(Fields::code).value().toString() << "\n==========\n"; } else { dbg << u" doc:" - << (doc ? u"%1chars"_qs.arg(doc.field(Fields::code).value().toString().length()) - : u"*none*"_qs) + << (doc ? u"%1chars"_s.arg(doc.field(Fields::code).value().toString().length()) + : u"*none*"_s) << "\n"; } dbg << " validDocVersion:" - << (validDocVersion ? QString::number(*validDocVersion) : u"*none*"_qs) << "\n"; + << (validDocVersion ? QString::number(*validDocVersion) : u"*none*"_s) << "\n"; if (options & DumpOption::ValidCode) { dbg << " validDoc: ------------\n" << validDoc.field(Fields::code).value().toString() << "\n==========\n"; } else { dbg << u" validDoc:" - << (validDoc ? u"%1chars"_qs.arg( + << (validDoc ? u"%1chars"_s.arg( validDoc.field(Fields::code).value().toString().length()) - : u"*none*"_qs) + : u"*none*"_s) << "\n"; } - dbg << " scopeVersion:" << (scopeVersion ? QString::number(*scopeVersion) : u"*none*"_qs) + dbg << " scopeVersion:" << (scopeVersion ? QString::number(*scopeVersion) : u"*none*"_s) << "\n"; dbg << " scopeDependenciesLoadTime:" << scopeDependenciesLoadTime << "\n"; dbg << " scopeDependenciesChanged" << scopeDependenciesChanged << "\n"; diff --git a/tools/qmlls/qqmllanguageserver.cpp b/tools/qmlls/qqmllanguageserver.cpp index e56c2ade1d..05093db463 100644 --- a/tools/qmlls/qqmllanguageserver.cpp +++ b/tools/qmlls/qqmllanguageserver.cpp @@ -39,6 +39,7 @@ QT_BEGIN_NAMESPACE namespace QmlLsp { using namespace QLspSpecification; +using namespace Qt::StringLiterals; /*! \internal \class QmlLsp::QQmlLanguageServer @@ -95,7 +96,7 @@ void QQmlLanguageServer::setupCapabilities(const QLspSpecification::InitializePa QString QQmlLanguageServer::name() const { - return u"QQmlLanguageServer"_qs; + return u"QQmlLanguageServer"_s; } void QQmlLanguageServer::errorExit() diff --git a/tools/qmlls/textsynchronization.cpp b/tools/qmlls/textsynchronization.cpp index f15d9c57c3..efd06aea98 100644 --- a/tools/qmlls/textsynchronization.cpp +++ b/tools/qmlls/textsynchronization.cpp @@ -31,6 +31,8 @@ #include "textdocument.h" using namespace QLspSpecification; +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE TextSynchronization::TextSynchronization(QmlLsp::QQmlCodeModel *codeModel, QObject *parent) @@ -105,7 +107,7 @@ void TextSynchronization::registerHandlers(QLanguageServer *server, QLanguageSer QString TextSynchronization::name() const { - return u"TextSynchonization"_qs; + return u"TextSynchonization"_s; } void TextSynchronization::setupCapabilities(const QLspSpecification::InitializeParams &, diff --git a/tools/qmltc/main.cpp b/tools/qmltc/main.cpp index c8d62ba078..fa30f311fd 100644 --- a/tools/qmltc/main.cpp +++ b/tools/qmltc/main.cpp @@ -45,6 +45,8 @@ #include <cstdlib> // EXIT_SUCCESS, EXIT_FAILURE +using namespace Qt::StringLiterals; + void setupLogger(QQmlJSLogger &logger) // prepare logger to work with compiler { const QSet<QQmlJSLoggerCategory> exceptions { @@ -67,7 +69,7 @@ int main(int argc, char **argv) // random seeding. qSetGlobalQHashSeed(0); QCoreApplication app(argc, argv); - QCoreApplication::setApplicationName(u"qmltc"_qs); + QCoreApplication::setApplicationName(u"qmltc"_s); QCoreApplication::setApplicationVersion(QStringLiteral(QT_VERSION_STR)); // command-line parsing: @@ -76,34 +78,34 @@ int main(int argc, char **argv) parser.addVersionOption(); QCommandLineOption importPathOption { - u"I"_qs, QCoreApplication::translate("main", "Look for QML modules in specified directory"), + u"I"_s, QCoreApplication::translate("main", "Look for QML modules in specified directory"), QCoreApplication::translate("main", "import directory") }; parser.addOption(importPathOption); QCommandLineOption qmldirOption { - u"i"_qs, QCoreApplication::translate("main", "Include extra qmldir files"), + u"i"_s, QCoreApplication::translate("main", "Include extra qmldir files"), QCoreApplication::translate("main", "qmldir file") }; parser.addOption(qmldirOption); QCommandLineOption outputCppOption { - u"impl"_qs, QCoreApplication::translate("main", "Generated C++ source file path"), + u"impl"_s, QCoreApplication::translate("main", "Generated C++ source file path"), QCoreApplication::translate("main", "cpp path") }; parser.addOption(outputCppOption); QCommandLineOption outputHOption { - u"header"_qs, QCoreApplication::translate("main", "Generated C++ header file path"), + u"header"_s, QCoreApplication::translate("main", "Generated C++ header file path"), QCoreApplication::translate("main", "h path") }; parser.addOption(outputHOption); QCommandLineOption resourceOption { - u"resource"_qs, + u"resource"_s, QCoreApplication::translate( "main", "Qt resource file that might later contain one of the compiled files"), QCoreApplication::translate("main", "resource file name") }; parser.addOption(resourceOption); QCommandLineOption namespaceOption { - u"namespace"_qs, QCoreApplication::translate("main", "Namespace of the generated C++ code"), + u"namespace"_s, QCoreApplication::translate("main", "Namespace of the generated C++ code"), QCoreApplication::translate("main", "namespace") }; parser.addOption(namespaceOption); @@ -116,7 +118,7 @@ int main(int argc, char **argv) parser.showHelp(); } else { fprintf(stderr, "%s\n", - qPrintable(u"Too many input files specified: '"_qs + sources.join(u"' '"_qs) + qPrintable(u"Too many input files specified: '"_s + sources.join(u"' '"_s) + u'\'')); } return EXIT_FAILURE; @@ -145,14 +147,14 @@ int main(int argc, char **argv) QString outputCppFile; if (!parser.isSet(outputCppOption)) { - outputCppFile = url.first(url.size() - 3) + u"cpp"_qs; + outputCppFile = url.first(url.size() - 3) + u"cpp"_s; } else { outputCppFile = parser.value(outputCppOption); } QString outputHFile; if (!parser.isSet(outputHOption)) { - outputHFile = url.first(url.size() - 3) + u"h"_qs; + outputHFile = url.first(url.size() - 3) + u"h"_s; } else { outputHFile = parser.value(outputHOption); } @@ -168,7 +170,7 @@ int main(int argc, char **argv) QQmlJSSaveFunction noop([](auto &&...) { return true; }); QQmlJSCompileError error; if (!qCompileQmlFile(document, url, noop, nullptr, &error)) { - error.augment(u"Error compiling qml file: "_qs).print(); + error.augment(u"Error compiling qml file: "_s).print(); return EXIT_FAILURE; } diff --git a/tools/qmltc/prototype/codegenerator.cpp b/tools/qmltc/prototype/codegenerator.cpp index 223b6e7691..eb2e0ef23b 100644 --- a/tools/qmltc/prototype/codegenerator.cpp +++ b/tools/qmltc/prototype/codegenerator.cpp @@ -49,6 +49,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_LOGGING_CATEGORY(lcCodeGenerator, "qml.qmltc.compiler", QtWarningMsg); static QString figureReturnType(const QQmlJSMetaMethod &m) @@ -60,7 +62,7 @@ static QString figureReturnType(const QQmlJSMetaMethod &m) // due to QML/C++ name collisions and unique C++ name generation QString type; if (isVoidMethod) { - type = u"void"_qs; + type = u"void"_s; } else { type = m.returnType()->augmentedInternalName(); } @@ -209,12 +211,12 @@ static QStringList generate_assignToSpecialAlias(const QQmlJSScope::ConstPtr &ty // only place for it is init) // NB: this variable would behave correctly as long as QML init and QML finalize // are non-virtual functions -static const QmltcVariable childrenOffsetVariable { u"qsizetype"_qs, u"QML_choffset"_qs, +static const QmltcVariable childrenOffsetVariable { u"qsizetype"_s, u"QML_choffset"_s, QString() }; // represents QV4::ExecutableCompilationUnit -static const QmltcVariable compilationUnitVariable { u"QV4::ExecutableCompilationUnit *"_qs, - u"QML_cu"_qs, QString() }; +static const QmltcVariable compilationUnitVariable { u"QV4::ExecutableCompilationUnit *"_s, + u"QML_cu"_s, QString() }; Q_LOGGING_CATEGORY(lcCodeGen, "qml.compiler.CodeGenerator", QtWarningMsg); @@ -244,12 +246,12 @@ void CodeGenerator::constructObjects(QSet<QString> &requiredCppIncludes) QmlIR::Object *irObject = objects[objectIndex]; if (!irObject) { recordError(QQmlJS::SourceLocation {}, - u"Internal compiler error: IR object is null"_qs); + u"Internal compiler error: IR object is null"_s); return; } QQmlJSScope::Ptr object = m_localTypeResolver->scopeForLocation(irObject->location); if (!object) { - recordError(irObject->location, u"Object of unknown type"_qs); + recordError(irObject->location, u"Object of unknown type"_s); return; } m_typeToObjectIndex.insert(object, objectIndex); @@ -328,7 +330,7 @@ bool CodeGenerator::ignoreObject(const CodeGenObject &object) const QString buildCallSpecialMethodValue(bool documentRoot, const QString &outerFlagName, bool overridesInterface) { - const QString callInBase = overridesInterface ? u"false"_qs : u"true"_qs; + const QString callInBase = overridesInterface ? u"false"_s : u"true"_s; if (documentRoot) { return outerFlagName + u" && " + callInBase; } else { @@ -339,7 +341,7 @@ QString buildCallSpecialMethodValue(bool documentRoot, const QString &outerFlagN static QString generate_callCompilationUnit(const QString &urlMethodName) { // NB: assume `engine` variable always exists - return u"QQmlEnginePrivate::get(engine)->compilationUnitFromUrl(%1())"_qs.arg(urlMethodName); + return u"QQmlEnginePrivate::get(engine)->compilationUnitFromUrl(%1())"_s.arg(urlMethodName); } void CodeGenerator::compileAlias(QmltcType ¤t, const QQmlJSMetaProperty &alias, @@ -356,7 +358,7 @@ void CodeGenerator::compileAlias(QmltcType ¤t, const QQmlJSMetaProperty &a Q_ASSERT(type); const bool aliasToProperty = aliasExprBits.size() > 1; // and not an object - QString latestAccessor = u"this"_qs; + QString latestAccessor = u"this"_s; QString latestAccessorNonPrivate; // TODO: crutch for notify QStringList prologue; QStringList writeSpecificEpilogue; @@ -369,15 +371,15 @@ void CodeGenerator::compileAlias(QmltcType ¤t, const QQmlJSMetaProperty &a // TODO: the context fetching must be done once in the notify code // (across multiple alias properties). now there's a huge duplication - prologue << u"auto context = QQmlData::get(this)->outerContext;"_qs; + prologue << u"auto context = QQmlData::get(this)->outerContext;"_s; // there's a special case: when `this` type has compiled QML type as a base // type and it is not a root, it has a non-root first context, so we need to // step one level up if (m_qmlCompiledBaseTypes.contains(owner->baseTypeName()) && m_typeToObjectIndex[owner] != 0) { Q_ASSERT(!owner->baseTypeName().isEmpty()); - prologue << u"// `this` is special: not a root and its base type is compiled"_qs; - prologue << u"context = context->parent().data();"_qs; + prologue << u"// `this` is special: not a root and its base type is compiled"_s; + prologue << u"context = context->parent().data();"_s; } // doing the above allows us to lookup id object by integer, which is fast latestAccessor = u"alias_objectById_" + idString; // unique enough @@ -438,11 +440,11 @@ void CodeGenerator::compileAlias(QmltcType ¤t, const QQmlJSMetaProperty &a if (resultingProperty.isList()) { info.underlyingType = u"QQmlListProperty<" + info.underlyingType + u">"; } else if (resultingProperty.type()->isReferenceType()) { - info.underlyingType += u"*"_qs; + info.underlyingType += u"*"_s; } // reset to generic type when having alias to id: if (m_aliasesToIds.contains(resultingProperty)) - info.underlyingType = u"QObject*"_qs; + info.underlyingType = u"QObject*"_s; // READ must always be present info.readLine = latestAccessor + u"->" + resultingProperty.read() + u"()"; @@ -451,7 +453,7 @@ void CodeGenerator::compileAlias(QmltcType ¤t, const QQmlJSMetaProperty &a if (QString bindableName = resultingProperty.bindable(); !bindableName.isEmpty()) info.bindableLine = latestAccessor + u"->" + bindableName + u"()"; } else { - info.underlyingType = u"QObject*"_qs; + info.underlyingType = u"QObject*"_s; info.readLine = latestAccessor; // NB: id-pointing aliases are read-only, also alias to object is not // bindable since it's not a QProperty itself @@ -472,19 +474,19 @@ void CodeGenerator::compileAlias(QmltcType ¤t, const QQmlJSMetaProperty &a // getter.body += writeSpecificEpilogue; getter.userVisible = true; current.functions.emplaceBack(getter); - mocLines << u"READ"_qs << getter.name; + mocLines << u"READ"_s << getter.name; } // else always an error? if (!info.writeLine.isEmpty()) { QmltcMethod setter {}; - setter.returnType = u"void"_qs; + setter.returnType = u"void"_s; setter.name = compilationData.write; QList<QQmlJSMetaMethod> methods = type->methods(resultingProperty.write()); if (methods.isEmpty()) { // QmltcVariable setter.parameterList.emplaceBack(QQmlJSUtils::constRefify(info.underlyingType), - aliasName + u"_", u""_qs); + aliasName + u"_", u""_s); } else { setter.parameterList = compileMethodParameters(methods.at(0).parameterNames(), methods.at(0).parameterTypes(), true); @@ -497,7 +499,7 @@ void CodeGenerator::compileAlias(QmltcType ¤t, const QQmlJSMetaProperty &a std::transform(setter.parameterList.cbegin(), setter.parameterList.cend(), std::back_inserter(parameterNames), [](const QmltcVariable &x) { return x.name; }); - QString commaSeparatedParameterNames = parameterNames.join(u", "_qs); + QString commaSeparatedParameterNames = parameterNames.join(u", "_s); setter.body << info.writeLine.arg(commaSeparatedParameterNames) + u";"; } else { setter.body << info.writeLine + u";"; @@ -505,7 +507,7 @@ void CodeGenerator::compileAlias(QmltcType ¤t, const QQmlJSMetaProperty &a setter.body += writeSpecificEpilogue; setter.userVisible = true; current.functions.emplaceBack(setter); - mocLines << u"WRITE"_qs << setter.name; + mocLines << u"WRITE"_s << setter.name; } // 2. add bindable @@ -517,12 +519,12 @@ void CodeGenerator::compileAlias(QmltcType ¤t, const QQmlJSMetaProperty &a bindable.body << u"return " + info.bindableLine + u";"; bindable.userVisible = true; current.functions.emplaceBack(bindable); - mocLines << u"BINDABLE"_qs << bindable.name; + mocLines << u"BINDABLE"_s << bindable.name; } // 3. add notify - which is pretty special if (QString notifyName = resultingProperty.notify(); !notifyName.isEmpty()) { // notify is very special (even more than reasonable) - current.endInit.body << u"{ // alias notify connection:"_qs; + current.endInit.body << u"{ // alias notify connection:"_s; // TODO: part of the prologue (e.g. QQmlData::get(this)->outerContext) // must be shared across different notifies (to speed up finalize) current.endInit.body += prologue; @@ -532,17 +534,17 @@ void CodeGenerator::compileAlias(QmltcType ¤t, const QQmlJSMetaProperty &a current.endInit.body << u"QObject::connect(" + latestAccessorNonPrivate + u", &" + type->internalName() + u"::" + notifyName + u", this, &" + current.cppType + u"::" + compilationData.notify + u");"; - current.endInit.body << u"}"_qs; + current.endInit.body << u"}"_s; } // 4. add moc entry // Q_PROPERTY(QString text READ text WRITE setText BINDABLE bindableText NOTIFY textChanged) - current.mocCode << u"Q_PROPERTY(" + mocLines.join(u" "_qs) + u")"; + current.mocCode << u"Q_PROPERTY(" + mocLines.join(u" "_s) + u")"; // 5. add extra moc entry if this alias is default one if (aliasName == owner->defaultPropertyName()) { // Q_CLASSINFO("DefaultProperty", propertyName) - current.mocCode << u"Q_CLASSINFO(\"DefaultProperty\", \"%1\")"_qs.arg(aliasName); + current.mocCode << u"Q_CLASSINFO(\"DefaultProperty\", \"%1\")"_s.arg(aliasName); } } @@ -614,7 +616,7 @@ void CodeGenerator::compileBinding(QmltcType ¤t, const QmlIR::Binding &bin switch (binding.type) { case QmlIR::Binding::Type_Boolean: { - addPropertyLine(propertyName, p, binding.value.b ? u"true"_qs : u"false"_qs); + addPropertyLine(propertyName, p, binding.value.b ? u"true"_s : u"false"_s); break; } case QmlIR::Binding::Type_Number: { @@ -670,7 +672,7 @@ void CodeGenerator::compileBinding(QmltcType ¤t, const QmlIR::Binding &bin // `this` (at least at present it seems to be so) - e.g. the whole logic // of separating object binding into object creation and object binding // setup relies on the fact that we use `this` - const QString qobjectParent = u"this"_qs; + const QString qobjectParent = u"this"_s; const QString objectAddr = accessor.name; if (binding.flags & QmlIR::Binding::IsOnAssignment) { @@ -678,14 +680,14 @@ void CodeGenerator::compileBinding(QmltcType ¤t, const QmlIR::Binding &bin const auto uniqueId = UniqueStringId(current, onAssignmentName); if (!m_onAssignmentObjectsCreated.contains(uniqueId)) { m_onAssignmentObjectsCreated.insert(uniqueId); - current.init.body << u"auto %1 = new %2(creator, engine, %3);"_qs.arg( + current.init.body << u"auto %1 = new %2(creator, engine, %3);"_s.arg( onAssignmentName, bindingObject.type->internalName(), qobjectParent); - current.init.body << u"creator->set(%1, %2);"_qs.arg( + current.init.body << u"creator->set(%1, %2);"_s.arg( QString::number(m_visitor->creationIndex(bindingObject.type)), onAssignmentName); // static_cast is fine, because we (must) know the exact type - current.endInit.body << u"auto %1 = creator->get<%2>(%3);"_qs.arg( + current.endInit.body << u"auto %1 = creator->get<%2>(%3);"_s.arg( onAssignmentName, bindingObject.type->internalName(), QString::number(m_visitor->creationIndex(bindingObject.type))); @@ -695,12 +697,12 @@ void CodeGenerator::compileBinding(QmltcType ¤t, const QmlIR::Binding &bin // NB: we expect one "on" assignment per property, so creating // QQmlProperty each time should be fine (unlike QQmlListReference) - current.endInit.body << u"{"_qs; + current.endInit.body << u"{"_s; current.endInit.body << u"QQmlProperty qmlprop(" + objectAddr + u", QStringLiteral(\"" + propertyName + u"\"));"; current.endInit.body << u"QT_PREPEND_NAMESPACE(QQmlCppOnAssignmentHelper)::set(" + onAssignmentName + u", qmlprop);"; - current.endInit.body << u"}"_qs; + current.endInit.body << u"}"_s; break; } @@ -735,12 +737,12 @@ void CodeGenerator::compileBinding(QmltcType ¤t, const QmlIR::Binding &bin if (bindingObject.irObject->flags & QV4::CompiledData::Object::IsComponent) { // NB: this one is special - and probably becomes a view delegate. // object binding separation also does not apply here - const QString objectName = makeGensym(u"sc"_qs); + const QString objectName = makeGensym(u"sc"_s); Q_ASSERT(m_typeToObjectIndex.contains(bindingObject.type)); const int objectIndex = int(m_typeToObjectIndex[bindingObject.type]); Q_ASSERT(m_componentIndices.contains(objectIndex)); const int index = m_componentIndices[objectIndex]; - current.endInit.body << u"{"_qs; + current.endInit.body << u"{"_s; current.endInit.body << QStringLiteral( "auto thisContext = QQmlData::get(%1)->outerContext;") .arg(qobjectParent); @@ -755,28 +757,28 @@ void CodeGenerator::compileBinding(QmltcType ¤t, const QmlIR::Binding &bin .arg(objectName); const auto isComponentBased = [](const QQmlJSScope::ConstPtr &type) { auto base = QQmlJSScope::nonCompositeBaseType(type); - return base && base->internalName() == u"QQmlComponent"_qs; + return base && base->internalName() == u"QQmlComponent"_s; }; if (!m_doc->stringAt(bindingObject.irObject->idNameIndex).isEmpty() && isComponentBased(bindingObject.type)) { QmltcCodeGenerator::generate_setIdValue( - ¤t.endInit.body, u"thisContext"_qs, bindingObject.irObject->id, + ¤t.endInit.body, u"thisContext"_s, bindingObject.irObject->id, objectName, m_doc->stringAt(bindingObject.irObject->idNameIndex)); } setObjectBinding(objectName); - current.endInit.body << u"}"_qs; + current.endInit.body << u"}"_s; break; } - const QString objectName = makeGensym(u"o"_qs); - current.init.body << u"auto %1 = new %2(creator, engine, %3);"_qs.arg( + const QString objectName = makeGensym(u"o"_s); + current.init.body << u"auto %1 = new %2(creator, engine, %3);"_s.arg( objectName, bindingObject.type->internalName(), qobjectParent); - current.init.body << u"creator->set(%1, %2);"_qs.arg( + current.init.body << u"creator->set(%1, %2);"_s.arg( QString::number(m_visitor->creationIndex(bindingObject.type)), objectName); // refetch the same object during endInit to set the bindings - current.endInit.body << u"auto %1 = creator->get<%2>(%3);"_qs.arg( + current.endInit.body << u"auto %1 = creator->get<%2>(%3);"_s.arg( objectName, bindingObject.type->internalName(), QString::number(m_visitor->creationIndex(bindingObject.type))); setObjectBinding(objectName); @@ -786,12 +788,12 @@ void CodeGenerator::compileBinding(QmltcType ¤t, const QmlIR::Binding &bin break; } case QmlIR::Binding::Type_AttachedProperty: { - Q_ASSERT(accessor.name == u"this"_qs); // TODO: doesn't have to hold, in fact + Q_ASSERT(accessor.name == u"this"_s); // TODO: doesn't have to hold, in fact const auto attachedObject = m_objects.at(binding.value.objectIndex); const auto &irObject = attachedObject.irObject; const auto &type = attachedObject.type; Q_ASSERT(irObject && type); - if (propertyName == u"Component"_qs) { + if (propertyName == u"Component"_s) { // TODO: there's a special QQmlComponentAttached, which has to be // called? c.f. qqmlobjectcreator.cpp's finalize() const auto compileComponent = [&](const QmlIR::Binding &b) { @@ -814,7 +816,7 @@ void CodeGenerator::compileBinding(QmltcType ¤t, const QmlIR::Binding &bin if (!m_attachedTypesAlreadyRegistered.contains(uniqueId)) { m_attachedTypesAlreadyRegistered.insert(uniqueId); current.variables.emplaceBack(attachedTypeName + u" *", attachedMemberName, - u"nullptr"_qs); + u"nullptr"_s); // Note: getting attached property is fairly expensive const QString getAttachedPropertyLine = u"qobject_cast<" + attachedTypeName + u" *>(qmlAttachedPropertiesObject<" + attachingType->internalName() @@ -834,7 +836,7 @@ void CodeGenerator::compileBinding(QmltcType ¤t, const QmlIR::Binding &bin break; } case QmlIR::Binding::Type_GroupProperty: { - Q_ASSERT(accessor.name == u"this"_qs); // TODO: doesn't have to hold, in fact + Q_ASSERT(accessor.name == u"this"_s); // TODO: doesn't have to hold, in fact if (p.read().isEmpty()) { recordError(binding.location, u"READ function of group property '" + propertyName + u"' is unknown"); @@ -929,11 +931,11 @@ void CodeGenerator::compileBinding(QmltcType ¤t, const QmlIR::Binding &bin if (propertyType != m_localTypeResolver->varType() && propertyType->accessSemantics() != QQmlJSScope::AccessSemantics::Reference) { // TODO: this should really be done before the compiler here - recordError(binding.location, u"Cannot assign null to incompatible property"_qs); + recordError(binding.location, u"Cannot assign null to incompatible property"_s); } else if (propertyType->accessSemantics() == QQmlJSScope::AccessSemantics::Reference) { - addPropertyLine(p.propertyName(), p, u"nullptr"_qs); + addPropertyLine(p.propertyName(), p, u"nullptr"_s); } else { - addPropertyLine(p.propertyName(), p, u"QVariant::fromValue(nullptr)"_qs); + addPropertyLine(p.propertyName(), p, u"QVariant::fromValue(nullptr)"_s); } break; } @@ -976,22 +978,22 @@ static QmltcType compileScriptBindingPropertyChangeHandler( // default member variable and ctor: const QString pointerToObject = objectCppType + u" *"; bindingFunctor.variables.emplaceBack( - QmltcVariable { pointerToObject, u"m_self"_qs, u"nullptr"_qs }); + QmltcVariable { pointerToObject, u"m_self"_s, u"nullptr"_s }); bindingFunctor.baselineCtor.name = functorCppType; bindingFunctor.baselineCtor.parameterList.emplaceBack( - QmltcVariable { pointerToObject, u"self"_qs, QString() }); - bindingFunctor.baselineCtor.initializerList.emplaceBack(u"m_self(self)"_qs); + QmltcVariable { pointerToObject, u"self"_s, QString() }); + bindingFunctor.baselineCtor.initializerList.emplaceBack(u"m_self(self)"_s); // call operator: QmltcMethod callOperator {}; - callOperator.returnType = u"void"_qs; - callOperator.name = u"operator()"_qs; + callOperator.returnType = u"void"_s; + callOperator.name = u"operator()"_s; callOperator.parameterList = slotParameters; - callOperator.modifiers << u"const"_qs; + callOperator.modifiers << u"const"_s; QmltcCodeGenerator::generate_callExecuteRuntimeFunction( &callOperator.body, urlMethodName + u"()", relativeToAbsoluteRuntimeIndex(irObject, binding.value.compiledScriptIndex), - u"m_self"_qs, u"void"_qs, slotParameters); + u"m_self"_s, u"void"_s, slotParameters); bindingFunctor.functions.emplaceBack(std::move(callOperator)); @@ -1077,7 +1079,7 @@ void CodeGenerator::compileScriptBinding(QmltcType ¤t, const QmlIR::Bindin slotParameters = compileMethodParameters(paramNames, paramTypes, true); signalReturnType = figureReturnType(s); return BindingKind::SignalHandler; - } else if (propertyName.endsWith(u"Changed"_qs)) { + } else if (propertyName.endsWith(u"Changed"_s)) { return BindingKind::BindablePropertyChangeHandler; } return BindingKind::JustProperty; @@ -1102,7 +1104,7 @@ void CodeGenerator::compileScriptBinding(QmltcType ¤t, const QmlIR::Bindin int valueTypeIndex = -1; if (accessor.isValueType) { Q_ASSERT(accessor.scope != object.type); - bindingTarget = u"this"_qs; // TODO: not necessarily "this"? + bindingTarget = u"this"_s; // TODO: not necessarily "this"? auto [groupProperty, groupPropertyIndex] = getMetaPropertyIndex(accessor.scope, accessor.propertyName); if (groupPropertyIndex < 0) { @@ -1117,21 +1119,21 @@ void CodeGenerator::compileScriptBinding(QmltcType ¤t, const QmlIR::Bindin QmltcCodeGenerator::generate_createBindingOnProperty( ¤t.endInit.body, generate_callCompilationUnit(m_urlMethodName), - u"this"_qs, // NB: always using enclosing object as a scope for the binding + u"this"_s, // NB: always using enclosing object as a scope for the binding relativeToAbsoluteRuntimeIndex(object.irObject, binding.value.compiledScriptIndex), bindingTarget, // binding target absoluteIndex, property, valueTypeIndex, accessor.name); break; } case BindingKind::SignalHandler: { - QString This_signal = u"this"_qs; - QString This_slot = u"this"_qs; + QString This_signal = u"this"_s; + QString This_slot = u"this"_s; QString objectClassName_signal = objectType->internalName(); QString objectClassName_slot = objectType->internalName(); // TODO: ugly crutch to make stuff work - if (accessor.name != u"this"_qs) { // e.g. if attached property + if (accessor.name != u"this"_s) { // e.g. if attached property This_signal = accessor.name; - This_slot = u"this"_qs; // still + This_slot = u"this"_s; // still objectClassName_signal = objectType->baseTypeName(); objectClassName_slot = current.cppType; // real base class where slot would go } @@ -1149,7 +1151,7 @@ void CodeGenerator::compileScriptBinding(QmltcType ¤t, const QmlIR::Bindin &slotMethod.body, m_urlMethodName + u"()", relativeToAbsoluteRuntimeIndex(object.irObject, binding.value.compiledScriptIndex), - u"this"_qs, // Note: because script bindings always use current QML object scope + u"this"_s, // Note: because script bindings always use current QML object scope signalReturnType, slotParameters); slotMethod.type = QQmlJSMetaMethod::Slot; @@ -1167,7 +1169,7 @@ void CodeGenerator::compileScriptBinding(QmltcType ¤t, const QmlIR::Bindin const QString bindingFunctorName = makeGensym(bindingSymbolName + u"Functor"); QString actualPropertyName; - QRegularExpression onChangedRegExp(u"on(\\w+)Changed"_qs); + QRegularExpression onChangedRegExp(u"on(\\w+)Changed"_s); QRegularExpressionMatch match = onChangedRegExp.match(propertyName); if (match.hasMatch()) { actualPropertyName = match.captured(1); @@ -1268,15 +1270,15 @@ void CodeGenerator::compileScriptBindingOfComponent(QmltcType ¤t, int runtimeIndex = relativeToAbsoluteRuntimeIndex(irObject, binding.value.compiledScriptIndex); QmltcCodeGenerator::generate_callExecuteRuntimeFunction( - &slotMethod.body, m_urlMethodName + u"()", runtimeIndex, u"this"_qs, signalReturnType); + &slotMethod.body, m_urlMethodName + u"()", runtimeIndex, u"this"_s, signalReturnType); slotMethod.type = QQmlJSMetaMethod::Slot; // TODO: there's actually an attached type, which has completed/destruction // signals that are typically emitted -- do we care enough about supporting // that? see QQmlComponentAttached - if (signalName == u"completed"_qs) { + if (signalName == u"completed"_s) { current.handleOnCompleted.body << slotName + u"();"; - } else if (signalName == u"destruction"_qs) { + } else if (signalName == u"destruction"_s) { if (!current.dtor) { // TODO: double-check that this stuff is actually correct now: current.dtor = QmltcDtor {}; diff --git a/tools/qmltc/prototype/qml2cppdefaultpasses.cpp b/tools/qmltc/prototype/qml2cppdefaultpasses.cpp index f0c2c3349c..ff7b8b12e8 100644 --- a/tools/qmltc/prototype/qml2cppdefaultpasses.cpp +++ b/tools/qmltc/prototype/qml2cppdefaultpasses.cpp @@ -37,103 +37,105 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static QString const cppKeywords[] = { - u"alignas"_qs, - u"alignof"_qs, - u"and"_qs, - u"and_eq"_qs, - u"asm"_qs, - u"atomic_cancel"_qs, - u"atomic_commit"_qs, - u"atomic_noexcept"_qs, - u"auto"_qs, - u"bitand"_qs, - u"bitor"_qs, - u"bool"_qs, - u"break"_qs, - u"case"_qs, - u"catch"_qs, - u"char"_qs, - u"char8_t"_qs, - u"char16_t"_qs, - u"char32_t"_qs, - u"class"_qs, - u"compl"_qs, - u"concept"_qs, - u"const"_qs, - u"consteval"_qs, - u"constexpr"_qs, - u"const_cast"_qs, - u"continue"_qs, - u"co_await"_qs, - u"co_return"_qs, - u"co_yield"_qs, - u"decltype"_qs, - u"default"_qs, - u"delete"_qs, - u"do"_qs, - u"double"_qs, - u"dynamic_cast"_qs, - u"else"_qs, - u"enum"_qs, - u"explicit"_qs, - u"export"_qs, - u"extern"_qs, - u"false"_qs, - u"float"_qs, - u"for"_qs, - u"friend"_qs, - u"goto"_qs, - u"if"_qs, - u"inline"_qs, - u"int"_qs, - u"long"_qs, - u"mutable"_qs, - u"namespace"_qs, - u"new"_qs, - u"noexcept"_qs, - u"not"_qs, - u"not_eq"_qs, - u"nullptr"_qs, - u"operator"_qs, - u"or"_qs, - u"or_eq"_qs, - u"private"_qs, - u"protected"_qs, - u"public"_qs, - u"reflexpr"_qs, - u"register"_qs, - u"reinterpret_cast"_qs, - u"requires"_qs, - u"return"_qs, - u"short"_qs, - u"signed"_qs, - u"sizeof"_qs, - u"static"_qs, - u"static_assert"_qs, - u"static_cast"_qs, - u"struct"_qs, - u"switch"_qs, - u"synchronized"_qs, - u"template"_qs, - u"this"_qs, - u"thread_local"_qs, - u"throw"_qs, - u"true"_qs, - u"try"_qs, - u"typedef"_qs, - u"typeid"_qs, - u"typename"_qs, - u"union"_qs, - u"unsigned"_qs, - u"using"_qs, - u"virtual"_qs, - u"void"_qs, - u"volatile"_qs, - u"wchar_t"_qs, - u"while"_qs, - u"xor"_qs, - u"xor_eq"_qs, + u"alignas"_s, + u"alignof"_s, + u"and"_s, + u"and_eq"_s, + u"asm"_s, + u"atomic_cancel"_s, + u"atomic_commit"_s, + u"atomic_noexcept"_s, + u"auto"_s, + u"bitand"_s, + u"bitor"_s, + u"bool"_s, + u"break"_s, + u"case"_s, + u"catch"_s, + u"char"_s, + u"char8_t"_s, + u"char16_t"_s, + u"char32_t"_s, + u"class"_s, + u"compl"_s, + u"concept"_s, + u"const"_s, + u"consteval"_s, + u"constexpr"_s, + u"const_cast"_s, + u"continue"_s, + u"co_await"_s, + u"co_return"_s, + u"co_yield"_s, + u"decltype"_s, + u"default"_s, + u"delete"_s, + u"do"_s, + u"double"_s, + u"dynamic_cast"_s, + u"else"_s, + u"enum"_s, + u"explicit"_s, + u"export"_s, + u"extern"_s, + u"false"_s, + u"float"_s, + u"for"_s, + u"friend"_s, + u"goto"_s, + u"if"_s, + u"inline"_s, + u"int"_s, + u"long"_s, + u"mutable"_s, + u"namespace"_s, + u"new"_s, + u"noexcept"_s, + u"not"_s, + u"not_eq"_s, + u"nullptr"_s, + u"operator"_s, + u"or"_s, + u"or_eq"_s, + u"private"_s, + u"protected"_s, + u"public"_s, + u"reflexpr"_s, + u"register"_s, + u"reinterpret_cast"_s, + u"requires"_s, + u"return"_s, + u"short"_s, + u"signed"_s, + u"sizeof"_s, + u"static"_s, + u"static_assert"_s, + u"static_cast"_s, + u"struct"_s, + u"switch"_s, + u"synchronized"_s, + u"template"_s, + u"this"_s, + u"thread_local"_s, + u"throw"_s, + u"true"_s, + u"try"_s, + u"typedef"_s, + u"typeid"_s, + u"typename"_s, + u"union"_s, + u"unsigned"_s, + u"using"_s, + u"virtual"_s, + u"void"_s, + u"volatile"_s, + u"wchar_t"_s, + u"while"_s, + u"xor"_s, + u"xor_eq"_s, }; static bool isReservedWord(QStringView word) @@ -169,13 +171,13 @@ Q_LOGGING_CATEGORY(lcDefaultPasses, "qml.qmltc.compilerpasses", QtWarningMsg); static bool isComponent(const QQmlJSScope::ConstPtr &type) { auto base = type->baseType(); - return base && base->internalName() == u"QQmlComponent"_qs; + return base && base->internalName() == u"QQmlComponent"_s; } static bool isComponentBased(const QQmlJSScope::ConstPtr &type) { auto base = QQmlJSScope::nonCompositeBaseType(type); - return base && base->internalName() == u"QQmlComponent"_qs; + return base && base->internalName() == u"QQmlComponent"_s; } static QString findPropertyName(const Qml2CppContext &context, const QQmlJSScope::ConstPtr &type, @@ -199,7 +201,7 @@ void verifyTypes(const Qml2CppContext &context, QList<Qml2CppObject> &objects) // TODO: this whole verify function is a mess Q_ASSERT(!property.isAlias()); if (property.propertyName().isEmpty()) - context.recordError(irObject->location, u"Property with unknown name found"_qs); + context.recordError(irObject->location, u"Property with unknown name found"_s); const auto type = property.type(); if (type) @@ -222,7 +224,7 @@ void verifyTypes(const Qml2CppContext &context, QList<Qml2CppObject> &objects) const QQmlJSScope::ConstPtr &objectType) { Q_ASSERT(alias.isAlias()); if (alias.propertyName().isEmpty()) { - context.recordError(irObject->location, u"Property alias with unknown name found"_qs); + context.recordError(irObject->location, u"Property alias with unknown name found"_s); return; } @@ -230,7 +232,7 @@ void verifyTypes(const Qml2CppContext &context, QList<Qml2CppObject> &objects) irObject->aliasesEnd(), alias.propertyName()); QStringList aliasExprBits = alias.aliasExpression().split(u'.'); if (aliasExprBits.isEmpty()) { - context.recordError(loc, u"Alias expression is invalid"_qs); + context.recordError(loc, u"Alias expression is invalid"_s); return; } @@ -242,7 +244,7 @@ void verifyTypes(const Qml2CppContext &context, QList<Qml2CppObject> &objects) aliasExprBits.removeFirst(); for (const QString &bit : qAsConst(aliasExprBits)) { if (bit.isEmpty()) { - context.recordError(loc, u"Alias expression contains empty piece"_qs); + context.recordError(loc, u"Alias expression contains empty piece"_s); break; } // TODO: we might need some better location, but this is not @@ -280,7 +282,7 @@ void verifyTypes(const Qml2CppContext &context, QList<Qml2CppObject> &objects) // it's an error here if (propName.isEmpty()) { context.recordError(binding.location, - u"Cannot assign to non-existent default property"_qs); + u"Cannot assign to non-existent default property"_s); return; } @@ -325,7 +327,7 @@ void verifyTypes(const Qml2CppContext &context, QList<Qml2CppObject> &objects) const auto [irObject, type] = object; Q_ASSERT(irObject && type); // assume verified if (!type->baseType()) { // base class exists - context.recordError(type->sourceLocation(), u"QML type has undefined base type"_qs); + context.recordError(type->sourceLocation(), u"QML type has undefined base type"_s); // not critical for type verification, so do not break the iteration } @@ -337,7 +339,7 @@ void verifyTypes(const Qml2CppContext &context, QList<Qml2CppObject> &objects) #if 0 context.recordError(type->sourceLocation(), - u"QML type of this kind is not supported (QML_CUSTOMPARSER)"_qs); + u"QML type of this kind is not supported (QML_CUSTOMPARSER)"_s); continue; #else // do silent error only because QQmlListModel is affected as well @@ -410,7 +412,7 @@ static void checkObjectStringsForCollisions(const Qml2CppContext &context, name); return irEnum.location; }; - isValidName(name, getEnumLocation, u"Enumeration"_qs, uniqueSymbols); + isValidName(name, getEnumLocation, u"Enumeration"_s, uniqueSymbols); const auto enumKeys = e.keys(); for (const auto &key : enumKeys) { @@ -419,7 +421,7 @@ static void checkObjectStringsForCollisions(const Qml2CppContext &context, irEnum.enumValuesEnd(), key); }; // no support for enum classes: each key is visible outside of enum - isValidName(key, getEnumKeyLocation, u"Enumeration key"_qs, uniqueSymbols); + isValidName(key, getEnumKeyLocation, u"Enumeration key"_s, uniqueSymbols); } } @@ -428,7 +430,7 @@ static void checkObjectStringsForCollisions(const Qml2CppContext &context, const QQmlJSMetaProperty &p = it.value(); QStringView name = p.propertyName(); const auto getPropertyLocation = [&]() { return p.type()->sourceLocation(); }; - isValidName(name, getPropertyLocation, u"Property"_qs, uniqueSymbols); + isValidName(name, getPropertyLocation, u"Property"_s, uniqueSymbols); } const auto methods = type->ownMethods(); @@ -436,7 +438,7 @@ static void checkObjectStringsForCollisions(const Qml2CppContext &context, const QQmlJSMetaMethod &m = it.value(); QStringView name = m.methodName(); const auto getMethodLocation = [&]() { return m.returnType()->sourceLocation(); }; - isValidName(name, getMethodLocation, u"Method"_qs, uniqueSymbols); + isValidName(name, getMethodLocation, u"Method"_s, uniqueSymbols); const auto parameterNames = m.parameterNames(); QSet<QStringView> uniqueParameters; // parameters can shadow @@ -446,7 +448,7 @@ static void checkObjectStringsForCollisions(const Qml2CppContext &context, static auto paramTypes = m.parameterTypes(); return paramTypes.at(i)->sourceLocation(); }; - isValidName(paramName, getParamLocation, u"Parameter"_qs, uniqueParameters); + isValidName(paramName, getParamLocation, u"Parameter"_s, uniqueParameters); } } } @@ -519,7 +521,7 @@ QHash<QString, qsizetype> makeUniqueCppNames(const Qml2CppContext &context, return typeCounts; } if (cppName.isEmpty()) { - context.recordError(root->sourceLocation(), u"Root object's name is empty"_qs); + context.recordError(root->sourceLocation(), u"Root object's name is empty"_s); return typeCounts; } typeCounts.insert(cppName, 1); @@ -533,21 +535,21 @@ static void setupQmlCppType(const Qml2CppContext &context, const QQmlJSScope::Pt { Q_ASSERT(type); if (filePath.isEmpty()) { - context.recordError(type->sourceLocation(), u"QML type has unknown file path"_qs); + context.recordError(type->sourceLocation(), u"QML type has unknown file path"_s); return; } if (type->filePath().endsWith(u".h")) // consider this one to be already set up return; - if (!filePath.endsWith(u".qml"_qs)) { + if (!filePath.endsWith(u".qml"_s)) { context.recordError(type->sourceLocation(), - u"QML type has non-QML origin (internal error)"_qs); + u"QML type has non-QML origin (internal error)"_s); return; } // TODO: this does not cover QT_QMLTC_FILE_BASENAME renaming if (filePath != context.documentUrl) { // this file name will be discovered during findCppIncludes - type->setFilePath(QFileInfo(filePath).baseName().toLower() + u".h"_qs); + type->setFilePath(QFileInfo(filePath).baseName().toLower() + u".h"_s); } const auto properties = type->ownProperties(); @@ -587,7 +589,7 @@ QSet<QString> setupQmlCppTypes(const Qml2CppContext &context, QList<Qml2CppObjec auto pair = context.typeResolver->importedType(base); if (pair.first.isEmpty()) { context.recordError(object.type->sourceLocation(), - u"QML base type has unknown origin. Do you miss an import?"_qs); + u"QML base type has unknown origin. Do you miss an import?"_s); continue; } @@ -797,8 +799,8 @@ static void populateCppIncludes(QSet<QString> &cppIncludes, const QQmlJSScope::C const auto constructPrivateInclude = [](QStringView publicInclude) -> QString { if (publicInclude.isEmpty()) return QString(); - Q_ASSERT(publicInclude.endsWith(u".h"_qs) || publicInclude.endsWith(u".hpp"_qs)); - const qsizetype dotLocation = publicInclude.endsWith(u".h"_qs) ? publicInclude.size() - 2 + Q_ASSERT(publicInclude.endsWith(u".h"_s) || publicInclude.endsWith(u".hpp"_s)); + const qsizetype dotLocation = publicInclude.endsWith(u".h"_s) ? publicInclude.size() - 2 : publicInclude.size() - 4; QStringView extension = publicInclude.sliced(dotLocation); QStringView includeWithoutExtension = publicInclude.first(dotLocation); @@ -905,7 +907,7 @@ static void updateImplicitComponents(const Qml2CppContext &context, Qml2CppObjec // NB: in case property is a QQmlComponent, we need to handle it // specially - if (p.type()->internalName() == u"QQmlComponent"_qs) { + if (p.type()->internalName() == u"QQmlComponent"_s) { // if it's an implicit component, call update function Q_ASSERT(binding.value.objectIndex < objects.size()); update(objects[binding.value.objectIndex], binding.value.objectIndex); @@ -984,7 +986,7 @@ static void setObjectId(const Qml2CppContext &context, const QList<Qml2CppObject if (irObject->idNameIndex != 0) { if (idToObjectIndex.contains(irObject->idNameIndex)) { - context.recordError(irObject->location, u"Object id is not unique"_qs); + context.recordError(irObject->location, u"Object id is not unique"_s); return; } irObject->id = int(idToObjectIndex.size()); diff --git a/tools/qmltc/qmltccodewriter.cpp b/tools/qmltc/qmltccodewriter.cpp index a46ee60444..946ac8a735 100644 --- a/tools/qmltc/qmltccodewriter.cpp +++ b/tools/qmltc/qmltccodewriter.cpp @@ -38,6 +38,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static QString urlToMacro(const QString &url) { QFileInfo fi(url); @@ -49,13 +51,13 @@ static QString getFunctionCategory(const QmltcMethodBase &method) QString category; switch (method.access) { case QQmlJSMetaMethod::Private: - category = u"private"_qs; + category = u"private"_s; break; case QQmlJSMetaMethod::Protected: - category = u"protected"_qs; + category = u"protected"_s; break; case QQmlJSMetaMethod::Public: - category = u"public"_qs; + category = u"public"_s; break; } return category; @@ -66,10 +68,10 @@ static QString getFunctionCategory(const QmltcMethod &method) QString category = getFunctionCategory(static_cast<const QmltcMethodBase &>(method)); switch (method.type) { case QQmlJSMetaMethod::Signal: - category = u"Q_SIGNALS"_qs; + category = u"Q_SIGNALS"_s; break; case QQmlJSMetaMethod::Slot: - category += u" Q_SLOTS"_qs; + category += u" Q_SLOTS"_s; break; case QQmlJSMetaMethod::Method: break; @@ -106,16 +108,16 @@ static std::pair<QString, QString> functionSignatures(const QmltcMethodBase &met headerParamList.back() += u" = " + variable.defaultValue; } - const QString headerSignature = name + u"(" + headerParamList.join(u", "_qs) + u")" + const QString headerSignature = name + u"(" + headerParamList.join(u", "_s) + u")" + prependSpace(method.modifiers.join(u" ")); - const QString cppSignature = name + u"(" + cppParamList.join(u", "_qs) + u")" + const QString cppSignature = name + u"(" + cppParamList.join(u", "_s) + u")" + prependSpace(method.modifiers.join(u" ")); return { headerSignature, cppSignature }; } static QString functionReturnType(const QmltcMethod &m) { - return appendSpace(m.declarationPrefixes.join(u" "_qs)) + m.returnType; + return appendSpace(m.declarationPrefixes.join(u" "_s)) + m.returnType; } void QmltcCodeWriter::writeGlobalHeader(QmltcOutputWrapper &code, const QString &sourcePath, @@ -134,8 +136,8 @@ void QmltcCodeWriter::writeGlobalHeader(QmltcOutputWrapper &code, const QString u"// It may change from version to version and should not be relied upon."); const QString headerMacro = urlToMacro(sourcePath); - code.rawAppendToHeader(u"#ifndef %1_H"_qs.arg(headerMacro)); - code.rawAppendToHeader(u"#define %1_H"_qs.arg(headerMacro)); + code.rawAppendToHeader(u"#ifndef %1_H"_s.arg(headerMacro)); + code.rawAppendToHeader(u"#define %1_H"_s.arg(headerMacro)); code.rawAppendToHeader(u"#include <QtCore/qproperty.h>"); code.rawAppendToHeader(u"#include <QtCore/qobject.h>"); @@ -171,9 +173,9 @@ void QmltcCodeWriter::writeGlobalHeader(QmltcOutputWrapper &code, const QString code.rawAppendToCpp(u"QT_USE_NAMESPACE // avoid issues with QT_NAMESPACE"); if (!outNamespace.isEmpty()) { code.rawAppendToHeader(u""); // blank line - code.rawAppendToHeader(u"namespace %1 {"_qs.arg(outNamespace)); + code.rawAppendToHeader(u"namespace %1 {"_s.arg(outNamespace)); code.rawAppendToCpp(u""); // blank line - code.rawAppendToCpp(u"namespace %1 {"_qs.arg(outNamespace)); + code.rawAppendToCpp(u"namespace %1 {"_s.arg(outNamespace)); } } @@ -181,13 +183,13 @@ void QmltcCodeWriter::writeGlobalFooter(QmltcOutputWrapper &code, const QString const QString &outNamespace) { if (!outNamespace.isEmpty()) { - code.rawAppendToCpp(u"} // namespace %1"_qs.arg(outNamespace)); + code.rawAppendToCpp(u"} // namespace %1"_s.arg(outNamespace)); code.rawAppendToCpp(u""); // blank line - code.rawAppendToHeader(u"} // namespace %1"_qs.arg(outNamespace)); + code.rawAppendToHeader(u"} // namespace %1"_s.arg(outNamespace)); code.rawAppendToHeader(u""); // blank line } - code.rawAppendToHeader(u"#endif // %1_H"_qs.arg(urlToMacro(sourcePath))); + code.rawAppendToHeader(u"#endif // %1_H"_s.arg(urlToMacro(sourcePath))); code.rawAppendToHeader(u""); // blank line } @@ -234,8 +236,8 @@ void QmltcCodeWriter::write(QmltcOutputWrapper &code, const QmltcProgram &progra if (!type.typeCount) continue; code.rawAppendToHeader(u""); // blank line - code.rawAppendToHeader(u"constexpr %1 %2::%3()"_qs.arg(type.typeCount->returnType, - type.cppType, type.typeCount->name)); + code.rawAppendToHeader(u"constexpr %1 %2::%3()"_s.arg(type.typeCount->returnType, + type.cppType, type.typeCount->name)); code.rawAppendToHeader(u"{"); for (const QString &line : qAsConst(type.typeCount->body)) code.rawAppendToHeader(line, 1); @@ -277,7 +279,7 @@ void QmltcCodeWriter::write(QmltcOutputWrapper &code, const QmltcType &type) std::back_inserter(nonEmptyBaseClasses), [](const QString &entry) { return !entry.isEmpty(); }); if (!nonEmptyBaseClasses.isEmpty()) - str += u" : public " + nonEmptyBaseClasses.join(u", public "_qs); + str += u" : public " + nonEmptyBaseClasses.join(u", public "_s); return str; }; @@ -377,8 +379,8 @@ void QmltcCodeWriter::write(QmltcOutputWrapper &code, const QmltcType &type) // add typeCount declaration, definition is added later code.rawAppendToHeader(u""); // blank line code.rawAppendToHeader(u"protected:"); - code.rawAppendToHeader(u"constexpr static %1 %2();"_qs.arg(type.typeCount->returnType, - type.typeCount->name), + code.rawAppendToHeader(u"constexpr static %1 %2();"_s.arg(type.typeCount->returnType, + type.typeCount->name), 1); } @@ -454,7 +456,7 @@ void QmltcCodeWriter::write(QmltcOutputWrapper &code, const QmltcCtor &ctor) code.rawAppendToCpp(u":", 1); // double \n to make separate initializer list lines stand out more code.rawAppendToCpp( - ctor.initializerList.join(u",\n\n" + u" "_qs.repeated(code.cppIndent + 1)), + ctor.initializerList.join(u",\n\n" + u" "_s.repeated(code.cppIndent + 1)), 1); } }; @@ -470,14 +472,14 @@ void QmltcCodeWriter::write(QmltcOutputWrapper &code, const QmltcDtor &dtor) void QmltcCodeWriter::write(QmltcOutputWrapper &code, const QmltcVariable &var) { - const QString optionalPart = var.defaultValue.isEmpty() ? u""_qs : u" = " + var.defaultValue; + const QString optionalPart = var.defaultValue.isEmpty() ? u""_s : u" = " + var.defaultValue; code.rawAppendToHeader(var.cppType + u" " + var.name + optionalPart + u";"); } void QmltcCodeWriter::write(QmltcOutputWrapper &code, const QmltcProperty &prop) { Q_ASSERT(prop.defaultValue.isEmpty()); // we don't support it yet (or at all?) - code.rawAppendToHeader(u"Q_OBJECT_BINDABLE_PROPERTY(%1, %2, %3, &%1::%4)"_qs.arg( + code.rawAppendToHeader(u"Q_OBJECT_BINDABLE_PROPERTY(%1, %2, %3, &%1::%4)"_s.arg( prop.containingClass, prop.cppType, prop.name, prop.signalName)); } diff --git a/tools/qmltc/qmltccompiler.cpp b/tools/qmltc/qmltccompiler.cpp index 94325e939f..52d913dfe5 100644 --- a/tools/qmltc/qmltccompiler.cpp +++ b/tools/qmltc/qmltccompiler.cpp @@ -41,10 +41,12 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_LOGGING_CATEGORY(lcQmltcCompiler, "qml.qmltc.compiler", QtWarningMsg); -const QString QmltcCodeGenerator::privateEngineName = u"ePriv"_qs; -const QString QmltcCodeGenerator::typeCountName = u"q_qmltc_typeCount"_qs; +const QString QmltcCodeGenerator::privateEngineName = u"ePriv"_s; +const QString QmltcCodeGenerator::typeCountName = u"q_qmltc_typeCount"_s; QmltcCompiler::QmltcCompiler(const QString &url, QmltcTypeResolver *resolver, QmltcVisitor *visitor, QQmlJSLogger *logger) @@ -75,7 +77,7 @@ void QmltcCompiler::compile(const QmltcCompilerInfo &info, QmlIR::Document *doc) const auto isComponent = [](const QQmlJSScope::ConstPtr &type) { auto base = type->baseType(); - return base && base->internalName() == u"QQmlComponent"_qs; + return base && base->internalName() == u"QQmlComponent"_s; }; // Note: we only compile "pure" QML types. any component-wrapped type is @@ -139,11 +141,11 @@ void QmltcCompiler::compile(const QmltcCompilerInfo &info, QmlIR::Document *doc) void QmltcCompiler::compileUrlMethod(QmltcMethod &urlMethod, const QString &urlMethodName) { urlMethod.name = urlMethodName; - urlMethod.returnType = u"const QUrl&"_qs; - urlMethod.body << u"static QUrl url {QStringLiteral(\"qrc:%1\")};"_qs.arg(m_info.resourcePath); - urlMethod.body << u"return url;"_qs; - urlMethod.declarationPrefixes << u"static"_qs; - urlMethod.modifiers << u"noexcept"_qs; + urlMethod.returnType = u"const QUrl&"_s; + urlMethod.body << u"static QUrl url {QStringLiteral(\"qrc:%1\")};"_s.arg(m_info.resourcePath); + urlMethod.body << u"return url;"_s; + urlMethod.declarationPrefixes << u"static"_s; + urlMethod.modifiers << u"noexcept"_s; } void QmltcCompiler::compileType( @@ -151,7 +153,7 @@ void QmltcCompiler::compileType( std::function<void(QmltcType &, const QQmlJSScope::ConstPtr &)> compileElements) { if (type->isSingleton()) { - recordError(type->sourceLocation(), u"Singleton types are not supported"_qs); + recordError(type->sourceLocation(), u"Singleton types are not supported"_s); return; } @@ -179,7 +181,7 @@ void QmltcCompiler::compileType( current.baseClasses = { baseClass }; if (!documentRoot) { // make document root a friend to allow it to access init and endInit - current.otherCode << u"friend class %1;"_qs.arg(rootType->internalName()); + current.otherCode << u"friend class %1;"_s.arg(rootType->internalName()); // additionally make an immediate parent a friend since that parent // would create the object through a non-public constructor @@ -188,28 +190,28 @@ void QmltcCompiler::compileType( return scope->parentScope(); return scope; }; - current.otherCode << u"friend class %1;"_qs.arg( + current.otherCode << u"friend class %1;"_s.arg( realQmlScope(type->parentScope())->internalName()); } else { // make QQmltcObjectCreationBase<DocumentRoot> a friend to allow it to // be created for the root object - current.otherCode << u"friend class QQmltcObjectCreationBase<%1>;"_qs.arg( + current.otherCode << u"friend class QQmltcObjectCreationBase<%1>;"_s.arg( rootType->internalName()); QmltcMethod typeCountMethod; typeCountMethod.name = QmltcCodeGenerator::typeCountName; - typeCountMethod.returnType = u"uint"_qs; + typeCountMethod.returnType = u"uint"_s; typeCountMethod.body << u"return " + generator.generate_typeCount() + u";"; current.typeCount = typeCountMethod; } // make QQmltcObjectCreationHelper a friend of every type since it provides // useful helper methods for all types - current.otherCode << u"friend class QT_PREPEND_NAMESPACE(QQmltcObjectCreationHelper);"_qs; + current.otherCode << u"friend class QT_PREPEND_NAMESPACE(QQmltcObjectCreationHelper);"_s; current.mocCode = { - u"Q_OBJECT"_qs, + u"Q_OBJECT"_s, // Note: isAnonymous holds for non-root types in the document as well - isAnonymous ? u"QML_ANONYMOUS"_qs : u"QML_ELEMENT"_qs, + isAnonymous ? u"QML_ANONYMOUS"_s : u"QML_ELEMENT"_s, }; // add special member functions @@ -228,23 +230,23 @@ void QmltcCompiler::compileType( current.baselineCtor.name = current.cppType; current.externalCtor.name = current.cppType; - current.init.name = u"QML_init"_qs; - current.init.returnType = u"QQmlRefPointer<QQmlContextData>"_qs; - current.beginClass.name = u"QML_beginClass"_qs; - current.beginClass.returnType = u"void"_qs; - current.endInit.name = u"QML_endInit"_qs; - current.endInit.returnType = u"void"_qs; - current.completeComponent.name = u"QML_completeComponent"_qs; - current.completeComponent.returnType = u"void"_qs; - current.finalizeComponent.name = u"QML_finalizeComponent"_qs; - current.finalizeComponent.returnType = u"void"_qs; - current.handleOnCompleted.name = u"QML_handleOnCompleted"_qs; - current.handleOnCompleted.returnType = u"void"_qs; - QmltcVariable creator(u"QQmltcObjectCreationHelper*"_qs, u"creator"_qs); - QmltcVariable engine(u"QQmlEngine*"_qs, u"engine"_qs); - QmltcVariable parent(u"QObject*"_qs, u"parent"_qs, u"nullptr"_qs); - QmltcVariable ctxtdata(u"const QQmlRefPointer<QQmlContextData>&"_qs, u"parentContext"_qs); - QmltcVariable finalizeFlag(u"bool"_qs, u"canFinalize"_qs); + current.init.name = u"QML_init"_s; + current.init.returnType = u"QQmlRefPointer<QQmlContextData>"_s; + current.beginClass.name = u"QML_beginClass"_s; + current.beginClass.returnType = u"void"_s; + current.endInit.name = u"QML_endInit"_s; + current.endInit.returnType = u"void"_s; + current.completeComponent.name = u"QML_completeComponent"_s; + current.completeComponent.returnType = u"void"_s; + current.finalizeComponent.name = u"QML_finalizeComponent"_s; + current.finalizeComponent.returnType = u"void"_s; + current.handleOnCompleted.name = u"QML_handleOnCompleted"_s; + current.handleOnCompleted.returnType = u"void"_s; + QmltcVariable creator(u"QQmltcObjectCreationHelper*"_s, u"creator"_s); + QmltcVariable engine(u"QQmlEngine*"_s, u"engine"_s); + QmltcVariable parent(u"QObject*"_s, u"parent"_s, u"nullptr"_s); + QmltcVariable ctxtdata(u"const QQmlRefPointer<QQmlContextData>&"_s, u"parentContext"_s); + QmltcVariable finalizeFlag(u"bool"_s, u"canFinalize"_s); current.baselineCtor.parameterList = { parent }; if (documentRoot) { current.externalCtor.parameterList = { engine, parent }; @@ -277,26 +279,26 @@ void QmltcCompiler::compileType( } // compilation stub: - current.externalCtor.body << u"Q_UNUSED(engine);"_qs; - current.endInit.body << u"Q_UNUSED(engine);"_qs; - current.endInit.body << u"Q_UNUSED(creator);"_qs; + current.externalCtor.body << u"Q_UNUSED(engine);"_s; + current.endInit.body << u"Q_UNUSED(engine);"_s; + current.endInit.body << u"Q_UNUSED(creator);"_s; if (documentRoot) { - current.externalCtor.body << u"// document root:"_qs; + current.externalCtor.body << u"// document root:"_s; // if it's document root, we want to create our QQmltcObjectCreationBase // that would store all the created objects - current.externalCtor.body << u"QQmltcObjectCreationBase<%1> objectHolder;"_qs.arg( + current.externalCtor.body << u"QQmltcObjectCreationBase<%1> objectHolder;"_s.arg( type->internalName()); current.externalCtor.body - << u"QQmltcObjectCreationHelper creator = objectHolder.view();"_qs; - current.externalCtor.body << u"creator.set(0, this);"_qs; // special case + << u"QQmltcObjectCreationHelper creator = objectHolder.view();"_s; + current.externalCtor.body << u"creator.set(0, this);"_s; // special case // now call init current.externalCtor.body << current.init.name + u"(&creator, engine, QQmlContextData::get(engine->rootContext()), /* " u"endInit */ true);"; - current.endInit.body << u"Q_UNUSED(canFinalize);"_qs; + current.endInit.body << u"Q_UNUSED(canFinalize);"_s; } else { - current.externalCtor.body << u"// not document root:"_qs; + current.externalCtor.body << u"// not document root:"_s; // just call init, we don't do any setup here otherwise current.externalCtor.body << current.init.name + u"(creator, engine, QQmlData::get(parent)->outerContext);"; @@ -338,7 +340,7 @@ void QmltcCompiler::compileTypeElements(QmltcType ¤t, const QQmlJSScope::C for (const QQmlJSMetaProperty &p : qAsConst(properties)) { if (p.index() == -1) { recordError(type->sourceLocation(), - u"Internal error: property '%1' has incomplete information"_qs.arg( + u"Internal error: property '%1' has incomplete information"_s.arg( p.propertyName())); continue; } @@ -364,12 +366,12 @@ void QmltcCompiler::compileTypeElements(QmltcType ¤t, const QQmlJSScope::C auto it = sortedBindings.cbegin(); for (; it != scriptBindingsBegin; ++it) { m_prototypeCodegen->compileBinding(current, **it, object, - { object.type, u"this"_qs, u""_qs, false }); + { object.type, u"this"_s, u""_s, false }); } for (; it != sortedBindings.cend(); ++it) { m_prototypeCodegen->compileBinding(current, **it, object, - { type, u"this"_qs, u""_qs, false }); + { type, u"this"_s, u""_s, false }); } } } @@ -384,7 +386,7 @@ void QmltcCompiler::compileEnum(QmltcType ¤t, const QQmlJSMetaEnum &e) // structure: (C++ type name, enum keys, enum values, MOC line) current.enums.emplaceBack(e.name(), e.keys(), std::move(values), - u"Q_ENUM(%1)"_qs.arg(e.name())); + u"Q_ENUM(%1)"_s.arg(e.name())); } static QList<QmltcVariable> @@ -415,7 +417,7 @@ void QmltcCompiler::compileMethod(QmltcType ¤t, const QQmlJSMetaMethod &m, Q_ASSERT(isVoidMethod || m.returnType()); QString type; if (isVoidMethod) { - type = u"void"_qs; + type = u"void"_s; } else { type = m.returnType()->augmentedInternalName(); } @@ -436,7 +438,7 @@ void QmltcCompiler::compileMethod(QmltcType ¤t, const QQmlJSMetaMethod &m, Q_ASSERT(index >= 0); QmltcCodeGenerator urlGenerator { m_url, m_visitor }; QmltcCodeGenerator::generate_callExecuteRuntimeFunction( - &code, urlGenerator.urlMethodName() + u"()", index, u"this"_qs, returnType, + &code, urlGenerator.urlMethodName() + u"()", index, u"this"_s, returnType, compiledParams); } @@ -448,7 +450,7 @@ void QmltcCompiler::compileMethod(QmltcType ¤t, const QQmlJSMetaMethod &m, compiled.type = methodType; compiled.access = m.access(); if (methodType != QQmlJSMetaMethod::Signal) { - compiled.declarationPrefixes << u"Q_INVOKABLE"_qs; + compiled.declarationPrefixes << u"Q_INVOKABLE"_s; compiled.userVisible = m.access() == QQmlJSMetaMethod::Public; } else { compiled.userVisible = !m.isImplicitQmlPropertyChangeSignal(); @@ -489,16 +491,16 @@ void QmltcCompiler::compileProperty(QmltcType ¤t, const QQmlJSMetaProperty // the QQmlListProperty object retrieved with the getter. Setting it would make no sense. if (p.isWritable() && !p.isList()) { QmltcMethod setter {}; - setter.returnType = u"void"_qs; + setter.returnType = u"void"_s; setter.name = compilationData.write; // QmltcVariable setter.parameterList.emplaceBack(QQmlJSUtils::constRefify(underlyingType), name + u"_", - u""_qs); + u""_s); setter.body << variableName + u".setValue(" + name + u"_);"; setter.body << u"Q_EMIT " + compilationData.notify + u"();"; setter.userVisible = true; current.functions.emplaceBack(setter); - mocPieces << u"WRITE"_qs << setter.name; + mocPieces << u"WRITE"_s << setter.name; } QmltcMethod getter {}; @@ -507,7 +509,7 @@ void QmltcCompiler::compileProperty(QmltcType ¤t, const QQmlJSMetaProperty getter.body << u"return " + variableName + u".value();"; getter.userVisible = true; current.functions.emplaceBack(getter); - mocPieces << u"READ"_qs << getter.name; + mocPieces << u"READ"_s << getter.name; // 2. add bindable if (!p.isList()) { @@ -518,21 +520,21 @@ void QmltcCompiler::compileProperty(QmltcType ¤t, const QQmlJSMetaProperty + u"));"; bindable.userVisible = true; current.functions.emplaceBack(bindable); - mocPieces << u"BINDABLE"_qs << bindable.name; + mocPieces << u"BINDABLE"_s << bindable.name; } // 3. add/check notify (actually, this is already done inside QmltcVisitor) if (owner->isPropertyRequired(name)) - mocPieces << u"REQUIRED"_qs; + mocPieces << u"REQUIRED"_s; // 4. add moc entry // e.g. Q_PROPERTY(QString p READ getP WRITE setP BINDABLE bindableP) - current.mocCode << u"Q_PROPERTY(" + mocPieces.join(u" "_qs) + u")"; + current.mocCode << u"Q_PROPERTY(" + mocPieces.join(u" "_s) + u")"; // 5. add extra moc entry if this property is marked default if (name == owner->defaultPropertyName()) - current.mocCode << u"Q_CLASSINFO(\"DefaultProperty\", \"%1\")"_qs.arg(name); + current.mocCode << u"Q_CLASSINFO(\"DefaultProperty\", \"%1\")"_s.arg(name); // structure: (C++ type name, name, C++ class name, C++ signal name) current.properties.emplaceBack(underlyingType, variableName, current.cppType, @@ -569,7 +571,7 @@ void QmltcCompiler::compileBinding(QmltcType ¤t, const QQmlJSMetaPropertyB case QQmlJSMetaPropertyBinding::BoolLiteral: { const bool value = binding.boolValue(); generator.generate_assignToProperty(¤t.init.body, type, p, - value ? u"true"_qs : u"false"_qs, accessor.name); + value ? u"true"_s : u"false"_s, accessor.name); break; } case QQmlJSMetaPropertyBinding::NumberLiteral: { @@ -589,13 +591,13 @@ void QmltcCompiler::compileBinding(QmltcType ¤t, const QQmlJSMetaPropertyB && propertyType->accessSemantics() != QQmlJSScope::AccessSemantics::Reference) { // TODO: this should really be done before the compiler here recordError(binding.sourceLocation(), - u"Cannot assign null to incompatible property"_qs); + u"Cannot assign null to incompatible property"_s); } else if (propertyType->accessSemantics() == QQmlJSScope::AccessSemantics::Reference) { - generator.generate_assignToProperty(¤t.init.body, type, p, u"nullptr"_qs, + generator.generate_assignToProperty(¤t.init.body, type, p, u"nullptr"_s, accessor.name); } else { generator.generate_assignToProperty(¤t.init.body, type, p, - u"QVariant::fromValue(nullptr)"_qs, accessor.name); + u"QVariant::fromValue(nullptr)"_s, accessor.name); } break; } @@ -609,11 +611,11 @@ void QmltcCompiler::compileBinding(QmltcType ¤t, const QQmlJSMetaPropertyB // case QQmlJSMetaPropertyBinding::AttachedProperty: // case QQmlJSMetaPropertyBinding::GroupProperty: case QQmlJSMetaPropertyBinding::Invalid: { - m_logger->log(u"This binding is invalid"_qs, Log_Compiler, binding.sourceLocation()); + m_logger->log(u"This binding is invalid"_s, Log_Compiler, binding.sourceLocation()); break; } default: { - m_logger->log(u"Binding type is not supported (yet)"_qs, Log_Compiler, + m_logger->log(u"Binding type is not supported (yet)"_s, Log_Compiler, binding.sourceLocation()); break; } diff --git a/tools/qmltc/qmltccompiler.h b/tools/qmltc/qmltccompiler.h index 9318420ea5..0cef51f064 100644 --- a/tools/qmltc/qmltccompiler.h +++ b/tools/qmltc/qmltccompiler.h @@ -94,7 +94,7 @@ private: struct BindingAccessorData { QQmlJSScope::ConstPtr scope; // usually the current type - QString name = u"this"_qs; + QString name = QStringLiteral("this"); QString propertyName = QString(); bool isValueType = false; }; diff --git a/tools/qmltc/qmltccompilerpieces.cpp b/tools/qmltc/qmltccompilerpieces.cpp index 35e4e49295..d7ccd7cbf0 100644 --- a/tools/qmltc/qmltccompilerpieces.cpp +++ b/tools/qmltc/qmltccompilerpieces.cpp @@ -34,6 +34,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + void QmltcCodeGenerator::generate_assignToProperty(QStringList *block, const QQmlJSScope::ConstPtr &type, const QQmlJSMetaProperty &p, @@ -52,7 +54,7 @@ void QmltcCodeGenerator::generate_assignToProperty(QStringList *block, auto [prologue, wrappedValue, epilogue] = QmltcCodeGenerator::wrap_mismatchingTypeConversion(p, value); *block += prologue; - *block << u"%1->m_%2 = %3;"_qs.arg(accessor, propertyName, wrappedValue); + *block << u"%1->m_%2 = %3;"_s.arg(accessor, propertyName, wrappedValue); *block += epilogue; } else if (QString propertySetter = p.write(); !propertySetter.isEmpty()) { // there's a WRITE function @@ -64,7 +66,7 @@ void QmltcCodeGenerator::generate_assignToProperty(QStringList *block, *block += epilogue; } else { // TODO: we should remove this branch eventually // this property is weird, fallback to `setProperty` - *block << u"{ // couldn't find property setter, so using QObject::setProperty()"_qs; + *block << u"{ // couldn't find property setter, so using QObject::setProperty()"_s; QString val = value; if (constructFromQObject) { const QString variantName = u"var_" + propertyName; @@ -74,7 +76,7 @@ void QmltcCodeGenerator::generate_assignToProperty(QStringList *block, } // NB: setProperty() would handle private properties *block << accessor + u"->setProperty(\"" + propertyName + u"\", " + val + u");"; - *block << u"}"_qs; + *block << u"}"_s; } } @@ -83,7 +85,7 @@ void QmltcCodeGenerator::generate_setIdValue(QStringList *block, const QString & const QString &idString) { Q_ASSERT(index >= 0); - *block << u"%1->setIdValue(%2 /* id: %3 */, %4);"_qs.arg(context, QString::number(index), + *block << u"%1->setIdValue(%2 /* id: %3 */, %4);"_s.arg(context, QString::number(index), idString, accessor); } @@ -95,14 +97,14 @@ void QmltcCodeGenerator::generate_callExecuteRuntimeFunction(QStringList *block, { *block << u"QQmlEnginePrivate *e = QQmlEnginePrivate::get(qmlEngine(" + accessor + u"));"; - const QString returnValueName = u"_ret"_qs; + const QString returnValueName = u"_ret"_s; QStringList args; args.reserve(parameters.size() + 1); QStringList types; types.reserve(parameters.size() + 1); - if (returnType == u"void"_qs) { - args << u"nullptr"_qs; - types << u"QMetaType::fromType<void>()"_qs; + if (returnType == u"void"_s) { + args << u"nullptr"_s; + types << u"QMetaType::fromType<void>()"_s; } else { *block << returnType + u" " + returnValueName + u"{};"; // TYPE _ret{}; args << u"const_cast<void *>(reinterpret_cast<const void *>(std::addressof(" @@ -116,11 +118,11 @@ void QmltcCodeGenerator::generate_callExecuteRuntimeFunction(QStringList *block, types << u"QMetaType::fromType<std::decay_t<" + p.cppType + u">>()"; } - *block << u"void *_a[] = { " + args.join(u", "_qs) + u" };"; - *block << u"QMetaType _t[] = { " + types.join(u", "_qs) + u" };"; + *block << u"void *_a[] = { " + args.join(u", "_s) + u" };"; + *block << u"QMetaType _t[] = { " + types.join(u", "_s) + u" };"; *block << u"e->executeRuntimeFunction(" + url + u", " + QString::number(index) + u", " + accessor + u", " + QString::number(parameters.size()) + u", _a, _t);"; - if (returnType != u"void"_qs) + if (returnType != u"void"_s) *block << u"return " + returnValueName + u";"; } @@ -165,20 +167,20 @@ QmltcCodeGenerator::wrap_mismatchingTypeConversion(const QQmlJSMetaProperty &p, QStringList prologue; QStringList epilogue; auto propType = p.type(); - if (isDerivedFromBuiltin(propType, u"QVariant"_qs)) { + if (isDerivedFromBuiltin(propType, u"QVariant"_s)) { const QString variantName = u"var_" + p.propertyName(); - prologue << u"{ // accepts QVariant"_qs; + prologue << u"{ // accepts QVariant"_s; prologue << u"QVariant " + variantName + u";"; prologue << variantName + u".setValue(" + value + u");"; - epilogue << u"}"_qs; + epilogue << u"}"_s; value = u"std::move(" + variantName + u")"; - } else if (isDerivedFromBuiltin(propType, u"QJSValue"_qs)) { + } else if (isDerivedFromBuiltin(propType, u"QJSValue"_s)) { const QString jsvalueName = u"jsvalue_" + p.propertyName(); - prologue << u"{ // accepts QJSValue"_qs; + prologue << u"{ // accepts QJSValue"_s; // Note: do not assume we have the engine, acquire it from `this` - prologue << u"auto e = qmlEngine(this);"_qs; + prologue << u"auto e = qmlEngine(this);"_s; prologue << u"QJSValue " + jsvalueName + u" = e->toScriptValue(" + value + u");"; - epilogue << u"}"_qs; + epilogue << u"}"_s; value = u"std::move(" + jsvalueName + u")"; } return { prologue, value, epilogue }; @@ -200,7 +202,7 @@ QString QmltcCodeGenerator::wrap_qOverload(const QList<QmltcVariable> ¶meter types.reserve(parameters.size()); for (const QmltcVariable &p : parameters) types.emplaceBack(p.cppType); - return u"qOverload<" + types.join(u", "_qs) + u">(" + overloaded + u")"; + return u"qOverload<" + types.join(u", "_s) + u">(" + overloaded + u")"; } QString QmltcCodeGenerator::wrap_addressof(const QString &addressed) diff --git a/tools/qmltc/qmltccompilerpieces.h b/tools/qmltc/qmltccompilerpieces.h index a081122b33..282985c30b 100644 --- a/tools/qmltc/qmltccompilerpieces.h +++ b/tools/qmltc/qmltccompilerpieces.h @@ -112,8 +112,9 @@ struct QmltcCodeGenerator QString urlMethodName() const { + using namespace Qt::StringLiterals; QFileInfo fi(documentUrl); - return u"q_qmltc_docUrl_" + fi.fileName().replace(u".qml"_qs, u""_qs).replace(u'.', u'_'); + return u"q_qmltc_docUrl_" + fi.fileName().replace(u".qml"_s, u""_s).replace(u'.', u'_'); } }; @@ -137,6 +138,8 @@ struct QmltcCodeGenerator inline decltype(auto) QmltcCodeGenerator::generate_initCode(QmltcType ¤t, const QQmlJSScope::ConstPtr &type) const { + using namespace Qt::StringLiterals; + // qmltc_init()'s parameters: // * QQmltcObjectCreationHelper* creator // * QQmlEngine* engine @@ -144,9 +147,9 @@ inline decltype(auto) QmltcCodeGenerator::generate_initCode(QmltcType ¤t, // * bool canFinalize [optional, when document root] const bool isDocumentRoot = type == visitor->result(); - current.init.body << u"Q_UNUSED(creator);"_qs; // can happen sometimes + current.init.body << u"Q_UNUSED(creator);"_s; // can happen sometimes - current.init.body << u"auto context = parentContext;"_qs; + current.init.body << u"auto context = parentContext;"_s; // if parent scope has a QML base type and is not a (current) document root, // the parentContext we passed as input to this object is a context of @@ -168,8 +171,8 @@ inline decltype(auto) QmltcCodeGenerator::generate_initCode(QmltcType ¤t, if (auto parentScope = realQmlScope(type->parentScope()); parentScope != visitor->result() && hasQmlBase(parentScope)) { - current.init.body << u"// NB: context->parent() is the context of this document"_qs; - current.init.body << u"context = context->parent();"_qs; + current.init.body << u"// NB: context->parent() is the context of this document"_s; + current.init.body << u"context = context->parent();"_s; } // any object with QML base class has to call base's init method @@ -178,8 +181,8 @@ inline decltype(auto) QmltcCodeGenerator::generate_initCode(QmltcType ¤t, // init creates new context. for document root, it's going to be a real // parent context, so store it temporarily in `context` variable if (isDocumentRoot) - lhs = u"context = "_qs; - current.init.body << u"// 0. call base's init method"_qs; + lhs = u"context = "_s; + current.init.body << u"// 0. call base's init method"_s; Q_ASSERT(!isDocumentRoot || visitor->qmlTypesWithQmlBases()[0] == visitor->result()); const auto isCurrentType = [&](const QQmlJSScope::ConstPtr &qmlType) { @@ -187,13 +190,13 @@ inline decltype(auto) QmltcCodeGenerator::generate_initCode(QmltcType ¤t, }; const QString creationOffset = generate_typeCount(isCurrentType); - current.init.body << u"{"_qs; - current.init.body << u"QQmltcObjectCreationHelper subCreator(creator, %1);"_qs.arg( + current.init.body << u"{"_s; + current.init.body << u"QQmltcObjectCreationHelper subCreator(creator, %1);"_s.arg( creationOffset); current.init.body << QStringLiteral("%1%2::%3(&subCreator, engine, context, /* finalize */ false);") .arg(lhs, base->internalName(), current.init.name); - current.init.body << u"}"_qs; + current.init.body << u"}"_s; } current.init.body @@ -203,7 +206,7 @@ inline decltype(auto) QmltcCodeGenerator::generate_initCode(QmltcType ¤t, // when generating root, we need to create a new (document-level) context. // otherwise, just use existing context as is if (isDocumentRoot) { - current.init.body << u"// 1. create new QML context for this document"_qs; + current.init.body << u"// 1. create new QML context for this document"_s; // TODO: the last 2 parameters are {0, true} because we deal with // document root only here. in reality, there are inline components // which need { index, true } instead @@ -213,31 +216,31 @@ inline decltype(auto) QmltcCodeGenerator::generate_initCode(QmltcType ¤t, "context, 0, true);") .arg(privateEngineName, urlMethodName()); } else { - current.init.body << u"// 1. use current context as this object's context"_qs; - current.init.body << u"// context = context;"_qs; + current.init.body << u"// 1. use current context as this object's context"_s; + current.init.body << u"// context = context;"_s; } if (!type->baseType()->isComposite() || isDocumentRoot) { - current.init.body << u"// 2. set context for this object"_qs; + current.init.body << u"// 2. set context for this object"_s; current.init.body << QStringLiteral( "%1->setInternalContext(this, context, QQmlContextData::%2);") .arg(privateEngineName, - (isDocumentRoot ? u"DocumentRoot"_qs - : u"OrdinaryObject"_qs)); + (isDocumentRoot ? u"DocumentRoot"_s + : u"OrdinaryObject"_s)); if (isDocumentRoot) - current.init.body << u"context->setContextObject(this);"_qs; + current.init.body << u"context->setContextObject(this);"_s; } if (int id = visitor->runtimeId(type); id >= 0) { - current.init.body << u"// 3. set id since it is provided"_qs; - QmltcCodeGenerator::generate_setIdValue(¤t.init.body, u"context"_qs, id, u"this"_qs, - u"<unknown>"_qs); + current.init.body << u"// 3. set id since it is provided"_s; + QmltcCodeGenerator::generate_setIdValue(¤t.init.body, u"context"_s, id, u"this"_s, + u"<unknown>"_s); } const auto generateFinalLines = [¤t, isDocumentRoot]() { if (isDocumentRoot) { - current.init.body << u"// 4. finish the document root creation"_qs; - current.init.body << u"if (canFinalize) {"_qs; + current.init.body << u"// 4. finish the document root creation"_s; + current.init.body << u"if (canFinalize) {"_s; current.init.body << QStringLiteral(" %1(creator, /* finalize */ true);") .arg(current.beginClass.name); current.init.body << QStringLiteral(" %1(creator, engine, /* finalize */ true);") @@ -248,9 +251,9 @@ inline decltype(auto) QmltcCodeGenerator::generate_initCode(QmltcType ¤t, .arg(current.finalizeComponent.name); current.init.body << QStringLiteral(" %1(creator, /* finalize */ true);") .arg(current.handleOnCompleted.name); - current.init.body << u"}"_qs; + current.init.body << u"}"_s; } - current.init.body << u"return context;"_qs; + current.init.body << u"return context;"_s; }; return QScopeGuard(generateFinalLines); @@ -271,34 +274,36 @@ QmltcCodeGenerator::generate_initCodeForTopLevelComponent(QmltcType ¤t, { Q_UNUSED(type); + using namespace Qt::StringLiterals; + // since we create a document root as QQmlComponent, we only need to fake // QQmlComponent construction in init: - current.init.body << u"// init QQmlComponent: see QQmlObjectCreator::createComponent()"_qs; - current.init.body << u"{"_qs; + current.init.body << u"// init QQmlComponent: see QQmlObjectCreator::createComponent()"_s; + current.init.body << u"{"_s; // we already called QQmlComponent(parent) constructor. now we need: // 1. QQmlComponent(engine, parent) logic: - current.init.body << u"// QQmlComponent(engine, parent):"_qs; - current.init.body << u"auto d = QQmlComponentPrivate::get(this);"_qs; - current.init.body << u"Q_ASSERT(d);"_qs; - current.init.body << u"d->engine = engine;"_qs; - current.init.body << u"QObject::connect(engine, &QObject::destroyed, this, [d]() {"_qs; - current.init.body << u" d->state.creator.reset();"_qs; - current.init.body << u" d->engine = nullptr;"_qs; - current.init.body << u"});"_qs; + current.init.body << u"// QQmlComponent(engine, parent):"_s; + current.init.body << u"auto d = QQmlComponentPrivate::get(this);"_s; + current.init.body << u"Q_ASSERT(d);"_s; + current.init.body << u"d->engine = engine;"_s; + current.init.body << u"QObject::connect(engine, &QObject::destroyed, this, [d]() {"_s; + current.init.body << u" d->state.creator.reset();"_s; + current.init.body << u" d->engine = nullptr;"_s; + current.init.body << u"});"_s; // 2. QQmlComponent(engine, compilationUnit, start, parent) logic: - current.init.body << u"// QQmlComponent(engine, compilationUnit, start, parent):"_qs; + current.init.body << u"// QQmlComponent(engine, compilationUnit, start, parent):"_s; current.init.body << u"auto compilationUnit = QQmlEnginePrivate::get(engine)->compilationUnitFromUrl(" + QmltcCodeGenerator::urlMethodName() + u"());"; - current.init.body << u"d->compilationUnit = compilationUnit;"_qs; - current.init.body << u"d->start = 0;"_qs; - current.init.body << u"d->url = compilationUnit->finalUrl();"_qs; - current.init.body << u"d->progress = 1.0;"_qs; + current.init.body << u"d->compilationUnit = compilationUnit;"_s; + current.init.body << u"d->start = 0;"_s; + current.init.body << u"d->url = compilationUnit->finalUrl();"_s; + current.init.body << u"d->progress = 1.0;"_s; // 3. QQmlObjectCreator::createComponent() logic which is left: - current.init.body << u"// QQmlObjectCreator::createComponent():"_qs; - current.init.body << u"d->creationContext = context;"_qs; - current.init.body << u"Q_ASSERT(QQmlData::get(this, /*create*/ false));"_qs; - current.init.body << u"}"_qs; + current.init.body << u"// QQmlObjectCreator::createComponent():"_s; + current.init.body << u"d->creationContext = context;"_s; + current.init.body << u"Q_ASSERT(QQmlData::get(this, /*create*/ false));"_s; + current.init.body << u"}"_s; } /*! @@ -313,42 +318,44 @@ inline decltype(auto) QmltcCodeGenerator::generate_endInitCode(QmltcType ¤t, const QQmlJSScope::ConstPtr &type) const { + using namespace Qt::StringLiterals; + // QML_endInit()'s parameters: // * QQmltcObjectCreationHelper* creator // * QQmlEngine* engine // * bool canFinalize [optional, when document root] const bool isDocumentRoot = type == visitor->result(); - current.endInit.body << u"Q_UNUSED(creator);"_qs; - current.endInit.body << u"Q_UNUSED(engine);"_qs; + current.endInit.body << u"Q_UNUSED(creator);"_s; + current.endInit.body << u"Q_UNUSED(engine);"_s; if (isDocumentRoot) - current.endInit.body << u"Q_UNUSED(canFinalize);"_qs; + current.endInit.body << u"Q_UNUSED(canFinalize);"_s; if (auto base = type->baseType(); base->isComposite()) { - current.endInit.body << u"// call base's finalize method"_qs; + current.endInit.body << u"// call base's finalize method"_s; Q_ASSERT(!isDocumentRoot || visitor->qmlTypesWithQmlBases()[0] == visitor->result()); const auto isCurrentType = [&](const QQmlJSScope::ConstPtr &qmlType) { return qmlType == type; }; const QString creationOffset = generate_typeCount(isCurrentType); - current.endInit.body << u"{"_qs; - current.endInit.body << u"QQmltcObjectCreationHelper subCreator(creator, %1);"_qs.arg( + current.endInit.body << u"{"_s; + current.endInit.body << u"QQmltcObjectCreationHelper subCreator(creator, %1);"_s.arg( creationOffset); - current.endInit.body << u"%1::%2(&subCreator, engine, /* finalize */ false);"_qs.arg( + current.endInit.body << u"%1::%2(&subCreator, engine, /* finalize */ false);"_s.arg( base->internalName(), current.endInit.name); - current.endInit.body << u"}"_qs; + current.endInit.body << u"}"_s; } if (visitor->hasDeferredBindings(type)) { - current.endInit.body << u"{ // defer bindings"_qs; - current.endInit.body << u"auto ddata = QQmlData::get(this);"_qs; - current.endInit.body << u"auto thisContext = ddata->outerContext;"_qs; - current.endInit.body << u"Q_ASSERT(thisContext);"_qs; + current.endInit.body << u"{ // defer bindings"_s; + current.endInit.body << u"auto ddata = QQmlData::get(this);"_s; + current.endInit.body << u"auto thisContext = ddata->outerContext;"_s; + current.endInit.body << u"Q_ASSERT(thisContext);"_s; current.endInit.body << QStringLiteral("ddata->deferData(%1, " "QQmlEnginePrivate::get(engine)->" "compilationUnitFromUrl(%2()), thisContext);") .arg(QString::number(visitor->qmlIrObjectIndex(type)), QmltcCodeGenerator::urlMethodName()); - current.endInit.body << u"}"_qs; + current.endInit.body << u"}"_s; } // TODO: QScopeGuard here is redundant. we should call endInit of children @@ -358,11 +365,11 @@ QmltcCodeGenerator::generate_endInitCode(QmltcType ¤t, return; const auto types = visitor->pureQmlTypes(); - current.endInit.body << u"// finalize children"_qs; + current.endInit.body << u"// finalize children"_s; for (qsizetype i = 1; i < types.size(); ++i) { const auto &type = types[i]; Q_ASSERT(!type->isComponentRootElement()); - current.endInit.body << u"creator->get<%1>(%2)->%3(creator, engine);"_qs.arg( + current.endInit.body << u"creator->get<%1>(%2)->%3(creator, engine);"_s.arg( type->internalName(), QString::number(i), current.endInit.name); } }; @@ -381,54 +388,56 @@ inline void QmltcCodeGenerator::generate_interfaceCallCode(QmltcMethod *function const QString &interfaceName, const QString &interfaceCall) const { + using namespace Qt::StringLiterals; + // function's parameters: // * QQmltcObjectCreationHelper* creator // * bool canFinalize [optional, when document root] const bool isDocumentRoot = type == visitor->result(); - function->body << u"Q_UNUSED(creator);"_qs; + function->body << u"Q_UNUSED(creator);"_s; if (isDocumentRoot) - function->body << u"Q_UNUSED(canFinalize);"_qs; + function->body << u"Q_UNUSED(canFinalize);"_s; if (auto base = type->baseType(); base->isComposite()) { - function->body << u"// call base's method"_qs; + function->body << u"// call base's method"_s; Q_ASSERT(!isDocumentRoot || visitor->qmlTypesWithQmlBases()[0] == visitor->result()); const auto isCurrentType = [&](const QQmlJSScope::ConstPtr &qmlType) { return qmlType == type; }; const QString creationOffset = generate_typeCount(isCurrentType); - function->body << u"{"_qs; - function->body << u"QQmltcObjectCreationHelper subCreator(creator, %1);"_qs.arg( + function->body << u"{"_s; + function->body << u"QQmltcObjectCreationHelper subCreator(creator, %1);"_s.arg( creationOffset); - function->body << u"%1::%2(&subCreator, /* finalize */ false);"_qs.arg(base->internalName(), - function->name); - function->body << u"}"_qs; + function->body << u"%1::%2(&subCreator, /* finalize */ false);"_s.arg(base->internalName(), + function->name); + function->body << u"}"_s; } if (!isDocumentRoot) return; const auto types = visitor->pureQmlTypes(); - function->body << u"// call children's methods"_qs; + function->body << u"// call children's methods"_s; for (qsizetype i = 1; i < types.size(); ++i) { const auto &type = types[i]; Q_ASSERT(!type->isComponentRootElement()); - function->body << u"{"_qs; - function->body << u"auto child = creator->get<%1>(%2);"_qs.arg(type->internalName(), - QString::number(i)); - function->body << u"child->%1(creator);"_qs.arg(function->name); + function->body << u"{"_s; + function->body << u"auto child = creator->get<%1>(%2);"_s.arg(type->internalName(), + QString::number(i)); + function->body << u"child->%1(creator);"_s.arg(function->name); if (type->hasInterface(interfaceName)) { - function->body << u"Q_ASSERT(dynamic_cast<%1 *>(child) != nullptr);"_qs.arg( + function->body << u"Q_ASSERT(dynamic_cast<%1 *>(child) != nullptr);"_s.arg( interfaceName); - function->body << u"child->%1();"_qs.arg(interfaceCall); + function->body << u"child->%1();"_s.arg(interfaceCall); } - function->body << u"}"_qs; + function->body << u"}"_s; } if (type->hasInterface(interfaceName)) { - function->body << u"if (canFinalize) {"_qs; - function->body << u" // call own method"_qs; - function->body << u" this->%1();"_qs.arg(interfaceCall); - function->body << u"}"_qs; + function->body << u"if (canFinalize) {"_s; + function->body << u" // call own method"_s; + function->body << u" this->%1();"_s.arg(interfaceCall); + function->body << u"}"_s; } } @@ -442,7 +451,8 @@ inline void QmltcCodeGenerator::generate_interfaceCallCode(QmltcMethod *function inline void QmltcCodeGenerator::generate_beginClassCode(QmltcType ¤t, const QQmlJSScope::ConstPtr &type) const { - generate_interfaceCallCode(¤t.beginClass, type, u"QQmlParserStatus"_qs, u"classBegin"_qs); + using namespace Qt::StringLiterals; + generate_interfaceCallCode(¤t.beginClass, type, u"QQmlParserStatus"_s, u"classBegin"_s); } /*! @@ -456,8 +466,9 @@ inline void QmltcCodeGenerator::generate_completeComponentCode(QmltcType ¤t, const QQmlJSScope::ConstPtr &type) const { - generate_interfaceCallCode(¤t.completeComponent, type, u"QQmlParserStatus"_qs, - u"componentComplete"_qs); + using namespace Qt::StringLiterals; + generate_interfaceCallCode(¤t.completeComponent, type, u"QQmlParserStatus"_s, + u"componentComplete"_s); } /*! @@ -471,8 +482,9 @@ inline void QmltcCodeGenerator::generate_finalizeComponentCode(QmltcType ¤t, const QQmlJSScope::ConstPtr &type) const { - generate_interfaceCallCode(¤t.finalizeComponent, type, u"QQmlFinalizerHook"_qs, - u"componentFinalized"_qs); + using namespace Qt::StringLiterals; + generate_interfaceCallCode(¤t.finalizeComponent, type, u"QQmlFinalizerHook"_s, + u"componentFinalized"_s); } /*! @@ -486,38 +498,40 @@ inline void QmltcCodeGenerator::generate_handleOnCompletedCode(QmltcType ¤t, const QQmlJSScope::ConstPtr &type) const { + using namespace Qt::StringLiterals; + // QML_handleOnCompleted()'s parameters: // * QQmltcObjectCreationHelper* creator // * bool canFinalize [optional, when document root] const bool isDocumentRoot = type == visitor->result(); - current.handleOnCompleted.body << u"Q_UNUSED(creator);"_qs; + current.handleOnCompleted.body << u"Q_UNUSED(creator);"_s; if (isDocumentRoot) - current.handleOnCompleted.body << u"Q_UNUSED(canFinalize);"_qs; + current.handleOnCompleted.body << u"Q_UNUSED(canFinalize);"_s; if (auto base = type->baseType(); base->isComposite()) { - current.handleOnCompleted.body << u"// call base's method"_qs; + current.handleOnCompleted.body << u"// call base's method"_s; Q_ASSERT(!isDocumentRoot || visitor->qmlTypesWithQmlBases()[0] == visitor->result()); const auto isCurrentType = [&](const QQmlJSScope::ConstPtr &qmlType) { return qmlType == type; }; const QString creationOffset = generate_typeCount(isCurrentType); - current.handleOnCompleted.body << u"{"_qs; + current.handleOnCompleted.body << u"{"_s; current.handleOnCompleted.body - << u"QQmltcObjectCreationHelper subCreator(creator, %1);"_qs.arg(creationOffset); - current.handleOnCompleted.body << u"%1::%2(&subCreator, /* finalize */ false);"_qs.arg( + << u"QQmltcObjectCreationHelper subCreator(creator, %1);"_s.arg(creationOffset); + current.handleOnCompleted.body << u"%1::%2(&subCreator, /* finalize */ false);"_s.arg( base->internalName(), current.handleOnCompleted.name); - current.handleOnCompleted.body << u"}"_qs; + current.handleOnCompleted.body << u"}"_s; } if (!isDocumentRoot) // document root does all the work here return; const auto types = visitor->pureQmlTypes(); - current.handleOnCompleted.body << u"// call children's methods"_qs; + current.handleOnCompleted.body << u"// call children's methods"_s; for (qsizetype i = 1; i < types.size(); ++i) { const auto &type = types[i]; Q_ASSERT(!type->isComponentRootElement()); - current.handleOnCompleted.body << u"creator->get<%1>(%2)->%3(creator);"_qs.arg( + current.handleOnCompleted.body << u"creator->get<%1>(%2)->%3(creator);"_s.arg( type->internalName(), QString::number(i), current.handleOnCompleted.name); } } @@ -579,6 +593,8 @@ QmltcCodeGenerator::generate_handleOnCompletedCode(QmltcType ¤t, template<typename Predicate> inline QString QmltcCodeGenerator::generate_typeCount(Predicate p) const { + using namespace Qt::StringLiterals; + const QList<QQmlJSScope::ConstPtr> typesWithBaseTypeCount = visitor->qmlTypesWithQmlBases(); QStringList components; components.reserve(1 + typesWithBaseTypeCount.size()); @@ -591,7 +607,7 @@ inline QString QmltcCodeGenerator::generate_typeCount(Predicate p) const for (const QQmlJSScope::ConstPtr &t : typesWithBaseTypeCount) { if (p(t)) break; - QString typeCountTemplate = u"QQmltcObjectCreationHelper::typeCount<%1>()"_qs; + QString typeCountTemplate = u"QQmltcObjectCreationHelper::typeCount<%1>()"_s; if (t == visitor->result()) { // t is this document's root components << typeCountTemplate.arg(t->baseTypeName()); } else { @@ -599,7 +615,7 @@ inline QString QmltcCodeGenerator::generate_typeCount(Predicate p) const } } - return components.join(u" + "_qs); + return components.join(u" + "_s); } QT_END_NAMESPACE diff --git a/tools/qmltc/qmltcpropertyutils.h b/tools/qmltc/qmltcpropertyutils.h index 85fa540eaf..b655961629 100644 --- a/tools/qmltc/qmltcpropertyutils.h +++ b/tools/qmltc/qmltcpropertyutils.h @@ -47,7 +47,7 @@ inline QString getUnderlyingType(const QQmlJSMetaProperty &p) if (p.isList()) { underlyingType = u"QQmlListProperty<" + underlyingType + u">"; } else if (p.type()->isReferenceType()) { - underlyingType += u"*"_qs; + underlyingType += u'*'; } return underlyingType; } diff --git a/tools/qmltc/qmltcvisitor.cpp b/tools/qmltc/qmltcvisitor.cpp index eb3fb7155a..ed85ccf479 100644 --- a/tools/qmltc/qmltcvisitor.cpp +++ b/tools/qmltc/qmltcvisitor.cpp @@ -35,6 +35,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static QString uniqueNameFromPieces(const QStringList &pieces, QHash<QString, int> &repetitions) { QString possibleName = pieces.join(u'_'); @@ -99,7 +101,7 @@ void QmltcVisitor::findCppIncludes() const auto constructPrivateInclude = [](QStringView publicInclude) -> QString { if (publicInclude.isEmpty()) return QString(); - Q_ASSERT(publicInclude.endsWith(u".h"_qs) || publicInclude.endsWith(u".hpp"_qs)); + Q_ASSERT(publicInclude.endsWith(u".h"_s) || publicInclude.endsWith(u".hpp"_s)); const qsizetype dotLocation = publicInclude.lastIndexOf(u'.'); QStringView extension = publicInclude.sliced(dotLocation); QStringView includeWithoutExtension = publicInclude.first(dotLocation); @@ -241,20 +243,20 @@ bool QmltcVisitor::visit(QQmlJS::AST::UiPublicMember *publicMember) // of now this is done in the pass over the types after the ast // traversal - const QString notifyName = name + u"Changed"_qs; + const QString notifyName = name + u"Changed"_s; // also check that notify is already a method of the scope { auto owningScope = m_savedBindingOuterScope ? m_savedBindingOuterScope : m_currentScope; const auto methods = owningScope->ownMethods(notifyName); if (methods.size() != 1) { const QString errorString = - methods.isEmpty() ? u"no signal"_qs : u"too many signals"_qs; + methods.isEmpty() ? u"no signal"_s : u"too many signals"_s; m_logger->log( - u"internal error: %1 found for property '%2'"_qs.arg(errorString, name), + u"internal error: %1 found for property '%2'"_s.arg(errorString, name), Log_Compiler, publicMember->identifierToken); return false; } else if (methods[0].methodType() != QQmlJSMetaMethod::Signal) { - m_logger->log(u"internal error: method %1 of property %2 must be a signal"_qs.arg( + m_logger->log(u"internal error: method %1 of property %2 must be a signal"_s.arg( notifyName, name), Log_Compiler, publicMember->identifierToken); return false; @@ -283,7 +285,7 @@ bool QmltcVisitor::visit(QQmlJS::AST::UiInlineComponent *component) { if (!QQmlJSImportVisitor::visit(component)) return false; - m_logger->log(u"Inline components are not supported"_qs, Log_Compiler, + m_logger->log(u"Inline components are not supported"_s, Log_Compiler, component->firstSourceLocation()); // despite the failure, return true here so that we do not assert in // QQmlJSImportVisitor::endVisit(UiInlineComponent) diff --git a/tools/shared/qqmltoolingsettings.cpp b/tools/shared/qqmltoolingsettings.cpp index f2c4cd02c6..38bcf71eb6 100644 --- a/tools/shared/qqmltoolingsettings.cpp +++ b/tools/shared/qqmltoolingsettings.cpp @@ -37,6 +37,8 @@ #include <QtCore/qsettings.h> #include <QtCore/qstandardpaths.h> +using namespace Qt::StringLiterals; + void QQmlToolingSettings::addOption(const QString &name, QVariant defaultValue) { m_values[name] = defaultValue; @@ -62,7 +64,7 @@ bool QQmlToolingSettings::read(const QString &settingsFilePath) bool QQmlToolingSettings::writeDefaults() const { - const QString path = QFileInfo(u".%1.ini"_qs.arg(m_toolName)).absoluteFilePath(); + const QString path = QFileInfo(u".%1.ini"_s.arg(m_toolName)).absoluteFilePath(); QSettings settings(path, QSettings::IniFormat); for (auto it = m_values.constBegin(); it != m_values.constEnd(); ++it) { @@ -88,7 +90,7 @@ bool QQmlToolingSettings::search(const QString &path) QSet<QString> dirs; - const QString settingsFileName = u".%1.ini"_qs.arg(m_toolName); + const QString settingsFileName = u".%1.ini"_s.arg(m_toolName); while (dir.exists() && dir.isReadable()) { const QString dirPath = dir.absolutePath(); @@ -115,7 +117,7 @@ bool QQmlToolingSettings::search(const QString &path) break; } - if (const QString iniFile = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, u"%1.ini"_qs.arg(m_toolName)); !iniFile.isEmpty()) { + if (const QString iniFile = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, u"%1.ini"_s.arg(m_toolName)); !iniFile.isEmpty()) { if (read(iniFile)) { for (const QString &dir : qAsConst(dirs)) m_seenDirectories[dir] = iniFile; |