diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-04-22 08:52:16 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-04-26 10:12:44 +0200 |
commit | 42b6ca327a4a30671ab8c031d33c5e31e503cf21 (patch) | |
tree | 603a8bcc2f5e86e782adce6f496c5f9e21ced82f | |
parent | e4a9c6caea4b19d1b0bfd03bc5500bf48c9c44d5 (diff) |
Migrate from QLatin1Char to UTF-16 char literals
Preparing for the deprecation of QLatin1Char in 6.4.
Task-number: QTBUG-98434
Change-Id: I8bc92aa9f4e6dbfcb12d2025c5a1e760ab4f0d7f
Reviewed-by: Christian Tismer <tismer@stackless.com>
(cherry picked from commit 42666b5bab09a80a65ae8f61961985f4923b7d65)
41 files changed, 367 insertions, 378 deletions
diff --git a/examples/scriptableapplication/mainwindow.cpp b/examples/scriptableapplication/mainwindow.cpp index 15c8b59f0..2705d138c 100644 --- a/examples/scriptableapplication/mainwindow.cpp +++ b/examples/scriptableapplication/mainwindow.cpp @@ -115,7 +115,8 @@ MainWindow::MainWindow() void MainWindow::slotRunScript() { - const QStringList script = m_scriptEdit->toPlainText().trimmed().split(QLatin1Char('\n'), Qt::SkipEmptyParts); + const QString text = m_scriptEdit->toPlainText().trimmed(); + const QStringList script = text.split(u'\n', Qt::SkipEmptyParts); if (!script.isEmpty()) runScript(script); } diff --git a/sources/pyside6/libpyside/feature_select.cpp b/sources/pyside6/libpyside/feature_select.cpp index 9459e1ca9..d1f5eb40f 100644 --- a/sources/pyside6/libpyside/feature_select.cpp +++ b/sources/pyside6/libpyside/feature_select.cpp @@ -594,7 +594,7 @@ static QStringList parseFields(const char *propstr, bool *stdwrite) if (stdwrite) *stdwrite = true; QString s = QString(QLatin1String(propstr)); - auto list = s.split(QLatin1Char(':')); + auto list = s.split(u':'); assert(list.size() == 2 || list.size() == 3); auto name = list[0]; auto read = list[1]; diff --git a/sources/pyside6/libpyside/pysidesignal.cpp b/sources/pyside6/libpyside/pysidesignal.cpp index 303c94b57..b35053d93 100644 --- a/sources/pyside6/libpyside/pysidesignal.cpp +++ b/sources/pyside6/libpyside/pysidesignal.cpp @@ -1062,15 +1062,15 @@ QStringList getArgsFromSignature(const char *signature, bool *isShortCircuit) QStringList result; if (isShortCircuit) - *isShortCircuit = !qsignature.contains(QLatin1Char('(')); + *isShortCircuit = !qsignature.contains(u'('); if (qsignature.contains(QLatin1String("()")) || qsignature.contains(QLatin1String("(void)"))) return result; - if (qsignature.endsWith(QLatin1Char(')'))) { - const int paren = qsignature.indexOf(QLatin1Char('(')); + if (qsignature.endsWith(u')')) { + const int paren = qsignature.indexOf(u'('); if (paren >= 0) { qsignature.chop(1); qsignature.remove(0, paren + 1); - result = qsignature.split(QLatin1Char(',')); + result = qsignature.split(u','); for (QString &type : result) type = type.trimmed(); } @@ -1131,13 +1131,13 @@ QString getCallbackSignature(const char *signal, QObject *receiver, PyObject *ca QStringList args = getArgsFromSignature(signal, &isShortCircuit); if (!isShortCircuit) { - signature.append(QLatin1Char('(')); + signature.append(u'('); if (numArgs == -1) numArgs = std::numeric_limits<qsizetype>::max(); while (!args.isEmpty() && (args.size() > (numArgs - useSelf))) args.removeLast(); - signature.append(args.join(QLatin1Char(','))); - signature.append(QLatin1Char(')')); + signature.append(args.join(u',')); + signature.append(u')'); } return signature; } diff --git a/sources/shiboken6/ApiExtractor/abstractmetaargument.cpp b/sources/shiboken6/ApiExtractor/abstractmetaargument.cpp index 366fc00a1..95027e4dc 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetaargument.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetaargument.cpp @@ -144,7 +144,7 @@ bool AbstractMetaArgument::hasModifiedDefaultValueExpression() const QString AbstractMetaArgumentData::toString() const { - QString result = m_type.name() + QLatin1Char(' ') + m_name; + QString result = m_type.name() + u' ' + m_name; if (!m_expression.isEmpty()) result += QLatin1String(" = ") + m_expression; return result; diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp index a059c00fb..42537ac02 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp @@ -63,7 +63,7 @@ static inline QString colonColon() { return QStringLiteral("::"); } static QString stripTemplateArgs(const QString &name) { - int pos = name.indexOf(QLatin1Char('<')); + int pos = name.indexOf(u'<'); return pos < 0 ? name : name.left(pos); } @@ -150,7 +150,7 @@ void AbstractMetaBuilderPrivate::checkFunctionModifications() QString signature = modification.signature(); QString name = signature.trimmed(); - name.truncate(name.indexOf(QLatin1Char('('))); + name.truncate(name.indexOf(u'(')); AbstractMetaClass *clazz = AbstractMetaClass::findClass(m_metaClasses, centry); if (!clazz) @@ -1259,7 +1259,7 @@ void AbstractMetaBuilderPrivate::fixReturnTypeOfConversionOperator(AbstractMetaF Q_ASSERT(operatorRegExp.isValid()); QString castTo = metaFunction->name().remove(operatorRegExp).trimmed(); - if (castTo.endsWith(QLatin1Char('&'))) + if (castTo.endsWith(u'&')) castTo.chop(1); if (castTo.startsWith(QLatin1String("const "))) castTo.remove(0, 6); @@ -1477,7 +1477,7 @@ bool AbstractMetaBuilderPrivate::setupInheritance(AbstractMetaClass *metaClass) QStringList baseClasses = metaClass->baseClassNames(); // we only support our own containers and ONLY if there is only one baseclass - if (baseClasses.size() == 1 && baseClasses.constFirst().contains(QLatin1Char('<'))) { + if (baseClasses.size() == 1 && baseClasses.constFirst().contains(u'<')) { TypeInfo info; ComplexTypeEntry* baseContainerType; AbstractMetaClass* templ = findTemplateClass(baseClasses.constFirst(), metaClass, &info, &baseContainerType); @@ -1731,13 +1731,13 @@ static QString functionSignature(const FunctionModelItem &functionItem) const ArgumentList &arguments = functionItem->arguments(); for (const ArgumentModelItem &arg : arguments) args << arg->type().toString(); - return functionItem->name() + QLatin1Char('(') + args.join(QLatin1Char(',')) + QLatin1Char(')'); + return functionItem->name() + u'(' + args.join(u',') + u')'; } static inline QString qualifiedFunctionSignatureWithType(const FunctionModelItem &functionItem, const QString &className = QString()) { - QString result = functionItem->type().toString() + QLatin1Char(' '); + QString result = functionItem->type().toString() + u' '; if (!className.isEmpty()) result += className + colonColon(); result += functionSignature(functionItem); @@ -2577,7 +2577,7 @@ QString AbstractMetaBuilderPrivate::fixDefaultValue(QString expr, const Abstract if (type.isFlags() || type.isEnum()) { expr = fixEnumDefault(type, expr); - } else if (type.isContainer() && expr.contains(QLatin1Char('<'))) { + } else if (type.isContainer() && expr.contains(u'<')) { // Expand a container of a nested class, fex // "QList<FormatRange>()" -> "QList<QTextLayout::FormatRange>()" if (type.instantiations().size() != 1) @@ -2717,7 +2717,7 @@ AbstractMetaClassList AbstractMetaBuilderPrivate::getBaseClasses(const AbstractM const QStringList &baseClassNames = metaClass->baseClassNames(); for (const QString& parent : baseClassNames) { AbstractMetaClass *cls = nullptr; - if (parent.contains(QLatin1Char('<'))) + if (parent.contains(u'<')) cls = findTemplateClass(parent, metaClass); else cls = AbstractMetaClass::findClass(m_metaClasses, parent); @@ -3066,7 +3066,7 @@ static void writeRejectLogFile(const QString &name, for (int reason = 0; reason < AbstractMetaBuilder::NoReason; ++reason) { - s << QString(72, QLatin1Char('*')) << Qt::endl; + s << QByteArray(72, '*') << '\n'; switch (reason) { case AbstractMetaBuilder::NotInTypeSystem: s << "Not in type system"; @@ -3108,7 +3108,7 @@ static void writeRejectLogFile(const QString &name, s << " - " << it.key() << Qt::endl; } - s << QString(72, QLatin1Char('*')) << Qt::endl << Qt::endl; + s << QByteArray(72, '*') << "\n\n"; } } @@ -3254,7 +3254,7 @@ void AbstractMetaBuilder::setSkipDeprecated(bool value) static inline bool isFileSystemSlash(QChar c) { - return c == QLatin1Char('/') || c == QLatin1Char('\\'); + return c == u'/' || c == u'\\'; } static bool matchHeader(const QString &headerPath, const QString &fileName) diff --git a/sources/shiboken6/ApiExtractor/abstractmetaenum.cpp b/sources/shiboken6/ApiExtractor/abstractmetaenum.cpp index 336cd4f2a..4e030c392 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetaenum.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetaenum.cpp @@ -208,7 +208,7 @@ QString AbstractMetaEnum::package() const QString AbstractMetaEnum::fullName() const { - return package() + QLatin1Char('.') + qualifier() + QLatin1Char('.') + name(); + return package() + u'.' + qualifier() + u'.' + name(); } EnumKind AbstractMetaEnum::enumKind() const diff --git a/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp b/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp index 3c5660f7e..8cd289616 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp @@ -480,7 +480,7 @@ QString AbstractMetaFunctionPrivate::signature() const if (m_cachedSignature.isEmpty()) { m_cachedSignature = m_originalName; - m_cachedSignature += QLatin1Char('('); + m_cachedSignature += u'('; for (qsizetype i = 0; i < m_arguments.size(); ++i) { const AbstractMetaArgument &a = m_arguments.at(i); @@ -489,10 +489,10 @@ QString AbstractMetaFunctionPrivate::signature() const m_cachedSignature += QLatin1String(", "); m_cachedSignature += t.cppSignature(); // We need to have the argument names in the qdoc files - m_cachedSignature += QLatin1Char(' '); + m_cachedSignature += u' '; m_cachedSignature += a.name(); } - m_cachedSignature += QLatin1Char(')'); + m_cachedSignature += u')'; if (m_constant) m_cachedSignature += QLatin1String(" const"); @@ -837,10 +837,10 @@ QString AbstractMetaFunction::pyiTypeReplaced(int argumentIndex) const QString AbstractMetaFunctionPrivate::formatMinimalSignature(const AbstractMetaFunction *q, bool comment) const { - QString result = m_originalName + QLatin1Char('('); + QString result = m_originalName + u'('; for (qsizetype i = 0; i < m_arguments.size(); ++i) { if (i > 0) - result += QLatin1Char(','); + result += u','; QString typeName; if (comment) @@ -849,7 +849,7 @@ QString AbstractMetaFunctionPrivate::formatMinimalSignature(const AbstractMetaFu typeName = m_arguments.at(i).type().minimalSignature(); result += typeName; } - result += QLatin1Char(')'); + result += u')'; if (m_constant) result += QLatin1String("const"); result = TypeDatabase::normalizedSignature(result); diff --git a/sources/shiboken6/ApiExtractor/abstractmetalang.cpp b/sources/shiboken6/ApiExtractor/abstractmetalang.cpp index 3ffdf5814..d0d9adc4d 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetalang.cpp @@ -410,7 +410,7 @@ void AbstractMetaClass::addPropertySpec(const QPropertySpec &spec) void AbstractMetaClassPrivate::addFunction(const AbstractMetaFunctionCPtr &function) { - Q_ASSERT(!function->signature().startsWith(QLatin1Char('('))); + Q_ASSERT(!function->signature().startsWith(u'(')); if (!function->isDestructor()) m_functions << function; @@ -1315,7 +1315,7 @@ void AbstractMetaClass::getFunctionsFromInvisibleNamespacesToBeGenerated(Abstrac QString AbstractMetaClass::fullName() const { - return package() + QLatin1Char('.') + d->m_typeEntry->targetLangName(); + return package() + u'.' + d->m_typeEntry->targetLangName(); } static void addExtraIncludeForType(AbstractMetaClass *metaClass, const AbstractMetaType &type) diff --git a/sources/shiboken6/ApiExtractor/abstractmetatype.cpp b/sources/shiboken6/ApiExtractor/abstractmetatype.cpp index 6861dbc99..ee0e9264f 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetatype.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetatype.cpp @@ -475,10 +475,10 @@ bool AbstractMetaType::hasTemplateChildren() const static inline QString formatArraySize(int e) { QString result; - result += QLatin1Char('['); + result += u'['; if (e >= 0) result += QString::number(e); - result += QLatin1Char(']'); + result += u']'; return result; } @@ -492,7 +492,7 @@ QString AbstractMetaTypeData::formatSignature(bool minimal) const if (m_pattern == AbstractMetaType::ArrayPattern) { // Build nested array dimensions a[2][3] in correct order result += m_arrayElementType->minimalSignature(); - const int arrayPos = result.indexOf(QLatin1Char('[')); + const int arrayPos = result.indexOf(u'['); if (arrayPos != -1) result.insert(arrayPos, formatArraySize(m_arrayElementCount)); else @@ -501,26 +501,26 @@ QString AbstractMetaTypeData::formatSignature(bool minimal) const result += m_typeEntry->qualifiedCppName(); } if (!m_instantiations.isEmpty()) { - result += QLatin1Char('<'); + result += u'<'; if (minimal) - result += QLatin1Char(' '); + result += u' '; for (int i = 0, size = m_instantiations.size(); i < size; ++i) { if (i > 0) - result += QLatin1Char(','); + result += u','; result += m_instantiations.at(i).minimalSignature(); } result += QLatin1String(" >"); } if (!minimal && (!m_indirections.isEmpty() || m_referenceType != NoReference)) - result += QLatin1Char(' '); + result += u' '; for (Indirection i : m_indirections) result += TypeInfo::indirectionKeyword(i); switch (m_referenceType) { case NoReference: break; case LValueReference: - result += QLatin1Char('&'); + result += u'&'; break; case RValueReference: result += QLatin1String("&&"); @@ -557,12 +557,12 @@ QString AbstractMetaTypeData::formatPythonSignature() const if (!m_typeEntry->isPrimitive() && !m_typeEntry->isSmartPointer()) { const QString package = m_typeEntry->targetLangPackage(); if (!package.isEmpty()) - result += package + QLatin1Char('.'); + result += package + u'.'; } if (m_pattern == AbstractMetaType::ArrayPattern) { // Build nested array dimensions a[2][3] in correct order result += m_arrayElementType->formatPythonSignature(); - const int arrayPos = result.indexOf(QLatin1Char('[')); + const int arrayPos = result.indexOf(u'['); if (arrayPos != -1) result.insert(arrayPos, formatArraySize(m_arrayElementCount)); else @@ -571,13 +571,13 @@ QString AbstractMetaTypeData::formatPythonSignature() const result += m_typeEntry->targetLangName(); } if (!m_instantiations.isEmpty()) { - result += QLatin1Char('['); + result += u'['; for (int i = 0, size = m_instantiations.size(); i < size; ++i) { if (i > 0) result += QLatin1String(", "); result += m_instantiations.at(i).formatPythonSignature(); } - result += QLatin1Char(']'); + result += u']'; } if (m_typeEntry->isPrimitive()) for (Indirection i : m_indirections) diff --git a/sources/shiboken6/ApiExtractor/apiextractor.cpp b/sources/shiboken6/ApiExtractor/apiextractor.cpp index ce2a3c67f..b4ab42482 100644 --- a/sources/shiboken6/ApiExtractor/apiextractor.cpp +++ b/sources/shiboken6/ApiExtractor/apiextractor.cpp @@ -182,7 +182,7 @@ bool ApiExtractor::runHelper(ApiExtractorFlags flags) return false; } - const QString pattern = QDir::tempPath() + QLatin1Char('/') + const QString pattern = QDir::tempPath() + u'/' + m_cppFileNames.constFirst().baseName() + QStringLiteral("_XXXXXX.hpp"); QTemporaryFile ppFile(pattern); diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp index 5ce33f433..1638285e0 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp +++ b/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp @@ -70,8 +70,8 @@ static QString fixTypeName(QString t) { // Fix "Foo &" -> "Foo&", similarly "Bar **" -> "Bar**" int pos = t.size() - 1; - for (; pos >= 0 && (t.at(pos) == QLatin1Char('&') || t.at(pos) == QLatin1Char('*')); --pos) {} - if (pos > 0 && t.at(pos) == QLatin1Char(' ')) + for (; pos >= 0 && (t.at(pos) == u'&' || t.at(pos) == u'*'); --pos) {} + if (pos > 0 && t.at(pos) == u' ') t.remove(pos, 1); return t; } @@ -81,13 +81,13 @@ static QString fixTypeName(QString t) // the class name "Foo<T1,T2>" is the scope for nested items. static bool insertTemplateParameterIntoClassName(const QString &parmName, QString *name) { - if (Q_UNLIKELY(!name->endsWith(QLatin1Char('>')))) + if (Q_UNLIKELY(!name->endsWith(u'>'))) return false; - const bool needsComma = name->at(name->size() - 2) != QLatin1Char('<'); + const bool needsComma = name->at(name->size() - 2) != u'<'; const int insertionPos = name->size() - 1; name->insert(insertionPos, parmName); if (needsComma) - name->insert(insertionPos, QLatin1Char(',')); + name->insert(insertionPos, u','); return true; } @@ -290,7 +290,7 @@ static QString msgCannotDetermineException(const std::string_view &snippetV) snippet += QStringLiteral("..."); return QLatin1String("Cannot determine exception specification: \"") - + snippet + QLatin1Char('"'); + + snippet + u'"'; } // Return whether noexcept(<value>) throws. noexcept() takes a constexpr value. @@ -399,7 +399,7 @@ FunctionModelItem BuilderPrivate::createMemberFunction(const CXCursor &cursor, m_currentFunctionType == CodeModel::Signal || m_currentFunctionType == CodeModel::Slot ? m_currentFunctionType // by annotation : functionTypeFromCursor(cursor); - isTemplateCode |= m_currentClass->name().endsWith(QLatin1Char('>')); + isTemplateCode |= m_currentClass->name().endsWith(u'>'); auto result = createFunction(cursor, functionType, isTemplateCode); result->setAccessPolicy(accessPolicy(clang_getCXXAccessSpecifier(cursor))); result->setConstant(clang_CXXMethod_isConst(cursor) != 0); @@ -453,9 +453,9 @@ void BuilderPrivate::addField(const CXCursor &cursor) static QStringList qualifiedName(const QString &t) { QStringList result; - int end = t.indexOf(QLatin1Char('<')); + int end = t.indexOf(u'<'); if (end == -1) - end = t.indexOf(QLatin1Char('(')); + end = t.indexOf(u'('); if (end == -1) end = t.size(); int lastPos = 0; @@ -602,7 +602,7 @@ TypeInfo BuilderPrivate::createTypeInfoUncached(const CXType &type, // Obtain template instantiations if the name has '<' (thus excluding // typedefs like "std::string". - if (typeName.contains(QLatin1Char('<'))) + if (typeName.contains(u'<')) addTemplateInstantiations(nestedType, &typeName, &typeInfo); typeInfo.setQualifiedName(qualifiedName(typeName)); @@ -886,9 +886,9 @@ FileModelItem Builder::dom() const static QString msgOutOfOrder(const CXCursor &cursor, const char *expectedScope) { - return getCursorKindName(cursor.kind) + QLatin1Char(' ') + return getCursorKindName(cursor.kind) + u' ' + getCursorSpelling(cursor) + QLatin1String(" encountered outside ") - + QLatin1String(expectedScope) + QLatin1Char('.'); + + QLatin1String(expectedScope) + u'.'; } static CodeModel::ClassType codeModelClassTypeFromCursor(CXCursorKind kind) @@ -1075,7 +1075,7 @@ BaseVisitor::StartTokenResult Builder::startToken(const CXCursor &cursor) const NamespaceModelItem parentNamespaceItem = qSharedPointerDynamicCast<_NamespaceModelItem>(d->m_scopeStack.back()); if (parentNamespaceItem.isNull()) { const QString message = msgOutOfOrder(cursor, "namespace") - + QLatin1String(" (current scope: ") + d->m_scopeStack.back()->name() + QLatin1Char(')'); + + QLatin1String(" (current scope: ") + d->m_scopeStack.back()->name() + u')'; const Diagnostic d(message, cursor, CXDiagnostic_Error); qWarning() << d; appendDiagnostic(d); diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp b/sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp index c7d471547..973bdfa2b 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp +++ b/sources/shiboken6/ApiExtractor/clangparser/clangutils.cpp @@ -195,7 +195,7 @@ QPair<int, int> parseTemplateArgumentList(const QString &l, const TemplateArgumentHandler &handler, int from) { - const int ltPos = l.indexOf(QLatin1Char('<'), from); + const int ltPos = l.indexOf(u'<', from); if (ltPos == - 1) return qMakePair(-1, -1); int startPos = ltPos + 1; @@ -211,7 +211,7 @@ QPair<int, int> parseTemplateArgumentList(const QString &l, if (--level == 0) return qMakePair(ltPos, p); // Skip over next ',': "a<b<c,d>,e>" - for (; p < end && (l.at(p).isSpace() || l.at(p) == QLatin1Char(',')); ++p) {} + for (; p < end && (l.at(p).isSpace() || l.at(p) == u','); ++p) {} } startPos = p; break; diff --git a/sources/shiboken6/ApiExtractor/codesniphelpers.cpp b/sources/shiboken6/ApiExtractor/codesniphelpers.cpp index f9bae0a65..4002729fc 100644 --- a/sources/shiboken6/ApiExtractor/codesniphelpers.cpp +++ b/sources/shiboken6/ApiExtractor/codesniphelpers.cpp @@ -51,9 +51,9 @@ QString CodeSnipHelpers::dedent(const QString &code) if (code.isEmpty()) return code; // Right trim if indent=0, or trim if single line - if (!code.at(0).isSpace() || !code.contains(QLatin1Char('\n'))) + if (!code.at(0).isSpace() || !code.contains(u'\n')) return code.trimmed(); - const auto lines = QStringView{code}.split(QLatin1Char('\n')); + const auto lines = QStringView{code}.split(u'\n'); int spacesToRemove = std::numeric_limits<int>::max(); for (const auto &line : lines) { if (!isEmpty(line)) { @@ -68,35 +68,35 @@ QString CodeSnipHelpers::dedent(const QString &code) for (const auto &line : lines) { if (!isEmpty(line) && spacesToRemove < line.size()) result += line.mid(spacesToRemove).toString(); - result += QLatin1Char('\n'); + result += u'\n'; } return result; } QString CodeSnipHelpers::fixSpaces(QString code) { - code.remove(QLatin1Char('\r')); + code.remove(u'\r'); // Check for XML <tag>\n<space>bla... if (code.startsWith(QLatin1String("\n "))) code.remove(0, 1); while (!code.isEmpty() && code.back().isSpace()) code.chop(1); code = dedent(code); - if (!code.isEmpty() && !code.endsWith(QLatin1Char('\n'))) - code.append(QLatin1Char('\n')); + if (!code.isEmpty() && !code.endsWith(u'\n')) + code.append(u'\n'); return code; } // Prepend a line to the code, observing indentation void CodeSnipHelpers::prependCode(QString *code, QString firstLine) { - while (!code->isEmpty() && code->front() == QLatin1Char('\n')) + while (!code->isEmpty() && code->front() == u'\n') code->remove(0, 1); if (!code->isEmpty() && code->front().isSpace()) { const int indent = firstNonBlank(*code); - firstLine.prepend(QString(indent, QLatin1Char(' '))); + firstLine.prepend(QString(indent, u' ')); } - if (!firstLine.endsWith(QLatin1Char('\n'))) - firstLine += QLatin1Char('\n'); + if (!firstLine.endsWith(u'\n')) + firstLine += u'\n'; code->prepend(firstLine); } diff --git a/sources/shiboken6/ApiExtractor/docparser.cpp b/sources/shiboken6/ApiExtractor/docparser.cpp index 563774508..3067c7266 100644 --- a/sources/shiboken6/ApiExtractor/docparser.cpp +++ b/sources/shiboken6/ApiExtractor/docparser.cpp @@ -140,7 +140,7 @@ R"(<xsl:template match="/"> for (const DocModification &mod : mods) { if (isXpathDocModification(mod)) { QString xpath = mod.xpath(); - xpath.replace(QLatin1Char('"'), QLatin1String(""")); + xpath.replace(u'"', QLatin1String(""")); xsl += QLatin1String("<xsl:template match=\"") + xpath + QLatin1String("\">") + mod.code() + QLatin1String("</xsl:template>\n"); @@ -154,7 +154,7 @@ R"(<xsl:template match="/"> qPrintable(msgXpathDocModificationError(mods, errorMessage))); if (result == xml) { const QString message = QLatin1String("Query did not result in any modifications to \"") - + xml + QLatin1Char('"'); + + xml + u'"'; qCWarning(lcShibokenDoc, "%s", qPrintable(msgXpathDocModificationError(mods, message))); } diff --git a/sources/shiboken6/ApiExtractor/doxygenparser.cpp b/sources/shiboken6/ApiExtractor/doxygenparser.cpp index 0a1703d31..8a1787f5a 100644 --- a/sources/shiboken6/ApiExtractor/doxygenparser.cpp +++ b/sources/shiboken6/ApiExtractor/doxygenparser.cpp @@ -78,7 +78,7 @@ void DoxygenParser::fillDocumentation(AbstractMetaClass* metaClass) QString doxyFilePath; for (const char *prefix : prefixes) { - doxyFilePath = documentationDataDirectory() + QLatin1Char('/') + doxyFilePath = documentationDataDirectory() + u'/' + QLatin1String(prefix) + doxyFileSuffix; if (QFile::exists(doxyFilePath)) break; @@ -165,7 +165,7 @@ void DoxygenParser::fillDocumentation(AbstractMetaClass* metaClass) if (!isProperty) { funcQuery += QLatin1String("/../") + tag.second; } else { - funcQuery = QLatin1Char('(') + funcQuery; + funcQuery = u'(' + funcQuery; funcQuery += u"/../"_qs + tag.second + u")[1]"_qs; } diff --git a/sources/shiboken6/ApiExtractor/include.cpp b/sources/shiboken6/ApiExtractor/include.cpp index 6273d0e58..c902d601c 100644 --- a/sources/shiboken6/ApiExtractor/include.cpp +++ b/sources/shiboken6/ApiExtractor/include.cpp @@ -37,10 +37,10 @@ QString Include::toString() const { if (m_type == IncludePath) - return QLatin1String("#include <") + m_name + QLatin1Char('>'); + return QLatin1String("#include <") + m_name + u'>'; if (m_type == LocalPath) - return QLatin1String("#include \"") + m_name + QLatin1Char('"'); - return QLatin1String("import ") + m_name + QLatin1Char(';'); + return QLatin1String("#include \"") + m_name + u'"'; + return QLatin1String("import ") + m_name + u';'; } size_t qHash(const Include& inc) diff --git a/sources/shiboken6/ApiExtractor/messages.cpp b/sources/shiboken6/ApiExtractor/messages.cpp index 5a4c506a4..bd805d326 100644 --- a/sources/shiboken6/ApiExtractor/messages.cpp +++ b/sources/shiboken6/ApiExtractor/messages.cpp @@ -461,7 +461,7 @@ QString msgNamespaceToBeExtendedNotFound(const QString &namespaceName, const QSt { return QLatin1String("The namespace '") + namespaceName + QLatin1String("' to be extended cannot be found in package ") - + packageName + QLatin1Char('.'); + + packageName + u'.'; } QString msgPropertyTypeParsingFailed(const QString &name, const QString &typeName, @@ -665,14 +665,14 @@ QString msgLeftOverArguments(const QVariantMap &remainingArgs) if (!value.isEmpty()) str << ' ' << value; } - str << "\nCommand line: " << QCoreApplication::arguments().join(QLatin1Char(' ')); + str << "\nCommand line: " << QCoreApplication::arguments().join(u' '); return message; } QString msgInvalidVersion(const QString &package, const QString &version) { return QLatin1String("Invalid version \"") + version - + QLatin1String("\" specified for package ") + package + QLatin1Char('.'); + + QLatin1String("\" specified for package ") + package + u'.'; } QString msgCyclicDependency(const QString &funcName, const QString &graphName, @@ -711,7 +711,7 @@ QString msgClassNotFound(const TypeEntry *t) QString msgUnknownOperator(const AbstractMetaFunction* func) { QString result = QLatin1String("Unknown operator: \"") + func->originalName() - + QLatin1Char('"'); + + u'"'; if (const AbstractMetaClass *c = func->implementingClass()) result += QLatin1String(" in class: ") + c->name(); return result; diff --git a/sources/shiboken6/ApiExtractor/modifications.cpp b/sources/shiboken6/ApiExtractor/modifications.cpp index bb1e7505e..ee1ee8ef0 100644 --- a/sources/shiboken6/ApiExtractor/modifications.cpp +++ b/sources/shiboken6/ApiExtractor/modifications.cpp @@ -55,8 +55,8 @@ QString TemplateInstance::expandCode() const while (!code.isEmpty() && code.at(code.size() - 1).isSpace()) code.chop(1); QString result = QLatin1String("// TEMPLATE - ") + m_name + QLatin1String(" - START"); - if (!code.startsWith(QLatin1Char('\n'))) - result += QLatin1Char('\n'); + if (!code.startsWith(u'\n')) + result += u'\n'; result += code; result += QLatin1String("\n// TEMPLATE - ") + m_name + QLatin1String(" - END\n"); return result; @@ -92,7 +92,7 @@ void CodeSnipAbstract::purgeEmptyFragments() QRegularExpression CodeSnipAbstract::placeHolderRegex(int index) { - return QRegularExpression(QLatin1Char('%') + QString::number(index) + QStringLiteral("\\b")); + return QRegularExpression(u'%' + QString::number(index) + QStringLiteral("\\b")); } void purgeEmptyCodeSnips(QList<CodeSnip> *list) @@ -300,7 +300,7 @@ Arguments splitParameters(QStringView paramString, QString *errorMessage) for (const auto &t : tokens) { Argument argument; // Check defaultValue, "int @b@=5" - const int equalPos = t.lastIndexOf(QLatin1Char('=')); + const int equalPos = t.lastIndexOf(u'='); if (equalPos != -1) { const int defaultValuePos = equalPos + 1; argument.defaultValue = @@ -308,14 +308,14 @@ Arguments splitParameters(QStringView paramString, QString *errorMessage) } QString typeString = (equalPos != -1 ? t.left(equalPos) : t).trimmed().toString(); // Check @name@ - const int atPos = typeString.indexOf(QLatin1Char('@')); + const int atPos = typeString.indexOf(u'@'); if (atPos != -1) { const int namePos = atPos + 1; - const int nameEndPos = typeString.indexOf(QLatin1Char('@'), namePos); + const int nameEndPos = typeString.indexOf(u'@', namePos); if (nameEndPos == -1) { if (errorMessage != nullptr) { *errorMessage = QLatin1String("Mismatched @ in \"") - + paramString.toString() + QLatin1Char('"'); + + paramString.toString() + u'"'; } return {}; } @@ -358,14 +358,14 @@ AddedFunction::AddedFunctionPtr // Skip past "operator()(...)" const int parenSearchStartPos = signature.startsWith(callOperator()) ? callOperator().size() : 0; - const int openParenPos = signature.indexOf(QLatin1Char('('), parenSearchStartPos); + const int openParenPos = signature.indexOf(u'(', parenSearchStartPos); if (openParenPos < 0) { return AddedFunctionPtr(new AddedFunction(signature.toString(), arguments, returnType)); } const QString name = signature.left(openParenPos).trimmed().toString(); - const int closingParenPos = signature.lastIndexOf(QLatin1Char(')')); + const int closingParenPos = signature.lastIndexOf(u')'); if (closingParenPos < 0) { *errorMessage = QLatin1String("Missing closing parenthesis"); return {}; @@ -457,7 +457,7 @@ QDebug operator<<(QDebug d, const CodeSnip &s) if (f.instance().isNull()) { d << '"'; const QString &code = f.code(); - const auto lines = QStringView{code}.split(QLatin1Char('\n')); + const auto lines = QStringView{code}.split(u'\n'); for (int i = 0, size = lines.size(); i < size; ++i) { if (i) d << "\\n"; @@ -849,7 +849,7 @@ bool FunctionModification::matches(const QString &functionSignature) const bool FunctionModification::setSignature(const QString &s, QString *errorMessage) { - if (s.startsWith(QLatin1Char('^'))) { + if (s.startsWith(u'^')) { d->m_signaturePattern.setPattern(s); if (!d->m_signaturePattern.isValid()) { if (errorMessage) { diff --git a/sources/shiboken6/ApiExtractor/parser/codemodel.cpp b/sources/shiboken6/ApiExtractor/parser/codemodel.cpp index 957ea303d..ba5b9022b 100644 --- a/sources/shiboken6/ApiExtractor/parser/codemodel.cpp +++ b/sources/shiboken6/ApiExtractor/parser/codemodel.cpp @@ -586,7 +586,7 @@ void _ScopeModelItem::purgeClassDeclarations() // For an empty class, check if there is a matching template // definition, and remove it if this is the case. if (!klass->isTemplate() && klass->isEmpty()) { - const QString definitionPrefix = klass->name() + QLatin1Char('<'); + const QString definitionPrefix = klass->name() + u'<'; const bool definitionFound = std::any_of(m_classes.cbegin(), m_classes.cend(), [definitionPrefix] (const ClassModelItem &c) { @@ -663,7 +663,7 @@ public: const QString &itemName = item->name(); if (!itemName.startsWith(m_name)) return false; - return itemName.size() == m_name.size() || itemName.at(m_name.size()) == QLatin1Char('<'); + return itemName.size() == m_name.size() || itemName.at(m_name.size()) == u'<'; } private: @@ -674,7 +674,7 @@ private: ClassModelItem _ScopeModelItem::findClass(const QString &name) const { // A fully qualified template is matched by name only - const ClassList::const_iterator it = name.contains(QLatin1Char('<')) + const ClassList::const_iterator it = name.contains(u'<') ? std::find_if(m_classes.begin(), m_classes.end(), ModelItemNamePredicate<_ClassModelItem>(name)) : std::find_if(m_classes.begin(), m_classes.end(), ClassNamePredicate(name)); return it != m_classes.end() ? *it : ClassModelItem(); diff --git a/sources/shiboken6/ApiExtractor/parser/typeinfo.cpp b/sources/shiboken6/ApiExtractor/parser/typeinfo.cpp index a6db82b35..2ca48ec30 100644 --- a/sources/shiboken6/ApiExtractor/parser/typeinfo.cpp +++ b/sources/shiboken6/ApiExtractor/parser/typeinfo.cpp @@ -399,15 +399,15 @@ QString TypeInfo::toString() const tmp += d->m_qualifiedName.join(QLatin1String("::")); if (const int instantiationCount = d->m_instantiations.size()) { - tmp += QLatin1Char('<'); + tmp += u'<'; for (int i = 0; i < instantiationCount; ++i) { if (i) tmp += QLatin1String(", "); tmp += d->m_instantiations.at(i).toString(); } - if (tmp.endsWith(QLatin1Char('>'))) - tmp += QLatin1Char(' '); - tmp += QLatin1Char('>'); + if (tmp.endsWith(u'>')) + tmp += u' '; + tmp += u'>'; } for (Indirection i : d->m_indirections) @@ -417,7 +417,7 @@ QString TypeInfo::toString() const case NoReference: break; case LValueReference: - tmp += QLatin1Char('&'); + tmp += u'&'; break; case RValueReference: tmp += QLatin1String("&&"); @@ -432,14 +432,11 @@ QString TypeInfo::toString() const tmp += d->m_arguments.at(i).toString(); } - tmp += QLatin1Char(')'); + tmp += u')'; } - for (const QString &elt : d->m_arrayElements) { - tmp += QLatin1Char('['); - tmp += elt; - tmp += QLatin1Char(']'); - } + for (const QString &elt : d->m_arrayElements) + tmp += u'[' + elt + u']'; return tmp; } @@ -508,10 +505,8 @@ void TypeInfo::stripQualifiers(QString *s) { stripLeadingConst(s); stripLeadingVolatile(s); - while (s->endsWith(QLatin1Char('&')) || s->endsWith(QLatin1Char('*')) - || s->endsWith(QLatin1Char(' '))) { + while (s->endsWith(u'&') || s->endsWith(u'*') || s->endsWith(u' ')) s->chop(1); - } } // Helper functionality to simplify a raw standard type as returned by diff --git a/sources/shiboken6/ApiExtractor/propertyspec.cpp b/sources/shiboken6/ApiExtractor/propertyspec.cpp index f66eeeaf6..cd0118e13 100644 --- a/sources/shiboken6/ApiExtractor/propertyspec.cpp +++ b/sources/shiboken6/ApiExtractor/propertyspec.cpp @@ -200,7 +200,7 @@ TypeSystemProperty QPropertySpec::typeSystemPropertyFromQ_Property(const QString // Q_PROPERTY(QString objectName READ objectName WRITE setObjectName NOTIFY objectNameChanged) const QString declaration = declarationIn.simplified(); - auto propertyTokens = declaration.split(QLatin1Char(' '), Qt::SkipEmptyParts); + auto propertyTokens = declaration.split(u' ', Qt::SkipEmptyParts); // To properly parse complicated type declarations like // "Q_PROPERTY(const QList<QString > *objectName READ objectName ..." @@ -243,7 +243,7 @@ TypeSystemProperty QPropertySpec::typeSystemPropertyFromQ_Property(const QString result.type = propertyTokens.constFirst(); for (int pos = 1; pos < namePos; ++pos) - result.type += QLatin1Char(' ') + propertyTokens.at(pos); + result.type += u' ' + propertyTokens.at(pos); // Fix errors like "Q_PROPERTY(QXYSeries *series .." to be of type "QXYSeries*" while (!result.name.isEmpty() && !result.name.at(0).isLetter()) { diff --git a/sources/shiboken6/ApiExtractor/qtdocparser.cpp b/sources/shiboken6/ApiExtractor/qtdocparser.cpp index e7fe8f9e2..f49442d39 100644 --- a/sources/shiboken6/ApiExtractor/qtdocparser.cpp +++ b/sources/shiboken6/ApiExtractor/qtdocparser.cpp @@ -87,8 +87,8 @@ static void formatFunctionUnqualifiedArgTypeQuery(QTextStream &str, // to "Qt::Alignment" as seen by qdoc. const auto *flagsEntry = static_cast<const FlagsTypeEntry *>(metaType.typeEntry()); QString name = flagsEntry->qualifiedCppName(); - if (name.endsWith(QLatin1Char('>')) && name.startsWith(QLatin1String("QFlags<"))) { - const int lastColon = name.lastIndexOf(QLatin1Char(':')); + if (name.endsWith(u'>') && name.startsWith(QLatin1String("QFlags<"))) { + const int lastColon = name.lastIndexOf(u':'); if (lastColon != -1) { name.replace(lastColon + 1, name.size() - lastColon - 1, metaType.name()); name.remove(0, 7); @@ -348,7 +348,7 @@ void QtDocParser::fillDocumentation(AbstractMetaClass* metaClass) context = context->enclosingClass(); } - QString sourceFileRoot = documentationDataDirectory() + QLatin1Char('/') + QString sourceFileRoot = documentationDataDirectory() + u'/' + metaClass->qualifiedCppName().toLower(); sourceFileRoot.replace(QLatin1String("::"), QLatin1String("-")); @@ -452,8 +452,8 @@ Documentation QtDocParser::retrieveModuleDocumentation(const QString& name) // TODO: This method of acquiring the module name supposes that the target language uses // dots as module separators in package names. Improve this. QString moduleName = name; - moduleName.remove(0, name.lastIndexOf(QLatin1Char('.')) + 1); - const QString prefix = documentationDataDirectory() + QLatin1Char('/') + moduleName.remove(0, name.lastIndexOf(u'.') + 1); + const QString prefix = documentationDataDirectory() + u'/' + moduleName.toLower(); QString sourceFile = prefix + QLatin1String(".xml"); diff --git a/sources/shiboken6/ApiExtractor/reporthandler.cpp b/sources/shiboken6/ApiExtractor/reporthandler.cpp index f0c5bf31e..4b9d8187b 100644 --- a/sources/shiboken6/ApiExtractor/reporthandler.cpp +++ b/sources/shiboken6/ApiExtractor/reporthandler.cpp @@ -142,12 +142,12 @@ void ReportHandler::messageOutput(QtMsgType type, const QMessageLogContext &cont } QString message = m_prefix; if (!message.isEmpty()) - message.append(QLatin1Char(' ')); + message.append(u' '); const int prefixLength = message.size(); message.append(text); // Replace file location tab by space if (fileLocationPos >= 0) - message[prefixLength + fileLocationPos + 1] = QLatin1Char(' '); + message[prefixLength + fileLocationPos + 1] = u' '; fprintf(stderr, "%s\n", qPrintable(qFormatLogMessage(type, context, message))); } diff --git a/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp b/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp index bd0835426..070a21f12 100644 --- a/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp +++ b/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp @@ -65,9 +65,9 @@ void TestCodeInjections::testReadFile() char *argv[] = {nullptr}; QCoreApplication app(argc, argv); - QString attribute = QLatin1String("file='") + filePath + QLatin1Char('\''); + QString attribute = QLatin1String("file='") + filePath + u'\''; if (!snippet.isEmpty()) - attribute += QLatin1String(" snippet='") + snippet + QLatin1Char('\''); + attribute += QLatin1String(" snippet='") + snippet + u'\''; QString xmlCode = QLatin1String("\ <typesystem package=\"Foo\">\n\ diff --git a/sources/shiboken6/ApiExtractor/textstream.cpp b/sources/shiboken6/ApiExtractor/textstream.cpp index 2b8e9f29b..fb9d78876 100644 --- a/sources/shiboken6/ApiExtractor/textstream.cpp +++ b/sources/shiboken6/ApiExtractor/textstream.cpp @@ -250,7 +250,7 @@ void disableIndent(TextStream &s) void ensureEndl(TextStream &s) { - if (s.lastChar() != QLatin1Char('\n')) + if (s.lastChar() != u'\n') s << '\n'; } diff --git a/sources/shiboken6/ApiExtractor/typedatabase.cpp b/sources/shiboken6/ApiExtractor/typedatabase.cpp index 42a9473e9..58099097c 100644 --- a/sources/shiboken6/ApiExtractor/typedatabase.cpp +++ b/sources/shiboken6/ApiExtractor/typedatabase.cpp @@ -47,8 +47,8 @@ static QString wildcardToRegExp(QString w) { - w.replace(QLatin1Char('?'), QLatin1Char('.')); - w.replace(QLatin1Char('*'), QStringLiteral(".*")); + w.replace(u'?', u'.'); + w.replace(u'*', QStringLiteral(".*")); return w; } @@ -136,7 +136,7 @@ static const IntTypeNormalizationEntries &intTypeNormalizationEntries() firstTime = false; for (auto t : {"char", "short", "int", "long"}) { const QString intType = QLatin1String(t); - if (!TypeDatabase::instance()->findType(QLatin1Char('u') + intType)) { + if (!TypeDatabase::instance()->findType(u'u' + intType)) { IntTypeNormalizationEntry entry; entry.replacement = QStringLiteral("unsigned ") + intType; entry.regex.setPattern(QStringLiteral("\\bu") + intType + QStringLiteral("\\b")); @@ -271,7 +271,7 @@ ContainerTypeEntry* TypeDatabase::findContainerType(const QString &name) const { QString template_name = name; - int pos = name.indexOf(QLatin1Char('<')); + int pos = name.indexOf(u'<'); if (pos > 0) template_name = name.left(pos); @@ -485,7 +485,7 @@ TypeEntry *TypeDatabase::resolveTypeDefEntry(TypedefEntry *typedefEntry, QString *errorMessage) { QString sourceName = typedefEntry->sourceType(); - const int lessThanPos = sourceName.indexOf(QLatin1Char('<')); + const int lessThanPos = sourceName.indexOf(u'<'); if (lessThanPos != -1) sourceName.truncate(lessThanPos); ComplexTypeEntry *source = nullptr; @@ -505,7 +505,7 @@ TypeEntry *TypeDatabase::resolveTypeDefEntry(TypedefEntry *typedefEntry, if (!source) { if (errorMessage) *errorMessage = QLatin1String("Unable to resolve typedef \"") - + typedefEntry->sourceType() + QLatin1Char('"'); + + typedefEntry->sourceType() + u'"'; return nullptr; } @@ -630,21 +630,21 @@ FunctionModificationList TypeDatabase::functionModifications(const QString& sign bool TypeDatabase::addSuppressedWarning(const QString &warning, QString *errorMessage) { QString pattern; - if (warning.startsWith(QLatin1Char('^')) && warning.endsWith(QLatin1Char('$'))) { + if (warning.startsWith(u'^') && warning.endsWith(u'$')) { pattern = warning; } else { // Legacy syntax: Use wildcards '*' (unless escaped by '\') QList<int> asteriskPositions; const int warningSize = warning.size(); for (int i = 0; i < warningSize; ++i) { - if (warning.at(i) == QLatin1Char('\\')) + if (warning.at(i) == u'\\') ++i; - else if (warning.at(i) == QLatin1Char('*')) + else if (warning.at(i) == u'*') asteriskPositions.append(i); } asteriskPositions.append(warningSize); - pattern.append(QLatin1Char('^')); + pattern.append(u'^'); int lastPos = 0; for (int a = 0, aSize = asteriskPositions.size(); a < aSize; ++a) { if (a) @@ -654,7 +654,7 @@ bool TypeDatabase::addSuppressedWarning(const QString &warning, QString *errorMe pattern.append(QRegularExpression::escape(warning.mid(lastPos, nextPos - lastPos))); lastPos = nextPos + 1; } - pattern.append(QLatin1Char('$')); + pattern.append(u'$'); } QRegularExpression expression(pattern); @@ -687,12 +687,12 @@ QString TypeDatabase::modifiedTypesystemFilepath(const QString& tsFile, const QS if (tsFi.isFile()) // Make path absolute return tsFi.absoluteFilePath(); if (!currentPath.isEmpty()) { - const QFileInfo fi(currentPath + QLatin1Char('/') + tsFile); + const QFileInfo fi(currentPath + u'/' + tsFile); if (fi.isFile()) return fi.absoluteFilePath(); } for (const QString &path : m_typesystemPaths) { - const QFileInfo fi(path + QLatin1Char('/') + tsFile); + const QFileInfo fi(path + u'/' + tsFile); if (fi.isFile()) return fi.absoluteFilePath(); } diff --git a/sources/shiboken6/ApiExtractor/typeparser.cpp b/sources/shiboken6/ApiExtractor/typeparser.cpp index fba3a8801..1b2e770c8 100644 --- a/sources/shiboken6/ApiExtractor/typeparser.cpp +++ b/sources/shiboken6/ApiExtractor/typeparser.cpp @@ -82,7 +82,7 @@ Scanner::Token Scanner::nextToken(QString *errorMessage) Token tok = NoToken; // remove whitespace - while (m_pos < m_length && m_chars[m_pos] == QLatin1Char(' ')) + while (m_pos < m_length && m_chars[m_pos] == u' ') ++m_pos; m_tokenStart = m_pos; @@ -108,7 +108,7 @@ Scanner::Token Scanner::nextToken(QString *errorMessage) ++m_pos; break; default: - if (c.isLetterOrNumber() || c == QLatin1Char('_')) { + if (c.isLetterOrNumber() || c == u'_') { tok = Identifier; } else { QString message; @@ -131,7 +131,7 @@ Scanner::Token Scanner::nextToken(QString *errorMessage) } if (tok == Identifier) { - if (c.isLetterOrNumber() || c == QLatin1Char('_')) + if (c.isLetterOrNumber() || c == u'_') ++m_pos; else break; @@ -141,23 +141,23 @@ Scanner::Token Scanner::nextToken(QString *errorMessage) if (tok == Identifier) { switch (m_pos - m_tokenStart) { case 5: - if (m_chars[m_tokenStart] == QLatin1Char('c') - && m_chars[m_tokenStart + 1] == QLatin1Char('o') - && m_chars[m_tokenStart + 2] == QLatin1Char('n') - && m_chars[m_tokenStart + 3] == QLatin1Char('s') - && m_chars[m_tokenStart + 4] == QLatin1Char('t')) { + if (m_chars[m_tokenStart] == u'c' + && m_chars[m_tokenStart + 1] == u'o' + && m_chars[m_tokenStart + 2] == u'n' + && m_chars[m_tokenStart + 3] == u's' + && m_chars[m_tokenStart + 4] == u't') { tok = ConstToken; } break; case 8: - if (m_chars[m_tokenStart] == QLatin1Char('v') - && m_chars[m_tokenStart + 1] == QLatin1Char('o') - && m_chars[m_tokenStart + 2] == QLatin1Char('l') - && m_chars[m_tokenStart + 3] == QLatin1Char('a') - && m_chars[m_tokenStart + 4] == QLatin1Char('t') - && m_chars[m_tokenStart + 5] == QLatin1Char('i') - && m_chars[m_tokenStart + 6] == QLatin1Char('l') - && m_chars[m_tokenStart + 7] == QLatin1Char('e')) { + if (m_chars[m_tokenStart] == u'v' + && m_chars[m_tokenStart + 1] == u'o' + && m_chars[m_tokenStart + 2] == u'l' + && m_chars[m_tokenStart + 3] == u'a' + && m_chars[m_tokenStart + 4] == u't' + && m_chars[m_tokenStart + 5] == u'i' + && m_chars[m_tokenStart + 6] == u'l' + && m_chars[m_tokenStart + 7] == u'e') { tok = VolatileToken; } break; @@ -285,7 +285,7 @@ TypeInfo TypeParser::parse(const QString &str, QString *errorMessage) colon_prefix = false; } else { QStringList qualifiedName = stack.top().qualifiedName(); - qualifiedName.last().append(QLatin1Char(' ') + scanner.identifier()); + qualifiedName.last().append(u' ' + scanner.identifier()); stack.top().setQualifiedName(qualifiedName); } break; diff --git a/sources/shiboken6/ApiExtractor/typesystem.cpp b/sources/shiboken6/ApiExtractor/typesystem.cpp index fd92ee076..7514e93dc 100644 --- a/sources/shiboken6/ApiExtractor/typesystem.cpp +++ b/sources/shiboken6/ApiExtractor/typesystem.cpp @@ -483,7 +483,7 @@ QString TypeEntry::buildTargetLangName() const for (auto p = parent(); p && p->type() != TypeEntry::TypeSystemType; p = p->parent()) { if (NamespaceTypeEntry::isVisibleScope(p)) { if (!result.isEmpty()) - result.prepend(QLatin1Char('.')); + result.prepend(u'.'); QString n = p->m_d->m_entryName; n.replace(QLatin1String("::"), QLatin1String(".")); // Primitive types may have "std::" result.prepend(n); @@ -569,7 +569,7 @@ QString TypeEntry::targetLangEntryName() const { if (m_d->m_cachedTargetLangEntryName.isEmpty()) { m_d->m_cachedTargetLangEntryName = targetLangName(); - const int lastDot = m_d->m_cachedTargetLangEntryName.lastIndexOf(QLatin1Char('.')); + const int lastDot = m_d->m_cachedTargetLangEntryName.lastIndexOf(u'.'); if (lastDot != -1) m_d->m_cachedTargetLangEntryName.remove(0, lastDot + 1); } @@ -588,7 +588,7 @@ void TypeEntry::setTargetLangPackage(const QString &p) QString TypeEntry::qualifiedTargetLangName() const { - return targetLangPackage() + QLatin1Char('.') + targetLangName(); + return targetLangPackage() + u'.' + targetLangName(); } bool TypeEntry::isValue() const diff --git a/sources/shiboken6/ApiExtractor/typesystemparser.cpp b/sources/shiboken6/ApiExtractor/typesystemparser.cpp index 2db8300ba..532605416 100644 --- a/sources/shiboken6/ApiExtractor/typesystemparser.cpp +++ b/sources/shiboken6/ApiExtractor/typesystemparser.cpp @@ -128,12 +128,12 @@ static bool setRejectionRegularExpression(const QString &patternIn, QString *errorMessage) { QString pattern; - if (patternIn.startsWith(QLatin1Char('^')) && patternIn.endsWith(QLatin1Char('$'))) + if (patternIn.startsWith(u'^') && patternIn.endsWith(u'$')) pattern = patternIn; else if (patternIn == QLatin1String("*")) pattern = QStringLiteral("^.*$"); else - pattern = QLatin1Char('^') + QRegularExpression::escape(patternIn) + QLatin1Char('$'); + pattern = u'^' + QRegularExpression::escape(patternIn) + u'$'; re->setPattern(pattern); if (!re->isValid()) { *errorMessage = msgInvalidRegularExpression(patternIn, re->errorString()); @@ -157,7 +157,7 @@ std::optional<QString> bool useLine = false; bool foundLabel = false; QString result; - const auto lines = QStringView{code}.split(QLatin1Char('\n')); + const auto lines = QStringView{code}.split(u'\n'); for (const auto &line : lines) { if (snippetRe.match(line).hasMatch()) { foundLabel = true; @@ -165,7 +165,7 @@ std::optional<QString> if (!useLine) break; // End of snippet reached } else if (useLine) - result += line.toString() + QLatin1Char('\n'); + result += line.toString() + u'\n'; } if (!foundLabel) return {}; @@ -546,7 +546,7 @@ private: QString TypeSystemEntityResolver::readFile(const QString &entityName, QString *errorMessage) const { QString fileName = entityName; - if (!fileName.contains(QLatin1Char('.'))) + if (!fileName.contains(u'.')) fileName += QLatin1String(".xml"); QString path = TypeDatabase::instance()->modifiedTypesystemFilepath(fileName, m_currentPath); if (!QFileInfo::exists(path)) // PySide6-specific hack @@ -1153,7 +1153,7 @@ bool TypeSystemParser::importFileElement(const QXmlStreamAttributes &atts) break; } if (from && to) - characters(line + QLatin1Char('\n')); + characters(line + u'\n'); if (!from && line.contains(quoteFrom)) { from = true; foundFromOk = true; @@ -1170,7 +1170,7 @@ bool TypeSystemParser::importFileElement(const QXmlStreamAttributes &atts) if (!foundFromOk) m_error = fromError; if (!foundFromOk && !foundToOk) - m_error = fromError + QLatin1Char(' ') + toError; + m_error = fromError + u' ' + toError; return false; } @@ -1214,7 +1214,7 @@ static bool shouldDropTypeEntry(const TypeDatabase *db, if (db->shouldDropTypeEntry(name)) // Unqualified return true; } - name.prepend(QLatin1Char('.')); + name.prepend(u'.'); name.prepend(entry->name()); } } @@ -1224,7 +1224,7 @@ static bool shouldDropTypeEntry(const TypeDatabase *db, // Returns empty string if there's no error. static QString checkSignatureError(const QString& signature, const QString& tag) { - QString funcName = signature.left(signature.indexOf(QLatin1Char('('))).trimmed(); + QString funcName = signature.left(signature.indexOf(u'(')).trimmed(); static const QRegularExpression whiteSpace(QStringLiteral("\\s")); Q_ASSERT(whiteSpace.isValid()); if (!funcName.startsWith(QLatin1String("operator ")) && funcName.contains(whiteSpace)) { @@ -1318,7 +1318,7 @@ FlagsTypeEntry * { if (!checkRootElement()) return nullptr; - auto ftype = new FlagsTypeEntry(QLatin1String("QFlags<") + enumEntry->name() + QLatin1Char('>'), + auto ftype = new FlagsTypeEntry(QLatin1String("QFlags<") + enumEntry->name() + u'>', since, currentParentTypeEntry()->typeSystemTypeEntry()); ftype->setOriginator(enumEntry); @@ -1335,15 +1335,16 @@ FlagsTypeEntry * return nullptr; QStringList lst = flagName.split(colonColon()); - const QString targetLangFlagName = QStringList(lst.mid(0, lst.size() - 1)).join(QLatin1Char('.')); + const QString name = lst.takeLast(); + const QString targetLangFlagName = lst.join(u'.'); const QString &targetLangQualifier = enumEntry->targetLangQualifier(); if (targetLangFlagName != targetLangQualifier) { qCWarning(lcShiboken).noquote().nospace() << QStringLiteral("enum %1 and flags %2 (%3) differ in qualifiers") - .arg(targetLangQualifier, lst.constFirst(), targetLangFlagName); + .arg(targetLangQualifier, lst.value(0), targetLangFlagName); } - ftype->setFlagsName(lst.constLast()); + ftype->setFlagsName(name); enumEntry->setFlags(ftype); m_database->addFlagsType(ftype); @@ -1553,7 +1554,7 @@ EnumTypeEntry * // put in the flags parallel... if (!flagNames.isEmpty()) { - const QStringList &flagNameList = flagNames.split(QLatin1Char(',')); + const QStringList &flagNameList = flagNames.split(u','); for (const QString &flagName : flagNameList) parseFlagsEntry(reader, entry, flagName.trimmed(), since, attributes); } @@ -1853,7 +1854,7 @@ bool TypeSystemParser::parseRenameFunction(const ConditionalStreamReader &, return false; } - *name = signature.left(signature.indexOf(QLatin1Char('('))).trimmed(); + *name = signature.left(signature.indexOf(u'(')).trimmed(); QString errorString = checkSignatureError(signature, QLatin1String("function")); if (!errorString.isEmpty()) { @@ -2465,7 +2466,7 @@ bool TypeSystemParser::parseAddFunction(const ConditionalStreamReader &, // Create signature for matching modifications signature = TypeDatabase::normalizedSignature(originalSignature); - if (!signature.contains(QLatin1Char('('))) + if (!signature.contains(u'(')) signature += QLatin1String("()"); m_currentSignature = signature; @@ -2778,7 +2779,7 @@ bool TypeSystemParser::readFileSnippet(QXmlStreamAttributes *attributes, CodeSni QString source = fileName; if (!snippetLabel.isEmpty()) - source += QLatin1String(" (") + snippetLabel + QLatin1Char(')'); + source += QLatin1String(" (") + snippetLabel + u')'; QString content; QTextStream str(&content); str << "// ========================================================================\n" @@ -3043,7 +3044,7 @@ bool TypeSystemParser::startElement(const ConditionalStreamReader &reader, Stack } } // Allow for primitive and/or std:: types only, else require proper nesting. - if (element != StackElement::PrimitiveTypeEntry && name.contains(QLatin1Char(':')) + if (element != StackElement::PrimitiveTypeEntry && name.contains(u':') && !name.contains(QLatin1String("std::"))) { m_error = msgIncorrectlyNestedName(name); return false; diff --git a/sources/shiboken6/ApiExtractor/xmlutils.cpp b/sources/shiboken6/ApiExtractor/xmlutils.cpp index 6edca2fa5..2cd2e3b81 100644 --- a/sources/shiboken6/ApiExtractor/xmlutils.cpp +++ b/sources/shiboken6/ApiExtractor/xmlutils.cpp @@ -37,8 +37,8 @@ XQuery::~XQuery() = default; QString XQuery::evaluate(QString xPathExpression, QString *errorMessage) { // XQuery can't have invalid XML characters - xPathExpression.replace(QLatin1Char('&'), QLatin1String("&")); - xPathExpression.replace(QLatin1Char('<'), QLatin1String("<")); + xPathExpression.replace(u'&', QLatin1String("&")); + xPathExpression.replace(u'<', QLatin1String("<")); return doEvaluate(xPathExpression, errorMessage); } diff --git a/sources/shiboken6/ApiExtractor/xmlutils_libxslt.cpp b/sources/shiboken6/ApiExtractor/xmlutils_libxslt.cpp index e1e185130..92a897cac 100644 --- a/sources/shiboken6/ApiExtractor/xmlutils_libxslt.cpp +++ b/sources/shiboken6/ApiExtractor/xmlutils_libxslt.cpp @@ -145,7 +145,7 @@ QString LibXmlXQuery::doEvaluate(const QString &xPathExpression, QString *errorM XmlPathObjectUniquePtr xPathObject(xmlXPathEvalExpression(xPathExpressionX, m_xpathContext.get())); if (!xPathObject) { *errorMessage = QLatin1String("xmlXPathEvalExpression() failed for \"") + xPathExpression - + QLatin1Char('"'); + + u'"'; return QString(); } QString result; diff --git a/sources/shiboken6/generator/generator.cpp b/sources/shiboken6/generator/generator.cpp index a78759c9e..26a152a1b 100644 --- a/sources/shiboken6/generator/generator.cpp +++ b/sources/shiboken6/generator/generator.cpp @@ -109,7 +109,7 @@ QString DefaultValue::initialization() const case DefaultValue::Custom: return QLatin1String(" = ") + m_value; case DefaultValue::Enum: - return QLatin1Char('{') + m_value + QLatin1Char('}'); + return u'{' + m_value + u'}'; case DefaultValue::Pointer: return QLatin1String("{nullptr}"); case DefaultValue::Void: @@ -129,8 +129,8 @@ QString DefaultValue::constructorParameter() const return QLatin1String("false"); case DefaultValue::CppScalar: { // PYSIDE-846: Use static_cast in case of "unsigned long" and similar - const QString cast = m_value.contains(QLatin1Char(' ')) - ? QLatin1String("static_cast<") + m_value + QLatin1Char('>') + const QString cast = m_value.contains(u' ') + ? QLatin1String("static_cast<") + m_value + u'>' : m_value; return cast + QLatin1String("(0)"); } @@ -427,7 +427,7 @@ QString Generator::packageName() static QString getModuleName() { QString result = TypeDatabase::instance()->defaultPackageName(); - result.remove(0, result.lastIndexOf(QLatin1Char('.')) + 1); + result.remove(0, result.lastIndexOf(u'.') + 1); return result; } @@ -458,8 +458,8 @@ bool Generator::generateFileForContext(const GeneratorContext &context) if (fileName.isEmpty()) return true; - QString filePath = outputDirectory() + QLatin1Char('/') + subDirectoryForClass(cls) - + QLatin1Char('/') + fileName; + QString filePath = outputDirectory() + u'/' + subDirectoryForClass(cls) + + u'/' + fileName; FileOut fileOut(filePath); generateClass(fileOut.stream, context); @@ -604,7 +604,7 @@ QString Generator::getFullTypeNameWithoutModifiers(const AbstractMetaType &type) typeName.chop(2); break; } - while (typeName.endsWith(QLatin1Char('*')) || typeName.endsWith(QLatin1Char(' '))) + while (typeName.endsWith(u'*') || typeName.endsWith(u' ')) typeName.chop(1); return QLatin1String("::") + typeName; } @@ -619,13 +619,13 @@ std::optional<DefaultValue> if (type.isContainer()) { QString ctor = type.cppSignature(); - if (ctor.endsWith(QLatin1Char('*'))) { + if (ctor.endsWith(u'*')) { ctor.chop(1); return DefaultValue(DefaultValue::Pointer, ctor.trimmed()); } if (ctor.startsWith(QLatin1String("const "))) ctor.remove(0, sizeof("const ") / sizeof(char) - 1); - if (ctor.endsWith(QLatin1Char('&'))) { + if (ctor.endsWith(u'&')) { ctor.chop(1); ctor = ctor.trimmed(); } @@ -725,8 +725,8 @@ std::optional<DefaultValue> static QString constructorCall(const QString &qualifiedCppName, const QStringList &args) { - return QLatin1String("::") + qualifiedCppName + QLatin1Char('(') - + args.join(QLatin1String(", ")) + QLatin1Char(')'); + return QLatin1String("::") + qualifiedCppName + u'(' + + args.join(QLatin1String(", ")) + u')'; } std::optional<DefaultValue> @@ -843,7 +843,7 @@ QString Generator::subDirectoryForPackage(QString packageNameIn) const { if (packageNameIn.isEmpty()) packageNameIn = packageName(); - packageNameIn.replace(QLatin1Char('.'), QDir::separator()); + packageNameIn.replace(u'.', QDir::separator()); return packageNameIn; } @@ -856,13 +856,13 @@ static QString getClassTargetFullName_(const T *t, bool includePackageName) // If the type was marked as 'visible=false' we should not use it in // the type name if (NamespaceTypeEntry::isVisibleScope(context->typeEntry())) { - name.prepend(QLatin1Char('.')); + name.prepend(u'.'); name.prepend(context->name()); } context = context->enclosingClass(); } if (includePackageName) { - name.prepend(QLatin1Char('.')); + name.prepend(u'.'); name.prepend(t->package()); } return name; @@ -895,8 +895,8 @@ QString getClassTargetFullName(const AbstractMetaType &metaType, bool includePac QString getFilteredCppSignatureString(QString signature) { signature.replace(QLatin1String("::"), QLatin1String("_")); - signature.replace(QLatin1Char('<'), QLatin1Char('_')); - signature.replace(QLatin1Char('>'), QLatin1Char('_')); - signature.replace(QLatin1Char(' '), QLatin1Char('_')); + signature.replace(u'<', u'_'); + signature.replace(u'>', u'_'); + signature.replace(u' ', u'_'); return signature; } diff --git a/sources/shiboken6/generator/main.cpp b/sources/shiboken6/generator/main.cpp index ce1e15d35..0baec419a 100644 --- a/sources/shiboken6/generator/main.cpp +++ b/sources/shiboken6/generator/main.cpp @@ -130,14 +130,14 @@ static void printOptions(QTextStream &s, const OptionDescriptions &options) { s.setFieldAlignment(QTextStream::AlignLeft); for (const auto &od : options) { - if (!od.first.startsWith(QLatin1Char('-'))) + if (!od.first.startsWith(u'-')) s << "--"; s << od.first; if (od.second.isEmpty()) { s << ", "; } else { s << Qt::endl; - const auto lines = QStringView{od.second}.split(QLatin1Char('\n')); + const auto lines = QStringView{od.second}.split(u'\n'); for (const auto &line : lines) s << " " << line << Qt::endl; s << Qt::endl; @@ -222,7 +222,7 @@ static std::optional<CommandLineArguments> getProjectFileArguments() QString projectFileName; for (const QString &arg : qAsConst(arguments)) { if (arg.startsWith(QLatin1String("--project-file"))) { - int split = arg.indexOf(QLatin1Char('=')); + int split = arg.indexOf(u'='); if (split > 0) projectFileName = arg.mid(split + 1).trimmed(); break; @@ -252,7 +252,7 @@ static void getCommandLineArg(QString arg, int &argNum, CommandLineArguments &ar { if (arg.startsWith(QLatin1String("--"))) { arg.remove(0, 2); - const int split = arg.indexOf(QLatin1Char('=')); + const int split = arg.indexOf(u'='); if (split < 0) { args.options.insert(arg, QString()); return; @@ -277,15 +277,15 @@ static void getCommandLineArg(QString arg, int &argNum, CommandLineArguments &ar } return; } - if (arg.startsWith(QLatin1Char('-'))) { + if (arg.startsWith(u'-')) { arg.remove(0, 1); - if (arg.startsWith(QLatin1Char('I'))) // Shorthand path arguments -I/usr/include... + if (arg.startsWith(u'I')) // Shorthand path arguments -I/usr/include... args.addToOptionsPathList(includePathOption(), arg.mid(1)); - else if (arg.startsWith(QLatin1Char('F'))) + else if (arg.startsWith(u'F')) args.addToOptionsPathList(frameworkIncludePathOption(), arg.mid(1)); else if (arg.startsWith(QLatin1String("isystem"))) args.addToOptionsPathList(systemIncludePathOption(), arg.mid(7)); - else if (arg.startsWith(QLatin1Char('T'))) + else if (arg.startsWith(u'T')) args.addToOptionsPathList(typesystemPathOption(), arg.mid(1)); else if (arg == QLatin1String("h")) args.options.insert(helpOption(), QString()); @@ -330,7 +330,7 @@ static inline QString languageLevelDescription() { return QLatin1String("C++ Language level (c++11..c++17, default=") + QLatin1String(clang::languageLevelOption(clang::emulatedCompilerLanguageLevel())) - + QLatin1Char(')'); + + u')'; } void printUsage() @@ -447,7 +447,7 @@ int shibokenMain(int argc, char *argv[]) QCoreApplication app(argc, argv); ReportHandler::install(); if (ReportHandler::isDebug(ReportHandler::SparseDebug)) - qCInfo(lcShiboken()).noquote().nospace() << QCoreApplication::arguments().join(QLatin1Char(' ')); + qCInfo(lcShiboken()).noquote().nospace() << QCoreApplication::arguments().join(u' '); // Store command arguments in a map const auto projectFileArgumentsOptional = getProjectFileArguments(); @@ -577,7 +577,7 @@ int shibokenMain(int argc, char *argv[]) const QStringList &versions = ait.value().toStringList(); args.options.erase(ait); for (const QString &fullVersion : versions) { - QStringList parts = fullVersion.split(QLatin1Char(',')); + QStringList parts = fullVersion.split(u','); QString package; QString version; package = parts.size() == 1 ? u"*"_qs : parts.constFirst(); @@ -631,13 +631,13 @@ int shibokenMain(int argc, char *argv[]) QString messagePrefix = QFileInfo(typeSystemFileName).baseName(); if (messagePrefix.startsWith(QLatin1String("typesystem_"))) messagePrefix.remove(0, 11); - ReportHandler::setPrefix(QLatin1Char('(') + messagePrefix + QLatin1Char(')')); + ReportHandler::setPrefix(u'(' + messagePrefix + u')'); QFileInfoList cppFileNames; for (const QString &cppFileName : qAsConst(args.positionalArguments)) { const QFileInfo cppFileNameFi(cppFileName); if (!cppFileNameFi.isFile() && !cppFileNameFi.isSymLink()) { - errorPrint(QLatin1Char('"') + cppFileName + QLatin1String("\" does not exist.")); + errorPrint(u'"' + cppFileName + QLatin1String("\" does not exist.")); return EXIT_FAILURE; } cppFileNames.append(cppFileNameFi); @@ -720,7 +720,7 @@ int shibokenMain(int argc, char *argv[]) ReportHandler::endProgress(); if (!ok) { errorPrint(QLatin1String("Error running generator: ") - + QLatin1String(g->name()) + QLatin1Char('.')); + + QLatin1String(g->name()) + u'.'); return EXIT_FAILURE; } } diff --git a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp index e5c05bfba..a9c520431 100644 --- a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp +++ b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp @@ -204,7 +204,7 @@ void QtDocGenerator::writeFormattedText(TextStream &s, const QString &doc, QtXmlToSphinx x(this, m_parameters, doc, metaClassName); s << x; } else { - const auto lines = QStringView{doc}.split(QLatin1Char('\n')); + const auto lines = QStringView{doc}.split(u'\n'); int typesystemIndentation = std::numeric_limits<int>::max(); // check how many spaces must be removed from the beginning of each line for (const auto &line : lines) { @@ -240,7 +240,7 @@ static void writeInheritedByList(TextStream& s, const AbstractMetaClass* metaCla s << "**Inherited by:** "; QStringList classes; for (auto c : qAsConst(res)) - classes << QLatin1String(":ref:`") + c->name() + QLatin1Char('`'); + classes << QLatin1String(":ref:`") + c->name() + u'`'; s << classes.join(QLatin1String(", ")) << "\n\n"; } @@ -331,21 +331,21 @@ void QtDocGenerator::writeFunctionList(TextStream& s, const AbstractMetaClass* c QString className; if (!func->isConstructor()) - className = cppClass->fullName() + QLatin1Char('.'); + className = cppClass->fullName() + u'.'; else if (func->implementingClass() && func->implementingClass()->enclosingClass()) - className = func->implementingClass()->enclosingClass()->fullName() + QLatin1Char('.'); + className = func->implementingClass()->enclosingClass()->fullName() + u'.'; QString funcName = getFuncName(func); QString str = QLatin1String("def :meth:`"); str += funcName; - str += QLatin1Char('<'); + str += u'<'; if (!funcName.startsWith(className)) str += className; str += funcName; str += QLatin1String(">` ("); str += parseArgDocStyle(cppClass, func); - str += QLatin1Char(')'); + str += u')'; if (func->isStatic()) staticFunctionList << str; @@ -482,7 +482,7 @@ QString QtDocGenerator::parseArgDocStyle(const AbstractMetaClass* /* cppClass */ bool thisIsoptional = !arg.defaultValueExpression().isEmpty(); if (optArgs || thisIsoptional) { - ret += QLatin1Char('['); + ret += u'['; optArgs++; } @@ -508,11 +508,11 @@ QString QtDocGenerator::parseArgDocStyle(const AbstractMetaClass* /* cppClass */ else if (defValue == QLatin1String("0") && arg.type().isObject()) defValue = none(); } - ret += QLatin1Char('=') + defValue; + ret += u'=' + defValue; } } - ret += QString(optArgs, QLatin1Char(']')); + ret += QString(optArgs, u']'); return ret; } @@ -542,7 +542,7 @@ void QtDocGenerator::writeDocSnips(TextStream &s, break; QString codeBlock = code.mid(startBlock, endBlock - startBlock); - const QStringList rows = codeBlock.split(QLatin1Char('\n')); + const QStringList rows = codeBlock.split(u'\n'); int currentRow = 0; int offset = 0; @@ -559,9 +559,9 @@ void QtDocGenerator::writeDocSnips(TextStream &s, if (currentRow == 0) { //find offset for (auto c : row) { - if (c == QLatin1Char(' ')) + if (c == u' ') offset++; - else if (c == QLatin1Char('\n')) + else if (c == u'\n') offset = 0; else break; @@ -625,10 +625,10 @@ QString QtDocGenerator::functionSignature(const AbstractMetaClass* cppClass, funcName = cppClass->fullName(); if (!func->isConstructor()) - funcName += QLatin1Char('.') + getFuncName(func); + funcName += u'.' + getFuncName(func); - return funcName + QLatin1Char('(') + parseArgDocStyle(cppClass, func) - + QLatin1Char(')'); + return funcName + u'(' + parseArgDocStyle(cppClass, func) + + u')'; } QString QtDocGenerator::translateToPythonType(const AbstractMetaType &type, @@ -668,9 +668,9 @@ QString QtDocGenerator::translateToPythonType(const AbstractMetaType &type, strType = intT(); } else if (type.isContainer()) { QString strType = translateType(type, cppClass, Options(ExcludeConst) | ExcludeReference); - strType.remove(QLatin1Char('*')); - strType.remove(QLatin1Char('>')); - strType.remove(QLatin1Char('<')); + strType.remove(u'*'); + strType.remove(u'>'); + strType.remove(u'<'); strType.replace(QLatin1String("::"), QLatin1String(".")); if (strType.contains(QLatin1String("QList")) || strType.contains(QLatin1String("QVector"))) { strType.replace(QLatin1String("QList"), QLatin1String("list of ")); @@ -678,14 +678,14 @@ QString QtDocGenerator::translateToPythonType(const AbstractMetaType &type, } else if (strType.contains(QLatin1String("QHash")) || strType.contains(QLatin1String("QMap"))) { strType.remove(QLatin1String("QHash")); strType.remove(QLatin1String("QMap")); - QStringList types = strType.split(QLatin1Char(',')); + QStringList types = strType.split(u','); strType = QString::fromLatin1("Dictionary with keys of type %1 and values of type %2.") .arg(types[0], types[1]); } } else { auto k = AbstractMetaClass::findClass(api().classes(), type.typeEntry()); strType = k ? k->fullName() : type.name(); - strType = QStringLiteral(":any:`") + strType + QLatin1Char('`'); + strType = QStringLiteral(":any:`") + strType + u'`'; } return strType; } @@ -759,15 +759,14 @@ static void writeFancyToc(TextStream& s, const QStringList& items) { using TocMap = QMap<QChar, QStringList>; TocMap tocMap; - QChar Q = QLatin1Char('Q'); QChar idx; for (QString item : items) { if (item.isEmpty()) continue; item.chop(4); // Remove the .rst extension // skip namespace if necessary - const QString className = item.split(QLatin1Char('.')).last(); - if (className.startsWith(Q) && className.length() > 1) + const QString className = item.split(u'.').last(); + if (className.startsWith(u'Q') && className.length() > 1) idx = className[1]; else idx = className[0]; @@ -787,7 +786,7 @@ static void writeFancyToc(TextStream& s, const QStringList& items) row.clear(); row << QtXmlToSphinx::TableCell(QString{}); } - const QString entry = QLatin1String("* :doc:`") + item + QLatin1Char('`'); + const QString entry = QLatin1String("* :doc:`") + item + u'`'; row << QtXmlToSphinx::TableCell(entry); } if (!row.isEmpty()) @@ -815,8 +814,8 @@ void QtDocGenerator::writeModuleDocumentation() std::sort(it.value().begin(), it.value().end()); QString key = it.key(); - key.replace(QLatin1Char('.'), QLatin1Char('/')); - QString outputDir = outputDirectory() + QLatin1Char('/') + key; + key.replace(u'.', u'/'); + QString outputDir = outputDirectory() + u'/' + key; FileOut output(outputDir + QLatin1String("/index.rst")); TextStream& s = output.stream; @@ -829,7 +828,7 @@ void QtDocGenerator::writeModuleDocumentation() // information when neeeded. For example, the RST files in the extras directory // doesn't include the PySide# prefix in their names. QString moduleName = it.key(); - const int lastIndex = moduleName.lastIndexOf(QLatin1Char('.')); + const int lastIndex = moduleName.lastIndexOf(u'.'); if (lastIndex >= 0) moduleName.remove(0, lastIndex + 1); @@ -850,7 +849,7 @@ void QtDocGenerator::writeModuleDocumentation() // Strip to "Property.rst" in output directory const QString newFileName = fi.fileName().mid(moduleName.size() + 1); it.value().append(newFileName); - const QString newFilePath = outputDir + QLatin1Char('/') + newFileName; + const QString newFilePath = outputDir + u'/' + newFileName; if (QFile::exists(newFilePath)) QFile::remove(newFilePath); if (!QFile::copy(fi.absoluteFilePath(), newFilePath)) { @@ -872,7 +871,7 @@ void QtDocGenerator::writeModuleDocumentation() << "Detailed Description\n--------------------\n\n"; // module doc is always wrong and C++istic, so go straight to the extra directory! - QFile moduleDoc(m_extraSectionDir + QLatin1Char('/') + moduleName + QFile moduleDoc(m_extraSectionDir + u'/' + moduleName + QLatin1String(".rst")); if (moduleDoc.open(QIODevice::ReadOnly | QIODevice::Text)) { s << moduleDoc.readAll(); @@ -924,7 +923,7 @@ void QtDocGenerator::writeAdditionalDocumentation() const continue; const QString line = QFile::decodeName(lineBA); // Parse "[directory]" specification - if (line.size() > 2 && line.startsWith(QLatin1Char('[')) && line.endsWith(QLatin1Char(']'))) { + if (line.size() > 2 && line.startsWith(u'[') && line.endsWith(u']')) { const QString dir = line.mid(1, line.size() - 2); if (dir.isEmpty() || dir == QLatin1String(".")) { targetDir = outDir.absolutePath(); @@ -939,11 +938,11 @@ void QtDocGenerator::writeAdditionalDocumentation() const } } else { // Normal file entry - QFileInfo fi(m_parameters.docDataDir + QLatin1Char('/') + line); + QFileInfo fi(m_parameters.docDataDir + u'/' + line); if (fi.isFile()) { const QString rstFileName = fi.baseName() + rstSuffix; - const QString rstFile = targetDir + QLatin1Char('/') + rstFileName; - const QString context = targetDir.mid(targetDir.lastIndexOf(QLatin1Char('/')) + 1); + const QString rstFile = targetDir + u'/' + rstFileName; + const QString context = targetDir.mid(targetDir.lastIndexOf(u'/') + 1); if (convertToRst(fi.absoluteFilePath(), rstFile, context, &errorMessage)) { ++successCount; @@ -1089,7 +1088,7 @@ bool QtDocGenerator::convertToRst(const QString &sourceFileName, // QtXmlToSphinxDocGeneratorInterface QString QtDocGenerator::expandFunction(const QString &function) const { - const int firstDot = function.indexOf(QLatin1Char('.')); + const int firstDot = function.indexOf(u'.'); const AbstractMetaClass *metaClass = nullptr; if (firstDot != -1) { const auto className = QStringView{function}.left(firstDot); @@ -1114,12 +1113,11 @@ QString QtDocGenerator::expandClass(const QString &context, return typeEntry->qualifiedTargetLangName(); // fall back to the old heuristic if the type wasn't found. QString result = name; - const auto rawlinklist = QStringView{name}.split(QLatin1Char('.')); - QStringList splittedContext = context.split(QLatin1Char('.')); + const auto rawlinklist = QStringView{name}.split(u'.'); + QStringList splittedContext = context.split(u'.'); if (rawlinklist.size() == 1 || rawlinklist.constFirst() == splittedContext.constLast()) { splittedContext.removeLast(); - result.prepend(QLatin1Char('~') + splittedContext.join(QLatin1Char('.')) - + QLatin1Char('.')); + result.prepend(u'~' + splittedContext.join(u'.') + u'.'); } return result; } @@ -1127,7 +1125,7 @@ QString QtDocGenerator::expandClass(const QString &context, QString QtDocGenerator::resolveContextForMethod(const QString &context, const QString &methodName) const { - const auto currentClass = QStringView{context}.split(QLatin1Char('.')).constLast(); + const auto currentClass = QStringView{context}.split(u'.').constLast(); const AbstractMetaClass *metaClass = nullptr; for (auto cls : api().classes()) { @@ -1156,7 +1154,7 @@ QString QtDocGenerator::resolveContextForMethod(const QString &context, return implementingClass->typeEntry()->qualifiedTargetLangName(); } - return QLatin1Char('~') + context; + return u'~' + context; } const QLoggingCategory &QtDocGenerator::loggingCategory() const @@ -1177,7 +1175,7 @@ QtXmlToSphinxLink QtDocGenerator::resolveLink(const QtXmlToSphinxLink &link) con if (link.type != QtXmlToSphinxLink::Reference || !isRelativeHtmlFile(link.linkRef)) return link; static const QString prefix = QStringLiteral("https://doc.qt.io/qt-") - + QString::number(QT_VERSION_MAJOR) + QLatin1Char('/'); + + QString::number(QT_VERSION_MAJOR) + u'/'; QtXmlToSphinxLink resolved = link; resolved.type = QtXmlToSphinxLink::External; resolved.linkRef = prefix + link.linkRef; diff --git a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp index 0cc796d30..859675a25 100644 --- a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp +++ b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp @@ -64,9 +64,9 @@ QString msgFallbackWarning(const QString &location, const QString &identifier, { QString message = QLatin1String("Falling back to \"") + QDir::toNativeSeparators(fallback) + QLatin1String("\" for \"") - + location + QLatin1Char('"'); + + location + u'"'; if (!identifier.isEmpty()) - message += QLatin1String(" [") + identifier + QLatin1Char(']'); + message += QLatin1String(" [") + identifier + u']'; return message; } @@ -163,7 +163,7 @@ TextStream &operator<<(TextStream &str, const QtXmlToSphinxLink &linkContext) const bool isExternal = linkContext.type == QtXmlToSphinxLink::External; if (!linkContext.linkText.isEmpty()) { writeEscapedRstText(str, linkContext.linkText); - if (isExternal && !linkContext.linkText.endsWith(QLatin1Char(' '))) + if (isExternal && !linkContext.linkText.endsWith(u' ')) str << ' '; str << '<'; } @@ -506,7 +506,7 @@ QString QtXmlToSphinx::transform(const QString& doc) static QString resolveFile(const QStringList &locations, const QString &path) { for (QString location : locations) { - location.append(QLatin1Char('/')); + location.append(u'/'); location.append(path); if (QFileInfo::exists(location)) return location; @@ -843,7 +843,7 @@ static inline QString fallbackPathAttribute() { return QStringLiteral("path"); } template <class Indent> // const char*/class Indentor void formatSnippet(TextStream &str, Indent indent, const QString &snippet) { - const auto lines = QStringView{snippet}.split(QLatin1Char('\n')); + const auto lines = QStringView{snippet}.split(u'\n'); for (const auto &line : lines) { if (!line.trimmed().isEmpty()) str << indent << line; @@ -1031,7 +1031,7 @@ void QtXmlToSphinx::handleListTag(QXmlStreamReader& reader) const char *separator = listType == BulletList ? "* " : "#. "; const char *indentLine = listType == BulletList ? " " : " "; for (const TableCell &cell : m_currentTable.constFirst()) { - const auto itemLines = QStringView{cell.data}.split(QLatin1Char('\n')); + const auto itemLines = QStringView{cell.data}.split(u'\n'); m_output << separator << itemLines.constFirst() << '\n'; for (qsizetype i = 1, max = itemLines.size(); i < max; ++i) m_output << indentLine << itemLines[i] << '\n'; @@ -1088,12 +1088,12 @@ QtXmlToSphinxLink *QtXmlToSphinx::handleLinkStart(const QString &type, QString r result->type = QtXmlToSphinxLink::External; } else if (type == functionLinkType() && !m_context.isEmpty()) { result->type = QtXmlToSphinxLink::Method; - const auto rawlinklist = QStringView{result->linkRef}.split(QLatin1Char('.')); + const auto rawlinklist = QStringView{result->linkRef}.split(u'.'); if (rawlinklist.size() == 1 || rawlinklist.constFirst() == m_context) { const auto lastRawLink = rawlinklist.constLast().toString(); QString context = m_generator->resolveContextForMethod(m_context, lastRawLink); if (!result->linkRef.startsWith(context)) - result->linkRef.prepend(context + QLatin1Char('.')); + result->linkRef.prepend(context + u'.'); } else { result->linkRef = m_generator->expandFunction(result->linkRef); } @@ -1169,7 +1169,7 @@ static bool copyImage(const QString &href, const QString &docDataDir, const QString &context, const QString &outputDir, const QLoggingCategory &lc, QString *errorMessage) { - const QChar slash = QLatin1Char('/'); + const QChar slash = u'/'; const int lastSlash = href.lastIndexOf(slash); const QString imagePath = lastSlash != -1 ? href.left(lastSlash) : QString(); const QString imageFileName = lastSlash != -1 ? href.right(href.size() - lastSlash - 1) : href; @@ -1183,10 +1183,10 @@ static bool copyImage(const QString &href, const QString &docDataDir, // FIXME: Not perfect yet, should have knowledge about namespaces (DataVis3D) or // nested classes "Pyside2.QtGui.QTouchEvent.QTouchPoint". QString relativeTargetDir = context; - const int lastDot = relativeTargetDir.lastIndexOf(QLatin1Char('.')); + const int lastDot = relativeTargetDir.lastIndexOf(u'.'); if (lastDot != -1) relativeTargetDir.truncate(lastDot); - relativeTargetDir.replace(QLatin1Char('.'), slash); + relativeTargetDir.replace(u'.', slash); if (!imagePath.isEmpty()) relativeTargetDir += slash + imagePath; @@ -1250,10 +1250,10 @@ void QtXmlToSphinx::handleInlineImageTag(QXmlStreamReader& reader) // enclosed by '|' and define it further down. Determine tag from the base //file name with number. QString tag = href; - int pos = tag.lastIndexOf(QLatin1Char('/')); + int pos = tag.lastIndexOf(u'/'); if (pos != -1) tag.remove(0, pos + 1); - pos = tag.indexOf(QLatin1Char('.')); + pos = tag.indexOf(u'.'); if (pos != -1) tag.truncate(pos); tag += QString::number(m_inlineImages.size() + 1); @@ -1362,7 +1362,7 @@ void QtXmlToSphinx::handleAnchorTag(QXmlStreamReader& reader) if (!anchor.isEmpty() && m_opened_anchor != anchor) { m_opened_anchor = anchor; if (!m_context.isEmpty()) - anchor.prepend(m_context + QLatin1Char('_')); + anchor.prepend(m_context + u'_'); m_output << rstLabel(anchor); } } else if (token == QXmlStreamReader::EndElement) { @@ -1381,7 +1381,7 @@ void QtXmlToSphinx::handleQuoteFileTag(QXmlStreamReader& reader) QXmlStreamReader::TokenType token = reader.tokenType(); if (token == QXmlStreamReader::Characters) { QString location = reader.text().toString(); - location.prepend(m_parameters.libSourceDir + QLatin1Char('/')); + location.prepend(m_parameters.libSourceDir + u'/'); QString errorMessage; QString code = readFromLocation(location, QString(), &errorMessage); if (!errorMessage.isEmpty()) @@ -1445,7 +1445,7 @@ void QtXmlToSphinx::Table::normalize() cell.colSpan = 0; col++; } else if (mergeCols) { - m_rows[row][maxCols - 1].data += QLatin1Char(' ') + cell.data; + m_rows[row][maxCols - 1].data += u' ' + cell.data; } } } @@ -1487,7 +1487,8 @@ void QtXmlToSphinx::Table::format(TextStream& s) const for (qsizetype i = 0, maxI = m_rows.size(); i < maxI; ++i) { const QtXmlToSphinx::TableRow& row = m_rows.at(i); for (qsizetype j = 0, maxJ = std::min(row.size(), colWidths.size()); j < maxJ; ++j) { - const auto rowLines = QStringView{row[j].data}.split(QLatin1Char('\n')); // cache this would be a good idea + // cache this would be a good idea + const auto rowLines = QStringView{row[j].data}.split(u'\n'); for (const auto &str : rowLines) colWidths[j] = std::max(colWidths[j], str.size()); rowHeights[i] = std::max(rowHeights[i], rowLines.size()); @@ -1499,10 +1500,8 @@ void QtXmlToSphinx::Table::format(TextStream& s) const // create a horizontal line to be used later. QString horizontalLine = QLatin1String("+"); - for (auto colWidth : colWidths) { - horizontalLine += QString(colWidth, QLatin1Char('-')); - horizontalLine += QLatin1Char('+'); - } + for (auto colWidth : colWidths) + horizontalLine += QString(colWidth, u'-') + u'+'; // write table rows for (qsizetype i = 0, maxI = m_rows.size(); i < maxI; ++i) { // for each row @@ -1528,7 +1527,8 @@ void QtXmlToSphinx::Table::format(TextStream& s) const qsizetype j = 0; for (qsizetype maxJ = std::min(row.size(), headerColumnCount); j < maxJ; ++j) { // for each column const QtXmlToSphinx::TableCell& cell = row[j]; - const auto rowLines = QStringView{cell.data}.split(QLatin1Char('\n')); // FIXME: Cache this!!! + // FIXME: Cache this!!! + const auto rowLines = QStringView{cell.data}.split(u'\n'); if (!j || !cell.colSpan) s << '|'; @@ -1572,7 +1572,7 @@ void QtXmlToSphinx::Table::formatDebug(QDebug &debug) const void QtXmlToSphinx::stripPythonQualifiers(QString *s) { - const int lastSep = s->lastIndexOf(QLatin1Char('.')); + const int lastSep = s->lastIndexOf(u'.'); if (lastSep != -1) s->remove(0, lastSep + 1); } diff --git a/sources/shiboken6/generator/qtdoc/rstformat.h b/sources/shiboken6/generator/qtdoc/rstformat.h index d14ecc55d..978581907 100644 --- a/sources/shiboken6/generator/qtdoc/rstformat.h +++ b/sources/shiboken6/generator/qtdoc/rstformat.h @@ -116,14 +116,14 @@ inline TextStream &operator<<(TextStream &str, const escape &e) // RST anchor string: Anything else but letters, numbers, '_' or '.' replaced by '-' inline bool isValidRstLabelChar(QChar c) { - return c.isLetterOrNumber() || c == QLatin1Char('_') || c == QLatin1Char('.'); + return c.isLetterOrNumber() || c == u'_' || c == u'.'; } inline QString toRstLabel(QString s) { for (int i = 0, size = s.size(); i < size; ++i) { if (!isValidRstLabelChar(s.at(i))) - s[i] = QLatin1Char('-'); + s[i] = u'-'; } return s; } diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index c6044008c..7836e2768 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -368,21 +368,18 @@ static bool isStdSetterName(QString setterName, QString propertyName) static QString buildPropertyString(const QPropertySpec &spec) { - QString text; - text += QLatin1Char('"'); - text += spec.name(); - text += QLatin1Char(':'); + QString text = u'"' + spec.name() + u':'; if (spec.read() != spec.name()) text += spec.read(); if (!spec.write().isEmpty()) { - text += QLatin1Char(':'); + text += u':'; if (!isStdSetterName(spec.write(), spec.name())) text += spec.write(); } - text += QLatin1Char('"'); + text += u'"'; return text; } @@ -889,18 +886,16 @@ QString CppGenerator::getVirtualFunctionReturnTypeName(const AbstractMetaFunctio return uR"("list")"_qs; } if (typeEntry->isSmartPointer()) - return QLatin1Char('"') + typeEntry->qualifiedCppName() + QLatin1Char('"'); + return u'"' + typeEntry->qualifiedCppName() + u'"'; if (avoidProtectedHack()) { auto metaEnum = api().findAbstractMetaEnum(func->type().typeEntry()); - if (metaEnum.has_value() && metaEnum->isProtected()) { - return QLatin1Char('"') + protectedEnumSurrogateName(metaEnum.value()) - + QLatin1Char('"'); - } + if (metaEnum.has_value() && metaEnum->isProtected()) + return u'"' + protectedEnumSurrogateName(metaEnum.value()) + u'"'; } if (func->type().isPrimitive()) - return QLatin1Char('"') + func->type().name() + QLatin1Char('"'); + return u'"' + func->type().name() + u'"'; return QLatin1String("reinterpret_cast<PyTypeObject *>(Shiboken::SbkType< ") + typeEntry->qualifiedCppName() + QLatin1String(" >())->tp_name"); @@ -971,7 +966,7 @@ QString CppGenerator::virtualMethodReturn(TextStream &s, const ApiExtractorResul } DefaultValue defaultReturnExpr(DefaultValue::Custom, expr); return QLatin1String("return ") + defaultReturnExpr.returnValue() - + QLatin1Char(';'); + + u';'; } } } @@ -992,7 +987,7 @@ QString CppGenerator::virtualMethodReturn(TextStream &s, const ApiExtractorResul return QLatin1String("return result;"); } return QLatin1String("return ") + defaultReturnExpr->returnValue() - + QLatin1Char(';'); + + u';'; } void CppGenerator::writeVirtualMethodNative(TextStream &s, @@ -1074,7 +1069,7 @@ void CppGenerator::writeVirtualMethodNative(TextStream &s, propFlag |= 4; QString propStr; if (propFlag) - propStr = QString::number(propFlag) + QLatin1Char(':'); + propStr = QString::number(propFlag) + u':'; s << "static PyObject *nameCache[2] = {};\n"; if (propFlag) @@ -1587,7 +1582,7 @@ return result;)"; const AbstractMetaClass *sourceClass = conv->ownerClass(); typeCheck = u"PyObject_TypeCheck(pyIn, "_qs + cpythonTypeNameExt(sourceClass->typeEntry()) + u')'; - toCppConv = QLatin1Char('*') + cpythonWrapperCPtr(sourceClass->typeEntry(), QLatin1String("pyIn")); + toCppConv = u'*' + cpythonWrapperCPtr(sourceClass->typeEntry(), QLatin1String("pyIn")); } else { // Constructor that does implicit conversion. if (!conv->typeReplaced(1).isEmpty() || conv->isModifiedToArray(1)) @@ -2108,7 +2103,8 @@ void CppGenerator::writeMethodWrapper(TextStream &s, const OverloadData &overloa QScopedPointer<Indentation> reverseIndent; if (callExtendedReverseOperator) { - QString revOpName = ShibokenGenerator::pythonOperatorFunctionName(rfunc).insert(2, QLatin1Char('r')); + QString revOpName = ShibokenGenerator::pythonOperatorFunctionName(rfunc); + revOpName.insert(2, u'r'); // For custom classes, operations like __radd__ and __rmul__ // will enter an infinite loop. if (rfunc->isBinaryOperator() && revOpName.contains(QLatin1String("shift"))) { @@ -2590,14 +2586,13 @@ static inline QString arrayHandleType(const AbstractMetaTypeList &nestedArrayTyp switch (nestedArrayTypes.size()) { case 1: return QStringLiteral("Shiboken::Conversions::ArrayHandle<") - + nestedArrayTypes.constLast().minimalSignature() - + QLatin1Char('>'); + + nestedArrayTypes.constLast().minimalSignature() + u'>'; case 2: return QStringLiteral("Shiboken::Conversions::Array2Handle<") + nestedArrayTypes.constLast().minimalSignature() + QStringLiteral(", ") + QString::number(nestedArrayTypes.constFirst().arrayElementCount()) - + QLatin1Char('>'); + + u'>'; } return QString(); } @@ -2991,7 +2986,7 @@ void CppGenerator::writeOverloadedFunctionDecisorEngine(TextStream &s, } else if (refFunc->isOperatorOverload() && !refFunc->isCallOperator()) { QString check; if (!refFunc->isReverseOperator()) - check.append(QLatin1Char('!')); + check.append(u'!'); check.append(QLatin1String("isReverse")); typeChecks.prepend(check); } @@ -3280,7 +3275,7 @@ void CppGenerator::writePythonToCppConversionFunctions(TextStream &s, // Python to C++ conversion function. StringStream c(TextStream::Language::Cpp); if (conversion.isEmpty()) - conversion = QLatin1Char('*') + cpythonWrapperCPtr(sourceType, QLatin1String("pyIn")); + conversion = u'*' + cpythonWrapperCPtr(sourceType, QLatin1String("pyIn")); if (!preConversion.isEmpty()) c << preConversion << '\n'; const QString fullTypeName = targetType.isSmartPointer() @@ -3376,7 +3371,7 @@ void CppGenerator::writePythonToCppConversionFunctions(TextStream &s, const Abst pos = match.capturedEnd(); const QString varName = match.captured(1); QString rightCode = code.mid(pos); - rightCode.replace(varName, QLatin1Char('*') + varName); + rightCode.replace(varName, u'*' + varName); code.replace(pos, code.size() - pos, rightCode); } typeName.append(QLatin1String(" *")); @@ -3643,7 +3638,7 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr const auto deRef = arg.type().shouldDereferenceArgument(); QString argName; if (deRef > 0) - argName += QString(deRef, QLatin1Char('*')); + argName += QString(deRef, u'*'); argName += QLatin1String(CPP_ARG) + QString::number(idx); userArgs.append(argName); } @@ -3680,11 +3675,11 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr StringStream uva(TextStream::Language::Cpp); if (func->isOperatorOverload() && !func->isCallOperator()) { - QString firstArg(QLatin1Char('(')); + QString firstArg(u'('); if (!func->isPointerOperator()) // no de-reference operator - firstArg += QLatin1Char('*'); + firstArg += u'*'; firstArg += QLatin1String(CPP_SELF_VAR); - firstArg += QLatin1Char(')'); + firstArg += u')'; QString secondArg = QLatin1String(CPP_ARG0); if (!func->isUnaryOperator()) { auto deRef = func->arguments().constFirst().type().shouldDereferenceArgument(); @@ -3760,7 +3755,7 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr const QString selfVarCast = func->ownerClass() == func->implementingClass() ? QLatin1String(CPP_SELF_VAR) : QLatin1String("reinterpret_cast<") + methodCallClassName - + QLatin1String(" *>(") + QLatin1String(CPP_SELF_VAR) + QLatin1Char(')'); + + QLatin1String(" *>(") + QLatin1String(CPP_SELF_VAR) + u')'; if (func->isConstant()) { if (avoidProtectedHack()) { mc << "const_cast<const ::"; @@ -3769,7 +3764,7 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr const QString selfWrapCast = ownerClass == func->implementingClass() ? QLatin1String(CPP_SELF_VAR) : QLatin1String("reinterpret_cast<") + wrapperName(ownerClass) - + QLatin1String(" *>(") + QLatin1String(CPP_SELF_VAR) + QLatin1Char(')'); + + QLatin1String(" *>(") + QLatin1String(CPP_SELF_VAR) + u')'; mc << wrapperName(ownerClass); mc << " *>(" << selfWrapCast << ")->"; } @@ -3852,8 +3847,8 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr } else { enumName = func->type().cppSignature(); } - const QString methodCall = enumName + QLatin1Char('(') - + mc.toString() + QLatin1Char(')'); + const QString methodCall = enumName + u'(' + + mc.toString() + u')'; mc.clear(); mc << methodCall; s << enumName; @@ -3867,7 +3862,7 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr s << '*'; methodCall = QLatin1String("new ") + func->type().typeEntry()->qualifiedCppName() - + QLatin1Char('(') + mc.toString() + QLatin1Char(')'); + + u'(' + mc.toString() + u')'; } } s << " " << CPP_RETURN_VAR << " = " << methodCall << ";\n"; @@ -4134,7 +4129,7 @@ void CppGenerator::writeEnumConverterInitialization(TextStream &s, const TypeEnt QString signature = enumType->qualifiedCppName(); // Replace "QFlags<Class::Option>" by "Class::Options" - if (flags && signature.startsWith(QLatin1String("QFlags<")) && signature.endsWith(QLatin1Char('>'))) { + if (flags && signature.startsWith(QLatin1String("QFlags<")) && signature.endsWith(u'>')) { signature.chop(1); signature.remove(0, 7); const int lastQualifierPos = signature.lastIndexOf(QLatin1String("::")); @@ -4247,7 +4242,7 @@ void CppGenerator::writeExtendedConverterInitialization(TextStream &s, const Typ s << "// Extended implicit conversions for " << externalType->qualifiedTargetLangName() << ".\n"; for (const AbstractMetaClass *sourceClass : conversions) { - const QString converterVar = cppApiVariableName(externalType->targetLangPackage()) + QLatin1Char('[') + const QString converterVar = cppApiVariableName(externalType->targetLangPackage()) + u'[' + getTypeIndexVariableName(externalType) + u']'; QString sourceTypeName = fixedCppTypeName(sourceClass->typeEntry()); QString targetTypeName = fixedCppTypeName(externalType); @@ -4436,11 +4431,11 @@ void CppGenerator::writeClassDefinition(TextStream &s, "extern \"C\" {\n"; if (!metaClass->typeEntry()->hashFunction().isEmpty()) - tp_hash = QLatin1Char('&') + cpythonBaseName(metaClass) + QLatin1String("_HashFunc"); + tp_hash = u'&' + cpythonBaseName(metaClass) + QLatin1String("_HashFunc"); const auto callOp = metaClass->findFunction(QLatin1String("operator()")); if (!callOp.isNull() && !callOp->isModifiedRemoved()) - tp_call = QLatin1Char('&') + cpythonFunctionName(callOp); + tp_call = u'&' + cpythonFunctionName(callOp); QString computedClassTargetFullName; if (!classContext.forSmartPointer()) @@ -4486,7 +4481,7 @@ void CppGenerator::writeClassDefinition(TextStream &s, } s << "{0, " << NULL_PTR << "}\n" << outdent << "};\n"; - int packageLevel = packageName().count(QLatin1Char('.')) + 1; + int packageLevel = packageName().count(u'.') + 1; s << "static PyType_Spec " << className << "_spec = {\n" << indent << '"' << packageLevel << ':' << computedClassTargetFullName << "\",\n" << "sizeof(SbkObject),\n0,\n" << tp_flags << ",\n" @@ -4569,7 +4564,7 @@ void CppGenerator::writeTypeAsSequenceDefinition(TextStream &s, for (const auto &seq : sequenceProtocols()) { const auto func = metaClass->findFunction(seq.name); if (!func.isNull()) { - funcs.insert(seq.name, QLatin1Char('&') + cpythonFunctionName(func)); + funcs.insert(seq.name, u'&' + cpythonFunctionName(func)); hasFunctions = true; } } @@ -4607,7 +4602,7 @@ void CppGenerator::writeTypeAsMappingDefinition(TextStream &s, const auto func = metaClass->findFunction(m.name); if (!func.isNull()) { const QString entry = QLatin1String("reinterpret_cast<void *>(&") - + cpythonFunctionName(func) + QLatin1Char(')'); + + cpythonFunctionName(func) + u')'; funcs.insert(m.name, entry); } else { funcs.insert(m.name, QLatin1String(NULL_PTR)); @@ -5202,7 +5197,7 @@ void CppGenerator::writeSignatureInfo(TextStream &s, const OverloadData &overloa // mark the multiple signatures as such, to make it easier to generate different code if (multiple) s << idx-- << ':'; - s << funcName << '(' << args.join(QLatin1Char(',')) << ')'; + s << funcName << '(' << args.join(u',') << ')'; if (!f->isVoid()) { QString t = f->pyiTypeReplaced(0); if (t.isEmpty()) @@ -5230,7 +5225,7 @@ static QString mangleName(QString name) if ( name == QLatin1String("None") || name == QLatin1String("False") || name == QLatin1String("True")) - name += QLatin1Char('_'); + name += u'_'; return name; } @@ -5253,13 +5248,13 @@ void CppGenerator::writeEnumInitialization(TextStream &s, const AbstractMetaEnum QString enumVarTypeObj; if (!cppEnum.isAnonymous()) { - int packageLevel = packageName().count(QLatin1Char('.')) + 1; + int packageLevel = packageName().count(u'.') + 1; FlagsTypeEntry *flags = enumTypeEntry->flags(); if (flags) { // The following could probably be made nicer: // We need 'flags->flagsName()' with the full module/class path. QString fullPath = getClassTargetFullName(cppEnum); - fullPath.truncate(fullPath.lastIndexOf(QLatin1Char('.')) + 1); + fullPath.truncate(fullPath.lastIndexOf(u'.') + 1); s << cpythonTypeNameExt(flags) << " = PySide::QFlags::create(\"" << packageLevel << ':' << fullPath << flags->flagsName() << "\", " << cpythonEnumName(cppEnum) << "_number_slots);\n"; @@ -5544,7 +5539,7 @@ void CppGenerator::writeSignatureStrings(TextStream &s, const auto lines = QStringView{signatures}.split(u'\n', Qt::SkipEmptyParts); for (auto line : lines) { // must anything be escaped? - if (line.contains(QLatin1Char('"')) || line.contains(QLatin1Char('\\'))) + if (line.contains(u'"') || line.contains(u'\\')) s << "R\"CPP(" << line << ")CPP\",\n"; else s << '"' << line << "\",\n"; @@ -6223,8 +6218,8 @@ bool CppGenerator::finishGeneration() metaType.typeEntry()->targetLangEnclosingEntry()); } - QString moduleFileName(outputDirectory() + QLatin1Char('/') + subDirectoryForPackage(packageName())); - moduleFileName += QLatin1Char('/') + moduleName().toLower() + QLatin1String("_module_wrapper.cpp"); + QString moduleFileName(outputDirectory() + u'/' + subDirectoryForPackage(packageName())); + moduleFileName += u'/' + moduleName().toLower() + QLatin1String("_module_wrapper.cpp"); FileOut file(moduleFileName); diff --git a/sources/shiboken6/generator/shiboken/headergenerator.cpp b/sources/shiboken6/generator/shiboken/headergenerator.cpp index 0f3dd9fba..51864a65b 100644 --- a/sources/shiboken6/generator/shiboken/headergenerator.cpp +++ b/sources/shiboken6/generator/shiboken/headergenerator.cpp @@ -567,8 +567,8 @@ bool HeaderGenerator::finishGeneration() if (usePySideExtensions()) typeFunctions << "QT_WARNING_POP\n"; - const QString moduleHeaderDir = outputDirectory() + QLatin1Char('/') - + subDirectoryForPackage(packageName()) + QLatin1Char('/'); + const QString moduleHeaderDir = outputDirectory() + u'/' + + subDirectoryForPackage(packageName()) + u'/'; const QString moduleHeaderFileName(moduleHeaderDir + getModuleHeaderFileName()); QString includeShield(QLatin1String("SBK_") + moduleName().toUpper() + QLatin1String("_PYTHON_H")); diff --git a/sources/shiboken6/generator/shiboken/overloaddata.cpp b/sources/shiboken6/generator/shiboken/overloaddata.cpp index 63511ff69..63fa4dbc6 100644 --- a/sources/shiboken6/generator/shiboken/overloaddata.cpp +++ b/sources/shiboken6/generator/shiboken/overloaddata.cpp @@ -62,7 +62,7 @@ static QString getTypeName(const AbstractMetaType &type) typeEntry = typeEntry->asPrimitive()->basicReferencedTypeEntry(); types << typeEntry->name(); } - typeName += QLatin1Char('<') + types.join(QLatin1Char(',')) + QLatin1String(" >"); + typeName += u'<' + types.join(u',') + QLatin1String(" >"); } return typeName; } @@ -113,7 +113,7 @@ static QString getImplicitConversionTypeName(const AbstractMetaType &containerTy for (const auto &otherType : containerType.instantiations()) types << (otherType == instantiation ? impConv : getTypeName(otherType)); - return containerType.typeEntry()->qualifiedCppName() + QLatin1Char('<') + return containerType.typeEntry()->qualifiedCppName() + u'<' + types.join(QLatin1String(", ")) + QLatin1String(" >"); } @@ -374,10 +374,10 @@ void OverloadDataRootNode::sortNextOverloads(const ApiExtractorResult &api) if (!unmappedResult.isValid()) { QString funcName = referenceFunction()->name(); if (auto owner = referenceFunction()->ownerClass()) - funcName.prepend(owner->name() + QLatin1Char('.')); + funcName.prepend(owner->name() + u'.'); // Dump overload graph - QString graphName = QDir::tempPath() + QLatin1Char('/') + funcName + QLatin1String(".dot"); + QString graphName = QDir::tempPath() + u'/' + funcName + QLatin1String(".dot"); graph.dumpDot(graphName, [] (const QString &n) { return n; }); AbstractMetaFunctionCList cyclic; for (const auto &typeName : unmappedResult.cyclic) { @@ -757,9 +757,9 @@ bool OverloadData::showGraph() const static inline QString toHtml(QString s) { - s.replace(QLatin1Char('<'), QLatin1String("<")); - s.replace(QLatin1Char('>'), QLatin1String(">")); - s.replace(QLatin1Char('&'), QLatin1String("&")); + s.replace(u'<', QLatin1String("<")); + s.replace(u'>', QLatin1String(">")); + s.replace(u'&', QLatin1String("&")); return s; } diff --git a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp index 8daa66473..2f3ccfb97 100644 --- a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp +++ b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp @@ -234,10 +234,10 @@ QString ShibokenGenerator::fullPythonClassName(const AbstractMetaClass *metaClas const AbstractMetaClass *enclosing = metaClass->enclosingClass(); while (enclosing) { if (NamespaceTypeEntry::isVisibleScope(enclosing->typeEntry())) - fullClassName.prepend(enclosing->name() + QLatin1Char('.')); + fullClassName.prepend(enclosing->name() + u'.'); enclosing = enclosing->enclosingClass(); } - fullClassName.prepend(packageName() + QLatin1Char('.')); + fullClassName.prepend(packageName() + u'.'); return fullClassName; } @@ -256,11 +256,11 @@ QString ShibokenGenerator::fullPythonFunctionName(const AbstractMetaFunctionCPtr funcName.append(QLatin1String(".__init__")); } else { - funcName.prepend(fullClassName + QLatin1Char('.')); + funcName.prepend(fullClassName + u'.'); } } else { - funcName = packageName() + QLatin1Char('.') + func->name(); + funcName = packageName() + u'.' + func->name(); } return funcName; } @@ -268,7 +268,7 @@ QString ShibokenGenerator::fullPythonFunctionName(const AbstractMetaFunctionCPtr QString ShibokenGenerator::protectedEnumSurrogateName(const AbstractMetaEnum &metaEnum) { QString result = metaEnum.fullName(); - result.replace(QLatin1Char('.'), QLatin1Char('_')); + result.replace(u'.', u'_'); result.replace(QLatin1String("::"), QLatin1String("_")); return result + QLatin1String("_Surrogate"); } @@ -358,7 +358,7 @@ QString ShibokenGenerator::cpythonSetterFunctionName(const QPropertySpec &proper static QString cpythonEnumFlagsName(const QString &moduleName, const QString &qualifiedCppName) { - QString result = QLatin1String("Sbk") + moduleName + QLatin1Char('_') + qualifiedCppName; + QString result = QLatin1String("Sbk") + moduleName + u'_' + qualifiedCppName; result.replace(QLatin1String("::"), QLatin1String("_")); return result; } @@ -366,7 +366,7 @@ static QString cpythonEnumFlagsName(const QString &moduleName, QString ShibokenGenerator::cpythonEnumName(const EnumTypeEntry *enumEntry) { QString p = enumEntry->targetLangPackage(); - p.replace(QLatin1Char('.'), QLatin1Char('_')); + p.replace(u'.', u'_'); return cpythonEnumFlagsName(p, enumEntry->qualifiedCppName()); } @@ -378,7 +378,7 @@ QString ShibokenGenerator::cpythonEnumName(const AbstractMetaEnum &metaEnum) QString ShibokenGenerator::cpythonFlagsName(const FlagsTypeEntry *flagsEntry) { QString p = flagsEntry->targetLangPackage(); - p.replace(QLatin1Char('.'), QLatin1Char('_')); + p.replace(u'.', u'_'); return cpythonEnumFlagsName(p, flagsEntry->originalName()); } @@ -496,14 +496,14 @@ QString ShibokenGenerator::getFormatUnitString(const AbstractMetaFunctionCPtr &f else result += QLatin1Char(objType); } else if (type.isCString()) { - result += QLatin1Char('z'); + result += u'z'; } else { qCWarning(lcShiboken).noquote().nospace() << "Method: " << func->ownerClass()->qualifiedCppName() << "::" << func->signature() << " => Arg:" << arg.name() << "index: " << arg.argumentIndex() << " - cannot be handled properly. Use an inject-code to fix it!"; - result += QLatin1Char('?'); + result += u'?'; } } return result; @@ -572,8 +572,8 @@ QString ShibokenGenerator::cpythonTypeName(const TypeEntry *type) QString ShibokenGenerator::cpythonTypeNameExt(const TypeEntry *type) { - return cppApiVariableName(type->targetLangPackage()) + QLatin1Char('[') - + getTypeIndexVariableName(type) + QLatin1Char(']'); + return cppApiVariableName(type->targetLangPackage()) + u'[' + + getTypeIndexVariableName(type) + u']'; } QString ShibokenGenerator::converterObject(const AbstractMetaType &type) @@ -587,13 +587,13 @@ QString ShibokenGenerator::converterObject(const AbstractMetaType &type) return QStringLiteral("Shiboken::Conversions::ArrayTypeConverter<") + nestedArrayTypes.constLast().minimalSignature() + QLatin1String(">(") + QString::number(nestedArrayTypes.size()) - + QLatin1Char(')'); + + u')'; } auto typeEntry = type.typeEntry(); if (typeEntry->isContainer() || typeEntry->isSmartPointer()) { return convertersVariableName(typeEntry->targetLangPackage()) - + QLatin1Char('[') + getTypeIndexVariableName(type) + QLatin1Char(']'); + + u'[' + getTypeIndexVariableName(type) + u']'; } return converterObject(typeEntry); } @@ -631,13 +631,13 @@ QString ShibokenGenerator::converterObject(const TypeEntry *type) } return convertersVariableName(type->targetLangPackage()) - + QLatin1Char('[') + getTypeIndexVariableName(type) + QLatin1Char(']'); + + u'[' + getTypeIndexVariableName(type) + u']'; } QString ShibokenGenerator::cpythonTypeNameExt(const AbstractMetaType &type) { - return cppApiVariableName(type.typeEntry()->targetLangPackage()) + QLatin1Char('[') - + getTypeIndexVariableName(type) + QLatin1Char(']'); + return cppApiVariableName(type.typeEntry()->targetLangPackage()) + u'[' + + getTypeIndexVariableName(type) + u']'; } static inline QString unknownOperator() { return QStringLiteral("__UNKNOWN_OPERATOR__"); } @@ -655,11 +655,11 @@ QString ShibokenGenerator::fixedCppTypeName(const AbstractMetaType &type) static QString _fixedCppTypeName(QString typeName) { - typeName.remove(QLatin1Char(' ')); - typeName.replace(QLatin1Char('.'), QLatin1Char('_')); - typeName.replace(QLatin1Char(','), QLatin1Char('_')); - typeName.replace(QLatin1Char('<'), QLatin1Char('_')); - typeName.replace(QLatin1Char('>'), QLatin1Char('_')); + typeName.remove(u' '); + typeName.replace(u'.', u'_'); + typeName.replace(u',', u'_'); + typeName.replace(u'<', u'_'); + typeName.replace(u'>', u'_'); typeName.replace(QLatin1String("::"), QLatin1String("_")); typeName.replace(QLatin1String("*"), QLatin1String("PTR")); typeName.replace(QLatin1String("&"), QLatin1String("REF")); @@ -670,7 +670,7 @@ QString ShibokenGenerator::fixedCppTypeName(const TypeEntry *type, QString typeN if (typeName.isEmpty()) typeName = type->qualifiedCppName(); if (!type->generateCode()) { - typeName.prepend(QLatin1Char('_')); + typeName.prepend(u'_'); typeName.prepend(type->targetLangPackage()); } return _fixedCppTypeName(typeName); @@ -758,7 +758,7 @@ QString ShibokenGenerator::pythonOperatorFunctionName(const AbstractMetaFunction } else if (func->isStatic() && func->arguments().size() == 2) { // If a operator overload function has 2 arguments and // is static we assume that it is a reverse operator. - op = op.insert(2, QLatin1Char('r')); + op = op.insert(2, u'r'); } return op; } @@ -1078,7 +1078,7 @@ QString ShibokenGenerator::cpythonToPythonConversionFunction(const AbstractMetaT + QLatin1String("ToPython(") + cpythonTypeNameExt(type) + QLatin1String(", "); if (conversion != QLatin1String("pointer")) - result += QLatin1Char('&'); + result += u'&'; return result; } return QStringLiteral("Shiboken::Conversions::copyToPython(%1, %2") @@ -1099,7 +1099,7 @@ QString ShibokenGenerator::cpythonToPythonConversionFunction(const TypeEntry *ty + QLatin1String("ToPython(") + cpythonTypeNameExt(type) + QLatin1String(", "); if (conversion != QLatin1String("pointer")) - result += QLatin1Char('&'); + result += u'&'; return result; } @@ -1119,14 +1119,14 @@ QString ShibokenGenerator::argumentString(const AbstractMetaFunctionCPtr &func, if (modified_type.isEmpty()) arg = translateType(argument.type(), func->implementingClass(), options); else - arg = modified_type.replace(QLatin1Char('$'), QLatin1Char('.')); + arg = modified_type.replace(u'$', u'.'); // "int a", "int a[]" - const int arrayPos = arg.indexOf(QLatin1Char('[')); + const int arrayPos = arg.indexOf(u'['); if (arrayPos != -1) - arg.insert(arrayPos, QLatin1Char(' ') + argument.name()); + arg.insert(arrayPos, u' ' + argument.name()); else - arg.append(QLatin1Char(' ') + argument.name()); + arg.append(u' ' + argument.name()); if ((options & Generator::SkipDefaultValues) != Generator::SkipDefaultValues && !argument.originalDefaultValueExpression().isEmpty()) @@ -1337,16 +1337,16 @@ static QString getArgumentsFromMethodCall(const QString &str) if (pos == -1) return QString(); pos = pos + funcCall.size(); - while (str.at(pos) == QLatin1Char(' ') || str.at(pos) == QLatin1Char('\t')) + while (str.at(pos) == u' ' || str.at(pos) == u'\t') ++pos; - if (str.at(pos) == QLatin1Char('(')) + if (str.at(pos) == u'(') ++pos; int begin = pos; int counter = 1; while (counter != 0) { - if (str.at(pos) == QLatin1Char('(')) + if (str.at(pos) == u'(') ++counter; - else if (str.at(pos) == QLatin1Char(')')) + else if (str.at(pos) == u')') --counter; ++pos; } @@ -1736,12 +1736,12 @@ static QString miniNormalizer(const QString &varType) if (normalized.startsWith(QLatin1String("::"))) normalized.remove(0, 2); QString suffix; - while (normalized.endsWith(QLatin1Char('*')) || normalized.endsWith(QLatin1Char('&'))) { + while (normalized.endsWith(u'*') || normalized.endsWith(u'&')) { suffix.prepend(normalized.at(normalized.size() - 1)); normalized.chop(1); normalized = normalized.trimmed(); } - const QString result = normalized + QLatin1Char(' ') + suffix; + const QString result = normalized + u' ' + suffix; return result.trimmed(); } // The position must indicate the first character after the opening '('. @@ -1807,7 +1807,7 @@ void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVa StringStream c(TextStream::Language::Cpp); int end = match.capturedStart(); int start = end; - while (start > 0 && code.at(start) != QLatin1Char('\n')) + while (start > 0 && code.at(start) != u'\n') --start; while (code.at(start).isSpace()) ++start; @@ -1825,7 +1825,7 @@ void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVa c << cpythonToCppConversionFunction(conversionType); QString prefix; if (!AbstractMetaType::stripDereference(&varName)) - prefix = QLatin1Char('&'); + prefix = u'&'; QString arg = getConverterTypeSystemVariableArgument(code, match.capturedEnd()); conversionString += arg; c << arg << ", " << prefix << '(' << varName << ')'; @@ -1836,7 +1836,7 @@ void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVa conversion = cpythonCheckFunction(conversionType); if (conversionType.typeEntry()->isPrimitive() && (conversionType.typeEntry()->name() == cPyObjectT() - || !conversion.endsWith(QLatin1Char(' ')))) { + || !conversion.endsWith(u' '))) { conversion += u'('; break; } @@ -1859,7 +1859,7 @@ void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVa throw Exception(m); } if (conversion.contains(QLatin1String("%in"))) { - conversion.prepend(QLatin1Char('(')); + conversion.prepend(u'('); conversion.replace(QLatin1String("%in"), arg); } else { conversion += arg; @@ -1877,7 +1877,7 @@ bool ShibokenGenerator::injectedCodeCallsCppFunction(const GeneratorContext &con { if (func->injectedCodeContains(u"%FUNCTION_NAME(")) return true; - QString funcCall = func->originalName() + QLatin1Char('('); + QString funcCall = func->originalName() + u'('; if (func->isConstructor()) funcCall.prepend(QLatin1String("new ")); if (func->injectedCodeContains(funcCall)) @@ -2356,7 +2356,7 @@ bool ShibokenGenerator::generateImplicitConversions() const QString ShibokenGenerator::moduleCppPrefix(const QString &moduleName) { QString result = moduleName.isEmpty() ? packageName() : moduleName; - result.replace(QLatin1Char('.'), QLatin1Char('_')); + result.replace(u'.', u'_'); return result; } @@ -2382,19 +2382,19 @@ QString ShibokenGenerator::convertersVariableName(const QString &moduleName) static QString processInstantiationsVariableName(const AbstractMetaType &type) { - QString res = QLatin1Char('_') + _fixedCppTypeName(type.typeEntry()->qualifiedCppName()).toUpper(); + QString res = u'_' + _fixedCppTypeName(type.typeEntry()->qualifiedCppName()).toUpper(); for (const auto &instantiation : type.instantiations()) { res += instantiation.isContainer() ? processInstantiationsVariableName(instantiation) - : QLatin1Char('_') + _fixedCppTypeName(instantiation.cppSignature()).toUpper(); + : u'_' + _fixedCppTypeName(instantiation.cppSignature()).toUpper(); } return res; } static void appendIndexSuffix(QString *s) { - if (!s->endsWith(QLatin1Char('_'))) - s->append(QLatin1Char('_')); + if (!s->endsWith(u'_')) + s->append(u'_'); s->append(QStringLiteral("IDX")); } @@ -2422,7 +2422,7 @@ QString ShibokenGenerator::getTypeIndexVariableName(const TypeEntry *type) // Disambiguate namespaces per module to allow for extending them. if (type->isNamespace()) { QString package = type->targetLangPackage(); - const int dot = package.lastIndexOf(QLatin1Char('.')); + const int dot = package.lastIndexOf(u'.'); result += QStringView{package}.right(package.size() - (dot + 1)); } result += _fixedCppTypeName(type->qualifiedCppName()).toUpper(); @@ -2433,7 +2433,7 @@ QString ShibokenGenerator::getTypeIndexVariableName(const AbstractMetaType &type { QString result = QLatin1String("SBK"); if (type.typeEntry()->isContainer()) - result += QLatin1Char('_') + moduleName().toUpper(); + result += u'_' + moduleName().toUpper(); result += processInstantiationsVariableName(type); appendIndexSuffix(&result); return result; @@ -2487,8 +2487,7 @@ QString ShibokenGenerator::minimalConstructorExpression(const ApiExtractorResult QString ShibokenGenerator::pythonArgsAt(int i) { - return QLatin1String(PYTHON_ARGS) + QLatin1Char('[') - + QString::number(i) + QLatin1Char(']'); + return QLatin1String(PYTHON_ARGS) + u'[' + QString::number(i) + u']'; } void ShibokenGenerator::replaceTemplateVariables(QString &code, @@ -2500,7 +2499,7 @@ void ShibokenGenerator::replaceTemplateVariables(QString &code, const AbstractMetaArgumentList &argument = func->arguments(); for (const AbstractMetaArgument &arg : argument) - code.replace(QLatin1Char('%') + QString::number(arg.argumentIndex() + 1), arg.name()); + code.replace(u'%' + QString::number(arg.argumentIndex() + 1), arg.name()); //template values code.replace(QLatin1String("%RETURN_TYPE"), translateType(func->type(), cpp_class)); diff --git a/sources/shiboken6/tests/dumpcodemodel/main.cpp b/sources/shiboken6/tests/dumpcodemodel/main.cpp index 527a81262..bde52fc14 100644 --- a/sources/shiboken6/tests/dumpcodemodel/main.cpp +++ b/sources/shiboken6/tests/dumpcodemodel/main.cpp @@ -50,7 +50,7 @@ static inline QString languageLevelDescription() { return QLatin1String("C++ Language level (c++11..c++17, default=") + QLatin1String(clang::languageLevelOption(clang::emulatedCompilerLanguageLevel())) - + QLatin1Char(')'); + + u')'; } static void formatDebugOutput(const FileModelItem &dom, bool verbose) @@ -268,7 +268,7 @@ int main(int argc, char **argv) const FileModelItem dom = AbstractMetaBuilderPrivate::buildDom(arguments, true, level, 0); if (dom.isNull()) { - QString message = QLatin1String("Unable to parse ") + positionalArguments.join(QLatin1Char(' ')); + QString message = QLatin1String("Unable to parse ") + positionalArguments.join(u' '); std::cerr << qPrintable(message) << '\n'; return -2; } |