aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetaargument.cpp6
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp50
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetaenum.cpp6
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetafield.cpp6
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetafunction.cpp38
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetatype.cpp62
-rw-r--r--sources/shiboken6/ApiExtractor/apiextractor.cpp8
-rw-r--r--sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp13
-rw-r--r--sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp14
-rw-r--r--sources/shiboken6/ApiExtractor/docparser.cpp16
-rw-r--r--sources/shiboken6/ApiExtractor/doxygenparser.cpp68
-rw-r--r--sources/shiboken6/ApiExtractor/include.cpp10
-rw-r--r--sources/shiboken6/ApiExtractor/messages.cpp122
-rw-r--r--sources/shiboken6/ApiExtractor/modifications.cpp36
-rw-r--r--sources/shiboken6/ApiExtractor/parser/typeinfo.cpp26
-rw-r--r--sources/shiboken6/ApiExtractor/predefined_templates.cpp100
-rw-r--r--sources/shiboken6/ApiExtractor/propertyspec.cpp10
-rw-r--r--sources/shiboken6/ApiExtractor/qtcompat.h62
-rw-r--r--sources/shiboken6/ApiExtractor/qtdocparser.cpp18
-rw-r--r--sources/shiboken6/ApiExtractor/reporthandler.cpp5
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testabstractmetaclass.cpp19
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testabstractmetatype.cpp13
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp49
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testarrayargument.cpp27
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp20
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testconversionoperator.cpp15
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp20
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testdroptypeentries.cpp29
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testenum.cpp31
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testfunctiontag.cpp13
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testmodifydocumentation.cpp10
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testmodifyfunction.cpp15
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testnamespace.cpp9
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testnestedtypes.cpp11
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testprimitivetypetag.cpp9
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testrefcounttag.cpp9
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testremoveoperatormethod.cpp31
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testresolvetype.cpp21
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testtemplates.cpp6
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testtyperevision.cpp11
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testutil.h4
-rw-r--r--sources/shiboken6/ApiExtractor/typedatabase.cpp96
-rw-r--r--sources/shiboken6/ApiExtractor/typesystem.cpp28
-rw-r--r--sources/shiboken6/ApiExtractor/typesystemparser.cpp148
-rw-r--r--sources/shiboken6/ApiExtractor/xmlutils.cpp12
-rw-r--r--sources/shiboken6/ApiExtractor/xmlutils_libxslt.cpp27
-rw-r--r--sources/shiboken6/generator/generator.cpp157
-rw-r--r--sources/shiboken6/generator/main.cpp140
-rw-r--r--sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp118
-rw-r--r--sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp74
-rw-r--r--sources/shiboken6/generator/qtdoc/qtxmltosphinx.h4
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp636
-rw-r--r--sources/shiboken6/generator/shiboken/headergenerator.cpp14
-rw-r--r--sources/shiboken6/generator/shiboken/overloaddata.cpp18
-rw-r--r--sources/shiboken6/generator/shiboken/shibokengenerator.cpp488
-rw-r--r--sources/shiboken6/generator/shiboken/shibokengenerator.h2
56 files changed, 1652 insertions, 1358 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetaargument.cpp b/sources/shiboken6/ApiExtractor/abstractmetaargument.cpp
index 366ef8bc0..b08da6f06 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetaargument.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetaargument.cpp
@@ -29,9 +29,13 @@
#include "abstractmetaargument.h"
#include "documentation.h"
+#include "qtcompat.h"
+
#include <QtCore/QDebug>
#include <QtCore/QSharedData>
+using namespace Qt::StringLiterals;
+
class AbstractMetaArgumentData : public QSharedData
{
public:
@@ -170,7 +174,7 @@ QString AbstractMetaArgumentData::toString() const
{
QString result = m_type.name() + u' ' + m_name;
if (!m_expression.isEmpty())
- result += QLatin1String(" = ") + m_expression;
+ result += u" = "_s + m_expression;
return result;
}
diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp
index 382ab28a5..23c07c780 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp
@@ -46,6 +46,8 @@
#include <clangparser/clangutils.h>
#include <clangparser/compilersupport.h>
+#include "qtcompat.h"
+
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFile>
@@ -59,6 +61,8 @@
#include <algorithm>
#include <memory>
+using namespace Qt::StringLiterals;
+
static inline QString colonColon() { return QStringLiteral("::"); }
static QString stripTemplateArgs(const QString &name)
@@ -77,7 +81,7 @@ bool AbstractMetaBuilderPrivate::m_useGlobalHeader = false;
bool AbstractMetaBuilderPrivate::m_codeModelTestMode = false;
AbstractMetaBuilderPrivate::AbstractMetaBuilderPrivate() :
- m_logDirectory(QLatin1String(".") + QDir::separator())
+ m_logDirectory(u"."_s + QDir::separator())
{
}
@@ -166,7 +170,7 @@ void AbstractMetaBuilderPrivate::checkFunctionModifications()
}
if (function->originalName() == name) {
- possibleSignatures.append(function->minimalSignature() + QLatin1String(" in ")
+ possibleSignatures.append(function->minimalSignature() + u" in "_s
+ function->implementingClass()->name());
}
}
@@ -209,7 +213,7 @@ void AbstractMetaBuilderPrivate::registerHashFunction(const FunctionModelItem &f
void AbstractMetaBuilderPrivate::registerToStringCapabilityIn(const NamespaceModelItem &nsItem)
{
- const FunctionList &streamOps = nsItem->findFunctions(QLatin1String("operator<<"));
+ const FunctionList &streamOps = nsItem->findFunctions(u"operator<<"_s);
for (const FunctionModelItem &item : streamOps)
registerToStringCapability(item, nullptr);
for (const NamespaceModelItem &ni : nsItem->namespaces())
@@ -600,7 +604,7 @@ void AbstractMetaBuilderPrivate::traverseDom(const FileModelItem &dom,
}
{
- const FunctionList &hashFunctions = dom->findFunctions(QLatin1String("qHash"));
+ const FunctionList &hashFunctions = dom->findFunctions(u"qHash"_s);
for (const FunctionModelItem &item : hashFunctions)
registerHashFunction(item, nullptr);
}
@@ -1046,8 +1050,8 @@ AbstractMetaClass *AbstractMetaBuilderPrivate::traverseClass(const FileModelItem
if (ReportHandler::isDebug(ReportHandler::MediumDebug)) {
const QString message = type->isContainer()
- ? u"container: '"_qs + fullClassName + u'\''
- : u"class: '"_qs + metaClass->fullName() + u'\'';
+ ? u"container: '"_s + fullClassName + u'\''
+ : u"class: '"_s + metaClass->fullName() + u'\'';
qCInfo(lcShiboken, "%s", qPrintable(message));
}
@@ -1722,7 +1726,7 @@ void AbstractMetaBuilderPrivate::fixArgumentNames(AbstractMetaFunction *func, co
for (int i = 0, size = arguments.size(); i < size; ++i) {
if (arguments.at(i).name().isEmpty())
- arguments[i].setName(QLatin1String("arg__") + QString::number(i + 1), false);
+ arguments[i].setName(u"arg__"_s + QString::number(i + 1), false);
}
}
@@ -1837,7 +1841,7 @@ static bool applyArrayArgumentModifications(const FunctionModificationList &func
const int i = argMod.index() - 1;
if (i < 0 || i >= func->arguments().size()) {
*errorMessage = msgCannotSetArrayUsage(func->minimalSignature(), i,
- QLatin1String("Index out of range."));
+ u"Index out of range."_s);
return false;
}
auto t = func->arguments().at(i).type();
@@ -1912,7 +1916,7 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio
const bool deprecated = functionItem->isDeprecated();
if (deprecated && m_skipDeprecated) {
- m_rejectedFunctions.insert(originalQualifiedSignatureWithReturn + QLatin1String(" is deprecated."),
+ m_rejectedFunctions.insert(originalQualifiedSignatureWithReturn + u" is deprecated."_s,
AbstractMetaBuilder::GenerationDisabled);
return nullptr;
}
@@ -2021,7 +2025,7 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio
qCWarning(lcShiboken, "%s",
qPrintable(msgSkippingFunction(functionItem, originalQualifiedSignatureWithReturn, reason)));
const QString rejectedFunctionSignature = originalQualifiedSignatureWithReturn
- + QLatin1String(": ") + reason;
+ + u": "_s + reason;
m_rejectedFunctions.insert(rejectedFunctionSignature, AbstractMetaBuilder::UnmatchedArgumentType);
delete metaFunction;
return nullptr;
@@ -2287,7 +2291,7 @@ static AbstractMetaArgument pointeeArgument(const AbstractMetaClass *s,
{
AbstractMetaArgument pointee;
pointee.setType(instantiationType(s, ste));
- pointee.setName(u"pointee"_qs);
+ pointee.setName(u"pointee"_s);
return pointee;
}
@@ -2363,18 +2367,18 @@ static void fixSmartPointerClass(AbstractMetaClass *s, const SmartPointerTypeEnt
const QString refCountName = ste->refCountMethodName();
if (!refCountName.isEmpty() && s->findFunction(refCountName).isNull())
- addMethod(s, u"int"_qs, refCountName);
+ addMethod(s, u"int"_s, refCountName);
const QString valueCheckMethod = ste->valueCheckMethod();
if (!valueCheckMethod.isEmpty() && s->findFunction(valueCheckMethod).isNull()) {
- auto f = addMethod(s, u"bool"_qs, valueCheckMethod);
+ auto f = addMethod(s, u"bool"_s, valueCheckMethod);
if (valueCheckMethod == u"operator bool")
f->setFunctionType(AbstractMetaFunction::ConversionOperator);
}
const QString nullCheckMethod = ste->nullCheckMethod();
if (!nullCheckMethod.isEmpty() && s->findFunction(nullCheckMethod).isNull())
- addMethod(s, u"bool"_qs, nullCheckMethod);
+ addMethod(s, u"bool"_s, nullCheckMethod);
}
// Create a missing smart pointer class
@@ -2383,7 +2387,7 @@ static AbstractMetaClass *createSmartPointerClass(const SmartPointerTypeEntry *s
{
auto *result = new AbstractMetaClass();
result->setTypeEntry(const_cast<SmartPointerTypeEntry *>(ste));
- auto *templateArg = new TemplateArgumentEntry(u"T"_qs, ste->version(),
+ auto *templateArg = new TemplateArgumentEntry(u"T"_s, ste->version(),
ste->typeSystemTypeEntry());
result->setTemplateArguments({templateArg});
fixSmartPointerClass(result, ste);
@@ -2471,7 +2475,7 @@ std::optional<AbstractMetaType>
if (typeInfo.isFunctionPointer()) {
if (errorMessageIn)
- *errorMessageIn = msgUnableToTranslateType(_typei, QLatin1String("Unsupported function pointer."));
+ *errorMessageIn = msgUnableToTranslateType(_typei, u"Unsupported function pointer."_s);
return {};
}
@@ -2511,7 +2515,7 @@ std::optional<AbstractMetaType>
auto elementType = translateTypeStatic(newInfo, currentClass, d, flags, &errorMessage);
if (!elementType.has_value()) {
if (errorMessageIn) {
- errorMessage.prepend(QLatin1String("Unable to translate array element: "));
+ errorMessage.prepend(u"Unable to translate array element: "_s);
*errorMessageIn = msgUnableToTranslateType(_typei, errorMessage);
}
return {};
@@ -2542,7 +2546,7 @@ std::optional<AbstractMetaType>
QStringList qualifierList = typeInfo.qualifiedName();
if (qualifierList.isEmpty()) {
- errorMessage = msgUnableToTranslateType(_typei, QLatin1String("horribly broken type"));
+ errorMessage = msgUnableToTranslateType(_typei, u"horribly broken type"_s);
if (errorMessageIn)
*errorMessageIn = errorMessage;
else
@@ -3325,10 +3329,10 @@ static void writeRejectLogFile(const QString &name,
void AbstractMetaBuilderPrivate::dumpLog() const
{
- writeRejectLogFile(m_logDirectory + QLatin1String("mjb_rejected_classes.log"), m_rejectedClasses);
- writeRejectLogFile(m_logDirectory + QLatin1String("mjb_rejected_enums.log"), m_rejectedEnums);
- writeRejectLogFile(m_logDirectory + QLatin1String("mjb_rejected_functions.log"), m_rejectedFunctions);
- writeRejectLogFile(m_logDirectory + QLatin1String("mjb_rejected_fields.log"), m_rejectedFields);
+ writeRejectLogFile(m_logDirectory + u"mjb_rejected_classes.log"_s, m_rejectedClasses);
+ writeRejectLogFile(m_logDirectory + u"mjb_rejected_enums.log"_s, m_rejectedEnums);
+ writeRejectLogFile(m_logDirectory + u"mjb_rejected_functions.log"_s, m_rejectedFunctions);
+ writeRejectLogFile(m_logDirectory + u"mjb_rejected_fields.log"_s, m_rejectedFields);
}
// Topological sorting of classes. Templates for use with
@@ -3395,7 +3399,7 @@ static QList<MetaClass *> topologicalSortHelper(const QList<MetaClass *> &classL
const auto result = graph.topologicalSort();
if (!result.isValid() && graph.nodeCount()) {
- QTemporaryFile tempFile(QDir::tempPath() + QLatin1String("/cyclic_depXXXXXX.dot"));
+ QTemporaryFile tempFile(QDir::tempPath() + u"/cyclic_depXXXXXX.dot"_s);
tempFile.setAutoRemove(false);
tempFile.open();
graph.dumpDot(tempFile.fileName(),
diff --git a/sources/shiboken6/ApiExtractor/abstractmetaenum.cpp b/sources/shiboken6/ApiExtractor/abstractmetaenum.cpp
index 9e5ed7b7d..8e0b45d4e 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetaenum.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetaenum.cpp
@@ -32,8 +32,12 @@
#include "typesystem.h"
#include "parser/enumvalue.h"
+#include "qtcompat.h"
+
#include <QtCore/QDebug>
+using namespace Qt::StringLiterals;
+
class AbstractMetaEnumValueData : public QSharedData
{
public:
@@ -170,7 +174,7 @@ QString AbstractMetaEnum::name() const
QString AbstractMetaEnum::qualifiedCppName() const
{
return enclosingClass()
- ? enclosingClass()->qualifiedCppName() + QLatin1String("::") + name()
+ ? enclosingClass()->qualifiedCppName() + u"::"_s + name()
: name();
}
diff --git a/sources/shiboken6/ApiExtractor/abstractmetafield.cpp b/sources/shiboken6/ApiExtractor/abstractmetafield.cpp
index 35306d5a0..0d2761ac8 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetafield.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetafield.cpp
@@ -35,8 +35,12 @@
#include "typesystem.h"
#include "parser/codemodel.h"
+#include "qtcompat.h"
+
#include <QtCore/QDebug>
+using namespace Qt::StringLiterals;
+
class AbstractMetaFieldData : public QSharedData
{
public:
@@ -143,7 +147,7 @@ void AbstractMetaField::setStatic(bool s)
QString AbstractMetaField::qualifiedCppName() const
{
- return enclosingClass()->qualifiedCppName() + QLatin1String("::")
+ return enclosingClass()->qualifiedCppName() + u"::"_s
+ originalName();
}
diff --git a/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp b/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp
index 89cd2306b..280b08cc2 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp
@@ -42,9 +42,13 @@
#include "typedatabase.h"
#include "typesystem.h"
+#include "qtcompat.h"
+
#include <QtCore/QDebug>
#include <QtCore/QRegularExpression>
+using namespace Qt::StringLiterals;
+
// Cache FunctionModificationList in a flat list per class (0 for global
// functions, or typically owner/implementing/declaring class.
struct ModificationCacheEntry
@@ -489,7 +493,7 @@ QString AbstractMetaFunctionPrivate::signature() const
const AbstractMetaArgument &a = m_arguments.at(i);
const AbstractMetaType &t = a.type();
if (i > 0)
- m_cachedSignature += QLatin1String(", ");
+ m_cachedSignature += u", "_s;
m_cachedSignature += t.cppSignature();
// We need to have the argument names in the qdoc files
m_cachedSignature += u' ';
@@ -498,7 +502,7 @@ QString AbstractMetaFunctionPrivate::signature() const
m_cachedSignature += u')';
if (m_constant)
- m_cachedSignature += QLatin1String(" const");
+ m_cachedSignature += u" const"_s;
}
return m_cachedSignature;
}
@@ -512,7 +516,7 @@ QString AbstractMetaFunction::classQualifiedSignature() const
{
QString result;
if (d->m_implementingClass)
- result += d->m_implementingClass->qualifiedCppName() + u"::"_qs;
+ result += d->m_implementingClass->qualifiedCppName() + u"::"_s;
result += signature();
return result;
}
@@ -714,12 +718,12 @@ AbstractMetaFunction::comparisonOperatorType() const
if (d->m_functionType != ComparisonOperator)
return {};
static const QHash<QString, ComparisonOperatorType> mapping = {
- {u"operator=="_qs, OperatorEqual},
- {u"operator!="_qs, OperatorNotEqual},
- {u"operator<"_qs, OperatorLess},
- {u"operator<="_qs, OperatorLessEqual},
- {u"operator>"_qs, OperatorGreater},
- {u"operator>="_qs, OperatorGreaterEqual}
+ {u"operator=="_s, OperatorEqual},
+ {u"operator!="_s, OperatorNotEqual},
+ {u"operator<"_s, OperatorLess},
+ {u"operator<="_s, OperatorLessEqual},
+ {u"operator>"_s, OperatorGreater},
+ {u"operator>="_s, OperatorGreaterEqual}
};
const auto it = mapping.constFind(originalName());
Q_ASSERT(it != mapping.constEnd());
@@ -906,11 +910,11 @@ QString AbstractMetaFunctionPrivate::formatMinimalSignature(const AbstractMetaFu
}
result += u')';
if (m_constant)
- result += QLatin1String("const");
+ result += u"const"_s;
result = TypeDatabase::normalizedSignature(result);
if (comment && !q->isVoid()) {
- result += u"->"_qs;
+ result += u"->"_s;
result += q->isTypeModified()
? q->modifiedTypeName() : q->type().minimalSignature();
}
@@ -935,14 +939,14 @@ QString AbstractMetaFunction::debugSignature() const
const bool isOverride = attributes() & AbstractMetaFunction::OverriddenCppMethod;
const bool isFinal = attributes() & AbstractMetaFunction::FinalCppMethod;
if (!isOverride && !isFinal && (attributes() & AbstractMetaFunction::VirtualCppMethod))
- result += QLatin1String("virtual ");
+ result += u"virtual "_s;
if (d->m_implementingClass)
- result += d->m_implementingClass->qualifiedCppName() + u"::"_qs;
+ result += d->m_implementingClass->qualifiedCppName() + u"::"_s;
result += minimalSignature();
if (isOverride)
- result += QLatin1String(" override");
+ result += u" override"_s;
if (isFinal)
- result += QLatin1String(" final");
+ result += u" final"_s;
return result;
}
@@ -1179,11 +1183,11 @@ bool AbstractMetaFunction::isOperatorOverload(const QString &funcName)
if (isConversionOperator(funcName))
return true;
- static const QRegularExpression opRegEx(QLatin1String("^operator([+\\-\\*/%=&\\|\\^\\<>!][=]?"
+ static const QRegularExpression opRegEx(u"^operator([+\\-\\*/%=&\\|\\^\\<>!][=]?"
"|\\+\\+|\\-\\-|&&|\\|\\||<<[=]?|>>[=]?|~"
"|\\[\\]|\\s+delete\\[?\\]?"
"|\\(\\)"
- "|\\s+new\\[?\\]?)$"));
+ "|\\s+new\\[?\\]?)$"_s);
Q_ASSERT(opRegEx.isValid());
return opRegEx.match(funcName).hasMatch();
}
diff --git a/sources/shiboken6/ApiExtractor/abstractmetatype.cpp b/sources/shiboken6/ApiExtractor/abstractmetatype.cpp
index 11b8bddfa..b5fa4100c 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetatype.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetatype.cpp
@@ -34,6 +34,8 @@
#include "typesystem.h"
#include "parser/codemodel.h"
+#include "qtcompat.h"
+
#ifndef QT_NO_DEBUG_STREAM
# include <QtCore/QDebug>
#endif
@@ -43,23 +45,25 @@
#include <QtCore/QSharedPointer>
#include <QtCore/QStack>
+using namespace Qt::StringLiterals;
+
using AbstractMetaTypeCPtr = QSharedPointer<const AbstractMetaType>;
const QSet<QString> &AbstractMetaType::cppFloatTypes()
{
- static const QSet<QString> result{u"double"_qs, u"float"_qs};
+ static const QSet<QString> result{u"double"_s, u"float"_s};
return result;
}
const QSet<QString> &AbstractMetaType::cppSignedCharTypes()
{
- static const QSet<QString> result{u"char"_qs, u"signed char"_qs};
+ static const QSet<QString> result{u"char"_s, u"signed char"_s};
return result;
}
const QSet<QString> &AbstractMetaType::cppUnsignedCharTypes()
{
- static const QSet<QString> result{u"unsigned char"_qs};
+ static const QSet<QString> result{u"unsigned char"_s};
return result;
}
@@ -73,14 +77,14 @@ const QSet<QString> &AbstractMetaType::cppSignedIntTypes()
{
static QSet<QString> result;
if (result.isEmpty()) {
- result = {u"char"_qs, u"signed char"_qs, u"short"_qs, u"short int"_qs,
- u"signed short"_qs, u"signed short int"_qs,
- u"int"_qs, u"signed int"_qs,
- u"long"_qs, u"long int"_qs,
- u"signed long"_qs, u"signed long int"_qs,
- u"long long"_qs, u"long long int"_qs,
- u"signed long long int"_qs,
- u"ptrdiff_t"_qs};
+ result = {u"char"_s, u"signed char"_s, u"short"_s, u"short int"_s,
+ u"signed short"_s, u"signed short int"_s,
+ u"int"_s, u"signed int"_s,
+ u"long"_s, u"long int"_s,
+ u"signed long"_s, u"signed long int"_s,
+ u"long long"_s, u"long long int"_s,
+ u"signed long long int"_s,
+ u"ptrdiff_t"_s};
result |= cppSignedCharTypes();
}
return result;
@@ -90,12 +94,12 @@ const QSet<QString> &AbstractMetaType::cppUnsignedIntTypes()
{
static QSet<QString> result;
if (result.isEmpty()) {
- result = {u"unsigned short"_qs, u"unsigned short int"_qs,
- u"unsigned"_qs, u"unsigned int"_qs,
- u"unsigned long"_qs, u"unsigned long int"_qs,
- u"unsigned long long"_qs,
- u"unsigned long long int"_qs,
- u"size_t"_qs};
+ result = {u"unsigned short"_s, u"unsigned short int"_s,
+ u"unsigned"_s, u"unsigned int"_s,
+ u"unsigned long"_s, u"unsigned long int"_s,
+ u"unsigned long long"_s,
+ u"unsigned long long int"_s,
+ u"size_t"_s};
result |= cppUnsignedCharTypes();
}
return result;
@@ -107,7 +111,7 @@ const QSet<QString> &AbstractMetaType::cppIntegralTypes()
if (result.isEmpty()) {
result |= cppSignedIntTypes();
result |= cppUnsignedIntTypes();
- result.insert(u"bool"_qs);
+ result.insert(u"bool"_s);
}
return result;
}
@@ -118,7 +122,7 @@ const QSet<QString> &AbstractMetaType::cppPrimitiveTypes()
if (result.isEmpty()) {
result |= cppIntegralTypes();
result |= cppFloatTypes();
- result.insert(u"wchar_t"_qs);
+ result.insert(u"wchar_t"_s);
}
return result;
}
@@ -245,7 +249,7 @@ bool AbstractMetaType::applyArrayModification(QString *errorMessage)
{
if (d->m_pattern == AbstractMetaType::NativePointerAsArrayPattern) {
- *errorMessage = QLatin1String("<array> modification already applied.");
+ *errorMessage = u"<array> modification already applied."_s;
return false;
}
if (!d->m_arrayElementType.isNull()) {
@@ -566,9 +570,9 @@ QString AbstractMetaTypeData::formatSignature(bool minimal) const
{
QString result;
if (m_constant)
- result += QLatin1String("const ");
+ result += u"const "_s;
if (m_volatile)
- result += QLatin1String("volatile ");
+ result += u"volatile "_s;
if (m_pattern == AbstractMetaType::ArrayPattern) {
// Build nested array dimensions a[2][3] in correct order
result += m_arrayElementType->minimalSignature();
@@ -589,7 +593,7 @@ QString AbstractMetaTypeData::formatSignature(bool minimal) const
result += u',';
result += m_instantiations.at(i).minimalSignature();
}
- result += QLatin1String(" >");
+ result += u" >"_s;
}
if (!minimal && (!m_indirections.isEmpty() || m_referenceType != NoReference))
@@ -603,7 +607,7 @@ QString AbstractMetaTypeData::formatSignature(bool minimal) const
result += u'&';
break;
case RValueReference:
- result += QLatin1String("&&");
+ result += u"&&"_s;
break;
}
return result;
@@ -629,7 +633,7 @@ QString AbstractMetaTypeData::formatPythonSignature() const
*/
QString result;
if (m_pattern == AbstractMetaType::NativePointerAsArrayPattern)
- result += QLatin1String("array ");
+ result += u"array "_s;
// We no longer use the "const" qualifier for heuristics. Instead,
// NativePointerAsArrayPattern indicates when we have <array> in XML.
// if (m_typeEntry->isPrimitive() && isConstant())
@@ -654,7 +658,7 @@ QString AbstractMetaTypeData::formatPythonSignature() const
result += u'[';
for (int i = 0, size = m_instantiations.size(); i < size; ++i) {
if (i > 0)
- result += QLatin1String(", ");
+ result += u", "_s;
result += m_instantiations.at(i).formatPythonSignature();
}
result += u']';
@@ -666,7 +670,7 @@ QString AbstractMetaTypeData::formatPythonSignature() const
// "PySide6.QtCore.Qt.ItemFlags" instead of "PySide6.QtCore.QFlags<Qt.ItemFlag>"
if (m_typeEntry->isFlags())
result = m_typeEntry->qualifiedTargetLangName();
- result.replace(QLatin1String("::"), QLatin1String("."));
+ result.replace(u"::"_s, u"."_s);
return result;
}
@@ -763,7 +767,7 @@ AbstractMetaType AbstractMetaType::createVoid()
{
static QScopedPointer<AbstractMetaType> metaType;
if (metaType.isNull()) {
- static const TypeEntry *voidTypeEntry = TypeDatabase::instance()->findType(QLatin1String("void"));
+ static const TypeEntry *voidTypeEntry = TypeDatabase::instance()->findType(u"void"_s);
Q_ASSERT(voidTypeEntry);
metaType.reset(new AbstractMetaType(voidTypeEntry));
metaType->decideUsagePattern();
@@ -773,7 +777,7 @@ AbstractMetaType AbstractMetaType::createVoid()
void AbstractMetaType::dereference(QString *type)
{
- type->prepend(u"(*"_qs);
+ type->prepend(u"(*"_s);
type->append(u')');
}
diff --git a/sources/shiboken6/ApiExtractor/apiextractor.cpp b/sources/shiboken6/ApiExtractor/apiextractor.cpp
index 1b8af285f..f33d183be 100644
--- a/sources/shiboken6/ApiExtractor/apiextractor.cpp
+++ b/sources/shiboken6/ApiExtractor/apiextractor.cpp
@@ -41,6 +41,8 @@
#include "typedatabase.h"
#include "typesystem.h"
+#include "qtcompat.h"
+
#include <QtCore/QDir>
#include <QtCore/QDebug>
#include <QtCore/QTemporaryFile>
@@ -49,6 +51,8 @@
#include <iostream>
#include <iterator>
+using namespace Qt::StringLiterals;
+
struct InstantiationCollectContext
{
AbstractMetaTypeList instantiatedContainers;
@@ -603,7 +607,7 @@ void ApiExtractorPrivate::collectInstantiatedOpqaqueContainers(InstantiationColl
if (typeOpt.has_value()
&& generateOpaqueContainer(typeOpt.value(), moduleEntry)) {
addInstantiatedContainersAndSmartPointers(context, typeOpt.value(),
- u"opaque containers"_qs);
+ u"opaque containers"_s);
}
}
}
@@ -665,7 +669,7 @@ ApiExtractorPrivate::collectContainerTypesFromConverterMacros(InstantiationColle
const QString &code,
bool toPythonMacro)
{
- QString convMacro = toPythonMacro ? QLatin1String("%CONVERTTOPYTHON[") : QLatin1String("%CONVERTTOCPP[");
+ QString convMacro = toPythonMacro ? u"%CONVERTTOPYTHON["_s : u"%CONVERTTOCPP["_s;
int offset = toPythonMacro ? sizeof("%CONVERTTOPYTHON") : sizeof("%CONVERTTOCPP");
int start = 0;
QString errorMessage;
diff --git a/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp
index 7aee6ed67..44f3e97c4 100644
--- a/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp
+++ b/sources/shiboken6/ApiExtractor/clangparser/clangbuilder.cpp
@@ -33,6 +33,8 @@
#include <codemodel.h>
#include <reporthandler.h>
+#include "qtcompat.h"
+
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QHash>
@@ -44,6 +46,8 @@
#include <cstring>
#include <ctype.h>
+using namespace Qt::StringLiterals;
+
namespace clang {
static inline QString colonColon() { return QStringLiteral("::"); }
@@ -289,8 +293,7 @@ static QString msgCannotDetermineException(const std::string_view &snippetV)
if (truncate)
snippet += QStringLiteral("...");
- return QLatin1String("Cannot determine exception specification: \"")
- + snippet + u'"';
+ return u"Cannot determine exception specification: \""_s + snippet + u'"';
}
// Return whether noexcept(<value>) throws. noexcept() takes a constexpr value.
@@ -891,8 +894,8 @@ FileModelItem Builder::dom() const
static QString msgOutOfOrder(const CXCursor &cursor, const char *expectedScope)
{
return getCursorKindName(cursor.kind) + u' '
- + getCursorSpelling(cursor) + QLatin1String(" encountered outside ")
- + QLatin1String(expectedScope) + u'.';
+ + getCursorSpelling(cursor) + u" encountered outside "_s
+ + QLatin1StringView(expectedScope) + u'.';
}
static CodeModel::ClassType codeModelClassTypeFromCursor(CXCursorKind kind)
@@ -1080,7 +1083,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() + u')';
+ + u" (current scope: "_s + d->m_scopeStack.back()->name() + u')';
const Diagnostic d(message, cursor, CXDiagnostic_Error);
qWarning() << d;
appendDiagnostic(d);
diff --git a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp
index 7d31f17e0..1c6b39228 100644
--- a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp
+++ b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp
@@ -31,6 +31,8 @@
#include <reporthandler.h>
+#include "qtcompat.h"
+
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFile>
@@ -46,6 +48,8 @@
#include <algorithm>
#include <iterator>
+using namespace Qt::StringLiterals;
+
namespace clang {
QVersionNumber libClangVersion()
@@ -227,17 +231,17 @@ static QString findClangLibDir()
{
for (const char *envVar : {"LLVM_INSTALL_DIR", "CLANG_INSTALL_DIR"}) {
if (qEnvironmentVariableIsSet(envVar)) {
- const QString path = QFile::decodeName(qgetenv(envVar)) + QLatin1String("/lib");
+ const QString path = QFile::decodeName(qgetenv(envVar)) + u"/lib"_s;
if (QFileInfo::exists(path))
return path;
qWarning("%s: %s as pointed to by %s does not exist.", __FUNCTION__, qPrintable(path), envVar);
}
}
const QString llvmConfig =
- QStandardPaths::findExecutable(QLatin1String("llvm-config"));
+ QStandardPaths::findExecutable(u"llvm-config"_s);
if (!llvmConfig.isEmpty()) {
QByteArray stdOut;
- if (runProcess(llvmConfig, QStringList{QLatin1String("--libdir")}, &stdOut)) {
+ if (runProcess(llvmConfig, QStringList{u"--libdir"_s}, &stdOut)) {
const QString path = QFile::decodeName(stdOut.trimmed());
if (QFileInfo::exists(path))
return path;
@@ -254,7 +258,7 @@ static QString findClangBuiltInIncludesDir()
if (!clangPathLibDir.isEmpty()) {
QString candidate;
QVersionNumber lastVersionNumber(1, 0, 0);
- const QString clangDirName = clangPathLibDir + QLatin1String("/clang");
+ const QString clangDirName = clangPathLibDir + u"/clang"_s;
QDir clangDir(clangDirName);
const QFileInfoList versionDirs =
clangDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
@@ -319,7 +323,7 @@ QByteArrayList emulatedCompilerOptions()
appendClangBuiltinIncludes(&headerPaths);
break;
case Compiler::Clang:
- headerPaths.append(gppInternalIncludePaths(compilerFromCMake(u"clang++"_qs)));
+ headerPaths.append(gppInternalIncludePaths(compilerFromCMake(u"clang++"_s)));
result.append(noStandardIncludeOption());
break;
case Compiler::Gpp:
diff --git a/sources/shiboken6/ApiExtractor/docparser.cpp b/sources/shiboken6/ApiExtractor/docparser.cpp
index f543e2eda..9a7fdd866 100644
--- a/sources/shiboken6/ApiExtractor/docparser.cpp
+++ b/sources/shiboken6/ApiExtractor/docparser.cpp
@@ -42,6 +42,8 @@
#include <QtCore/QDir>
#include <QtCore/QTextStream>
+#include "qtcompat.h"
+
#include <cstdlib>
#ifdef HAVE_LIBXSLT
# include <libxslt/xsltutils.h>
@@ -50,6 +52,8 @@
#include <algorithm>
+using namespace Qt::StringLiterals;
+
DocParser::DocParser()
{
#ifdef HAVE_LIBXSLT
@@ -139,14 +143,14 @@ R"(<xsl:template match="/">
return xml;
}
- QString xsl = QLatin1String(xslPrefix);
+ QString xsl = QLatin1StringView(xslPrefix);
for (const DocModification &mod : mods) {
if (isXpathDocModification(mod)) {
QString xpath = mod.xpath();
- xpath.replace(u'"', QLatin1String("&quot;"));
- xsl += QLatin1String("<xsl:template match=\"")
- + xpath + QLatin1String("\">")
- + mod.code() + QLatin1String("</xsl:template>\n");
+ xpath.replace(u'"', u"&quot;"_s);
+ xsl += u"<xsl:template match=\""_s
+ + xpath + u"\">"_s
+ + mod.code() + u"</xsl:template>\n"_s;
}
}
@@ -156,7 +160,7 @@ R"(<xsl:template match="/">
qCWarning(lcShibokenDoc, "%s",
qPrintable(msgXpathDocModificationError(mods, errorMessage)));
if (result == xml) {
- const QString message = QLatin1String("Query did not result in any modifications to \"")
+ const QString message = u"Query did not result in any modifications to \""_s
+ xml + u'"';
qCWarning(lcShibokenDoc, "%s",
qPrintable(msgXpathDocModificationError(mods, message)));
diff --git a/sources/shiboken6/ApiExtractor/doxygenparser.cpp b/sources/shiboken6/ApiExtractor/doxygenparser.cpp
index 8a1787f5a..a5189f99f 100644
--- a/sources/shiboken6/ApiExtractor/doxygenparser.cpp
+++ b/sources/shiboken6/ApiExtractor/doxygenparser.cpp
@@ -39,19 +39,23 @@
#include "typesystem.h"
#include "xmlutils.h"
+#include "qtcompat.h"
+
#include <QtCore/QFile>
#include <QtCore/QDir>
+using namespace Qt::StringLiterals;
+
static QString getSectionKindAttr(const AbstractMetaFunctionCPtr &func)
{
if (func->isSignal())
- return QLatin1String("signal");
+ return u"signal"_s;
QString kind = func->isPublic()
- ? QLatin1String("public") : QLatin1String("protected");
+ ? u"public"_s : u"protected"_s;
if (func->isStatic())
- kind += QLatin1String("-static");
+ kind += u"-static"_s;
else if (func->isSlot())
- kind += QLatin1String("-slot");
+ kind += u"-slot"_s;
return kind;
}
@@ -68,10 +72,10 @@ void DoxygenParser::fillDocumentation(AbstractMetaClass* metaClass)
QString doxyFileSuffix;
if (metaClass->enclosingClass()) {
doxyFileSuffix += metaClass->enclosingClass()->name();
- doxyFileSuffix += QLatin1String("_1_1"); // FIXME: Check why _1_1!!
+ doxyFileSuffix += u"_1_1"_s; // FIXME: Check why _1_1!!
}
doxyFileSuffix += metaClass->name();
- doxyFileSuffix += QLatin1String(".xml");
+ doxyFileSuffix += u".xml"_s;
const char* prefixes[] = { "class", "struct", "namespace" };
bool isProperty = false;
@@ -79,7 +83,7 @@ void DoxygenParser::fillDocumentation(AbstractMetaClass* metaClass)
QString doxyFilePath;
for (const char *prefix : prefixes) {
doxyFilePath = documentationDataDirectory() + u'/'
- + QLatin1String(prefix) + doxyFileSuffix;
+ + QLatin1StringView(prefix) + doxyFileSuffix;
if (QFile::exists(doxyFilePath))
break;
doxyFilePath.clear();
@@ -101,14 +105,14 @@ void DoxygenParser::fillDocumentation(AbstractMetaClass* metaClass)
}
static const QList<QPair<Documentation::Type, QString>> docTags = {
- { Documentation::Brief, QLatin1String("briefdescription") },
- { Documentation::Detailed, QLatin1String("detaileddescription") }
+ { Documentation::Brief, u"briefdescription"_s },
+ { Documentation::Detailed, u"detaileddescription"_s }
};
// Get class documentation
Documentation classDoc;
for (const auto &tag : docTags) {
- const QString classQuery = QLatin1String("/doxygen/compounddef/") + tag.second;
+ const QString classQuery = u"/doxygen/compounddef/"_s + tag.second;
QString doc = getDocumentation(xquery, classQuery,
metaClass->typeEntry()->docModifications());
if (doc.isEmpty())
@@ -123,37 +127,37 @@ void DoxygenParser::fillDocumentation(AbstractMetaClass* metaClass)
//Functions Documentation
const auto &funcs = DocParser::documentableFunctions(metaClass);
for (const auto &func : funcs) {
- QString query = QLatin1String("/doxygen/compounddef/sectiondef");
+ QString query = u"/doxygen/compounddef/sectiondef"_s;
// properties
if (func->isPropertyReader() || func->isPropertyWriter()
|| func->isPropertyResetter()) {
const auto prop = metaClass->propertySpecs().at(func->propertySpecIndex());
- query += QLatin1String("[@kind=\"property\"]/memberdef/name[text()=\"")
- + prop.name() + QLatin1String("\"]");
+ query += u"[@kind=\"property\"]/memberdef/name[text()=\""_s
+ + prop.name() + u"\"]"_s;
isProperty = true;
} else { // normal methods
QString kind = getSectionKindAttr(func);
- query += QLatin1String("[@kind=\"") + kind
- + QLatin1String("-func\"]/memberdef/name[text()=\"")
- + func->originalName() + QLatin1String("\"]");
+ query += u"[@kind=\""_s + kind
+ + u"-func\"]/memberdef/name[text()=\""_s
+ + func->originalName() + u"\"]"_s;
if (func->arguments().isEmpty()) {
- QString args = func->isConstant() ? QLatin1String("() const ") : QLatin1String("()");
- query += QLatin1String("/../argsstring[text()=\"") + args + QLatin1String("\"]");
+ QString args = func->isConstant() ? u"() const "_s : u"()"_s;
+ query += u"/../argsstring[text()=\""_s + args + u"\"]"_s;
} else {
int i = 1;
const AbstractMetaArgumentList &arguments = func->arguments();
for (const AbstractMetaArgument &arg : arguments) {
if (!arg.type().isPrimitive()) {
- query += QLatin1String("/../param[") + QString::number(i)
- + QLatin1String("]/type/ref[text()=\"")
+ query += u"/../param["_s + QString::number(i)
+ + u"]/type/ref[text()=\""_s
+ arg.type().cppSignature().toHtmlEscaped()
- + QLatin1String("\"]/../..");
+ + u"\"]/../.."_s;
} else {
- query += QLatin1String("/../param[") + QString::number(i)
- + QLatin1String("]/type[text(), \"")
+ query += u"/../param["_s + QString::number(i)
+ + u"]/type[text(), \""_s
+ arg.type().cppSignature().toHtmlEscaped()
- + QLatin1String("\"]/..");
+ + u"\"]/.."_s;
}
++i;
}
@@ -163,10 +167,10 @@ void DoxygenParser::fillDocumentation(AbstractMetaClass* metaClass)
for (const auto &tag : docTags) {
QString funcQuery(query);
if (!isProperty) {
- funcQuery += QLatin1String("/../") + tag.second;
+ funcQuery += u"/../"_s + tag.second;
} else {
funcQuery = u'(' + funcQuery;
- funcQuery += u"/../"_qs + tag.second + u")[1]"_qs;
+ funcQuery += u"/../"_s + tag.second + u")[1]"_s;
}
QString doc = getDocumentation(xquery, funcQuery, DocModificationList());
@@ -189,8 +193,8 @@ void DoxygenParser::fillDocumentation(AbstractMetaClass* metaClass)
Documentation fieldDoc;
for (const auto &tag : docTags) {
- QString query = QLatin1String("/doxygen/compounddef/sectiondef/memberdef/name[text()=\"")
- + field.name() + QLatin1String("\"]/../") + tag.second;
+ QString query = u"/doxygen/compounddef/sectiondef/memberdef/name[text()=\""_s
+ + field.name() + u"\"]/../"_s + tag.second;
QString doc = getDocumentation(xquery, query, DocModificationList());
if (doc.isEmpty()) {
qCWarning(lcShibokenDoc, "%s",
@@ -205,8 +209,8 @@ void DoxygenParser::fillDocumentation(AbstractMetaClass* metaClass)
//Enums
for (AbstractMetaEnum &meta_enum : metaClass->enums()) {
- QString query = QLatin1String("/doxygen/compounddef/sectiondef/memberdef[@kind=\"enum\"]/name[text()=\"")
- + meta_enum.name() + QLatin1String("\"]/..");
+ QString query = u"/doxygen/compounddef/sectiondef/memberdef[@kind=\"enum\"]/name[text()=\""_s
+ + meta_enum.name() + u"\"]/.."_s;
QString doc = getDocumentation(xquery, query, DocModificationList());
if (doc.isEmpty()) {
qCWarning(lcShibokenDoc, "%s",
@@ -219,7 +223,7 @@ void DoxygenParser::fillDocumentation(AbstractMetaClass* metaClass)
Documentation DoxygenParser::retrieveModuleDocumentation(const QString& name){
- QString sourceFile = documentationDataDirectory() + QLatin1String("/indexpage.xml");
+ QString sourceFile = documentationDataDirectory() + u"/indexpage.xml"_s;
if (!QFile::exists(sourceFile)) {
qCWarning(lcShibokenDoc).noquote().nospace()
@@ -236,7 +240,7 @@ Documentation DoxygenParser::retrieveModuleDocumentation(const QString& name){
}
// Module documentation
- QString query = QLatin1String("/doxygen/compounddef/detaileddescription");
+ QString query = u"/doxygen/compounddef/detaileddescription"_s;
const QString doc = getDocumentation(xquery, query, DocModificationList());
return Documentation(doc, {});
}
diff --git a/sources/shiboken6/ApiExtractor/include.cpp b/sources/shiboken6/ApiExtractor/include.cpp
index c902d601c..f4b53b040 100644
--- a/sources/shiboken6/ApiExtractor/include.cpp
+++ b/sources/shiboken6/ApiExtractor/include.cpp
@@ -34,13 +34,17 @@
#include <QtCore/QHash>
#include <QtCore/QTextStream>
+#include "qtcompat.h"
+
+using namespace Qt::StringLiterals;
+
QString Include::toString() const
{
if (m_type == IncludePath)
- return QLatin1String("#include <") + m_name + u'>';
+ return u"#include <"_s + m_name + u'>';
if (m_type == LocalPath)
- return QLatin1String("#include \"") + m_name + u'"';
- return QLatin1String("import ") + m_name + u';';
+ return u"#include \""_s + m_name + u'"';
+ return u"import "_s + m_name + u';';
}
size_t qHash(const Include& inc)
diff --git a/sources/shiboken6/ApiExtractor/messages.cpp b/sources/shiboken6/ApiExtractor/messages.cpp
index fb992a230..311b6ce4a 100644
--- a/sources/shiboken6/ApiExtractor/messages.cpp
+++ b/sources/shiboken6/ApiExtractor/messages.cpp
@@ -37,6 +37,8 @@
#include "typesystem.h"
#include <codemodel.h>
+#include "qtcompat.h"
+
#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include <QtCore/QDir>
@@ -44,6 +46,8 @@
#include <QtCore/QStringList>
#include <QtCore/QXmlStreamReader>
+using namespace Qt::StringLiterals;
+
static inline QString colonColon() { return QStringLiteral("::"); }
// abstractmetabuilder.cpp
@@ -268,16 +272,16 @@ QString msgNamespaceNoTypeEntry(const NamespaceModelItem &item,
QString msgAmbiguousVaryingTypesFound(const QString &qualifiedName, const TypeEntries &te)
{
- QString result = QLatin1String("Ambiguous types of varying types found for \"") + qualifiedName
- + QLatin1String("\": ");
+ QString result = u"Ambiguous types of varying types found for \""_s + qualifiedName
+ + u"\": "_s;
QDebug(&result) << te;
return result;
}
QString msgAmbiguousTypesFound(const QString &qualifiedName, const TypeEntries &te)
{
- QString result = QLatin1String("Ambiguous types found for \"") + qualifiedName
- + QLatin1String("\": ");
+ QString result = u"Ambiguous types found for \""_s + qualifiedName
+ + u"\": "_s;
QDebug(&result) << te;
return result;
}
@@ -298,9 +302,9 @@ QString msgUnmatchedParameterType(const ArgumentModelItem &arg, int n,
QString msgUnmatchedReturnType(const FunctionModelItem &functionItem,
const QString &why)
{
- return QLatin1String("unmatched return type '")
+ return u"unmatched return type '"_s
+ functionItem->type().toString()
- + QLatin1String("': ") + why;
+ + u"': "_s + why;
}
QString msgSkippingFunction(const FunctionModelItem &functionItem,
@@ -371,7 +375,7 @@ QString msgGlobalFunctionNotDefined(const FunctionTypeEntry *fte,
str << fte->sourceLocation() << "Global function '" << signature
<< "' is specified in typesystem, but not defined.";
if (!candidates.isEmpty())
- str << " Candidates are: " << candidates.join(u", "_qs);
+ str << " Candidates are: " << candidates.join(u", "_s);
str << ' ' << msgCompilationError;
return result;
}
@@ -431,20 +435,18 @@ QString msgArrayModificationFailed(const FunctionModelItem &functionItem,
QString msgCannotResolveEntity(const QString &name, const QString &reason)
{
- return QLatin1String("Cannot resolve entity \"") + name
- + QLatin1String("\": ") + reason;
+ return u"Cannot resolve entity \""_s + name + u"\": "_s + reason;
}
QString msgCannotSetArrayUsage(const QString &function, int i, const QString &reason)
{
- return function + QLatin1String(": Cannot use parameter ")
- + QString::number(i + 1) + QLatin1String(" as an array: ") + reason;
+ return function + u": Cannot use parameter "_s
+ + QString::number(i + 1) + u" as an array: "_s + reason;
}
QString msgUnableToTranslateType(const QString &t, const QString &why)
{
- return QLatin1String("Unable to translate type \"")
- + t + QLatin1String("\": ") + why;
+ return u"Unable to translate type \""_s + t + u"\": "_s + why;
}
QString msgUnableToTranslateType(const TypeInfo &typeInfo,
@@ -455,24 +457,24 @@ QString msgUnableToTranslateType(const TypeInfo &typeInfo,
QString msgCannotFindTypeEntry(const QString &t)
{
- return QLatin1String("Cannot find type entry for \"") + t + QLatin1String("\".");
+ return u"Cannot find type entry for \""_s + t + u"\"."_s;
}
QString msgCannotFindTypeEntryForSmartPointer(const QString &t, const QString &smartPointerType)
{
- return QLatin1String("Cannot find type entry \"") + t
- + QLatin1String("\" for instantiation of \"") + smartPointerType + QLatin1String("\".");
+ return u"Cannot find type entry \""_s + t
+ + u"\" for instantiation of \""_s +smartPointerType + u"\"."_s;
}
QString msgInvalidSmartPointerType(const TypeInfo &i)
{
- return QLatin1String("Invalid smart pointer type \"") + i.toString() + QLatin1String("\".");
+ return u"Invalid smart pointer type \""_s +i.toString() + u"\"."_s;
}
QString msgCannotFindSmartPointerInstantion(const TypeInfo &i)
{
- return QLatin1String("Cannot find instantiation of smart pointer type for \"")
- + i.toString() + QLatin1String("\".");
+ return u"Cannot find instantiation of smart pointer type for \""_s
+ + i.toString() + u"\"."_s;
}
QString msgCannotTranslateTemplateArgument(int i,
@@ -498,8 +500,8 @@ QString msgDisallowThread(const AbstractMetaFunction *f)
QString msgNamespaceToBeExtendedNotFound(const QString &namespaceName, const QString &packageName)
{
- return QLatin1String("The namespace '") + namespaceName
- + QLatin1String("' to be extended cannot be found in package ")
+ return u"The namespace '"_s + namespaceName
+ + u"' to be extended cannot be found in package "_s
+ packageName + u'.';
}
@@ -515,9 +517,8 @@ QString msgPropertyTypeParsingFailed(const QString &name, const QString &typeNam
QString msgPropertyExists(const QString &className, const QString &name)
{
- return QLatin1String("class ") + className
- + QLatin1String(" already has a property \"") + name
- + QLatin1String("\" (defined by Q_PROPERTY).");
+ return u"class "_s + className + u" already has a property \""_s
+ + name + u"\" (defined by Q_PROPERTY)."_s;
}
QString msgFunctionVisibilityModified(const AbstractMetaClass *c,
@@ -573,9 +574,9 @@ static QString functionDescription(const AbstractMetaFunction *function)
{
QString result = u'"' + function->classQualifiedSignature() + u'"';
if (function->flags().testFlag(AbstractMetaFunction::Flag::HiddenFriend))
- result += u" (hidden friend)"_qs;
+ result += u" (hidden friend)"_s;
if (function->flags().testFlag(AbstractMetaFunction::Flag::InheritedFromTemplate))
- result += u" (inherited from template)"_qs;
+ result += u" (inherited from template)"_s;
return result;
}
@@ -601,7 +602,7 @@ QString msgCannotFindDocumentation(const QString &fileName,
const QString &query)
{
return msgCannotFindDocumentation(fileName, "enum",
- metaClass->name() + QLatin1String("::") + e.name(),
+ metaClass->name() + u"::"_s + e.name(),
query);
}
@@ -611,7 +612,7 @@ QString msgCannotFindDocumentation(const QString &fileName,
const QString &query)
{
return msgCannotFindDocumentation(fileName, "field",
- metaClass->name() + QLatin1String("::") + f.name(),
+ metaClass->name() + u"::"_s + f.name(),
query);
}
@@ -663,9 +664,9 @@ QString msgWriteFailed(const QFile &f, qsizetype size)
QString msgCannotUseEnumAsInt(const QString &name)
{
- return QLatin1String("Cannot convert the protected scoped enum \"") + name
- + QLatin1String("\" to type int when generating wrappers for the protected hack. "
- "Compilation errors may occur when used as a function argument.");
+ return u"Cannot convert the protected scoped enum \""_s + name
+ + u"\" to type int when generating wrappers for the protected hack. "
+ "Compilation errors may occur when used as a function argument."_s;
}
QString msgConversionTypesDiffer(const QString &varType, const QString &conversionType)
@@ -687,19 +688,19 @@ QString msgConversionTypesDiffer(const QString &varType, const QString &conversi
QString msgCannotFindSmartPointerGetter(const SmartPointerTypeEntry *te)
{
- return u"Getter \""_qs + te->getter() + u"()\" of smart pointer \""_qs
- + te->name() + u"\" not found."_qs;
+ return u"Getter \""_s + te->getter() + u"()\" of smart pointer \""_s
+ + te->name() + u"\" not found."_s;
}
QString msgCannotFindSmartPointerMethod(const SmartPointerTypeEntry *te, const QString &m)
{
- return u"Method \""_qs + m + u"()\" of smart pointer \""_qs
- + te->name() + u"\" not found."_qs;
+ return u"Method \""_s + m + u"()\" of smart pointer \""_s
+ + te->name() + u"\" not found."_s;
}
QString msgMethodNotFound(const AbstractMetaClass *klass, const QString &name)
{
- return u"Method \""_qs + name + u"\" not found in class "_qs
+ return u"Method \""_s + name + u"\" not found in class "_s
+ klass->name() + u'.';
}
@@ -722,8 +723,8 @@ QString msgLeftOverArguments(const QVariantMap &remainingArgs)
QString msgInvalidVersion(const QString &package, const QString &version)
{
- return QLatin1String("Invalid version \"") + version
- + QLatin1String("\" specified for package ") + package + u'.';
+ return u"Invalid version \""_s + version
+ + u"\" specified for package "_s + package + u'.';
}
QString msgCyclicDependency(const QString &funcName, const QString &graphName,
@@ -754,9 +755,9 @@ QString msgCyclicDependency(const QString &funcName, const QString &graphName,
QString msgClassNotFound(const TypeEntry *t)
{
- return QLatin1String("Could not find class \"")
+ return u"Could not find class \""_s
+ t->qualifiedCppName()
- + QLatin1String("\" in the code model. Maybe it is forward declared?");
+ + u"\" in the code model. Maybe it is forward declared?"_s;
}
QString msgEnclosingClassNotFound(const TypeEntry *t)
@@ -770,10 +771,10 @@ QString msgEnclosingClassNotFound(const TypeEntry *t)
QString msgUnknownOperator(const AbstractMetaFunction* func)
{
- QString result = QLatin1String("Unknown operator: \"") + func->originalName()
+ QString result = u"Unknown operator: \""_s + func->originalName()
+ u'"';
if (const AbstractMetaClass *c = func->implementingClass())
- result += QLatin1String(" in class: ") + c->name();
+ result += u" in class: "_s + c->name();
return result;
}
@@ -801,8 +802,7 @@ QString msgCannotFindType(const QString &type, const QString &variable,
QString msgCannotBuildMetaType(const QString &s)
{
- return QLatin1String("Unable to build meta type for \"")
- + s + QLatin1String("\": ");
+ return u"Unable to build meta type for \""_s + s + u"\": "_s;
}
QString msgCouldNotFindMinimalConstructor(const QString &where, const QString &type, const QString &why)
@@ -848,36 +848,36 @@ QString msgRejectReason(const TypeRejection &r, const QString &needle)
QString msgCannotFindNamespaceToExtend(const QString &name,
const QString &extendsPackage)
{
- return QLatin1String("Cannot find namespace ") + name
- + QLatin1String(" in package ") + extendsPackage;
+ return u"Cannot find namespace "_s + name
+ + u" in package "_s + extendsPackage;
}
QString msgExtendingNamespaceRequiresPattern(const QString &name)
{
- return QLatin1String("Namespace ") + name
- + QLatin1String(" requires a file pattern since it extends another namespace.");
+ return u"Namespace "_s + name
+ + u" requires a file pattern since it extends another namespace."_s;
}
QString msgInvalidRegularExpression(const QString &pattern, const QString &why)
{
- return QLatin1String("Invalid pattern \"") + pattern + QLatin1String("\": ") + why;
+ return u"Invalid pattern \""_s + pattern + u"\": "_s + why;
}
QString msgNoRootTypeSystemEntry()
{
- return QLatin1String("Type system entry appears out of order, there does not seem to be a root type system element.");
+ return u"Type system entry appears out of order, there does not seem to be a root type system element."_s;
}
QString msgIncorrectlyNestedName(const QString &name)
{
- return QLatin1String("Nesting types by specifying '::' is no longer supported (")
- + name + QLatin1String(").");
+ return u"Nesting types by specifying '::' is no longer supported ("_s
+ + name + u")."_s;
}
QString msgCannotFindView(const QString &viewedName, const QString &name)
{
- return QLatin1String("Unable to find viewed type ") + viewedName
- + QLatin1String(" for ") + name;
+ return u"Unable to find viewed type "_s + viewedName
+ + u" for "_s + name;
}
QString msgCannotFindSnippet(const QString &file, const QString &snippetLabel)
@@ -917,25 +917,25 @@ QString msgUnknownTypeInArgumentTypeReplacement(const QString &typeReplaced,
QString msgDuplicateBuiltInTypeEntry(const QString &name)
{
- return u"A type entry duplicating the built-in type \""_qs
- + name + u"\" was found. It is ignored."_qs;
+ return u"A type entry duplicating the built-in type \""_s
+ + name + u"\" was found. It is ignored."_s;
}
QString msgDuplicateTypeEntry(const QString &name)
{
- return u"Duplicate type entry: '"_qs + name + u"'."_qs;
+ return u"Duplicate type entry: '"_s + name + u"'."_s;
}
QString msgInvalidTargetLanguageApiName(const QString &name)
{
- return u"Invalid target language API name \""_qs
- + name + u"\"."_qs;
+ return u"Invalid target language API name \""_s
+ + name + u"\"."_s;
}
QString msgUnknownCheckFunction(const TypeEntry *t)
{
- return u"Unknown check function for type: '"_qs
- + t->qualifiedCppName() + u"'."_qs;
+ return u"Unknown check function for type: '"_s
+ + t->qualifiedCppName() + u"'."_s;
}
QString msgArgumentClassNotFound(const AbstractMetaFunctionCPtr &func,
diff --git a/sources/shiboken6/ApiExtractor/modifications.cpp b/sources/shiboken6/ApiExtractor/modifications.cpp
index eb96e3c18..61498fb6c 100644
--- a/sources/shiboken6/ApiExtractor/modifications.cpp
+++ b/sources/shiboken6/ApiExtractor/modifications.cpp
@@ -33,19 +33,23 @@
#include "typeparser.h"
#include "typesystem.h"
+#include "qtcompat.h"
+
#include <QtCore/QDebug>
#include <algorithm>
#include <limits>
+using namespace Qt::StringLiterals;
+
static inline QString callOperator() { return QStringLiteral("operator()"); }
QString TemplateInstance::expandCode() const
{
TemplateEntry *templateEntry = TypeDatabase::instance()->findTemplate(m_name);
if (!templateEntry) {
- const QString m = QLatin1String("<insert-template> referring to non-existing template '")
- + m_name + QLatin1String("'.");
+ const QString m = u"<insert-template> referring to non-existing template '"_s
+ + m_name + u"'."_s;
throw Exception(m);
}
@@ -54,11 +58,11 @@ QString TemplateInstance::expandCode() const
code.replace(it.key(), it.value());
while (!code.isEmpty() && code.at(code.size() - 1).isSpace())
code.chop(1);
- QString result = QLatin1String("// TEMPLATE - ") + m_name + QLatin1String(" - START");
+ QString result = u"// TEMPLATE - "_s + m_name + u" - START"_s;
if (!code.startsWith(u'\n'))
result += u'\n';
result += code;
- result += QLatin1String("\n// TEMPLATE - ") + m_name + QLatin1String(" - END\n");
+ result += u"\n// TEMPLATE - "_s + m_name + u" - END\n"_s;
return result;
}
@@ -109,10 +113,14 @@ void purgeEmptyCodeSnips(QList<CodeSnip> *list)
// ---------------------- Modification
QString FunctionModification::accessModifierString() const
{
- if (isPrivate()) return QLatin1String("private");
- if (isProtected()) return QLatin1String("protected");
- if (isPublic()) return QLatin1String("public");
- if (isFriendly()) return QLatin1String("friendly");
+ if (isPrivate())
+ return u"private"_s;
+ if (isProtected())
+ return u"protected"_s;
+ if (isPublic())
+ return u"public"_s;
+ if (isFriendly())
+ return u"friendly"_s;
return QString();
}
@@ -314,7 +322,7 @@ Arguments splitParameters(QStringView paramString, QString *errorMessage)
const int nameEndPos = typeString.indexOf(u'@', namePos);
if (nameEndPos == -1) {
if (errorMessage != nullptr) {
- *errorMessage = QLatin1String("Mismatched @ in \"")
+ *errorMessage = u"Mismatched @ in \""_s
+ paramString.toString() + u'"';
}
return {};
@@ -367,7 +375,7 @@ AddedFunction::AddedFunctionPtr
const QString name = signature.left(openParenPos).trimmed().toString();
const int closingParenPos = signature.lastIndexOf(u')');
if (closingParenPos < 0) {
- *errorMessage = QLatin1String("Missing closing parenthesis");
+ *errorMessage = u"Missing closing parenthesis"_s;
return {};
}
@@ -388,8 +396,8 @@ AddedFunction::AddedFunctionPtr
TypeInfo type = p.type == u"..."
? TypeInfo::varArgsType() : TypeParser::parse(p.type, errorMessage);
if (!errorMessage->isEmpty()) {
- errorMessage->prepend(u"Unable to parse added function "_qs + signatureIn
- + u": "_qs);
+ errorMessage->prepend(u"Unable to parse added function "_s + signatureIn
+ + u": "_s);
return {};
}
arguments.append({type, p.name, p.defaultValue});
@@ -858,8 +866,8 @@ bool FunctionModification::setSignature(const QString &s, QString *errorMessage)
d->m_signaturePattern.setPattern(s);
if (!d->m_signaturePattern.isValid()) {
if (errorMessage) {
- *errorMessage = QLatin1String("Invalid signature pattern: \"")
- + s + QLatin1String("\": ") + d->m_signaturePattern.errorString();
+ *errorMessage = u"Invalid signature pattern: \""_s
+ + s + u"\": "_s + d->m_signaturePattern.errorString();
}
return false;
}
diff --git a/sources/shiboken6/ApiExtractor/parser/typeinfo.cpp b/sources/shiboken6/ApiExtractor/parser/typeinfo.cpp
index c7861a897..29b8f49d0 100644
--- a/sources/shiboken6/ApiExtractor/parser/typeinfo.cpp
+++ b/sources/shiboken6/ApiExtractor/parser/typeinfo.cpp
@@ -33,12 +33,16 @@
#include <clangparser/clangutils.h>
+#include "qtcompat.h"
+
#include <QtCore/QDebug>
#include <QtCore/QStack>
#include <QtCore/QTextStream>
#include <iostream>
+using namespace Qt::StringLiterals;
+
class TypeInfoData : public QSharedData
{
@@ -94,13 +98,13 @@ static inline TypeInfo createType(const QString &name)
TypeInfo TypeInfo::voidType()
{
- static const TypeInfo result = createType(QLatin1String("void"));
+ static const TypeInfo result = createType(u"void"_s);
return result;
}
TypeInfo TypeInfo::varArgsType()
{
- static const TypeInfo result = createType(QLatin1String("..."));
+ static const TypeInfo result = createType(u"..."_s);
return result;
}
@@ -316,7 +320,7 @@ TypeInfo TypeInfo::resolveType(CodeModelItem __item, TypeInfo const &__type, con
// typedef struct xcb_connection_t xcb_connection_t;
if (nextItem.data() ==__item.data()) {
std::cerr << "** WARNING Bailing out recursion of " << __FUNCTION__
- << "() on " << qPrintable(__type.qualifiedName().join(QLatin1String("::")))
+ << "() on " << qPrintable(__type.qualifiedName().join(u"::"_s))
<< std::endl;
return otherType;
}
@@ -391,18 +395,18 @@ QString TypeInfo::toString() const
{
QString tmp;
if (isConstant())
- tmp += QLatin1String("const ");
+ tmp += u"const "_s;
if (isVolatile())
- tmp += QLatin1String("volatile ");
+ tmp += u"volatile "_s;
- tmp += d->m_qualifiedName.join(QLatin1String("::"));
+ tmp += d->m_qualifiedName.join(u"::"_s);
if (const int instantiationCount = d->m_instantiations.size()) {
tmp += u'<';
for (int i = 0; i < instantiationCount; ++i) {
if (i)
- tmp += QLatin1String(", ");
+ tmp += u", "_s;
tmp += d->m_instantiations.at(i).toString();
}
if (tmp.endsWith(u'>'))
@@ -420,15 +424,15 @@ QString TypeInfo::toString() const
tmp += u'&';
break;
case RValueReference:
- tmp += QLatin1String("&&");
+ tmp += u"&&"_s;
break;
}
if (isFunctionPointer()) {
- tmp += QLatin1String(" (*)(");
+ tmp += u" (*)("_s;
for (qsizetype i = 0; i < d->m_arguments.size(); ++i) {
if (i != 0)
- tmp += QLatin1String(", ");
+ tmp += u", "_s;
tmp += d->m_arguments.at(i).toString();
}
@@ -555,7 +559,7 @@ void TypeInfo::formatTypeSystemSignature(QTextStream &str) const
{
if (d->m_constant)
str << "const ";
- str << d->m_qualifiedName.join(QLatin1String("::"));
+ str << d->m_qualifiedName.join(u"::"_s);
switch (d->m_referenceType) {
case NoReference:
break;
diff --git a/sources/shiboken6/ApiExtractor/predefined_templates.cpp b/sources/shiboken6/ApiExtractor/predefined_templates.cpp
index 6227b18f3..96610844c 100644
--- a/sources/shiboken6/ApiExtractor/predefined_templates.cpp
+++ b/sources/shiboken6/ApiExtractor/predefined_templates.cpp
@@ -28,6 +28,10 @@
#include "predefined_templates.h"
+#include "qtcompat.h"
+
+using namespace Qt::StringLiterals;
+
static QString pySequenceToCppContainer(const QString &insertFunc,
bool reserve)
{
@@ -39,7 +43,7 @@ static QString pySequenceToCppContainer(const QString &insertFunc,
(%out).reserve(size);
}
-)"_qs;
+)"_s;
}
result += uR"(Shiboken::AutoDecRef it(PyObject_GetIter(%in));
@@ -51,12 +55,12 @@ while (true) {
break;
}
%OUTTYPE_0 cppItem = %CONVERTTOCPP[%OUTTYPE_0](pyItem);
- (%out).)"_qs;
+ (%out).)"_s;
result += insertFunc;
result += uR"((cppItem);
}
-)"_qs;
+)"_s;
return result;
}
@@ -69,11 +73,11 @@ static QString cppMapToPyDict(bool isQMap)
{
return uR"(PyObject *%out = PyDict_New();
for (auto it = %in.cbegin(), end = %in.cend(); it != end; ++it) {
- const auto &key = it)"_qs
- + QLatin1String(isQMap ? qtMapKeyAccessor : stlMapKeyAccessor)
+ const auto &key = it)"_s
+ + QLatin1StringView(isQMap ? qtMapKeyAccessor : stlMapKeyAccessor)
+ uR"(;
- const auto &value = it)"_qs
- + QLatin1String(isQMap ? qtMapValueAccessor : stlMapValueAccessor)
+ const auto &value = it)"_s
+ + QLatin1StringView(isQMap ? qtMapValueAccessor : stlMapValueAccessor)
+ uR"(;
PyObject *pyKey = %CONVERTTOPYTHON[%INTYPE_0](key);
PyObject *pyValue = %CONVERTTOPYTHON[%INTYPE_1](value);
@@ -82,7 +86,7 @@ for (auto it = %in.cbegin(), end = %in.cend(); it != end; ++it) {
Py_DECREF(pyValue);
}
return %out;
-)"_qs;
+)"_s;
}
static QString pyDictToCppMap(bool isQMap)
@@ -93,11 +97,11 @@ Py_ssize_t pos = 0;
while (PyDict_Next(%in, &pos, &key, &value)) {
%OUTTYPE_0 cppKey = %CONVERTTOCPP[%OUTTYPE_0](key);
%OUTTYPE_1 cppValue = %CONVERTTOCPP[%OUTTYPE_1](value);
- %out.insert()"_qs
+ %out.insert()"_s
// STL needs a pair
- + (isQMap ? u"cppKey, cppValue"_qs : u"{cppKey, cppValue}"_qs) + uR"();
+ + (isQMap ? u"cppKey, cppValue"_s : u"{cppKey, cppValue}"_s) + uR"();
}
-)"_qs;
+)"_s;
}
// Convert a STL or Qt multi map to Dict of Lists using upperBound()
@@ -105,12 +109,12 @@ static QString cppMultiMapToPyDict(bool isQMultiMap)
{
return uR"(PyObject *%out = PyDict_New();
for (auto it = %in.cbegin(), end = %in.cend(); it != end; ) {
- const auto &key = it)"_qs
- + QLatin1String(isQMultiMap ? qtMapKeyAccessor : stlMapKeyAccessor)
+ const auto &key = it)"_s
+ + QLatin1StringView(isQMultiMap ? qtMapKeyAccessor : stlMapKeyAccessor)
+ uR"(;
PyObject *pyKey = %CONVERTTOPYTHON[%INTYPE_0](key);
- auto upper = %in.)"_qs
- + (isQMultiMap ? u"upperBound"_qs : u"upper_bound"_qs)
+ auto upper = %in.)"_s
+ + (isQMultiMap ? u"upperBound"_s : u"upper_bound"_s)
+ uR"((key);
const auto count = Py_ssize_t(std::distance(it, upper));
PyObject *pyValues = PyList_New(count);
@@ -123,7 +127,7 @@ static QString cppMultiMapToPyDict(bool isQMultiMap)
Py_DECREF(pyKey);
}
return %out;
-)"_qs;
+)"_s;
}
// Convert a STL or Qt multi hash to Dict of Lists using equalRange()
@@ -131,8 +135,8 @@ static QString cppMultiHashToPyDict(bool isQMultiHash)
{
return uR"(PyObject *%out = PyDict_New();
for (auto it = %in.cbegin(), end = %in.cend(); it != end; ) {
- const auto &key = it)"_qs
- + QLatin1String(isQMultiHash ? qtMapKeyAccessor : stlMapKeyAccessor)
+ const auto &key = it)"_s
+ + QLatin1StringView(isQMultiHash ? qtMapKeyAccessor : stlMapKeyAccessor)
+ uR"(;
PyObject *pyKey = %CONVERTTOPYTHON[%INTYPE_0](key);
auto range = %in.equal_range(key);
@@ -147,7 +151,7 @@ static QString cppMultiHashToPyDict(bool isQMultiHash)
Py_DECREF(pyKey);
}
return %out;
-)"_qs;
+)"_s;
}
// Convert Dict of Lists to a STL or Qt multi hash/map
@@ -162,84 +166,84 @@ static QString pyDictToCppMultiHash(bool isQMultiHash)
for (Py_ssize_t i = 0; i < size; ++i) {
Shiboken::AutoDecRef value(PySequence_GetItem(values, i));
%OUTTYPE_1 cppValue = %CONVERTTOCPP[%OUTTYPE_1](value);
- %out.insert()"_qs
- + (isQMultiHash ? u"cppKey, cppValue"_qs : u"{cppKey, cppValue}"_qs)
+ %out.insert()"_s
+ + (isQMultiHash ? u"cppKey, cppValue"_s : u"{cppKey, cppValue}"_s)
+ uR"();
}
}
-)"_qs;
+)"_s;
}
const PredefinedTemplates &predefinedTemplates()
{
static const PredefinedTemplates result{
- {u"shiboken_conversion_pylong_to_cpp"_qs,
- u"%out = %OUTTYPE(PyLong_AsLong(%in));\n"_qs},
+ {u"shiboken_conversion_pylong_to_cpp"_s,
+ u"%out = %OUTTYPE(PyLong_AsLong(%in));\n"_s},
// QPair/std::pair
- {u"shiboken_conversion_pysequence_to_cpppair"_qs,
+ {u"shiboken_conversion_pysequence_to_cpppair"_s,
uR"(%out.first = %CONVERTTOCPP[%OUTTYPE_0](PySequence_Fast_GET_ITEM(%in, 0));
%out.second = %CONVERTTOCPP[%OUTTYPE_1](PySequence_Fast_GET_ITEM(%in, 1));
-)"_qs},
+)"_s},
- {u"shiboken_conversion_cpppair_to_pytuple"_qs,
+ {u"shiboken_conversion_cpppair_to_pytuple"_s,
uR"(PyObject *%out = PyTuple_New(2);
PyTuple_SET_ITEM(%out, 0, %CONVERTTOPYTHON[%INTYPE_0](%in.first));
PyTuple_SET_ITEM(%out, 1, %CONVERTTOPYTHON[%INTYPE_1](%in.second));
return %out;
-)"_qs},
+)"_s},
// Sequential containers
- {u"shiboken_conversion_cppsequence_to_pylist"_qs,
+ {u"shiboken_conversion_cppsequence_to_pylist"_s,
uR"(PyObject *%out = PyList_New(Py_ssize_t(%in.size()));
Py_ssize_t idx = 0;
for (auto it = %in.cbegin(), end = %in.cend(); it != end; ++it, ++idx) {
const auto &cppItem = *it;
PyList_SET_ITEM(%out, idx, %CONVERTTOPYTHON[%INTYPE_0](cppItem));
}
-return %out;)"_qs},
+return %out;)"_s},
// PySet
- {u"shiboken_conversion_cppsequence_to_pyset"_qs,
+ {u"shiboken_conversion_cppsequence_to_pyset"_s,
uR"(PyObject *%out = PySet_New(nullptr);
for (const auto &cppItem : %in) {
PySet_Add(%out, %CONVERTTOPYTHON[%INTYPE_0](cppItem));
}
-return %out;)"_qs},
+return %out;)"_s},
- {u"shiboken_conversion_pyiterable_to_cppsequentialcontainer"_qs,
- pySequenceToCppContainer(u"push_back"_qs, false)},
- {u"shiboken_conversion_pyiterable_to_cppsequentialcontainer_reserve"_qs,
- pySequenceToCppContainer(u"push_back"_qs, true)},
- {u"shiboken_conversion_pyiterable_to_cppsetcontainer"_qs,
- pySequenceToCppContainer(u"insert"_qs, false)},
+ {u"shiboken_conversion_pyiterable_to_cppsequentialcontainer"_s,
+ pySequenceToCppContainer(u"push_back"_s, false)},
+ {u"shiboken_conversion_pyiterable_to_cppsequentialcontainer_reserve"_s,
+ pySequenceToCppContainer(u"push_back"_s, true)},
+ {u"shiboken_conversion_pyiterable_to_cppsetcontainer"_s,
+ pySequenceToCppContainer(u"insert"_s, false)},
// Maps
- {u"shiboken_conversion_stdmap_to_pydict"_qs,
+ {u"shiboken_conversion_stdmap_to_pydict"_s,
cppMapToPyDict(false)},
- {u"shiboken_conversion_qmap_to_pydict"_qs,
+ {u"shiboken_conversion_qmap_to_pydict"_s,
cppMapToPyDict(true)},
- {u"shiboken_conversion_pydict_to_stdmap"_qs,
+ {u"shiboken_conversion_pydict_to_stdmap"_s,
pyDictToCppMap(false)},
- {u"shiboken_conversion_pydict_to_qmap"_qs,
+ {u"shiboken_conversion_pydict_to_qmap"_s,
pyDictToCppMap(true)},
// Multi maps
- {u"shiboken_conversion_stdmultimap_to_pydict"_qs,
+ {u"shiboken_conversion_stdmultimap_to_pydict"_s,
cppMultiMapToPyDict(false)},
- {u"shiboken_conversion_qmultimap_to_pydict"_qs,
+ {u"shiboken_conversion_qmultimap_to_pydict"_s,
cppMultiMapToPyDict(true)},
// Multi hashes
- {u"shiboken_conversion_stdunorderedmultimap_to_pydict"_qs,
+ {u"shiboken_conversion_stdunorderedmultimap_to_pydict"_s,
cppMultiHashToPyDict(false)},
- {u"shiboken_conversion_qmultihash_to_pydict"_qs,
+ {u"shiboken_conversion_qmultihash_to_pydict"_s,
cppMultiHashToPyDict(true)},
// STL multi hash/map
- {u"shiboken_conversion_pydict_to_stdmultimap"_qs,
+ {u"shiboken_conversion_pydict_to_stdmultimap"_s,
pyDictToCppMultiHash(false)},
- {u"shiboken_conversion_pydict_to_qmultihash"_qs,
+ {u"shiboken_conversion_pydict_to_qmultihash"_s,
pyDictToCppMultiHash(true)}
};
diff --git a/sources/shiboken6/ApiExtractor/propertyspec.cpp b/sources/shiboken6/ApiExtractor/propertyspec.cpp
index cd0118e13..b28d6ec71 100644
--- a/sources/shiboken6/ApiExtractor/propertyspec.cpp
+++ b/sources/shiboken6/ApiExtractor/propertyspec.cpp
@@ -34,6 +34,8 @@
#include "messages.h"
#include "typesystem.h"
+#include "qtcompat.h"
+
#include <QtCore/QHash>
#ifndef QT_NO_DEBUG_STREAM
@@ -42,6 +44,8 @@
#include <algorithm>
+using namespace Qt::StringLiterals;
+
class QPropertySpecData : public QSharedData
{
public:
@@ -209,13 +213,13 @@ TypeSystemProperty QPropertySpec::typeSystemPropertyFromQ_Property(const QString
const auto it = std::find_if(propertyTokens.cbegin(), propertyTokens.cend(),
[](const QString &t) { return tokenLookup.contains(t); });
if (it == propertyTokens.cend()) {
- *errorMessage = QLatin1String("Invalid property specification, READ missing");
+ *errorMessage = u"Invalid property specification, READ missing"_s;
return result;
}
const int firstToken = int(it - propertyTokens.cbegin());
if (firstToken < 2) {
- *errorMessage = QLatin1String("Insufficient number of tokens in property specification");
+ *errorMessage = u"Insufficient number of tokens in property specification"_s;
return result;
}
@@ -251,7 +255,7 @@ TypeSystemProperty QPropertySpec::typeSystemPropertyFromQ_Property(const QString
result.name.remove(0, 1);
}
if (!result.isValid())
- *errorMessage = QLatin1String("Incomplete property specification");
+ *errorMessage = u"Incomplete property specification"_s;
return result;
}
diff --git a/sources/shiboken6/ApiExtractor/qtcompat.h b/sources/shiboken6/ApiExtractor/qtcompat.h
new file mode 100644
index 000000000..121ff1ffd
--- /dev/null
+++ b/sources/shiboken6/ApiExtractor/qtcompat.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt for Python.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTCOMPAT_H
+#define QTCOMPAT_H
+
+#include <QtCore/QtGlobal>
+
+#if QT_VERSION < 0x060400
+
+// QTBUG-98434, provide literals of Qt 6.4 for compatibility.
+
+# include <QtCore/QString>
+
+# define QLatin1StringView QLatin1String
+
+namespace Qt {
+inline namespace Literals {
+inline namespace StringLiterals {
+
+constexpr inline QLatin1String operator"" _L1(const char *str, size_t size) noexcept
+{
+ return QLatin1String(str, qsizetype(size));
+}
+
+inline QString operator"" _s(const char16_t *str, size_t size) noexcept
+{
+ return QString(QStringPrivate(nullptr, const_cast<char16_t *>(str), qsizetype(size)));
+}
+
+} // StringLiterals
+} // Literals
+} // Qt
+
+#endif // < 6.4
+
+#endif // QTCOMPAT_H
diff --git a/sources/shiboken6/ApiExtractor/qtdocparser.cpp b/sources/shiboken6/ApiExtractor/qtdocparser.cpp
index 7ac765781..672451e35 100644
--- a/sources/shiboken6/ApiExtractor/qtdocparser.cpp
+++ b/sources/shiboken6/ApiExtractor/qtdocparser.cpp
@@ -39,10 +39,14 @@
#include "reporthandler.h"
#include "typesystem.h"
+#include "qtcompat.h"
+
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QUrl>
+using namespace Qt::StringLiterals;
+
enum { debugFunctionSearch = 0 };
static inline QString briefStartElement() { return QStringLiteral("<brief>"); }
@@ -164,7 +168,7 @@ QString QtDocParser::queryFunctionDocumentation(const QString &sourceFileName,
classDocumentation.findFunctionCandidates(func->name(), func->isConstant());
if (candidates.isEmpty()) {
*errorMessage = msgCannotFindDocumentation(sourceFileName, func.data())
- + u" (no matches)"_qs;
+ + u" (no matches)"_s;
return {};
}
@@ -181,8 +185,8 @@ QString QtDocParser::queryFunctionDocumentation(const QString &sourceFileName,
|| funcFlags.testFlag(AbstractMetaFunction::Flag::OperatorTrailingClassArgumentRemoved)) {
QString classType = metaClass->qualifiedCppName();
if (!funcFlags.testFlag(AbstractMetaFunction::Flag::OperatorClassArgumentByValue)) {
- classType.prepend(u"const "_qs);
- classType.append(u" &"_qs);
+ classType.prepend(u"const "_s);
+ classType.append(u" &"_s);
}
if (funcFlags.testFlag(AbstractMetaFunction::Flag::OperatorLeadingClassArgumentRemoved))
fq.parameters.prepend(classType);
@@ -233,7 +237,7 @@ static QString extractBrief(QString *value)
const auto briefLength = briefEnd + briefEndElement().size() - briefStart;
QString briefValue = value->mid(briefStart, briefLength);
briefValue.insert(briefValue.size() - briefEndElement().size(),
- QLatin1String("<rst> More_...</rst>"));
+ u"<rst> More_...</rst>"_s);
value->remove(briefStart, briefLength);
return briefValue;
}
@@ -252,7 +256,7 @@ void QtDocParser::fillDocumentation(AbstractMetaClass* metaClass)
QString sourceFileRoot = documentationDataDirectory() + u'/'
+ metaClass->qualifiedCppName().toLower();
- sourceFileRoot.replace(QLatin1String("::"), QLatin1String("-"));
+ sourceFileRoot.replace(u"::"_s, u"-"_s);
QFileInfo sourceFile(sourceFileRoot + QStringLiteral(".webxml"));
if (!sourceFile.exists())
@@ -355,7 +359,7 @@ Documentation QtDocParser::retrieveModuleDocumentation(const QString& name)
const QString prefix = documentationDataDirectory() + u'/'
+ moduleName.toLower();
- const QString sourceFile = prefix + u"-index.webxml"_qs;
+ const QString sourceFile = prefix + u"-index.webxml"_s;
if (!QFile::exists(sourceFile)) {
qCWarning(lcShibokenDoc).noquote().nospace()
<< "Can't find qdoc file for module " << name << ", tried: "
@@ -378,7 +382,7 @@ Documentation QtDocParser::retrieveModuleDocumentation(const QString& name)
}
// If a QML module info file exists, insert a link to the Qt docs.
- const QFileInfo qmlModuleFi(prefix + QLatin1String("-qmlmodule.webxml"));
+ const QFileInfo qmlModuleFi(prefix + u"-qmlmodule.webxml"_s);
if (qmlModuleFi.isFile()) {
QString docString = doc.detailed();
const int pos = docString.lastIndexOf(u"</description>");
diff --git a/sources/shiboken6/ApiExtractor/reporthandler.cpp b/sources/shiboken6/ApiExtractor/reporthandler.cpp
index d20768628..077f66df6 100644
--- a/sources/shiboken6/ApiExtractor/reporthandler.cpp
+++ b/sources/shiboken6/ApiExtractor/reporthandler.cpp
@@ -29,12 +29,17 @@
#include "reporthandler.h"
#include "typesystem.h"
#include "typedatabase.h"
+
+#include "qtcompat.h"
+
#include <QtCore/QElapsedTimer>
#include <QtCore/QSet>
#include <cstring>
#include <cstdarg>
#include <cstdio>
+using namespace Qt::StringLiterals;
+
#if defined(_WINDOWS) || defined(NOCOLOR)
#define COLOR_END ""
#define COLOR_WHITE ""
diff --git a/sources/shiboken6/ApiExtractor/tests/testabstractmetaclass.cpp b/sources/shiboken6/ApiExtractor/tests/testabstractmetaclass.cpp
index f5de6077a..53db07c00 100644
--- a/sources/shiboken6/ApiExtractor/tests/testabstractmetaclass.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testabstractmetaclass.cpp
@@ -28,13 +28,18 @@
#include "testabstractmetaclass.h"
#include "abstractmetabuilder.h"
-#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetafunction.h>
#include <abstractmetalang.h>
#include <usingmember.h>
#include <typesystem.h>
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
void TestAbstractMetaClass::testClassName()
{
const char* cppCode ="class ClassName {};";
@@ -241,7 +246,7 @@ void TestAbstractMetaClass::testDefaultValues()
AbstractMetaClassList classes = builder->classes();
QCOMPARE(classes.size(), 2);
AbstractMetaClass* classA = AbstractMetaClass::findClass(classes, u"A");
- const auto candidates = classA->queryFunctionsByName(u"method"_qs);
+ const auto candidates = classA->queryFunctionsByName(u"method"_s);
QCOMPARE(candidates.size(), 1);
const auto &method = candidates.constFirst();
const AbstractMetaArgument &arg = method->arguments().constFirst();
@@ -271,7 +276,7 @@ void TestAbstractMetaClass::testModifiedDefaultValues()
AbstractMetaClassList classes = builder->classes();
QCOMPARE(classes.size(), 2);
AbstractMetaClass* classA = AbstractMetaClass::findClass(classes, u"A");
- const auto methodMatches = classA->queryFunctionsByName(QLatin1String("method"));
+ const auto methodMatches = classA->queryFunctionsByName(u"method"_s);
QCOMPARE(methodMatches.size(), 1);
const auto method = methodMatches.constFirst();
const AbstractMetaArgument &arg = method->arguments().constFirst();
@@ -362,7 +367,7 @@ void TestAbstractMetaClass::testSpecialFunctions()
QCOMPARE(ctors.size(), 2);
QCOMPARE(ctors.constFirst()->functionType(), AbstractMetaFunction::ConstructorFunction);
QCOMPARE(ctors.at(1)->functionType(), AbstractMetaFunction::CopyConstructorFunction);
- auto assigmentOps = classA->queryFunctionsByName(QLatin1String("operator="));
+ auto assigmentOps = classA->queryFunctionsByName(u"operator="_s);
QCOMPARE(assigmentOps.size(), 1);
QCOMPARE(assigmentOps.constFirst()->functionType(),
AbstractMetaFunction::AssignmentOperatorFunction);
@@ -373,7 +378,7 @@ void TestAbstractMetaClass::testSpecialFunctions()
QCOMPARE(ctors.size(), 2);
QCOMPARE(ctors.constFirst()->functionType(), AbstractMetaFunction::ConstructorFunction);
QCOMPARE(ctors.at(1)->functionType(), AbstractMetaFunction::CopyConstructorFunction);
- assigmentOps = classA->queryFunctionsByName(QLatin1String("operator="));
+ assigmentOps = classA->queryFunctionsByName(u"operator="_s);
QCOMPARE(assigmentOps.size(), 1);
QCOMPARE(assigmentOps.constFirst()->functionType(), AbstractMetaFunction::AssignmentOperatorFunction);
}
@@ -757,8 +762,8 @@ void TestAbstractMetaClass::testUsingTemplateMembers()
auto valueList = AbstractMetaClass::findClass(classes, u"ValueList");
QVERIFY(valueList);
auto list = valueList->templateBaseClass();
- QVERIFY(valueList->isUsingMember(list, QLatin1String("append"), Access::Public));
- QCOMPARE(valueList->queryFunctionsByName(QLatin1String("append")).size(), 2);
+ QVERIFY(valueList->isUsingMember(list, u"append"_s, Access::Public));
+ QCOMPARE(valueList->queryFunctionsByName(u"append"_s).size(), 2);
}
QTEST_APPLESS_MAIN(TestAbstractMetaClass)
diff --git a/sources/shiboken6/ApiExtractor/tests/testabstractmetatype.cpp b/sources/shiboken6/ApiExtractor/tests/testabstractmetatype.cpp
index aaa81fb5e..980db2035 100644
--- a/sources/shiboken6/ApiExtractor/tests/testabstractmetatype.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testabstractmetatype.cpp
@@ -27,7 +27,6 @@
****************************************************************************/
#include "testabstractmetatype.h"
-#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetafunction.h>
#include <abstractmetalang.h>
@@ -35,6 +34,12 @@
#include <parser/codemodel.h>
#include <typeparser.h>
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
void TestAbstractMetaType::parsing_data()
{
QTest::addColumn<QString>("input");
@@ -104,7 +109,7 @@ void TestAbstractMetaType::testApiVersionSupported()
<function signature='justAtest3()'/>\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode,
- false, QLatin1String("1.0")));
+ false, u"1.0"_s));
QVERIFY(!builder.isNull());
AbstractMetaClassList classes = builder->classes();
@@ -122,7 +127,7 @@ void TestAbstractMetaType::testApiVersionNotSupported()
<value-type name='object' since='0.1'/>\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode,
- true, QLatin1String("0.1")));
+ true, u"0.1"_s));
QVERIFY(!builder.isNull());
AbstractMetaClassList classes = builder->classes();
@@ -231,7 +236,7 @@ void TestAbstractMetaType::testObjectTypeUsedAsValue()
QCOMPARE(classes.size(), 1);
const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, u"A");
QVERIFY(classA);
- const auto overloads = classA->queryFunctionsByName(QLatin1String("method"));
+ const auto overloads = classA->queryFunctionsByName(u"method"_s);
QCOMPARE(overloads.size(), 1);
const auto method = overloads.constFirst();
QVERIFY(method);
diff --git a/sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp b/sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp
index 9eb49d6fc..d23e7b399 100644
--- a/sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp
@@ -27,7 +27,6 @@
****************************************************************************/
#include "testaddfunction.h"
-#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetafunction.h>
#include <abstractmetalang.h>
@@ -35,33 +34,39 @@
#include <modifications_p.h>
#include <typesystem.h>
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
void TestAddFunction::testParsingFuncNameAndConstness()
{
// generic test...
const char sig1[] = "func(type1, const type2, const type3* const)";
QString errorMessage;
- auto f1 = AddedFunction::createAddedFunction(QLatin1String(sig1), QLatin1String("void"),
+ auto f1 = AddedFunction::createAddedFunction(QLatin1StringView(sig1), u"void"_s,
&errorMessage);
QVERIFY2(!f1.isNull(), qPrintable(errorMessage));
QCOMPARE(f1->name(), u"func");
QCOMPARE(f1->arguments().size(), 3);
TypeInfo retval = f1->returnType();
- QCOMPARE(retval.qualifiedName(), QStringList{QLatin1String("void")});
+ QCOMPARE(retval.qualifiedName(), QStringList{u"void"_s});
QCOMPARE(retval.indirections(), 0);
QCOMPARE(retval.isConstant(), false);
QCOMPARE(retval.referenceType(), NoReference);
// test with a ugly template as argument and other ugly stuff
const char sig2[] = " _fu__nc_ ( type1, const type2, const Abc<int& , C<char*> * > * *@my_name@, const type3* const ) const ";
- auto f2 = AddedFunction::createAddedFunction(QLatin1String(sig2),
- QLatin1String("const Abc<int& , C<char*> * > * *"),
+ auto f2 = AddedFunction::createAddedFunction(QLatin1StringView(sig2),
+ u"const Abc<int& , C<char*> * > * *"_s,
&errorMessage);
QVERIFY2(!f2.isNull(), qPrintable(errorMessage));
QCOMPARE(f2->name(), u"_fu__nc_");
const auto &args = f2->arguments();
QCOMPARE(args.size(), 4);
retval = f2->returnType();
- QCOMPARE(retval.qualifiedName(), QStringList{QLatin1String("Abc")});
+ QCOMPARE(retval.qualifiedName(), QStringList{u"Abc"_s});
QCOMPARE(retval.instantiations().size(), 2);
QCOMPARE(retval.toString(), u"const Abc<int&, C<char*>*>**");
QCOMPARE(retval.indirections(), 2);
@@ -72,7 +77,7 @@ void TestAddFunction::testParsingFuncNameAndConstness()
QCOMPARE(args.at(2).name, u"my_name");
auto arg2Type = args.at(2).typeInfo;
- QCOMPARE(arg2Type.qualifiedName(), QStringList{QLatin1String("Abc")});
+ QCOMPARE(arg2Type.qualifiedName(), QStringList{u"Abc"_s});
QCOMPARE(arg2Type.instantiations().size(), 2);
QCOMPARE(arg2Type.toString(), u"const Abc<int&, C<char*>*>**");
QCOMPARE(arg2Type.indirections(), 2);
@@ -83,7 +88,7 @@ void TestAddFunction::testParsingFuncNameAndConstness()
// function with no args.
const char sig3[] = "func()";
- auto f3 = AddedFunction::createAddedFunction(QLatin1String(sig3), QLatin1String("void"),
+ auto f3 = AddedFunction::createAddedFunction(QLatin1StringView(sig3), u"void"_s,
&errorMessage);
QVERIFY2(!f3.isNull(), qPrintable(errorMessage));
QCOMPARE(f3->name(), u"func");
@@ -91,7 +96,7 @@ void TestAddFunction::testParsingFuncNameAndConstness()
// const call operator
const char sig4[] = "operator()(int)const";
- auto f4 = AddedFunction::createAddedFunction(QLatin1String(sig4), QLatin1String("int"),
+ auto f4 = AddedFunction::createAddedFunction(QLatin1StringView(sig4), u"int"_s,
&errorMessage);
QVERIFY2(!f4.isNull(), qPrintable(errorMessage));
QCOMPARE(f4->name(), u"operator()");
@@ -140,12 +145,12 @@ struct A {
QVERIFY(!addedFunc->isStatic());
AbstractMetaType returnType = addedFunc->type();
- QCOMPARE(returnType.typeEntry(), typeDb->findPrimitiveType(QLatin1String("int")));
+ QCOMPARE(returnType.typeEntry(), typeDb->findPrimitiveType(u"int"_s));
const AbstractMetaArgumentList &args = addedFunc->arguments();
QCOMPARE(args.size(), 3);
QCOMPARE(args.at(0).type().typeEntry(), returnType.typeEntry());
QCOMPARE(args.at(1).defaultValueExpression(), u"4.6");
- QCOMPARE(args.at(2).type().typeEntry(), typeDb->findType(QLatin1String("B")));
+ QCOMPARE(args.at(2).type().typeEntry(), typeDb->findType(u"B"_s));
auto addedCallOperator = classA->findFunction(u"operator()");
QVERIFY(addedCallOperator);
@@ -223,7 +228,7 @@ void TestAddFunction::testAddFunctionWithoutParenteses()
{
const char sig1[] = "func";
QString errorMessage;
- auto f1 = AddedFunction::createAddedFunction(QLatin1String(sig1), QLatin1String("void"),
+ auto f1 = AddedFunction::createAddedFunction(QLatin1StringView(sig1), u"void"_s,
&errorMessage);
QVERIFY2(!f1.isNull(), qPrintable(errorMessage));
QCOMPARE(f1->name(), u"func");
@@ -257,7 +262,7 @@ void TestAddFunction::testAddFunctionWithDefaultArgs()
{
const char sig1[] = "func";
QString errorMessage;
- auto f1 = AddedFunction::createAddedFunction(QLatin1String(sig1), QLatin1String("void"),
+ auto f1 = AddedFunction::createAddedFunction(QLatin1StringView(sig1), u"void"_s,
&errorMessage);
QVERIFY2(!f1.isNull(), qPrintable(errorMessage));
QCOMPARE(f1->name(), u"func");
@@ -308,7 +313,7 @@ void TestAddFunction::testAddFunctionAtModuleLevel()
TypeDatabase* typeDb = TypeDatabase::instance();
- AddedFunctionList addedFuncs = typeDb->findGlobalUserFunctions(QLatin1String("func"));
+ AddedFunctionList addedFuncs = typeDb->findGlobalUserFunctions(u"func"_s);
QCOMPARE(addedFuncs.size(), 1);
@@ -324,7 +329,7 @@ void TestAddFunction::testAddFunctionWithVarargs()
{
const char sig1[] = "func(int,char,...)";
QString errorMessage;
- auto f1 = AddedFunction::createAddedFunction(QLatin1String(sig1), QLatin1String("void"),
+ auto f1 = AddedFunction::createAddedFunction(QLatin1StringView(sig1), u"void"_s,
&errorMessage);
QVERIFY2(!f1.isNull(), qPrintable(errorMessage));
QCOMPARE(f1->name(), u"func");
@@ -416,7 +421,7 @@ void TestAddFunction::testAddFunctionWithApiVersion()
</add-function>\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode,
- true, QLatin1String("0.1")));
+ true, u"0.1"_s));
QVERIFY(!builder.isNull());
const auto globalFuncs = builder->globalFunctions();
QCOMPARE(globalFuncs.size(), 1);
@@ -514,18 +519,18 @@ void TestAddFunction::testAddFunctionTypeParser_data()
QTest::newRow("1-arg")
<< QString::fromLatin1("int @a@=42")
- << Arguments{{QLatin1String("int"), QLatin1String("a"), QLatin1String("42")}};
+ << Arguments{{u"int"_s, u"a"_s, u"42"_s}};
QTest::newRow("2-args")
<< QString::fromLatin1("double @d@, int @a@=42")
- << Arguments{{QLatin1String("double"), QLatin1String("d"), {}},
- {QLatin1String("int"), QLatin1String("a"), QLatin1String("42")}};
+ << Arguments{{u"double"_s, u"d"_s, {}},
+ {u"int"_s, u"a"_s, u"42"_s}};
QTest::newRow("template-var_args")
<< QString::fromLatin1("const QList<X,Y> &@list@ = QList<X,Y>{1,2}, int @b@=5, ...")
- << Arguments{{QLatin1String("const QList<X,Y> &"), QLatin1String("list"), QLatin1String("QList<X,Y>{1,2}")},
- {QLatin1String("int"), QLatin1String("b"), QLatin1String("5")},
- {QLatin1String("..."), {}, {}}};
+ << Arguments{{u"const QList<X,Y> &"_s, u"list"_s, u"QList<X,Y>{1,2}"_s},
+ {u"int"_s, u"b"_s, u"5"_s},
+ {u"..."_s, {}, {}}};
}
void TestAddFunction::testAddFunctionTypeParser()
diff --git a/sources/shiboken6/ApiExtractor/tests/testarrayargument.cpp b/sources/shiboken6/ApiExtractor/tests/testarrayargument.cpp
index 2a8cc000c..a03ec1954 100644
--- a/sources/shiboken6/ApiExtractor/tests/testarrayargument.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testarrayargument.cpp
@@ -27,7 +27,6 @@
****************************************************************************/
#include "testarrayargument.h"
-#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetaenum.h>
#include <abstractmetafunction.h>
@@ -35,6 +34,12 @@
#include <typesystem.h>
#include <parser/enumvalue.h>
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
void TestArrayArgument::testArrayArgumentWithSizeDefinedByInteger()
{
const char* cppCode ="\
@@ -91,21 +96,21 @@ void TestArrayArgument::testArraySignature()
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
QVERIFY(!builder.isNull());
const AbstractMetaClass *classA = AbstractMetaClass::findClass(builder->classes(), u"A");
- QCOMPARE(functionMinimalSignature(classA, QLatin1String("mi1")),
+ QCOMPARE(functionMinimalSignature(classA, u"mi1"_s),
u"mi1(int[5])");
- QCOMPARE(functionMinimalSignature(classA, QLatin1String("mi1c")),
+ QCOMPARE(functionMinimalSignature(classA, u"mi1c"_s),
u"mi1c(const int[5])");
- QCOMPARE(functionMinimalSignature(classA, QLatin1String("mi1cu")),
+ QCOMPARE(functionMinimalSignature(classA, u"mi1cu"_s),
u"mi1cu(const int[])");
- QCOMPARE(functionMinimalSignature(classA, QLatin1String("mc1cu")),
+ QCOMPARE(functionMinimalSignature(classA, u"mc1cu"_s),
u"mc1cu(const char*)");
- QCOMPARE(functionMinimalSignature(classA, QLatin1String("mc1cup")),
+ QCOMPARE(functionMinimalSignature(classA, u"mc1cup"_s),
u"mc1cup(const char*[])");
- QCOMPARE(functionMinimalSignature(classA, QLatin1String("muc2")),
+ QCOMPARE(functionMinimalSignature(classA, u"muc2"_s),
u"muc2(unsigned char*[2][3])");
- QCOMPARE(functionMinimalSignature(classA, QLatin1String("mc2c")),
+ QCOMPARE(functionMinimalSignature(classA, u"mc2c"_s),
u"mc2c(const char*[5][6])");
- QCOMPARE(functionMinimalSignature(classA, QLatin1String("mc2cu")),
+ QCOMPARE(functionMinimalSignature(classA, u"mc2cu"_s),
u"mc2cu(const char[][2])");
}
@@ -129,9 +134,9 @@ void TestArrayArgument::testArrayArgumentWithSizeDefinedByEnumValue()
AbstractMetaClass *classA = AbstractMetaClass::findClass(builder->classes(), u"A");
QVERIFY(classA);
- auto someEnum = classA->findEnum(QLatin1String("SomeEnum"));
+ auto someEnum = classA->findEnum(u"SomeEnum"_s);
QVERIFY(someEnum.has_value());
- auto nvalues = classA->findEnumValue(QLatin1String("NValues"));
+ auto nvalues = classA->findEnumValue(u"NValues"_s);
QVERIFY(nvalues.has_value());
const AbstractMetaArgument &arg = classA->functions().constLast()->arguments().constFirst();
diff --git a/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp b/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp
index ff5d65209..321299fa0 100644
--- a/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp
@@ -33,10 +33,14 @@
#include <textstream.h>
#include <typesystem.h>
+#include <qtcompat.h>
+
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtTest/QTest>
+using namespace Qt::StringLiterals;
+
void TestCodeInjections::testReadFile_data()
{
QTest::addColumn<QString>("filePath");
@@ -65,18 +69,18 @@ void TestCodeInjections::testReadFile()
char *argv[] = {nullptr};
QCoreApplication app(argc, argv);
- QString attribute = QLatin1String("file='") + filePath + u'\'';
+ QString attribute = u"file='"_s + filePath + u'\'';
if (!snippet.isEmpty())
- attribute += QLatin1String(" snippet='") + snippet + u'\'';
+ attribute += u" snippet='"_s + snippet + u'\'';
- QString xmlCode = QLatin1String("\
+ QString xmlCode = u"\
<typesystem package=\"Foo\">\n\
<value-type name='A'>\n\
- <conversion-rule class='target' ") + attribute + QLatin1String("/>\n\
- <inject-code class='target' ") + attribute + QLatin1String("/>\n\
+ <conversion-rule class='target' "_s + attribute + u"/>\n\
+ <inject-code class='target' "_s + attribute + u"/>\n\
<value-type name='B'/>\n\
</value-type>\n\
- </typesystem>\n");
+ </typesystem>\n"_s;
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode.toLocal8Bit().constData()));
QVERIFY(!builder.isNull());
AbstractMetaClassList classes = builder->classes();
@@ -101,7 +105,7 @@ void TestCodeInjections::testInjectWithValidApiVersion()
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode,
- true, QLatin1String("1.0")));
+ true, u"1.0"_s));
QVERIFY(!builder.isNull());
AbstractMetaClassList classes = builder->classes();
AbstractMetaClass* classA = AbstractMetaClass::findClass(classes, u"A");
@@ -121,7 +125,7 @@ void TestCodeInjections::testInjectWithInvalidApiVersion()
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode,
- true, QLatin1String("0.1")));
+ true, u"0.1"_s));
QVERIFY(!builder.isNull());
AbstractMetaClassList classes = builder->classes();
diff --git a/sources/shiboken6/ApiExtractor/tests/testconversionoperator.cpp b/sources/shiboken6/ApiExtractor/tests/testconversionoperator.cpp
index 7fb0ed521..014d14244 100644
--- a/sources/shiboken6/ApiExtractor/tests/testconversionoperator.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testconversionoperator.cpp
@@ -27,12 +27,17 @@
****************************************************************************/
#include "testconversionoperator.h"
-#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetafunction.h>
#include <abstractmetalang.h>
#include <typesystem.h>
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
void TestConversionOperator::testConversionOperator()
{
const char cppCode[] = "\
@@ -184,14 +189,14 @@ void TestConversionOperator::testConversionOperatorReturningConstReference()
QCOMPARE(classB->functions().size(), 3);
QCOMPARE(classA->externalConversionOperators().size(), 1);
QCOMPARE(classA->externalConversionOperators().constFirst()->type().cppSignature(),
- QLatin1String("A"));
+ u"A"_s);
QCOMPARE(classA->externalConversionOperators().constFirst()->ownerClass()->name(),
- QLatin1String("B"));
+ u"B"_s);
QCOMPARE(classA->implicitConversions().size(), 1);
QCOMPARE(classA->implicitConversions().constFirst()->type().cppSignature(),
- QLatin1String("A"));
+ u"A"_s);
QCOMPARE(classA->implicitConversions().constFirst()->ownerClass()->name(),
- QLatin1String("B"));
+ u"B"_s);
}
QTEST_APPLESS_MAIN(TestConversionOperator)
diff --git a/sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp b/sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp
index c08cbe87e..8d1de5940 100644
--- a/sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testconversionruletag.cpp
@@ -31,10 +31,14 @@
#include <abstractmetalang.h>
#include <typesystem.h>
+#include <qtcompat.h>
+
#include <QtCore/QFile>
#include <QtCore/QTemporaryFile>
#include <QtTest/QTest>
+using namespace Qt::StringLiterals;
+
void TestConversionRuleTag::testConversionRuleTagWithFile()
{
// FIXME PYSIDE7 remove
@@ -46,12 +50,12 @@ void TestConversionRuleTag::testConversionRuleTagWithFile()
file.close();
const char cppCode[] = "struct A {};\n";
- QString xmlCode = QLatin1String("\
+ QString xmlCode = u"\
<typesystem package='Foo'>\n\
<value-type name='A'>\n\
- <conversion-rule class='target' file='") + file.fileName() + QLatin1String("'/>\n\
+ <conversion-rule class='target' file='"_s + file.fileName() + u"'/>\n\
</value-type>\n\
- </typesystem>\n");
+ </typesystem>\n"_s;
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode.toLocal8Bit().data()));
QVERIFY(!builder.isNull());
AbstractMetaClassList classes = builder->classes();
@@ -103,7 +107,7 @@ void TestConversionRuleTag::testConversionRuleTagReplace()
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
QVERIFY(!builder.isNull());
TypeDatabase* typeDb = TypeDatabase::instance();
- PrimitiveTypeEntry* typeA = typeDb->findPrimitiveType(QLatin1String("A"));
+ PrimitiveTypeEntry* typeA = typeDb->findPrimitiveType(u"A"_s);
QVERIFY(typeA);
CustomConversion* conversion = typeA->customConversion();
@@ -130,7 +134,7 @@ void TestConversionRuleTag::testConversionRuleTagReplace()
QVERIFY(toNative);
QCOMPARE(toNative->sourceTypeName(), u"B");
QVERIFY(!toNative->isCustomType());
- TypeEntry* typeB = typeDb->findType(QLatin1String("B"));
+ TypeEntry* typeB = typeDb->findType(u"B"_s);
QVERIFY(typeB);
QCOMPARE(toNative->sourceType(), typeB);
QCOMPARE(toNative->sourceTypeCheck(), u"CheckIfInputObjectIsB(%IN)");
@@ -232,7 +236,7 @@ void TestConversionRuleTag::testConversionRuleTagWithInsertTemplate()
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
QVERIFY(!builder.isNull());
TypeDatabase* typeDb = TypeDatabase::instance();
- PrimitiveTypeEntry* typeA = typeDb->findPrimitiveType(QLatin1String("A"));
+ PrimitiveTypeEntry* typeA = typeDb->findPrimitiveType(u"A"_s);
QVERIFY(typeA);
CustomConversion* conversion = typeA->customConversion();
@@ -240,7 +244,7 @@ void TestConversionRuleTag::testConversionRuleTagWithInsertTemplate()
QCOMPARE(typeA, conversion->ownerType());
QCOMPARE(conversion->nativeToTargetConversion().trimmed(),
- QLatin1String(nativeToTargetExpected));
+ QLatin1StringView(nativeToTargetExpected));
QVERIFY(conversion->hasTargetToNativeConversions());
QCOMPARE(conversion->targetToNativeConversions().size(), 1);
@@ -248,7 +252,7 @@ void TestConversionRuleTag::testConversionRuleTagWithInsertTemplate()
CustomConversion::TargetToNativeConversion* toNative = conversion->targetToNativeConversions().constFirst();
QVERIFY(toNative);
QCOMPARE(toNative->conversion().trimmed(),
- QLatin1String(targetToNativeExpected));
+ QLatin1StringView(targetToNativeExpected));
}
QTEST_APPLESS_MAIN(TestConversionRuleTag)
diff --git a/sources/shiboken6/ApiExtractor/tests/testdroptypeentries.cpp b/sources/shiboken6/ApiExtractor/tests/testdroptypeentries.cpp
index 0d4649233..1d5974463 100644
--- a/sources/shiboken6/ApiExtractor/tests/testdroptypeentries.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testdroptypeentries.cpp
@@ -27,13 +27,18 @@
****************************************************************************/
#include "testdroptypeentries.h"
-#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetaenum.h>
#include <abstractmetalang.h>
#include <typesystem.h>
#include <conditionalstreamreader.h>
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
static const char* cppCode ="\
struct ValueA {};\n\
struct ValueB {};\n\
@@ -68,12 +73,12 @@ static const char* xmlCode = "\
void TestDropTypeEntries::testDropEntries()
{
- const QStringList droppedEntries{QLatin1String("Foo.ValueB"),
- QLatin1String("ObjectB"), // Check whether module can be omitted
- QLatin1String("Foo.NamespaceA.InnerClassA"),
- QLatin1String("Foo.NamespaceB"), QLatin1String("Foo.EnumB"),
- QLatin1String("Foo.funcB()"),
- QLatin1String("Foo.NamespaceA.InnerNamespaceA")};
+ const QStringList droppedEntries{u"Foo.ValueB"_s,
+ u"ObjectB"_s, // Check whether module can be omitted
+ u"Foo.NamespaceA.InnerClassA"_s,
+ u"Foo.NamespaceB"_s, u"Foo.EnumB"_s,
+ u"Foo.funcB()"_s,
+ u"Foo.NamespaceA.InnerNamespaceA"_s};
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false,
QString(), droppedEntries));
QVERIFY(!builder.isNull());
@@ -92,8 +97,8 @@ void TestDropTypeEntries::testDropEntries()
QCOMPARE(globalEnums.constFirst().name(), u"EnumA");
TypeDatabase* td = TypeDatabase::instance();
- QVERIFY(td->findType(QLatin1String("funcA")));
- QVERIFY(!td->findType(QLatin1String("funcB")));
+ QVERIFY(td->findType(u"funcA"_s));
+ QVERIFY(!td->findType(u"funcB"_s));
}
void TestDropTypeEntries::testDontDropEntries()
@@ -113,8 +118,8 @@ void TestDropTypeEntries::testDontDropEntries()
QCOMPARE(builder->globalEnums().size(), 2);
TypeDatabase* td = TypeDatabase::instance();
- QVERIFY(td->findType(QLatin1String("funcA")));
- QVERIFY(td->findType(QLatin1String("funcB")));
+ QVERIFY(td->findType(u"funcA"_s));
+ QVERIFY(td->findType(u"funcB"_s));
}
static const char* cppCode2 ="\
@@ -132,7 +137,7 @@ static const char* xmlCode2 = R"(
void TestDropTypeEntries::testDropEntryWithChildTags()
{
- QStringList droppedEntries(QLatin1String("Foo.ValueA"));
+ QStringList droppedEntries(u"Foo.ValueA"_s);
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode2, xmlCode2, false,
QString(), droppedEntries));
QVERIFY(!builder.isNull());
diff --git a/sources/shiboken6/ApiExtractor/tests/testenum.cpp b/sources/shiboken6/ApiExtractor/tests/testenum.cpp
index 3d3edc94a..0370e884d 100644
--- a/sources/shiboken6/ApiExtractor/tests/testenum.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testenum.cpp
@@ -27,7 +27,6 @@
****************************************************************************/
#include "testenum.h"
-#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetaenum.h>
#include <abstractmetafunction.h>
@@ -36,6 +35,12 @@
#include <typesystem.h>
#include <parser/enumvalue.h>
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
void TestEnum::testEnumCppSignature()
{
const char* cppCode ="\
@@ -74,7 +79,7 @@ void TestEnum::testEnumCppSignature()
// enum as parameter of a method
const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, u"A");
QCOMPARE(classA->enums().size(), 1);
- const auto funcs = classA->queryFunctionsByName(QLatin1String("method"));
+ const auto funcs = classA->queryFunctionsByName(u"method"_s);
QVERIFY(!funcs.isEmpty());
const auto method = funcs.constFirst();
AbstractMetaArgument arg = method->arguments().constFirst();
@@ -88,9 +93,9 @@ void TestEnum::testEnumCppSignature()
AbstractMetaEnumList classEnums = classA->enums();
QVERIFY(!classEnums.isEmpty());
QCOMPARE(classEnums.constFirst().name(), u"ClassEnum");
- auto e = AbstractMetaClass::findEnumValue(classes, QLatin1String("CA"));
+ auto e = AbstractMetaClass::findEnumValue(classes, u"CA"_s);
QVERIFY(e.has_value());
- e = AbstractMetaClass::findEnumValue(classes, QLatin1String("ClassEnum::CA"));
+ e = AbstractMetaClass::findEnumValue(classes, u"ClassEnum::CA"_s);
QVERIFY(e.has_value());
}
@@ -110,7 +115,7 @@ void TestEnum::testEnumWithApiVersion()
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode,
- true, QLatin1String("0.1")));
+ true, u"0.1"_s));
QVERIFY(!builder.isNull());
AbstractMetaClassList classes = builder->classes();
QCOMPARE(classes.size(), 1);
@@ -149,7 +154,7 @@ void TestEnum::testAnonymousEnum()
QCOMPARE(classes.size(), 1);
QCOMPARE(classes[0]->enums().size(), 2);
- auto anonEnumA1 = classes[0]->findEnum(QLatin1String("A1"));
+ auto anonEnumA1 = classes[0]->findEnum(u"A1"_s);
QVERIFY(anonEnumA1.has_value());
QVERIFY(anonEnumA1->isAnonymous());
QCOMPARE(anonEnumA1->typeEntry()->qualifiedCppName(), u"A::A1");
@@ -164,7 +169,7 @@ void TestEnum::testAnonymousEnum()
QCOMPARE(enumValueA1.value().value(), 1);
QCOMPARE(enumValueA1.stringValue(), QString());
- auto anonEnumIsThis = classes[0]->findEnum(QLatin1String("isThis"));
+ auto anonEnumIsThis = classes[0]->findEnum(u"isThis"_s);
QVERIFY(anonEnumIsThis.has_value());
QVERIFY(anonEnumIsThis->isAnonymous());
QCOMPARE(anonEnumIsThis->typeEntry()->qualifiedCppName(), u"A::isThis");
@@ -246,7 +251,7 @@ void TestEnum::testEnumValueFromNeighbourEnum()
QCOMPARE(classes.size(), 1);
QCOMPARE(classes[0]->enums().size(), 2);
- auto enumA = classes[0]->findEnum(QLatin1String("EnumA"));
+ auto enumA = classes[0]->findEnum(u"EnumA"_s);
QVERIFY(enumA.has_value());
QCOMPARE(enumA->typeEntry()->qualifiedCppName(), u"A::EnumA");
@@ -260,7 +265,7 @@ void TestEnum::testEnumValueFromNeighbourEnum()
QCOMPARE(enumValueA1.value().value(), 1);
QCOMPARE(enumValueA1.stringValue(), QString());
- auto enumB = classes[0]->findEnum(QLatin1String("EnumB"));
+ auto enumB = classes[0]->findEnum(u"EnumB"_s);
QVERIFY(enumB.has_value());
QCOMPARE(enumB->typeEntry()->qualifiedCppName(), u"A::EnumB");
@@ -307,7 +312,7 @@ void TestEnum::testEnumValueFromExpression()
AbstractMetaClass *classA = AbstractMetaClass::findClass(builder->classes(), u"A");
QVERIFY(classA);
- auto enumA = classA->findEnum(QLatin1String("EnumA"));
+ auto enumA = classA->findEnum(u"EnumA"_s);
QVERIFY(enumA.has_value());
QVERIFY(!enumA->isSigned());
QCOMPARE(enumA->typeEntry()->qualifiedCppName(), u"A::EnumA");
@@ -352,7 +357,7 @@ void TestEnum::testEnumValueFromExpression()
QCOMPARE(valueA7.stringValue(), u"ValueA3 << 1");
QCOMPARE(valueA7.value().unsignedValue(), 0xf0u << 1);
- const auto enumB = classA->findEnum(QLatin1String("EnumB"));
+ const auto enumB = classA->findEnum(u"EnumB"_s);
QVERIFY(enumB.has_value());
QVERIFY(enumB->isSigned());
QCOMPARE(enumB->typeEntry()->qualifiedCppName(), u"A::EnumB");
@@ -386,12 +391,12 @@ void TestEnum::testPrivateEnum()
QVERIFY(classA);
QCOMPARE(classA->enums().size(), 2);
- auto privateEnum = classA->findEnum(QLatin1String("PrivateEnum"));
+ auto privateEnum = classA->findEnum(u"PrivateEnum"_s);
QVERIFY(privateEnum.has_value());
QVERIFY(privateEnum->isPrivate());
QCOMPARE(privateEnum->typeEntry()->qualifiedCppName(), u"A::PrivateEnum");
- auto publicEnum = classA->findEnum(QLatin1String("PublicEnum"));
+ auto publicEnum = classA->findEnum(u"PublicEnum"_s);
QVERIFY(publicEnum.has_value());
QCOMPARE(publicEnum->typeEntry()->qualifiedCppName(), u"A::PublicEnum");
diff --git a/sources/shiboken6/ApiExtractor/tests/testfunctiontag.cpp b/sources/shiboken6/ApiExtractor/tests/testfunctiontag.cpp
index f6f2bbd1b..edc7b499a 100644
--- a/sources/shiboken6/ApiExtractor/tests/testfunctiontag.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testfunctiontag.cpp
@@ -27,12 +27,17 @@
****************************************************************************/
#include "testfunctiontag.h"
-#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetafunction.h>
#include <modifications.h>
#include <typesystem.h>
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
void TestFunctionTag::testFunctionTagForSpecificSignature()
{
const char cppCode[] = "void globalFunction(int); void globalFunction(float); void dummy();\n";
@@ -45,7 +50,7 @@ void TestFunctionTag::testFunctionTagForSpecificSignature()
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
QVERIFY(!builder.isNull());
- const TypeEntry *func = TypeDatabase::instance()->findType(QLatin1String("globalFunction"));
+ const TypeEntry *func = TypeDatabase::instance()->findType(u"globalFunction"_s);
QVERIFY(func);
QCOMPARE(builder->globalFunctions().size(), 1);
}
@@ -63,7 +68,7 @@ void TestFunctionTag::testFunctionTagForAllSignatures()
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
QVERIFY(!builder.isNull());
- const TypeEntry *func = TypeDatabase::instance()->findType(QLatin1String("globalFunction"));
+ const TypeEntry *func = TypeDatabase::instance()->findType(u"globalFunction"_s);
QVERIFY(func);
QCOMPARE(builder->globalFunctions().size(), 2);
}
@@ -78,7 +83,7 @@ void TestFunctionTag::testRenameGlobalFunction()
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode, false));
QVERIFY(!builder.isNull());
- const TypeEntry *func = TypeDatabase::instance()->findType(QLatin1String("global_function_with_ugly_name"));
+ const TypeEntry *func = TypeDatabase::instance()->findType(u"global_function_with_ugly_name"_s);
QVERIFY(func);
QCOMPARE(builder->globalFunctions().size(), 1);
diff --git a/sources/shiboken6/ApiExtractor/tests/testmodifydocumentation.cpp b/sources/shiboken6/ApiExtractor/tests/testmodifydocumentation.cpp
index f98077d3d..fcfc506af 100644
--- a/sources/shiboken6/ApiExtractor/tests/testmodifydocumentation.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testmodifydocumentation.cpp
@@ -34,10 +34,14 @@
#include <typesystem.h>
#include <qtdocparser.h>
+#include <qtcompat.h>
+
#include <QtCore/QCoreApplication>
#include <QtCore/QTemporaryDir>
#include <QtTest/QTest>
+using namespace Qt::StringLiterals;
+
void TestModifyDocumentation::testModifyDocumentation()
{
const char* cppCode ="struct B { void b(); }; class A {};\n";
@@ -65,10 +69,10 @@ R"(<typesystem package="Foo">
// Create a temporary directory for the documentation file since libxml2
// cannot handle Qt resources.
- QTemporaryDir tempDir(QDir::tempPath() + QLatin1String("/shiboken_testmodifydocXXXXXX"));
+ QTemporaryDir tempDir(QDir::tempPath() + u"/shiboken_testmodifydocXXXXXX"_s);
QVERIFY2(tempDir.isValid(), qPrintable(tempDir.errorString()));
- const QString docFileName = QLatin1String("a.xml");
- QVERIFY(QFile::copy(QLatin1String(":/") + docFileName, tempDir.filePath(docFileName)));
+ const QString docFileName = u"a.xml"_s;
+ QVERIFY(QFile::copy(u":/"_s + docFileName, tempDir.filePath(docFileName)));
QtDocParser docParser;
docParser.setDocumentationDataDirectory(tempDir.path());
diff --git a/sources/shiboken6/ApiExtractor/tests/testmodifyfunction.cpp b/sources/shiboken6/ApiExtractor/tests/testmodifyfunction.cpp
index 3646d626b..dd9593b3c 100644
--- a/sources/shiboken6/ApiExtractor/tests/testmodifyfunction.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testmodifyfunction.cpp
@@ -27,7 +27,6 @@
****************************************************************************/
#include "testmodifyfunction.h"
-#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetabuilder_p.h>
#include <abstractmetafunction.h>
@@ -35,6 +34,12 @@
#include <modifications.h>
#include <typesystem.h>
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
void TestModifyFunction::testRenameArgument_data()
{
QTest::addColumn<QByteArray>("pattern");
@@ -141,7 +146,7 @@ void TestModifyFunction::invalidateAfterUse()
<object-type name='E' />\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode,
- false, QLatin1String("0.1")));
+ false, u"0.1"_s));
QVERIFY(!builder.isNull());
AbstractMetaClassList classes = builder->classes();
const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, u"B");
@@ -214,7 +219,7 @@ void TestModifyFunction::testWithApiVersion()
</object-type>\n\
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode,
- false, QLatin1String("0.1")));
+ false, u"0.1"_s));
QVERIFY(!builder.isNull());
AbstractMetaClassList classes = builder->classes();
AbstractMetaClass* classB = AbstractMetaClass::findClass(classes, u"B");
@@ -253,7 +258,7 @@ struct A {
</typesystem>
)XML";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode,
- false, QLatin1String("0.1")));
+ false, u"0.1"_s));
QVERIFY(!builder.isNull());
AbstractMetaClassList classes = builder->classes();
const AbstractMetaClass *classA = AbstractMetaClass::findClass(classes, u"A");
@@ -307,7 +312,7 @@ void TestModifyFunction::testGlobalFunctionModification()
QVERIFY(!builder.isNull());
QCOMPARE(builder->globalFunctions().size(), 1);
- FunctionModificationList mods = TypeDatabase::instance()->functionModifications(QLatin1String("function(A*)"));
+ FunctionModificationList mods = TypeDatabase::instance()->functionModifications(u"function(A*)"_s);
QCOMPARE(mods.size(), 1);
const QList<ArgumentModification> &argMods = mods.constFirst().argument_mods();
QCOMPARE(argMods.size(), 1);
diff --git a/sources/shiboken6/ApiExtractor/tests/testnamespace.cpp b/sources/shiboken6/ApiExtractor/tests/testnamespace.cpp
index 34aa5eff5..2202df118 100644
--- a/sources/shiboken6/ApiExtractor/tests/testnamespace.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testnamespace.cpp
@@ -27,12 +27,17 @@
****************************************************************************/
#include "testnamespace.h"
-#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetalang.h>
#include <abstractmetaenum.h>
#include <typesystem.h>
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
void NamespaceTest::testNamespaceMembers()
{
const char* cppCode = "\
@@ -55,7 +60,7 @@ void NamespaceTest::testNamespaceMembers()
AbstractMetaClassList classes = builder->classes();
AbstractMetaClass *ns = AbstractMetaClass::findClass(classes, u"Namespace");
QVERIFY(ns);
- auto metaEnum = ns->findEnum(QLatin1String("Option"));
+ auto metaEnum = ns->findEnum(u"Option"_s);
QVERIFY(metaEnum.has_value());
const auto func = ns->findFunction(u"foo");
QVERIFY(!func.isNull());
diff --git a/sources/shiboken6/ApiExtractor/tests/testnestedtypes.cpp b/sources/shiboken6/ApiExtractor/tests/testnestedtypes.cpp
index eb5ebce31..4df8ddaf3 100644
--- a/sources/shiboken6/ApiExtractor/tests/testnestedtypes.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testnestedtypes.cpp
@@ -27,13 +27,18 @@
****************************************************************************/
#include "testnestedtypes.h"
-#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetafunction.h>
#include <abstractmetalang.h>
#include <modifications.h>
#include <typesystem.h>
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
void TestNestedTypes::testNestedTypesModifications()
{
const char* cppCode ="\
@@ -122,9 +127,9 @@ void TestNestedTypes::testDuplicationOfNestedTypes()
QCOMPARE(cls1->name(), u"SomeClass");
QCOMPARE(cls1->qualifiedCppName(), u"Namespace::SomeClass");
- TypeEntry* t1 = TypeDatabase::instance()->findType(QLatin1String("Namespace::SomeClass"));
+ TypeEntry* t1 = TypeDatabase::instance()->findType(u"Namespace::SomeClass"_s);
QVERIFY(t1);
- TypeEntry* t2 = TypeDatabase::instance()->findType(QLatin1String("SomeClass"));
+ TypeEntry* t2 = TypeDatabase::instance()->findType(u"SomeClass"_s);
QVERIFY(!t2);
}
diff --git a/sources/shiboken6/ApiExtractor/tests/testprimitivetypetag.cpp b/sources/shiboken6/ApiExtractor/tests/testprimitivetypetag.cpp
index 3d9829f2d..698c2206a 100644
--- a/sources/shiboken6/ApiExtractor/tests/testprimitivetypetag.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testprimitivetypetag.cpp
@@ -27,11 +27,16 @@
****************************************************************************/
#include "testprimitivetypetag.h"
-#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetalang.h>
#include <typesystem.h>
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
void TestPrimitiveTypeTag::testPrimitiveTypeDefaultConstructor()
{
const char* cppCode ="\
@@ -50,7 +55,7 @@ void TestPrimitiveTypeTag::testPrimitiveTypeDefaultConstructor()
const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, u"B");
QVERIFY(classB);
- PrimitiveTypeEntry* typeEntry = TypeDatabase::instance()->findPrimitiveType(QLatin1String("A"));
+ PrimitiveTypeEntry* typeEntry = TypeDatabase::instance()->findPrimitiveType(u"A"_s);
QVERIFY(typeEntry);
QVERIFY(typeEntry->hasDefaultConstructor());
QCOMPARE(typeEntry->defaultConstructor(), u"A()");
diff --git a/sources/shiboken6/ApiExtractor/tests/testrefcounttag.cpp b/sources/shiboken6/ApiExtractor/tests/testrefcounttag.cpp
index e8243643d..954bd8efe 100644
--- a/sources/shiboken6/ApiExtractor/tests/testrefcounttag.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testrefcounttag.cpp
@@ -27,12 +27,17 @@
****************************************************************************/
#include "testrefcounttag.h"
-#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetafunction.h>
#include <abstractmetalang.h>
#include <modifications.h>
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
void TestRefCountTag::testReferenceCountTag()
{
const char* cppCode ="\
@@ -85,7 +90,7 @@ void TestRefCountTag::testWithApiVersion()
</typesystem>\n";
QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode,
- false, QLatin1String("0.1")));
+ false, u"0.1"_s));
QVERIFY(!builder.isNull());
AbstractMetaClassList classes = builder->classes();
const AbstractMetaClass *classB = AbstractMetaClass::findClass(classes, u"B");
diff --git a/sources/shiboken6/ApiExtractor/tests/testremoveoperatormethod.cpp b/sources/shiboken6/ApiExtractor/tests/testremoveoperatormethod.cpp
index f30bcd9e0..3134d646b 100644
--- a/sources/shiboken6/ApiExtractor/tests/testremoveoperatormethod.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testremoveoperatormethod.cpp
@@ -27,12 +27,17 @@
****************************************************************************/
#include "testremoveoperatormethod.h"
-#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetafunction.h>
#include <abstractmetalang.h>
#include <typesystem.h>
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
void TestRemoveOperatorMethod::testRemoveOperatorMethod()
{
const char* cppCode ="\
@@ -93,18 +98,18 @@ void TestRemoveOperatorMethod::testRemoveOperatorMethod()
QVERIFY(classA);
QCOMPARE(classA->functions().size(), 14);
QStringList removedSignatures;
- removedSignatures.append(QLatin1String("operator>>(char&)"));
- removedSignatures.append(QLatin1String("operator>>(char*)"));
- removedSignatures.append(QLatin1String("operator>>(short&)"));
- removedSignatures.append(QLatin1String("operator>>(unsigned short&)"));
- removedSignatures.append(QLatin1String("operator>>(int&)"));
- removedSignatures.append(QLatin1String("operator>>(unsigned int&)"));
- removedSignatures.append(QLatin1String("operator>>(int64_t&)"));
- removedSignatures.append(QLatin1String("operator>>(uint64_t&)"));
- removedSignatures.append(QLatin1String("operator>>(float&)"));
- removedSignatures.append(QLatin1String("operator>>(double&)"));
- removedSignatures.append(QLatin1String("operator>>(Char&)"));
- removedSignatures.append(QLatin1String("operator>>(String&)"));
+ removedSignatures.append(u"operator>>(char&)"_s);
+ removedSignatures.append(u"operator>>(char*)"_s);
+ removedSignatures.append(u"operator>>(short&)"_s);
+ removedSignatures.append(u"operator>>(unsigned short&)"_s);
+ removedSignatures.append(u"operator>>(int&)"_s);
+ removedSignatures.append(u"operator>>(unsigned int&)"_s);
+ removedSignatures.append(u"operator>>(int64_t&)"_s);
+ removedSignatures.append(u"operator>>(uint64_t&)"_s);
+ removedSignatures.append(u"operator>>(float&)"_s);
+ removedSignatures.append(u"operator>>(double&)"_s);
+ removedSignatures.append(u"operator>>(Char&)"_s);
+ removedSignatures.append(u"operator>>(String&)"_s);
int notRemoved = classA->functions().size();
for (const auto &f : classA->functions()) {
QCOMPARE(f->isModifiedRemoved(), bool(removedSignatures.contains(f->minimalSignature())));
diff --git a/sources/shiboken6/ApiExtractor/tests/testresolvetype.cpp b/sources/shiboken6/ApiExtractor/tests/testresolvetype.cpp
index bfea490e4..f06ae4eb2 100644
--- a/sources/shiboken6/ApiExtractor/tests/testresolvetype.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testresolvetype.cpp
@@ -27,13 +27,18 @@
****************************************************************************/
#include "testresolvetype.h"
-#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetafunction.h>
#include <abstractmetalang.h>
#include <abstractmetatype.h>
#include <typesystem.h>
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
void TestResolveType::initTestCase()
{
// For enum lookup in testFixDefaultArguments()
@@ -138,7 +143,7 @@ public:
fixture->classType = AbstractMetaType(fixture->klass->typeEntry());
fixture->classType.decideUsagePattern();
- for (const auto &f : fixture->klass->findFunctions(u"Test"_qs)) {
+ for (const auto &f : fixture->klass->findFunctions(u"Test"_s)) {
if (f->functionType() == AbstractMetaFunction::ConstructorFunction
&& f->arguments().size() == 1) {
const auto type = f->arguments().constFirst().type();
@@ -151,7 +156,7 @@ public:
if (fixture->intType.isVoid() || fixture->stringType.isVoid())
return -3;
- auto listFunc = fixture->klass->findFunction(u"listFunc"_qs);
+ auto listFunc = fixture->klass->findFunction(u"listFunc"_s);
if (listFunc.isNull() || listFunc->arguments().size() != 1)
return -3;
fixture->listType = listFunc->arguments().constFirst().type();
@@ -178,7 +183,7 @@ void TestResolveType::testFixDefaultArguments_data()
<< fixture.intType << "enumValue1" << "Namespace::Test::Enum::enumValue1";
// Test expansion of container types
- QString expected = u"std::list<Namespace::Test>()"_qs;
+ QString expected = u"std::list<Namespace::Test>()"_s;
QTest::newRow("list")
<< fixture << setupOk << fixture.listType
<< expected << expected;
@@ -187,7 +192,7 @@ void TestResolveType::testFixDefaultArguments_data()
<< "std::list<Test>()" << expected;
// Test field expansion
- expected = u"Namespace::Test::INT_FIELD_1"_qs;
+ expected = u"Namespace::Test::INT_FIELD_1"_s;
QTest::newRow("qualified class field")
<< fixture << setupOk << fixture.intType
<< expected << expected;
@@ -199,7 +204,7 @@ void TestResolveType::testFixDefaultArguments_data()
<< "INT_FIELD_1" << expected;
// Test field expansion when constructing some class
- expected = u"QLatin1String(Namespace::Test::CHAR_FIELD_1)"_qs;
+ expected = u"QLatin1String(Namespace::Test::CHAR_FIELD_1)"_s;
QTest::newRow("class from qualified class field")
<< fixture << setupOk << fixture.classType
<< expected << expected;
@@ -211,7 +216,7 @@ void TestResolveType::testFixDefaultArguments_data()
<< "QLatin1String(CHAR_FIELD_1)" << expected;
// Test field expansion when constructing class itself
- expected = u"Namespace::Test(Namespace::Test::CHAR_FIELD_1)"_qs;
+ expected = u"Namespace::Test(Namespace::Test::CHAR_FIELD_1)"_s;
QTest::newRow("self from qualified class field")
<< fixture << setupOk << fixture.classType
<< expected << expected;
@@ -223,7 +228,7 @@ void TestResolveType::testFixDefaultArguments_data()
<< "Test(CHAR_FIELD_1)" << expected;
// Test enum expansion when constructing class itself
- expected = u"Namespace::Test(Namespace::Test::Enum::enumValue1)"_qs;
+ expected = u"Namespace::Test(Namespace::Test::Enum::enumValue1)"_s;
QTest::newRow("self from qualified enum")
<< fixture << setupOk << fixture.classType
<< expected << expected;
diff --git a/sources/shiboken6/ApiExtractor/tests/testtemplates.cpp b/sources/shiboken6/ApiExtractor/tests/testtemplates.cpp
index bc4230816..eb0dc2d01 100644
--- a/sources/shiboken6/ApiExtractor/tests/testtemplates.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testtemplates.cpp
@@ -33,10 +33,14 @@
#include <abstractmetalang.h>
#include <typesystem.h>
+#include <qtcompat.h>
+
#include <QtCore/QTemporaryFile>
#include <QtCore/QTextStream>
#include <QtTest/QTest>
+using namespace Qt::StringLiterals;
+
void TestTemplates::testTemplateWithNamespace()
{
const char cppCode[] = R"CPP(
@@ -394,7 +398,7 @@ typedef BaseTemplateClass<TypeOne> TypeOneClass;
const ComplexTypeEntry* oneType = one->typeEntry();
const ComplexTypeEntry* baseType = base->typeEntry();
QCOMPARE(oneType->baseContainerType(), baseType);
- QCOMPARE(one->baseClassNames(), QStringList(QLatin1String("BaseTemplateClass<TypeOne>")));
+ QCOMPARE(one->baseClassNames(), QStringList(u"BaseTemplateClass<TypeOne>"_s));
QVERIFY(one->hasTemplateBaseClassInstantiations());
AbstractMetaTypeList instantiations = one->templateBaseClassInstantiations();
diff --git a/sources/shiboken6/ApiExtractor/tests/testtyperevision.cpp b/sources/shiboken6/ApiExtractor/tests/testtyperevision.cpp
index 6205879a6..2302916ac 100644
--- a/sources/shiboken6/ApiExtractor/tests/testtyperevision.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testtyperevision.cpp
@@ -27,13 +27,18 @@
****************************************************************************/
#include "testtyperevision.h"
-#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetaenum.h>
#include <abstractmetalang.h>
#include <typesystem.h>
#include <typedatabase.h>
+#include <qtcompat.h>
+
+#include <QtTest/QTest>
+
+using namespace Qt::StringLiterals;
+
void TestTypeRevision::testRevisionAttr()
{
const char* cppCode = "class Rev_0 {};"
@@ -59,12 +64,12 @@ void TestTypeRevision::testRevisionAttr()
AbstractMetaClass *rev2 = AbstractMetaClass::findClass(classes, u"Rev_2");
QCOMPARE(rev2->typeEntry()->revision(), 2);
- auto rev3 = rev2->findEnum(QLatin1String("Rev_3"));
+ auto rev3 = rev2->findEnum(u"Rev_3"_s);
QVERIFY(rev3.has_value());
QCOMPARE(rev3->typeEntry()->revision(), 3);
FlagsTypeEntry* rev4 = rev3->typeEntry()->flags();
QCOMPARE(rev4->revision(), 4);
- auto rev5 = rev2->findEnum(QLatin1String("Rev_5"));
+ auto rev5 = rev2->findEnum(u"Rev_5"_s);
QVERIFY(rev5.has_value());
const EnumTypeEntry *revEnumTypeEntry = rev5->typeEntry();
QCOMPARE(revEnumTypeEntry->revision(), 5);
diff --git a/sources/shiboken6/ApiExtractor/tests/testutil.h b/sources/shiboken6/ApiExtractor/tests/testutil.h
index 56ce8a72e..849a5218c 100644
--- a/sources/shiboken6/ApiExtractor/tests/testutil.h
+++ b/sources/shiboken6/ApiExtractor/tests/testutil.h
@@ -51,7 +51,7 @@ namespace TestUtil
TypeDatabase* td = TypeDatabase::instance(true);
if (apiVersion.isEmpty())
TypeDatabase::clearApiVersions();
- else if (!TypeDatabase::setApiVersion(QLatin1String("*"), apiVersion))
+ else if (!TypeDatabase::setApiVersion(QStringLiteral("*"), apiVersion))
return nullptr;
td->setDropTypeEntries(dropTypeEntries);
QBuffer buffer;
@@ -63,7 +63,7 @@ namespace TestUtil
return nullptr;
buffer.close();
// parse C++ code
- QTemporaryFile tempSource(QDir::tempPath() + QLatin1String("/st_XXXXXX_main.cpp"));
+ QTemporaryFile tempSource(QDir::tempPath() + QStringLiteral("/st_XXXXXX_main.cpp"));
if (!tempSource.open()) {
qWarning().noquote().nospace() << "Creation of temporary file failed: "
<< tempSource.errorString();
diff --git a/sources/shiboken6/ApiExtractor/typedatabase.cpp b/sources/shiboken6/ApiExtractor/typedatabase.cpp
index 28beb0347..6b50ace69 100644
--- a/sources/shiboken6/ApiExtractor/typedatabase.cpp
+++ b/sources/shiboken6/ApiExtractor/typedatabase.cpp
@@ -36,6 +36,8 @@
#include "predefined_templates.h"
#include "clangparser/compilersupport.h"
+#include "qtcompat.h"
+
#include <QtCore/QBuffer>
#include <QtCore/QFile>
#include <QtCore/QDebug>
@@ -49,6 +51,7 @@
// #include <tr1/tuple>
#include <algorithm>
+using namespace Qt::StringLiterals;
using TypeDatabaseParserContextPtr = QSharedPointer<TypeDatabaseParserContext>;
@@ -80,29 +83,29 @@ static const PythonTypes &builtinPythonTypes()
static const PythonTypes result{
// "Traditional" custom types
// numpy
- {u"PyArrayObject"_qs, u"PyArray_Check"_qs, TypeSystem::CPythonType::Other},
- {u"PyBuffer"_qs, u"Shiboken::Buffer::checkType"_qs, TypeSystem::CPythonType::Other},
- {u"PyByteArray"_qs, u"PyByteArray_Check"_qs, TypeSystem::CPythonType::Other},
- {u"PyBytes"_qs, u"PyBytes_Check"_qs, TypeSystem::CPythonType::Other},
- {u"PyCallable"_qs, u"PyCallable_Check"_qs, TypeSystem::CPythonType::Other},
- {u"PyDate"_qs, u"PyDate_Check"_qs, TypeSystem::CPythonType::Other},
- {u"PyDateTime"_qs, u"PyDateTime_Check_Check"_qs, TypeSystem::CPythonType::Other},
- {u"PyDict"_qs, u"PyDict_Check"_qs, TypeSystem::CPythonType::Other},
+ {u"PyArrayObject"_s, u"PyArray_Check"_s, TypeSystem::CPythonType::Other},
+ {u"PyBuffer"_s, u"Shiboken::Buffer::checkType"_s, TypeSystem::CPythonType::Other},
+ {u"PyByteArray"_s, u"PyByteArray_Check"_s, TypeSystem::CPythonType::Other},
+ {u"PyBytes"_s, u"PyBytes_Check"_s, TypeSystem::CPythonType::Other},
+ {u"PyCallable"_s, u"PyCallable_Check"_s, TypeSystem::CPythonType::Other},
+ {u"PyDate"_s, u"PyDate_Check"_s, TypeSystem::CPythonType::Other},
+ {u"PyDateTime"_s, u"PyDateTime_Check_Check"_s, TypeSystem::CPythonType::Other},
+ {u"PyDict"_s, u"PyDict_Check"_s, TypeSystem::CPythonType::Other},
// Convenience macro in sbkconverter.h
- {u"PyObject"_qs, u"true"_qs, TypeSystem::CPythonType::Other},
+ {u"PyObject"_s, u"true"_s, TypeSystem::CPythonType::Other},
// shiboken-specific
- {u"PyPathLike"_qs, u"Shiboken::String::checkPath"_qs, TypeSystem::CPythonType::Other},
- {u"PySequence"_qs, u"Shiboken::String::checkIterable"_qs, TypeSystem::CPythonType::Other},
- {u"PyUnicode"_qs, u"PyUnicode_Check"_qs, TypeSystem::CPythonType::String},
- {u"PyTypeObject"_qs, u"PyType_Check"_qs, TypeSystem::CPythonType::Other},
- {u"str"_qs, u"Shiboken::String::check"_qs, TypeSystem::CPythonType::String},
+ {u"PyPathLike"_s, u"Shiboken::String::checkPath"_s, TypeSystem::CPythonType::Other},
+ {u"PySequence"_s, u"Shiboken::String::checkIterable"_s, TypeSystem::CPythonType::Other},
+ {u"PyUnicode"_s, u"PyUnicode_Check"_s, TypeSystem::CPythonType::String},
+ {u"PyTypeObject"_s, u"PyType_Check"_s, TypeSystem::CPythonType::Other},
+ {u"str"_s, u"Shiboken::String::check"_s, TypeSystem::CPythonType::String},
// Types used as target lang API types for primitive types
- {u"PyBool"_qs, u"PyBool_Check"_qs, TypeSystem::CPythonType::Bool},
- {u"PyComplex"_qs, u"PyComplex_Check"_qs, TypeSystem::CPythonType::Other},
- {u"PyLong"_qs, u"PyLong_Check"_qs, TypeSystem::CPythonType::Integer},
- {u"PyFloat"_qs, u"PyFloat_Check"_qs, TypeSystem::CPythonType::Float},
+ {u"PyBool"_s, u"PyBool_Check"_s, TypeSystem::CPythonType::Bool},
+ {u"PyComplex"_s, u"PyComplex_Check"_s, TypeSystem::CPythonType::Other},
+ {u"PyLong"_s, u"PyLong_Check"_s, TypeSystem::CPythonType::Integer},
+ {u"PyFloat"_s, u"PyFloat_Check"_s, TypeSystem::CPythonType::Float},
// Single character strings to match C++ char types
- {u"SbkChar"_qs, u"SbkChar_Check"_qs, TypeSystem::CPythonType::String}
+ {u"SbkChar"_s, u"SbkChar_Check"_s, TypeSystem::CPythonType::String}
};
return result;
}
@@ -212,7 +215,7 @@ static const IntTypeNormalizationEntries &intTypeNormalizationEntries()
if (firstTime) {
firstTime = false;
for (auto t : {"char", "short", "int", "long"}) {
- const QString intType = QLatin1String(t);
+ const QString intType = QLatin1StringView(t);
if (!TypeDatabase::instance()->findType(u'u' + intType)) {
IntTypeNormalizationEntry entry;
entry.replacement = QStringLiteral("unsigned ") + intType;
@@ -279,7 +282,8 @@ QString TypeDatabase::normalizedSignature(const QString &signature)
{
// QMetaObject::normalizedSignature() changes const-ref to value and
// changes "unsigned int" to "uint" which is undone by the below code
- QString normalized = QLatin1String(QMetaObject::normalizedSignature(signature.toUtf8().constData()));
+ QByteArray normalizedB = QMetaObject::normalizedSignature(signature.toUtf8().constData());
+ QString normalized = QLatin1StringView(normalizedB);
if (instance() && signature.contains(u"unsigned")) {
const IntTypeNormalizationEntries &entries = intTypeNormalizationEntries();
@@ -324,16 +328,16 @@ QStringList TypeDatabase::typesystemKeywords() const
switch (clang::emulatedCompilerLanguageLevel()) {
case LanguageLevel::Cpp11:
- result.append(u"c++11"_qs);
+ result.append(u"c++11"_s);
break;
case LanguageLevel::Cpp14:
- result.append(u"c++14"_qs);
+ result.append(u"c++14"_s);
break;
case LanguageLevel::Cpp17:
- result.append(u"c++17"_qs);
+ result.append(u"c++17"_s);
break;
case LanguageLevel::Cpp20:
- result.append(u"c++20"_qs);
+ result.append(u"c++20"_s);
break;
default:
break;
@@ -618,7 +622,7 @@ TypeEntry *TypeDatabasePrivate::resolveTypeDefEntry(TypedefEntry *typedefEntry,
}
if (!source) {
if (errorMessage)
- *errorMessage = QLatin1String("Unable to resolve typedef \"")
+ *errorMessage = u"Unable to resolve typedef \""_s
+ typedefEntry->sourceType() + u'"';
return nullptr;
}
@@ -757,7 +761,7 @@ void TypeDatabase::addGlobalUserFunctionModifications(const FunctionModification
QString TypeDatabase::globalNamespaceClassName(const TypeEntry * /*entry*/)
{
- return QLatin1String("Global");
+ return u"Global"_s;
}
FunctionModificationList TypeDatabase::functionModifications(const QString& signature) const
@@ -808,8 +812,8 @@ bool TypeDatabase::addSuppressedWarning(const QString &warning, QString *errorMe
QRegularExpression expression(pattern);
if (!expression.isValid()) {
- *errorMessage = QLatin1String("Invalid message pattern \"") + warning
- + QLatin1String("\": ") + expression.errorString();
+ *errorMessage = u"Invalid message pattern \""_s + warning
+ + u"\": "_s + expression.errorString();
return false;
}
expression.setPatternOptions(expression.patternOptions() | QRegularExpression::MultilineOption);
@@ -858,11 +862,11 @@ void TypeDatabasePrivate::addBuiltInContainerTypes(const TypeDatabaseParserConte
{
// Unless the user has added the standard containers (potentially with
// some opaque types), add them by default.
- const bool hasStdPair = findType(u"std::pair"_qs) != nullptr;
- const bool hasStdList = findType(u"std::list"_qs) != nullptr;
- const bool hasStdVector = findType(u"std::vector"_qs) != nullptr;
- const bool hasStdMap = findType(u"std::map"_qs) != nullptr;
- const bool hasStdUnorderedMap = findType(u"std::unordered_map"_qs) != nullptr;
+ const bool hasStdPair = findType(u"std::pair"_s) != nullptr;
+ const bool hasStdList = findType(u"std::list"_s) != nullptr;
+ const bool hasStdVector = findType(u"std::vector"_s) != nullptr;
+ const bool hasStdMap = findType(u"std::map"_s) != nullptr;
+ const bool hasStdUnorderedMap = findType(u"std::unordered_map"_s) != nullptr;
if (hasStdPair && hasStdList && hasStdVector && hasStdMap && hasStdUnorderedMap)
return;
@@ -927,10 +931,10 @@ bool TypeDatabasePrivate::prepareParsing(QFile &file, const QString &origFileNam
const QString &filepath = file.fileName();
if (!file.exists()) {
m_parsedTypesystemFiles[filepath] = false;
- QString message = u"Can't find "_qs + origFileName;
+ QString message = u"Can't find "_s + origFileName;
if (!currentPath.isEmpty())
- message += QLatin1String(", current path: ") + currentPath;
- message += u", typesystem paths: "_qs + m_typesystemPaths.join(u", "_qs);
+ message += u", current path: "_s + currentPath;
+ message += u", typesystem paths: "_s + m_typesystemPaths.join(u", "_s);
qCWarning(lcShiboken, "%s", qPrintable(message));
return false;
}
@@ -1342,12 +1346,12 @@ void TypeDatabasePrivate::addBuiltInPrimitiveTypes()
const QString &rootPackage = root->name();
// C++ primitive types
- auto *pyLongEntry = findType(u"PyLong"_qs);
+ auto *pyLongEntry = findType(u"PyLong"_s);
Q_ASSERT(pyLongEntry && pyLongEntry->isCustom());
auto *pyLongCustomEntry = static_cast<CustomTypeEntry *>(pyLongEntry);
- auto *pyBoolEntry = findType(u"PyBool"_qs);
+ auto *pyBoolEntry = findType(u"PyBool"_s);
Q_ASSERT(pyBoolEntry && pyBoolEntry->isCustom());
- auto *sbkCharEntry = findType(u"SbkChar"_qs);
+ auto *sbkCharEntry = findType(u"SbkChar"_s);
Q_ASSERT(sbkCharEntry && sbkCharEntry->isCustom());
auto *sbkCharCustomEntry = static_cast<CustomTypeEntry *>(sbkCharEntry);
@@ -1363,7 +1367,7 @@ void TypeDatabasePrivate::addBuiltInPrimitiveTypes()
}
}
- auto *pyFloatEntry = findType(u"PyFloat"_qs);
+ auto *pyFloatEntry = findType(u"PyFloat"_s);
Q_ASSERT(pyFloatEntry && pyFloatEntry->isCustom());
auto *pyFloatCustomEntry = static_cast<CustomTypeEntry *>(pyFloatEntry);
for (const auto &t : AbstractMetaType::cppFloatTypes()) {
@@ -1371,19 +1375,19 @@ void TypeDatabasePrivate::addBuiltInPrimitiveTypes()
addBuiltInPrimitiveType(t, root, rootPackage, pyFloatCustomEntry);
}
- auto *pyUnicodeEntry = findType(u"PyUnicode"_qs);
+ auto *pyUnicodeEntry = findType(u"PyUnicode"_s);
Q_ASSERT(pyUnicodeEntry && pyUnicodeEntry->isCustom());
auto *pyUnicodeCustomEntry = static_cast<CustomTypeEntry *>(pyUnicodeEntry);
- const QString stdString = u"std::string"_qs;
+ const QString stdString = u"std::string"_s;
if (!m_entries.contains(stdString)) {
- addBuiltInCppStringPrimitiveType(stdString, u"std::string_view"_qs,
+ addBuiltInCppStringPrimitiveType(stdString, u"std::string_view"_s,
root, rootPackage,
pyUnicodeCustomEntry);
}
- const QString stdWString = u"std::wstring"_qs;
+ const QString stdWString = u"std::wstring"_s;
if (!m_entries.contains(stdWString)) {
- addBuiltInCppStringPrimitiveType(stdWString, u"std::wstring_view"_qs,
+ addBuiltInCppStringPrimitiveType(stdWString, u"std::wstring_view"_s,
root, rootPackage,
pyUnicodeCustomEntry);
}
diff --git a/sources/shiboken6/ApiExtractor/typesystem.cpp b/sources/shiboken6/ApiExtractor/typesystem.cpp
index 58939cca5..22b6f5f8e 100644
--- a/sources/shiboken6/ApiExtractor/typesystem.cpp
+++ b/sources/shiboken6/ApiExtractor/typesystem.cpp
@@ -33,15 +33,19 @@
#include "messages.h"
#include "sourcelocation.h"
+#include "qtcompat.h"
+
#include <QtCore/QDebug>
#include <QtCore/QRegularExpression>
#include <QtCore/QSet>
#include <QtCore/QVarLengthArray>
+using namespace Qt::StringLiterals;
+
static QString buildName(const QString &entryName, const TypeEntry *parent)
{
return parent == nullptr || parent->type() == TypeEntry::TypeSystemType
- ? entryName : parent->name() + QLatin1String("::") + entryName;
+ ? entryName : parent->name() + u"::"_s + entryName;
}
// Access private class as 'd', cf macro Q_D()
@@ -167,7 +171,7 @@ void TypeEntry::setInclude(const Include &inc)
// because the Q_QDOC define was set, and the implementation header was never included.
if (inc.name().endsWith(u"qsharedpointer_impl.h")) {
QString path = inc.name();
- path.remove(QLatin1String("_impl"));
+ path.remove(u"_impl"_s);
m_d->m_include = Include(inc.type(), path);
} else {
m_d->m_include = inc;
@@ -380,7 +384,7 @@ QString TypeEntryPrivate::shortName() const
m_cachedShortName.reserve(m_name.size());
for (int i = parents.size() - 1; i >= 0; --i) {
m_cachedShortName.append(parents.at(i)->entryName());
- m_cachedShortName.append(QLatin1String("::"));
+ m_cachedShortName.append(u"::"_s);
}
m_cachedShortName.append(m_entryName);
} else {
@@ -476,7 +480,7 @@ QString TypeEntry::buildTargetLangName() const
if (!result.isEmpty())
result.prepend(u'.');
QString n = p->m_d->m_entryName;
- n.replace(QLatin1String("::"), QLatin1String(".")); // Primitive types may have "std::"
+ n.replace(u"::"_s, u"."_s); // Primitive types may have "std::"
result.prepend(n);
}
}
@@ -759,7 +763,7 @@ void TypeSystemTypeEntry::setSnakeCase(TypeSystem::SnakeCase sc)
// ----------------- VoidTypeEntry
VoidTypeEntry::VoidTypeEntry() :
- TypeEntry(QLatin1String("void"), VoidType, QVersionNumber(0, 0), nullptr)
+ TypeEntry(u"void"_s, VoidType, QVersionNumber(0, 0), nullptr)
{
}
@@ -774,7 +778,7 @@ TypeEntry *VoidTypeEntry::clone() const
}
VarargsTypeEntry::VarargsTypeEntry() :
- TypeEntry(QLatin1String("..."), VarargsType, QVersionNumber(0, 0), nullptr)
+ TypeEntry(u"..."_s, VarargsType, QVersionNumber(0, 0), nullptr)
{
}
@@ -833,7 +837,7 @@ class ArrayTypeEntryPrivate : public TypeEntryPrivate
public:
explicit ArrayTypeEntryPrivate(const TypeEntry *nested_type, const QVersionNumber &vr,
const TypeEntry *parent) :
- TypeEntryPrivate(QLatin1String("Array"), TypeEntry::ArrayType, vr, parent),
+ TypeEntryPrivate(u"Array"_s, TypeEntry::ArrayType, vr, parent),
m_nestedType(nested_type)
{
}
@@ -863,7 +867,7 @@ const TypeEntry *ArrayTypeEntry::nestedTypeEntry() const
QString ArrayTypeEntry::buildTargetLangName() const
{
S_D(const ArrayTypeEntry);
- return d->m_nestedType->targetLangName() + QLatin1String("[]");
+ return d->m_nestedType->targetLangName() + u"[]"_s;
}
TypeEntry *ArrayTypeEntry::clone() const
@@ -1135,7 +1139,7 @@ QString FlagsTypeEntry::buildTargetLangName() const
{
S_D(const FlagsTypeEntry);
QString on = d->m_originalName;
- on.replace(QLatin1String("::"), QLatin1String("."));
+ on.replace(u"::"_s, u"."_s);
return on;
}
@@ -1838,7 +1842,7 @@ bool SmartPointerTypeEntry::matchesInstantiation(const TypeEntry *e) const
static QString fixSmartPointerName(QString name)
{
- name.replace(u"::"_qs, u"_"_qs);
+ name.replace(u"::"_s, u"_"_s);
name.replace(u'<', u'_');
name.remove(u'>');
name.remove(u' ');
@@ -1860,7 +1864,7 @@ QString SmartPointerTypeEntry::getTargetName(const AbstractMetaType &metaType)
QString name = metaType.cppSignature();
const auto templatePos = name.indexOf(u'<');
if (templatePos != -1) { // "std::shared_ptr<A::B>" -> "shared_ptr<A::B>"
- const auto colonPos = name.lastIndexOf(u"::"_qs, templatePos);
+ const auto colonPos = name.lastIndexOf(u"::"_s, templatePos);
if (colonPos != -1)
name.remove(0, colonPos + 2);
}
@@ -2139,7 +2143,7 @@ QString CustomConversion::TargetToNativeConversion::sourceTypeCheck() const
if (cte->hasCheckFunction()) {
QString result = cte->checkFunction();
if (result != u"true") // For PyObject, which is always true
- result += u"(%in)"_qs;
+ result += u"(%in)"_s;
return result;
}
}
diff --git a/sources/shiboken6/ApiExtractor/typesystemparser.cpp b/sources/shiboken6/ApiExtractor/typesystemparser.cpp
index 47d0932f4..7d343d00e 100644
--- a/sources/shiboken6/ApiExtractor/typesystemparser.cpp
+++ b/sources/shiboken6/ApiExtractor/typesystemparser.cpp
@@ -33,6 +33,8 @@
#include "sourcelocation.h"
#include "conditionalstreamreader.h"
+#include "qtcompat.h"
+
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFile>
@@ -50,6 +52,8 @@
#include <optional>
#include <memory>
+using namespace Qt::StringLiterals;
+
static inline QString allowThreadAttribute() { return QStringLiteral("allow-thread"); }
static inline QString colonColon() { return QStringLiteral("::"); }
static inline QString checkFunctionAttribute() { return QStringLiteral("check-function"); }
@@ -512,8 +516,8 @@ static int indexOfAttribute(const QXmlStreamAttributes &atts,
static QString msgMissingAttribute(const QString &a)
{
- return QLatin1String("Required attribute '") + a
- + QLatin1String("' missing.");
+ return u"Required attribute '"_s + a
+ + u"' missing."_s;
}
QTextStream &operator<<(QTextStream &str, const QXmlStreamAttribute &attribute)
@@ -562,13 +566,13 @@ QString TypeSystemEntityResolver::readFile(const QString &entityName, QString *e
{
QString fileName = entityName;
if (!fileName.contains(u'.'))
- fileName += QLatin1String(".xml");
+ fileName += u".xml"_s;
QString path = TypeDatabase::instance()->modifiedTypesystemFilepath(fileName, m_currentPath);
if (!QFileInfo::exists(path)) // PySide6-specific hack
- fileName.prepend(QLatin1String("typesystem_"));
+ fileName.prepend(u"typesystem_"_s);
path = TypeDatabase::instance()->modifiedTypesystemFilepath(fileName, m_currentPath);
if (!QFileInfo::exists(path)) {
- *errorMessage = QLatin1String("Unable to resolve: ") + entityName;
+ *errorMessage = u"Unable to resolve: "_s + entityName;
return QString();
}
QFile file(path);
@@ -741,8 +745,8 @@ static bool addRejection(TypeDatabase *database, QXmlStreamAttributes *attribute
// Special case: When all fields except class are empty, completely exclude class
if (className == u"*") {
- *errorMessage = QLatin1String("bad reject entry, neither 'class', 'function-name'"
- " nor 'field' specified");
+ *errorMessage = u"bad reject entry, neither 'class', 'function-name'"
+ " nor 'field' specified"_s;
return false;
}
rejection.matchType = TypeRejection::ExcludeClass;
@@ -778,7 +782,7 @@ bool TypeSystemParser::parseXml(ConditionalStreamReader &reader)
case QXmlStreamReader::StartElement: {
const auto elementTypeOpt = elementFromTag(reader.name());
if (!elementTypeOpt.has_value()) {
- m_error = u"Unknown tag name: '"_qs + reader.name().toString() + u'\'';
+ m_error = u"Unknown tag name: '"_s + reader.name().toString() + u'\'';
return false;
}
m_stack.push(elementTypeOpt.value());
@@ -897,7 +901,7 @@ bool TypeSystemParser::endElement(StackElement element)
QString code = top->conversionCodeSnips.constLast().code();
if (element == StackElement::AddConversion) {
if (customConversion->targetToNativeConversions().isEmpty()) {
- m_error = u"CustomConversion's target to native conversions missing."_qs;
+ m_error = u"CustomConversion's target to native conversions missing."_s;
return false;
}
customConversion->targetToNativeConversions().last()->setConversion(code);
@@ -905,7 +909,7 @@ bool TypeSystemParser::endElement(StackElement element)
customConversion->setNativeToTargetConversion(code);
}
} else {
- m_error = QLatin1String("CustomConversion object is missing.");
+ m_error = u"CustomConversion object is missing."_s;
return false;
}
break;
@@ -1078,13 +1082,13 @@ bool TypeSystemParser::importFileElement(const QXmlStreamAttributes &atts)
{
const QString fileName = atts.value(nameAttribute()).toString();
if (fileName.isEmpty()) {
- m_error = QLatin1String("Required attribute 'name' missing for include-file tag.");
+ m_error = u"Required attribute 'name' missing for include-file tag."_s;
return false;
}
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- file.setFileName(QLatin1String(":/trolltech/generator/") + fileName);
+ file.setFileName(u":/trolltech/generator/"_s + fileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
m_error = msgCannotOpenForReading(file);
return false;
@@ -1273,7 +1277,7 @@ FlagsTypeEntry *
{
if (!checkRootElement())
return nullptr;
- auto ftype = new FlagsTypeEntry(QLatin1String("QFlags<") + enumEntry->name() + u'>',
+ auto ftype = new FlagsTypeEntry(u"QFlags<"_s + enumEntry->name() + u'>',
since,
currentParentTypeEntry()->typeSystemTypeEntry());
ftype->setOriginator(enumEntry);
@@ -1347,28 +1351,28 @@ SmartPointerTypeEntry *
}
if (smartPointerType.isEmpty()) {
- m_error = QLatin1String("No type specified for the smart pointer. Currently supported types: 'shared',");
+ m_error = u"No type specified for the smart pointer. Currently supported types: 'shared',"_s;
return nullptr;
}
if (smartPointerType != u"shared") {
- m_error = QLatin1String("Currently only the 'shared' type is supported.");
+ m_error = u"Currently only the 'shared' type is supported."_s;
return nullptr;
}
if (getter.isEmpty()) {
- m_error = QLatin1String("No function getter name specified for getting the raw pointer held by the smart pointer.");
+ m_error = u"No function getter name specified for getting the raw pointer held by the smart pointer."_s;
return nullptr;
}
- QString signature = getter + QLatin1String("()");
+ QString signature = getter + u"()"_s;
signature = TypeDatabase::normalizedSignature(signature);
if (signature.isEmpty()) {
- m_error = QLatin1String("No signature for the smart pointer getter found.");
+ m_error = u"No signature for the smart pointer getter found."_s;
return nullptr;
}
QString errorString = checkSignatureError(signature,
- QLatin1String("smart-pointer-type"));
+ u"smart-pointer-type"_s);
if (!errorString.isEmpty()) {
m_error = errorString;
return nullptr;
@@ -1451,13 +1455,13 @@ ContainerTypeEntry *
return nullptr;
const int typeIndex = indexOfAttribute(*attributes, u"type");
if (typeIndex == -1) {
- m_error = QLatin1String("no 'type' attribute specified");
+ m_error = u"no 'type' attribute specified"_s;
return nullptr;
}
const auto typeName = attributes->at(typeIndex).value();
const auto containerTypeOpt = containerTypeFromAttribute(typeName);
if (!containerTypeOpt.has_value()) {
- m_error = QLatin1String("there is no container of type ") + typeName.toString();
+ m_error = u"there is no container of type "_s + typeName.toString();
return nullptr;
}
attributes->removeAt(typeIndex);
@@ -1472,8 +1476,8 @@ ContainerTypeEntry *
if (name == u"opaque-containers") {
const auto attribute = attributes->takeAt(i);
if (!parseOpaqueContainers(attribute.value(), type)) {
- m_error = u"Error parsing the opaque container attribute: \""_qs
- + attribute.value().toString() + u"\"."_qs;
+ m_error = u"Error parsing the opaque container attribute: \""_s
+ + attribute.value().toString() + u"\"."_s;
return nullptr;
}
}
@@ -1664,7 +1668,7 @@ TypedefEntry *
return nullptr;
if (topElement != StackElement::Root
&& topElement != StackElement::NamespaceTypeEntry) {
- m_error = QLatin1String("typedef entries must be nested in namespaces or type system.");
+ m_error = u"typedef entries must be nested in namespaces or type system."_s;
return nullptr;
}
const int sourceIndex = indexOfAttribute(*attributes, sourceAttribute());
@@ -1821,18 +1825,18 @@ bool TypeSystemParser::parseRenameFunction(const ConditionalStreamReader &,
*name = signature.left(signature.indexOf(u'(')).trimmed();
- QString errorString = checkSignatureError(signature, QLatin1String("function"));
+ QString errorString = checkSignatureError(signature, u"function"_s);
if (!errorString.isEmpty()) {
m_error = errorString;
return false;
}
if (!rename.isEmpty()) {
- static const QRegularExpression functionNameRegExp(QLatin1String("^[a-zA-Z_][a-zA-Z0-9_]*$"));
+ static const QRegularExpression functionNameRegExp(u"^[a-zA-Z_][a-zA-Z0-9_]*$"_s);
Q_ASSERT(functionNameRegExp.isValid());
if (!functionNameRegExp.match(rename).hasMatch()) {
- m_error = QLatin1String("can not rename '") + signature + QLatin1String("', '")
- + rename + QLatin1String("' is not a valid function name");
+ m_error = u"can not rename '"_s + signature + u"', '"_s
+ + rename + u"' is not a valid function name"_s;
return false;
}
FunctionModification mod;
@@ -1854,7 +1858,7 @@ bool TypeSystemParser::parseInjectDocumentation(const ConditionalStreamReader &,
|| topElement == StackElement::AddFunction;
if (!validParent) {
m_error = u"inject-documentation must be inside modify-function, add-function"
- "modify-field or other tags that creates a type"_qs;
+ "modify-field or other tags that creates a type"_s;
return false;
}
@@ -1896,8 +1900,8 @@ bool TypeSystemParser::parseModifyDocumentation(const ConditionalStreamReader &,
|| topElement == StackElement::ModifyFunction
|| topElement == StackElement::ModifyField;
if (!validParent) {
- m_error = QLatin1String("modify-documentation must be inside modify-function, "
- "modify-field or other tags that creates a type");
+ m_error = u"modify-documentation must be inside modify-function, "
+ "modify-field or other tags that creates a type"_qs;
return false;
}
@@ -1996,14 +2000,14 @@ bool TypeSystemParser::loadTypesystem(const ConditionalStreamReader &,
generateChild = convertBoolean(attributes->takeAt(i).value(), generateAttribute(), true);
}
if (typeSystemName.isEmpty()) {
- m_error = QLatin1String("No typesystem name specified");
+ m_error = u"No typesystem name specified"_s;
return false;
}
const bool result =
m_context->db->parseFile(m_context, typeSystemName, m_currentPath,
generateChild && m_generate == TypeEntry::GenerateCode);
if (!result)
- m_error = u"Failed to parse: '"_qs + typeSystemName + u'\'';
+ m_error = u"Failed to parse: '"_s + typeSystemName + u'\'';
return result;
}
@@ -2011,7 +2015,7 @@ bool TypeSystemParser::parseRejectEnumValue(const ConditionalStreamReader &,
QXmlStreamAttributes *attributes)
{
if (!m_currentEnum) {
- m_error = QLatin1String("<reject-enum-value> node must be used inside a <enum-type> node");
+ m_error = u"<reject-enum-value> node must be used inside a <enum-type> node"_s;
return false;
}
const int nameIndex = indexOfAttribute(*attributes, nameAttribute());
@@ -2028,12 +2032,12 @@ bool TypeSystemParser::parseReplaceArgumentType(const ConditionalStreamReader &,
QXmlStreamAttributes *attributes)
{
if (topElement != StackElement::ModifyArgument) {
- m_error = QLatin1String("Type replacement can only be specified for argument modifications");
+ m_error = u"Type replacement can only be specified for argument modifications"_s;
return false;
}
const int modifiedTypeIndex = indexOfAttribute(*attributes, modifiedTypeAttribute());
if (modifiedTypeIndex == -1) {
- m_error = QLatin1String("Type replacement requires 'modified-type' attribute");
+ m_error = u"Type replacement requires 'modified-type' attribute"_s;
return false;
}
m_contextStack.top()->functionMods.last().argument_mods().last().setModifiedType(
@@ -2049,8 +2053,8 @@ bool TypeSystemParser::parseCustomConversion(const ConditionalStreamReader &,
&& topElement != StackElement::ValueTypeEntry
&& topElement != StackElement::PrimitiveTypeEntry
&& topElement != StackElement::ContainerTypeEntry) {
- m_error = QLatin1String("Conversion rules can only be specified for argument modification, "
- "value-type, primitive-type or container-type conversion.");
+ m_error = u"Conversion rules can only be specified for argument modification, "
+ "value-type, primitive-type or container-type conversion."_s;
return false;
}
@@ -2083,7 +2087,7 @@ bool TypeSystemParser::parseCustomConversion(const ConditionalStreamReader &,
}
if (top->entry->hasTargetConversionRule() || top->entry->hasCustomConversion()) {
- m_error = QLatin1String("Types can have only one conversion rule");
+ m_error = u"Types can have only one conversion rule"_s;
return false;
}
@@ -2122,7 +2126,7 @@ bool TypeSystemParser::parseNativeToTarget(const ConditionalStreamReader &,
QXmlStreamAttributes *attributes)
{
if (topElement != StackElement::ConversionRule) {
- m_error = QLatin1String("Native to Target conversion code can only be specified for custom conversion rules.");
+ m_error = u"Native to Target conversion code can only be specified for custom conversion rules."_s;
return false;
}
CodeSnip snip;
@@ -2137,7 +2141,7 @@ bool TypeSystemParser::parseAddConversion(const ConditionalStreamReader &,
QXmlStreamAttributes *attributes)
{
if (topElement != StackElement::TargetToNative) {
- m_error = QLatin1String("Target to Native conversions can only be added inside 'target-to-native' tags.");
+ m_error = u"Target to Native conversions can only be added inside 'target-to-native' tags."_s;
return false;
}
QString sourceTypeName;
@@ -2161,7 +2165,7 @@ bool TypeSystemParser::parseAddConversion(const ConditionalStreamReader &,
}
if (sourceTypeName.isEmpty()) {
- m_error = QLatin1String("Target to Native conversions must specify the input type with the 'type' attribute.");
+ m_error = u"Target to Native conversions must specify the input type with the 'type' attribute."_s;
return false;
}
top->entry->customConversion()->addTargetToNativeConversion(sourceTypeName, typeCheck);
@@ -2197,7 +2201,7 @@ bool TypeSystemParser::parseModifyArgument(const ConditionalStreamReader &,
&& topElement != StackElement::AddFunction
&& topElement != StackElement::DeclareFunction) {
m_error = u"Argument modification requires <modify-function>,"
- " <add-function> or <declare-function> as parent, was "_qs
+ " <add-function> or <declare-function> as parent, was "_s
+ tagFromElement(topElement).toString();
return false;
}
@@ -2241,7 +2245,7 @@ bool TypeSystemParser::parseNoNullPointer(const ConditionalStreamReader &reader,
StackElement topElement, QXmlStreamAttributes *attributes)
{
if (topElement != StackElement::ModifyArgument) {
- m_error = QLatin1String("no-null-pointer requires argument modification as parent");
+ m_error = u"no-null-pointer requires argument modification as parent"_s;
return false;
}
@@ -2263,7 +2267,7 @@ bool TypeSystemParser::parseDefineOwnership(const ConditionalStreamReader &,
QXmlStreamAttributes *attributes)
{
if (topElement != StackElement::ModifyArgument) {
- m_error = QLatin1String("define-ownership requires argument modification as parent");
+ m_error = u"define-ownership requires argument modification as parent"_s;
return false;
}
@@ -2313,7 +2317,7 @@ bool TypeSystemParser::parseRename(const ConditionalStreamReader &,
QXmlStreamAttributes *attributes)
{
if (topElement != StackElement::ModifyArgument) {
- m_error = QLatin1String("Argument modification parent required");
+ m_error = u"Argument modification parent required"_s;
return false;
}
@@ -2418,11 +2422,11 @@ bool TypeSystemParser::parseAddFunction(const ConditionalStreamReader &,
QString signature = TypeDatabase::normalizedAddedFunctionSignature(originalSignature);
if (signature.isEmpty()) {
- m_error = QLatin1String("No signature for the added function");
+ m_error = u"No signature for the added function"_s;
return false;
}
- QString errorString = checkSignatureError(signature, QLatin1String("add-function"));
+ QString errorString = checkSignatureError(signature, u"add-function"_s);
if (!errorString.isEmpty()) {
m_error = errorString;
return false;
@@ -2440,13 +2444,13 @@ bool TypeSystemParser::parseAddFunction(const ConditionalStreamReader &,
// Create signature for matching modifications
signature = TypeDatabase::normalizedSignature(originalSignature);
if (!signature.contains(u'('))
- signature += QLatin1String("()");
+ signature += u"()"_s;
m_currentSignature = signature;
if (!access.isEmpty()) {
const auto acessOpt = addedFunctionAccessFromAttribute(access);
if (!acessOpt.has_value()) {
- m_error = u"Bad access type '"_qs + access + u'\'';
+ m_error = u"Bad access type '"_s + access + u'\'';
return false;
}
func->setAccess(acessOpt.value());
@@ -2493,7 +2497,7 @@ bool TypeSystemParser::parseProperty(const ConditionalStreamReader &, StackEleme
}
}
if (!property.isValid()) {
- m_error = QLatin1String("<property> element is missing required attibutes (name/type/get).");
+ m_error = u"<property> element is missing required attibutes (name/type/get)."_s;
return false;
}
static_cast<ComplexTypeEntry *>(m_contextStack.top()->entry)->addProperty(property);
@@ -2583,11 +2587,11 @@ bool TypeSystemParser::parseModifyFunction(const ConditionalStreamReader &reader
const QString signature = TypeDatabase::normalizedSignature(originalSignature);
if (signature.isEmpty()) {
- m_error = QLatin1String("No signature for modified function");
+ m_error = u"No signature for modified function"_s;
return false;
}
- QString errorString = checkSignatureError(signature, QLatin1String("modify-function"));
+ QString errorString = checkSignatureError(signature, u"modify-function"_s);
if (!errorString.isEmpty()) {
m_error = errorString;
return false;
@@ -2605,7 +2609,7 @@ bool TypeSystemParser::parseModifyFunction(const ConditionalStreamReader &reader
if (!access.isEmpty()) {
const auto modifierFlagOpt = modifierFromAttribute(access);
if (!modifierFlagOpt.has_value()) {
- m_error = u"Bad access type '"_qs + access + u'\'';
+ m_error = u"Bad access type '"_s + access + u'\'';
return false;
}
const FunctionModification::ModifierFlag m = modifierFlagOpt.value();
@@ -2640,12 +2644,12 @@ bool TypeSystemParser::parseReplaceDefaultExpression(const ConditionalStreamRead
QXmlStreamAttributes *attributes)
{
if (!(topElement & StackElement::ModifyArgument)) {
- m_error = QLatin1String("Replace default expression only allowed as child of argument modification");
+ m_error = u"Replace default expression only allowed as child of argument modification"_s;
return false;
}
const int withIndex = indexOfAttribute(*attributes, u"with");
if (withIndex == -1 || attributes->at(withIndex).value().isEmpty()) {
- m_error = QLatin1String("Default expression replaced with empty string. Use remove-default-expression instead.");
+ m_error = u"Default expression replaced with empty string. Use remove-default-expression instead."_s;
return false;
}
@@ -2659,7 +2663,7 @@ bool TypeSystemParser::parseReferenceCount(const ConditionalStreamReader &reader
QXmlStreamAttributes *attributes)
{
if (topElement != StackElement::ModifyArgument) {
- m_error = QLatin1String("reference-count must be child of modify-argument");
+ m_error = u"reference-count must be child of modify-argument"_s;
return false;
}
@@ -2697,7 +2701,7 @@ bool TypeSystemParser::parseParentOwner(const ConditionalStreamReader &,
QXmlStreamAttributes *attributes)
{
if (topElement != StackElement::ModifyArgument) {
- m_error = QLatin1String("parent-policy must be child of modify-argument");
+ m_error = u"parent-policy must be child of modify-argument"_s;
return false;
}
ArgumentOwner ao;
@@ -2737,7 +2741,7 @@ bool TypeSystemParser::readFileSnippet(QXmlStreamAttributes *attributes, CodeSni
return true;
const QString resolved = m_context->db->modifiedTypesystemFilepath(fileName, m_currentPath);
if (!QFile::exists(resolved)) {
- m_error = QLatin1String("File for inject code not exist: ")
+ m_error = u"File for inject code not exist: "_s
+ QDir::toNativeSeparators(fileName);
return false;
}
@@ -2755,7 +2759,7 @@ bool TypeSystemParser::readFileSnippet(QXmlStreamAttributes *attributes, CodeSni
QString source = fileName;
if (!snippetLabel.isEmpty())
- source += QLatin1String(" (") + snippetLabel + u')';
+ source += u" ("_s + snippetLabel + u')';
QString content;
QTextStream str(&content);
str << "// ========================================================================\n"
@@ -2775,7 +2779,7 @@ bool TypeSystemParser::parseInjectCode(const ConditionalStreamReader &,
&& (topElement != StackElement::AddFunction)
&& (topElement != StackElement::ModifyFunction)
&& (topElement != StackElement::Root)) {
- m_error = QLatin1String("wrong parent type for code injection");
+ m_error = u"wrong parent type for code injection"_s;
return false;
}
@@ -2851,7 +2855,7 @@ bool TypeSystemParser::parseInclude(const ConditionalStreamReader &,
} else if (topElement == StackElement::ExtraIncludes) {
entry->addExtraInclude(inc);
} else {
- m_error = QLatin1String("Only supported parent tags are primitive-type, complex types or extra-includes");
+ m_error = u"Only supported parent tags are primitive-type, complex types or extra-includes"_s;
return false;
}
return true;
@@ -2879,8 +2883,8 @@ TemplateInstance *
(topElement != StackElement::NativeToTarget) &&
(topElement != StackElement::AddConversion) &&
(topElement != StackElement::ConversionRule)) {
- m_error = QLatin1String("Can only insert templates into code snippets, templates, "\
- "conversion-rule, native-to-target or add-conversion tags.");
+ m_error = u"Can only insert templates into code snippets, templates, "\
+ "conversion-rule, native-to-target or add-conversion tags."_s;
return nullptr;
}
const int nameIndex = indexOfAttribute(*attributes, nameAttribute());
@@ -2895,7 +2899,7 @@ bool TypeSystemParser::parseReplace(const ConditionalStreamReader &,
StackElement topElement, QXmlStreamAttributes *attributes)
{
if (topElement != StackElement::InsertTemplate) {
- m_error = QLatin1String("Can only insert replace rules into insert-template.");
+ m_error = u"Can only insert replace rules into insert-template."_s;
return false;
}
QString from;
@@ -3066,13 +3070,13 @@ bool TypeSystemParser::startElement(const ConditionalStreamReader &reader, Stack
if (name.isEmpty()) {
name = identifiedByValue;
} else if (!identifiedByValue.isEmpty()) {
- m_error = QLatin1String("can't specify both 'name' and 'identified-by-value' attributes");
+ m_error = u"can't specify both 'name' and 'identified-by-value' attributes"_s;
return false;
}
}
if (name.isEmpty()) {
- m_error = QLatin1String("no 'name' attribute specified");
+ m_error = u"no 'name' attribute specified"_s;
return false;
}
@@ -3147,7 +3151,7 @@ bool TypeSystemParser::startElement(const ConditionalStreamReader &reader, Stack
}
} else {
qCWarning(lcShiboken).noquote().nospace()
- << u"Type: "_qs + name + u" was rejected by typesystem"_qs;
+ << u"Type: "_s + name + u" was rejected by typesystem"_s;
}
} else if (element == StackElement::InjectDocumentation) {
@@ -3170,7 +3174,7 @@ bool TypeSystemParser::startElement(const ConditionalStreamReader &reader, Stack
|| element == StackElement::Template;
if (!topLevel && m_stack.at(m_stack.size() - 2) == StackElement::Root) {
- m_error = u"Tag requires parent: '"_qs + tagName.toString() + u'\'';
+ m_error = u"Tag requires parent: '"_s + tagName.toString() + u'\'';
return false;
}
@@ -3200,7 +3204,7 @@ bool TypeSystemParser::startElement(const ConditionalStreamReader &reader, Stack
break;
case StackElement::TargetToNative: {
if (topElement != StackElement::ConversionRule) {
- m_error = QLatin1String("Target to Native conversions can only be specified for custom conversion rules.");
+ m_error = u"Target to Native conversions can only be specified for custom conversion rules."_s;
return false;
}
@@ -3248,7 +3252,7 @@ bool TypeSystemParser::startElement(const ConditionalStreamReader &reader, Stack
break;
case StackElement::RemoveArgument:
if (topElement != StackElement::ModifyArgument) {
- m_error = QLatin1String("Removing argument requires argument modification as parent");
+ m_error = u"Removing argument requires argument modification as parent"_s;
return false;
}
@@ -3289,7 +3293,7 @@ bool TypeSystemParser::startElement(const ConditionalStreamReader &reader, Stack
break;
case StackElement::Array:
if (topElement != StackElement::ModifyArgument) {
- m_error = QLatin1String("array must be child of modify-argument");
+ m_error = u"array must be child of modify-argument"_s;
return false;
}
top->functionMods.last().argument_mods().last().setArray(true);
diff --git a/sources/shiboken6/ApiExtractor/xmlutils.cpp b/sources/shiboken6/ApiExtractor/xmlutils.cpp
index 2cd2e3b81..98f990e02 100644
--- a/sources/shiboken6/ApiExtractor/xmlutils.cpp
+++ b/sources/shiboken6/ApiExtractor/xmlutils.cpp
@@ -30,6 +30,10 @@
#include "xmlutils_libxslt.h"
+#include "qtcompat.h"
+
+using namespace Qt::StringLiterals;
+
XQuery::XQuery() = default;
XQuery::~XQuery() = default;
@@ -37,8 +41,8 @@ XQuery::~XQuery() = default;
QString XQuery::evaluate(QString xPathExpression, QString *errorMessage)
{
// XQuery can't have invalid XML characters
- xPathExpression.replace(u'&', QLatin1String("&amp;"));
- xPathExpression.replace(u'<', QLatin1String("&lt;"));
+ xPathExpression.replace(u'&', u"&amp;"_s);
+ xPathExpression.replace(u'<', u"&lt;"_s);
return doEvaluate(xPathExpression, errorMessage);
}
@@ -47,7 +51,7 @@ QSharedPointer<XQuery> XQuery::create(const QString &focus, QString *errorMessag
#if defined(HAVE_LIBXSLT)
return libXml_createXQuery(focus, errorMessage);
#else
- *errorMessage = QLatin1String(__FUNCTION__) + QLatin1String(" is not implemented.");
+ *errorMessage = QLatin1StringView(__FUNCTION__) + u" is not implemented."_s;
return QSharedPointer<XQuery>();
#endif
}
@@ -57,7 +61,7 @@ QString xsl_transform(const QString &xml, const QString &xsl, QString *errorMess
#if defined(HAVE_LIBXSLT)
return libXslt_transform(xml, xsl, errorMessage);
#else
- *errorMessage = QLatin1String(__FUNCTION__) + QLatin1String(" is not implemented.");
+ *errorMessage = QLatin1StringView(__FUNCTION__) + u" is not implemented."_s;
return xml;
#endif
}
diff --git a/sources/shiboken6/ApiExtractor/xmlutils_libxslt.cpp b/sources/shiboken6/ApiExtractor/xmlutils_libxslt.cpp
index ef4316951..8f15ca801 100644
--- a/sources/shiboken6/ApiExtractor/xmlutils_libxslt.cpp
+++ b/sources/shiboken6/ApiExtractor/xmlutils_libxslt.cpp
@@ -29,6 +29,8 @@
#include "xmlutils_libxslt.h"
#include "xmlutils.h"
+#include "qtcompat.h"
+
#include <QtCore/QByteArray>
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
@@ -44,6 +46,8 @@
#include <cstdlib>
#include <memory>
+using namespace Qt::StringLiterals;
+
static void cleanup()
{
xsltCleanupGlobals();
@@ -109,13 +113,13 @@ static QByteArray formatNode(xmlNodePtr node, QString *errorMessage)
xmlSaveToIO(qbXmlOutputWriteCallback, qbXmlOutputCloseCallback,
&result, "UTF-8", 0);
if (!saveContext) {
- *errorMessage = QLatin1String("xmlSaveToIO() failed.");
+ *errorMessage = u"xmlSaveToIO() failed."_s;
return result;
}
const long saveResult = xmlSaveTree(saveContext, node);
xmlSaveClose(saveContext);
if (saveResult < 0)
- *errorMessage = QLatin1String("xmlSaveTree() failed.");
+ *errorMessage = u"xmlSaveTree() failed."_s;
return result;
}
@@ -144,7 +148,7 @@ QString LibXmlXQuery::doEvaluate(const QString &xPathExpression, QString *errorM
XmlPathObjectUniquePtr xPathObject(xmlXPathEvalExpression(xPathExpressionX, m_xpathContext.get()));
if (!xPathObject) {
- *errorMessage = QLatin1String("xmlXPathEvalExpression() failed for \"") + xPathExpression
+ *errorMessage = u"xmlXPathEvalExpression() failed for \""_s + xPathExpression
+ u'"';
return QString();
}
@@ -166,12 +170,12 @@ QSharedPointer<XQuery> libXml_createXQuery(const QString &focus, QString *errorM
{
XmlDocUniquePtr doc(xmlParseFile(QFile::encodeName(focus).constData()));
if (!doc) {
- *errorMessage = QLatin1String("libxml2: Cannot set focus to ") + QDir::toNativeSeparators(focus);
+ *errorMessage = u"libxml2: Cannot set focus to "_s + QDir::toNativeSeparators(focus);
return {};
}
XmlXPathContextUniquePtr xpathContext(xmlXPathNewContext(doc.get()));
if (!xpathContext) {
- *errorMessage = QLatin1String("libxml2: xmlXPathNewContext() failed");
+ *errorMessage = u"libxml2: xmlXPathNewContext() failed"_s;
return {};
}
return QSharedPointer<XQuery>(new LibXmlXQuery(doc, xpathContext));
@@ -188,13 +192,13 @@ QString libXslt_transform(const QString &xml, QString xsl, QString *errorMessage
ensureInitialized();
// Read XML data
if (!xsl.startsWith(u"<?xml")) {
- xsl.prepend(QLatin1String(xsltPrefix));
- xsl.append(QLatin1String("</xsl:transform>"));
+ xsl.prepend(QLatin1StringView(xsltPrefix));
+ xsl.append(u"</xsl:transform>"_s);
}
const QByteArray xmlData = xml.toUtf8();
XmlDocUniquePtr xmlDoc(xmlParseMemory(xmlData.constData(), xmlData.size()));
if (!xmlDoc) {
- *errorMessage = QLatin1String("xmlParseMemory() failed for XML.");
+ *errorMessage = u"xmlParseMemory() failed for XML."_s;
return xml;
}
@@ -203,15 +207,14 @@ QString libXslt_transform(const QString &xml, QString xsl, QString *errorMessage
// xsltFreeStylesheet will delete this pointer
xmlDocPtr xslDoc = xmlParseMemory(xslData.constData(), xslData.size());
if (!xslDoc) {
- *errorMessage = QLatin1String("xmlParseMemory() failed for XSL \"")
- + xsl + QLatin1String("\".");
+ *errorMessage = u"xmlParseMemory() failed for XSL \""_s + xsl + u"\"."_s;
return xml;
};
// Parse XSL data
XmlStyleSheetUniquePtr xslt(xsltParseStylesheetDoc(xslDoc));
if (!xslt) {
- *errorMessage = QLatin1String("xsltParseStylesheetDoc() failed.");
+ *errorMessage = u"xsltParseStylesheetDoc() failed."_s;
return xml;
}
@@ -224,7 +227,7 @@ QString libXslt_transform(const QString &xml, QString xsl, QString *errorMessage
result = QString::fromUtf8(reinterpret_cast<char*>(buffer), bufferSize);
std::free(buffer);
} else {
- *errorMessage = QLatin1String("xsltSaveResultToString() failed.");
+ *errorMessage = u"xsltSaveResultToString() failed."_s;
result = xml;
}
return result.trimmed();
diff --git a/sources/shiboken6/generator/generator.cpp b/sources/shiboken6/generator/generator.cpp
index dde7d8828..9e1c251e6 100644
--- a/sources/shiboken6/generator/generator.cpp
+++ b/sources/shiboken6/generator/generator.cpp
@@ -39,12 +39,15 @@
#include "typesystem.h"
#include <typedatabase.h>
-#include <QtCore/QDebug>
+#include "qtcompat.h"
+
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QRegularExpression>
+using namespace Qt::StringLiterals;
+
static const char ENABLE_PYSIDE_EXTENSIONS[] = "enable-pyside-extensions";
static const char AVOID_PROTECTED_HACK[] = "avoid-protected-hack";
@@ -79,37 +82,37 @@ QString DefaultValue::returnValue() const
{
switch (m_type) {
case DefaultValue::Boolean:
- return QLatin1String("false");
+ return u"false"_s;
case DefaultValue::CppScalar:
- return QLatin1String("0");
+ return u"0"_s;
case DefaultValue::Custom:
case DefaultValue::Enum:
return m_value;
case DefaultValue::Pointer:
- return QLatin1String("nullptr");
+ return u"nullptr"_s;
case DefaultValue::Void:
return QString();
case DefaultValue::DefaultConstructorWithDefaultValues:
- return m_value + QLatin1String("()");
+ return m_value + u"()"_s;
case DefaultValue::DefaultConstructor:
break;
}
- return QLatin1String("{}");
+ return u"{}"_s;
}
QString DefaultValue::initialization() const
{
switch (m_type) {
case DefaultValue::Boolean:
- return QLatin1String("{false}");
+ return u"{false}"_s;
case DefaultValue::CppScalar:
- return QLatin1String("{0}");
+ return u"{0}"_s;
case DefaultValue::Custom:
- return QLatin1String(" = ") + m_value;
+ return u" = "_s + m_value;
case DefaultValue::Enum:
return u'{' + m_value + u'}';
case DefaultValue::Pointer:
- return QLatin1String("{nullptr}");
+ return u"{nullptr}"_s;
case DefaultValue::Void:
Q_ASSERT(false);
break;
@@ -124,13 +127,13 @@ QString DefaultValue::constructorParameter() const
{
switch (m_type) {
case DefaultValue::Boolean:
- return QLatin1String("false");
+ return u"false"_s;
case DefaultValue::CppScalar: {
// PYSIDE-846: Use static_cast in case of "unsigned long" and similar
const QString cast = m_value.contains(u' ')
- ? QLatin1String("static_cast<") + m_value + u'>'
+ ? u"static_cast<"_s + m_value + u'>'
: m_value;
- return cast + QLatin1String("(0)");
+ return cast + u"(0)"_s;
}
case DefaultValue::Custom:
case DefaultValue::Enum:
@@ -140,7 +143,7 @@ QString DefaultValue::constructorParameter() const
// taking different pointer types, cf
// QTreeWidgetItemIterator(QTreeWidget *) and
// QTreeWidgetItemIterator(QTreeWidgetItemIterator *).
- return QLatin1String("static_cast<") + m_value + QLatin1String("*>(nullptr)");
+ return u"static_cast<"_s + m_value + u"*>(nullptr)"_s;
case DefaultValue::Void:
Q_ASSERT(false);
break;
@@ -148,7 +151,7 @@ QString DefaultValue::constructorParameter() const
case DefaultValue::DefaultConstructorWithDefaultValues:
break;
}
- return m_value + QLatin1String("()");
+ return m_value + u"()"_s;
}
#ifndef QT_NO_DEBUG_STREAM
@@ -241,19 +244,19 @@ bool Generator::setup(const ApiExtractorResult &api)
Generator::OptionDescriptions Generator::options() const
{
return {
- {QLatin1String(AVOID_PROTECTED_HACK),
- u"Avoid the use of the '#define protected public' hack."_qs},
- {QLatin1String(ENABLE_PYSIDE_EXTENSIONS),
+ {QLatin1StringView(AVOID_PROTECTED_HACK),
+ u"Avoid the use of the '#define protected public' hack."_s},
+ {QLatin1StringView(ENABLE_PYSIDE_EXTENSIONS),
u"Enable PySide extensions, such as support for signal/slots,\n"
- "use this if you are creating a binding for a Qt-based library."_qs}
+ "use this if you are creating a binding for a Qt-based library."_s}
};
}
bool Generator::handleOption(const QString & key, const QString & /* value */)
{
- if (key == QLatin1String(ENABLE_PYSIDE_EXTENSIONS))
+ if (key == QLatin1StringView(ENABLE_PYSIDE_EXTENSIONS))
return ( m_d->m_usePySideExtensions = true);
- if (key == QLatin1String(AVOID_PROTECTED_HACK))
+ if (key == QLatin1StringView(AVOID_PROTECTED_HACK))
return (m_d->m_avoidProtectedHack = true);
return false;
}
@@ -269,7 +272,7 @@ QString Generator::fileNameForContextHelper(const GeneratorContext &context,
? metaClass->name() : metaClass->qualifiedCppName();
if (!flags.testFlag(FileNameFlag::KeepCase))
fileNameBase = fileNameBase.toLower();
- fileNameBase.replace(u"::"_qs, u"_"_qs);
+ fileNameBase.replace(u"::"_s, u"_"_s);
return fileNameBase + suffix;
}
@@ -362,8 +365,8 @@ QString Generator::getFileNameBaseForSmartPointer(const AbstractMetaType &smartP
const AbstractMetaType innerType = smartPointerType.getSmartPointerInnerType();
smartPointerType.typeEntry()->qualifiedCppName();
QString fileName = smartPointerType.typeEntry()->qualifiedCppName().toLower();
- fileName.replace(QLatin1String("::"), QLatin1String("_"));
- fileName.append(QLatin1String("_"));
+ fileName.replace(u"::"_s, u"_"_s);
+ fileName.append(u"_"_s);
fileName.append(innerType.name().toLower());
return fileName;
@@ -442,18 +445,18 @@ QString Generator::getFullTypeName(const TypeEntry *type)
if (type->isArray())
type = static_cast<const ArrayTypeEntry *>(type)->nestedTypeEntry();
if (!type->isCppPrimitive())
- result.prepend(QLatin1String("::"));
+ result.prepend(u"::"_s);
return result;
}
QString Generator::getFullTypeName(const AbstractMetaType &type)
{
if (type.isCString())
- return QLatin1String("const char*");
+ return u"const char*"_s;
if (type.isVoidPointer())
- return QLatin1String("void*");
+ return u"void*"_s;
if (type.typeEntry()->isContainer())
- return QLatin1String("::") + type.cppSignature();
+ return u"::"_s + type.cppSignature();
QString typeName;
if (type.typeEntry()->isComplex() && type.hasInstantiations())
typeName = getFullTypeNameWithoutModifiers(type);
@@ -464,15 +467,15 @@ QString Generator::getFullTypeName(const AbstractMetaType &type)
QString Generator::getFullTypeName(const AbstractMetaClass *metaClass)
{
- return QLatin1String("::") + metaClass->qualifiedCppName();
+ return u"::"_s + metaClass->qualifiedCppName();
}
QString Generator::getFullTypeNameWithoutModifiers(const AbstractMetaType &type)
{
if (type.isCString())
- return QLatin1String("const char*");
+ return u"const char*"_s;
if (type.isVoidPointer())
- return QLatin1String("void*");
+ return u"void*"_s;
if (!type.hasInstantiations())
return getFullTypeName(type.typeEntry());
QString typeName = type.cppSignature();
@@ -490,7 +493,7 @@ QString Generator::getFullTypeNameWithoutModifiers(const AbstractMetaType &type)
}
while (typeName.endsWith(u'*') || typeName.endsWith(u' '))
typeName.chop(1);
- return QLatin1String("::") + typeName;
+ return u"::"_s + typeName;
}
std::optional<DefaultValue>
@@ -513,13 +516,13 @@ std::optional<DefaultValue>
ctor.chop(1);
ctor = ctor.trimmed();
}
- return DefaultValue(DefaultValue::DefaultConstructor, QLatin1String("::") + ctor);
+ return DefaultValue(DefaultValue::DefaultConstructor, u"::"_s + ctor);
}
if (type.isNativePointer())
return DefaultValue(DefaultValue::Pointer, type.typeEntry()->qualifiedCppName());
if (type.isPointer())
- return DefaultValue(DefaultValue::Pointer, QLatin1String("::") + type.typeEntry()->qualifiedCppName());
+ return DefaultValue(DefaultValue::Pointer, u"::"_s + type.typeEntry()->qualifiedCppName());
if (type.typeEntry()->isSmartPointer())
return minimalConstructor(api, type.typeEntry());
@@ -568,13 +571,13 @@ std::optional<DefaultValue>
if (const auto *nullValue = enumEntry->nullValue())
return DefaultValue(DefaultValue::Enum, nullValue->name());
return DefaultValue(DefaultValue::Custom,
- QLatin1String("static_cast< ::") + type->qualifiedCppName()
- + QLatin1String(">(0)"));
+ u"static_cast< ::"_s + type->qualifiedCppName()
+ + u">(0)"_s);
}
if (type->isFlags()) {
return DefaultValue(DefaultValue::Custom,
- type->qualifiedCppName() + QLatin1String("(0)"));
+ type->qualifiedCppName() + u"(0)"_s);
}
if (type->isPrimitive()) {
@@ -584,7 +587,7 @@ std::optional<DefaultValue>
// heuristically returned. If this is wrong the build of the generated
// bindings will tell.
return ctor.isEmpty()
- ? DefaultValue(DefaultValue::DefaultConstructorWithDefaultValues, QLatin1String("::")
+ ? DefaultValue(DefaultValue::DefaultConstructorWithDefaultValues, u"::"_s
+ type->qualifiedCppName())
: DefaultValue(DefaultValue::Custom, ctor);
}
@@ -603,14 +606,14 @@ std::optional<DefaultValue>
}
if (errorString != nullptr)
- *errorString = QLatin1String("No default value could be determined.");
+ *errorString = u"No default value could be determined."_s;
return {};
}
static QString constructorCall(const QString &qualifiedCppName, const QStringList &args)
{
- return QLatin1String("::") + qualifiedCppName + u'('
- + args.join(QLatin1String(", ")) + u')';
+ return u"::"_s + qualifiedCppName + u'('
+ + args.join(u", "_s) + u')';
}
std::optional<DefaultValue>
@@ -636,12 +639,12 @@ std::optional<DefaultValue>
const auto &arguments = ctor->arguments();
if (arguments.isEmpty()) {
return DefaultValue(DefaultValue::DefaultConstructor,
- QLatin1String("::") + qualifiedCppName);
+ u"::"_s + qualifiedCppName);
}
// First argument has unmodified default: Default constructible with values
if (arguments.constFirst().hasUnmodifiedDefaultValueExpression()) {
return DefaultValue(DefaultValue::DefaultConstructorWithDefaultValues,
- QLatin1String("::") + qualifiedCppName);
+ u"::"_s + qualifiedCppName);
}
// Examine arguments, exclude functions taking a self parameter
bool simple = true;
@@ -693,9 +696,9 @@ QString Generator::translateType(AbstractMetaType cType,
}
if (cType.isVoid()) {
- s = QLatin1String("void");
+ s = u"void"_s;
} else if (cType.isArray()) {
- s = translateType(*cType.arrayElementType(), context, options) + QLatin1String("[]");
+ s = translateType(*cType.arrayElementType(), context, options) + u"[]"_s;
} else {
if (options & Generator::ExcludeConst || options & Generator::ExcludeReference) {
AbstractMetaType copyType = cType;
@@ -708,7 +711,7 @@ QString Generator::translateType(AbstractMetaType cType,
s = copyType.cppSignature();
if (!copyType.typeEntry()->isVoid() && !copyType.typeEntry()->isCppPrimitive())
- s.prepend(QLatin1String("::"));
+ s.prepend(u"::"_s);
} else {
s = cType.cppSignature();
}
@@ -721,41 +724,41 @@ static const QHash<QString, QString> &pythonOperators()
{
static const QHash<QString, QString> result = {
// call operator
- {u"operator()"_qs, u"__call__"_qs},
+ {u"operator()"_s, u"__call__"_s},
// Arithmetic operators
- {u"operator+"_qs, u"__add__"_qs},
- {u"operator-"_qs, u"__sub__"_qs},
- {u"operator*"_qs, u"__mul__"_qs},
- {u"operator/"_qs, u"__div__"_qs},
- {u"operator%"_qs, u"__mod__"_qs},
+ {u"operator+"_s, u"__add__"_s},
+ {u"operator-"_s, u"__sub__"_s},
+ {u"operator*"_s, u"__mul__"_s},
+ {u"operator/"_s, u"__div__"_s},
+ {u"operator%"_s, u"__mod__"_s},
// Inplace arithmetic operators
- {u"operator+="_qs, u"__iadd__"_qs},
- {u"operator-="_qs, u"__isub__"_qs},
- {u"operator++"_qs, u"__iadd__"_qs},
- {u"operator--"_qs, u"__isub__"_qs},
- {u"operator*="_qs, u"__imul__"_qs},
- {u"operator/="_qs, u"__idiv__"_qs},
- {u"operator%="_qs, u"__imod__"_qs},
+ {u"operator+="_s, u"__iadd__"_s},
+ {u"operator-="_s, u"__isub__"_s},
+ {u"operator++"_s, u"__iadd__"_s},
+ {u"operator--"_s, u"__isub__"_s},
+ {u"operator*="_s, u"__imul__"_s},
+ {u"operator/="_s, u"__idiv__"_s},
+ {u"operator%="_s, u"__imod__"_s},
// Bitwise operators
- {u"operator&"_qs, u"__and__"_qs},
- {u"operator^"_qs, u"__xor__"_qs},
- {u"operator|"_qs, u"__or__"_qs},
- {u"operator<<"_qs, u"__lshift__"_qs},
- {u"operator>>"_qs, u"__rshift__"_qs},
- {u"operator~"_qs, u"__invert__"_qs},
+ {u"operator&"_s, u"__and__"_s},
+ {u"operator^"_s, u"__xor__"_s},
+ {u"operator|"_s, u"__or__"_s},
+ {u"operator<<"_s, u"__lshift__"_s},
+ {u"operator>>"_s, u"__rshift__"_s},
+ {u"operator~"_s, u"__invert__"_s},
// Inplace bitwise operators
- {u"operator&="_qs, u"__iand__"_qs},
- {u"operator^="_qs, u"__ixor__"_qs},
- {u"operator|="_qs, u"__ior__"_qs},
- {u"operator<<="_qs, u"__ilshift__"_qs},
- {u"operator>>="_qs, u"__irshift__"_qs},
+ {u"operator&="_s, u"__iand__"_s},
+ {u"operator^="_s, u"__ixor__"_s},
+ {u"operator|="_s, u"__ior__"_s},
+ {u"operator<<="_s, u"__ilshift__"_s},
+ {u"operator>>="_s, u"__irshift__"_s},
// Comparison operators
- {u"operator=="_qs, u"__eq__"_qs},
- {u"operator!="_qs, u"__ne__"_qs},
- {u"operator<"_qs, u"__lt__"_qs},
- {u"operator>"_qs, u"__gt__"_qs},
- {u"operator<="_qs, u"__le__"_qs},
- {u"operator>="_qs, u"__ge__"_qs}
+ {u"operator=="_s, u"__eq__"_s},
+ {u"operator!="_s, u"__ne__"_s},
+ {u"operator<"_s, u"__lt__"_s},
+ {u"operator>"_s, u"__gt__"_s},
+ {u"operator<="_s, u"__le__"_s},
+ {u"operator>="_s, u"__ge__"_s}
};
return result;
}
@@ -806,7 +809,7 @@ QString getClassTargetFullName(const AbstractMetaEnum &metaEnum, bool includePac
QString getFilteredCppSignatureString(QString signature)
{
- signature.replace(QLatin1String("::"), QLatin1String("_"));
+ signature.replace(u"::"_s, u"_"_s);
signature.replace(u'<', u'_');
signature.replace(u'>', u'_');
signature.replace(u' ', u'_');
diff --git a/sources/shiboken6/generator/main.cpp b/sources/shiboken6/generator/main.cpp
index 1c9107d2d..c6f45dd46 100644
--- a/sources/shiboken6/generator/main.cpp
+++ b/sources/shiboken6/generator/main.cpp
@@ -45,9 +45,13 @@
#include <QtCore/QLibrary>
#include <QtCore/QVariant>
+#include "qtcompat.h"
+
#include <exception>
#include <iostream>
+using namespace Qt::StringLiterals;
+
static const QChar clangOptionsSplitter = u',';
static const QChar keywordsSplitter = u',';
static const QChar dropTypeEntriesSplitter = u';';
@@ -328,8 +332,8 @@ static inline Generators shibokenGenerators()
static inline QString languageLevelDescription()
{
- return QLatin1String("C++ Language level (c++11..c++17, default=")
- + QLatin1String(clang::languageLevelOption(clang::emulatedCompilerLanguageLevel()))
+ return u"C++ Language level (c++11..c++17, default="_s
+ + QLatin1StringView(clang::languageLevelOption(clang::emulatedCompilerLanguageLevel()))
+ u')';
}
@@ -344,57 +348,57 @@ void printUsage()
QTextStream(&pathSyntax) << "<path>[" << pathSplitter << "<path>"
<< pathSplitter << "...]";
OptionDescriptions generalOptions = {
- {QLatin1String("api-version=<\"package mask\">,<\"version\">"),
- QLatin1String("Specify the supported api version used to generate the bindings")},
- {QLatin1String("debug-level=[sparse|medium|full]"),
- QLatin1String("Set the debug level")},
- {QLatin1String("documentation-only"),
- QLatin1String("Do not generates any code, just the documentation")},
- {QLatin1String("drop-type-entries=\"<TypeEntry0>[;TypeEntry1;...]\""),
- QLatin1String("Semicolon separated list of type system entries (classes, namespaces,\n"
- "global functions and enums) to be dropped from generation.")},
+ {u"api-version=<\"package mask\">,<\"version\">"_s,
+ u"Specify the supported api version used to generate the bindings"_s},
+ {u"debug-level=[sparse|medium|full]"_s,
+ u"Set the debug level"_s},
+ {u"documentation-only"_s,
+ u"Do not generates any code, just the documentation"_s},
+ {u"drop-type-entries=\"<TypeEntry0>[;TypeEntry1;...]\""_s,
+ u"Semicolon separated list of type system entries (classes, namespaces,\n"
+ "global functions and enums) to be dropped from generation."_s},
{keywordsOption() + QStringLiteral("=keyword1[,keyword2,...]"),
- QLatin1String("A comma-separated list of keywords for conditional typesystem parsing")},
+ u"A comma-separated list of keywords for conditional typesystem parsing"_s},
{clangOptionOption(),
- QLatin1String("Option to be passed to clang")},
+ u"Option to be passed to clang"_s},
{clangOptionsOption(),
- QLatin1String("A comma-separated list of options to be passed to clang")},
- {QLatin1String("-F<path>"), {} },
- {QLatin1String("framework-include-paths=") + pathSyntax,
- QLatin1String("Framework include paths used by the C++ parser")},
- {QLatin1String("-isystem<path>"), {} },
- {QLatin1String("system-include-paths=") + pathSyntax,
- QLatin1String("System include paths used by the C++ parser")},
+ u"A comma-separated list of options to be passed to clang"_s},
+ {u"-F<path>"_s, {} },
+ {u"framework-include-paths="_s + pathSyntax,
+ u"Framework include paths used by the C++ parser"_s},
+ {u"-isystem<path>"_s, {} },
+ {u"system-include-paths="_s + pathSyntax,
+ u"System include paths used by the C++ parser"_s},
{useGlobalHeaderOption(),
- QLatin1String("Use the global headers in generated code.")},
- {QLatin1String("generator-set=<\"generator module\">"),
- QLatin1String("generator-set to be used. e.g. qtdoc")},
+ u"Use the global headers in generated code."_s},
+ {u"generator-set=<\"generator module\">"_s,
+ u"generator-set to be used. e.g. qtdoc"_s},
{skipDeprecatedOption(),
- QLatin1String("Skip deprecated functions")},
- {diffOption(), QLatin1String("Print a diff of wrapper files")},
- {dryrunOption(), QLatin1String("Dry run, do not generate wrapper files")},
- {QLatin1String("-h"), {} },
- {helpOption(), QLatin1String("Display this help and exit")},
- {QLatin1String("-I<path>"), {} },
- {QLatin1String("include-paths=") + pathSyntax,
- QLatin1String("Include paths used by the C++ parser")},
- {languageLevelOption() + QLatin1String("=, -std=<level>"),
+ u"Skip deprecated functions"_s},
+ {diffOption(), u"Print a diff of wrapper files"_s},
+ {dryrunOption(), u"Dry run, do not generate wrapper files"_s},
+ {u"-h"_s, {} },
+ {helpOption(), u"Display this help and exit"_s},
+ {u"-I<path>"_s, {} },
+ {u"include-paths="_s + pathSyntax,
+ u"Include paths used by the C++ parser"_s},
+ {languageLevelOption() + u"=, -std=<level>"_s,
languageLevelDescription()},
- {QLatin1String("license-file=<license-file>"),
- QLatin1String("File used for copyright headers of generated files")},
- {QLatin1String("no-suppress-warnings"),
- QLatin1String("Show all warnings")},
- {QLatin1String("output-directory=<path>"),
- QLatin1String("The directory where the generated files will be written")},
- {QLatin1String("project-file=<file>"),
- QLatin1String("text file containing a description of the binding project.\n"
- "Replaces and overrides command line arguments")},
- {QLatin1String("silent"), QLatin1String("Avoid printing any message")},
- {QLatin1String("-T<path>"), {} },
- {QLatin1String("typesystem-paths=") + pathSyntax,
- QLatin1String("Paths used when searching for typesystems")},
- {QLatin1String("version"),
- QLatin1String("Output version information and exit")}
+ {u"license-file=<license-file>"_s,
+ u"File used for copyright headers of generated files"_s},
+ {u"no-suppress-warnings"_s,
+ u"Show all warnings"_s},
+ {u"output-directory=<path>"_s,
+ u"The directory where the generated files will be written"_s},
+ {u"project-file=<file>"_s,
+ u"text file containing a description of the binding project.\n"
+ "Replaces and overrides command line arguments"_s},
+ {u"silent"_s, u"Avoid printing any message"_s},
+ {u"-T<path>"_s, {} },
+ {u"typesystem-paths="_s + pathSyntax,
+ u"Paths used when searching for typesystems"_s},
+ {u"version"_s,
+ u"Output version information and exit"_s}
};
printOptions(s, generalOptions);
@@ -459,7 +463,7 @@ int shibokenMain(int argc, char *argv[])
getCommandLineArgs(args);
Generators generators;
- auto ait = args.options.find(QLatin1String("version"));
+ auto ait = args.options.find(u"version"_s);
if (ait != args.options.end()) {
args.options.erase(ait);
printVerAndBanner();
@@ -467,9 +471,9 @@ int shibokenMain(int argc, char *argv[])
}
QString generatorSet;
- ait = args.options.find(QLatin1String("generator-set"));
- if (ait == args.options.end()) // Also check QLatin1String("generatorSet") command line argument for backward compatibility.
- ait = args.options.find(QLatin1String("generatorSet"));
+ ait = args.options.find(u"generator-set"_s);
+ if (ait == args.options.end()) // Also check "generatorSet" command line argument for backward compatibility.
+ ait = args.options.find(u"generatorSet"_s);
if (ait != args.options.end()) {
generatorSet = ait.value().toString();
args.options.erase(ait);
@@ -479,17 +483,17 @@ int shibokenMain(int argc, char *argv[])
if (generatorSet == u"qtdoc") {
generators = docGenerators();
if (generators.isEmpty()) {
- errorPrint(QLatin1String("Doc strings extractions was not enabled in this shiboken build."));
+ errorPrint(u"Doc strings extractions was not enabled in this shiboken build."_s);
return EXIT_FAILURE;
}
} else if (generatorSet.isEmpty() || generatorSet == u"shiboken") {
generators = shibokenGenerators();
} else {
- errorPrint(QLatin1String("Unknown generator set, try \"shiboken\" or \"qtdoc\"."));
+ errorPrint(u"Unknown generator set, try \"shiboken\" or \"qtdoc\"."_s);
return EXIT_FAILURE;
}
- ait = args.options.find(QLatin1String("help"));
+ ait = args.options.find(u"help"_s);
if (ait != args.options.end()) {
args.options.erase(ait);
printUsage();
@@ -515,7 +519,7 @@ int shibokenMain(int argc, char *argv[])
}
QString licenseComment;
- ait = args.options.find(QLatin1String("license-file"));
+ ait = args.options.find(u"license-file"_s);
if (ait != args.options.end()) {
QFile licenseFile(ait.value().toString());
args.options.erase(ait);
@@ -528,8 +532,8 @@ int shibokenMain(int argc, char *argv[])
}
}
- QString outputDirectory = QLatin1String("out");
- ait = args.options.find(QLatin1String("output-directory"));
+ QString outputDirectory = u"out"_s;
+ ait = args.options.find(u"output-directory"_s);
if (ait != args.options.end()) {
outputDirectory = ait.value().toString();
args.options.erase(ait);
@@ -552,22 +556,22 @@ int shibokenMain(int argc, char *argv[])
args.options.erase(ait);
}
- ait = args.options.find(QLatin1String("silent"));
+ ait = args.options.find(u"silent"_s);
if (ait != args.options.end()) {
extractor.setSilent(true);
args.options.erase(ait);
} else {
- ait = args.options.find(QLatin1String("debug-level"));
+ ait = args.options.find(u"debug-level"_s);
if (ait != args.options.end()) {
const QString value = ait.value().toString();
if (!ReportHandler::setDebugLevelFromArg(value)) {
- errorPrint(QLatin1String("Invalid debug level: ") + value);
+ errorPrint(u"Invalid debug level: "_s + value);
return EXIT_FAILURE;
}
args.options.erase(ait);
}
}
- ait = args.options.find(QLatin1String("no-suppress-warnings"));
+ ait = args.options.find(u"no-suppress-warnings"_s);
if (ait != args.options.end()) {
args.options.erase(ait);
extractor.setSuppressWarnings(false);
@@ -580,7 +584,7 @@ int shibokenMain(int argc, char *argv[])
QStringList parts = fullVersion.split(u',');
QString package;
QString version;
- package = parts.size() == 1 ? u"*"_qs : parts.constFirst();
+ package = parts.size() == 1 ? u"*"_s : parts.constFirst();
version = parts.constLast();
if (!extractor.setApiVersion(package, version)) {
errorPrint(msgInvalidVersion(package, version));
@@ -621,7 +625,7 @@ int shibokenMain(int argc, char *argv[])
args, extractor);
if (args.positionalArguments.size() < 2) {
- errorPrint(QLatin1String("Insufficient positional arguments, specify header-file and typesystem-file."));
+ errorPrint(u"Insufficient positional arguments, specify header-file and typesystem-file."_s);
std::cout << '\n';
printUsage();
return EXIT_FAILURE;
@@ -637,7 +641,7 @@ int shibokenMain(int argc, char *argv[])
for (const QString &cppFileName : qAsConst(args.positionalArguments)) {
const QFileInfo cppFileNameFi(cppFileName);
if (!cppFileNameFi.isFile() && !cppFileNameFi.isSymLink()) {
- errorPrint(u'"' + cppFileName + QLatin1String("\" does not exist."));
+ errorPrint(u'"' + cppFileName + u"\" does not exist."_s);
return EXIT_FAILURE;
}
cppFileNames.append(cppFileNameFi);
@@ -671,7 +675,7 @@ int shibokenMain(int argc, char *argv[])
* --project-file, also the arguments of each generator before
* checking if there isn't any existing arguments in argsHandler.
*/
- args.options.remove(QLatin1String("project-file"));
+ args.options.remove(u"project-file"_s);
for (auto it = projectFileArguments.options.cbegin(), end = projectFileArguments.options.cend();
it != end; ++it) {
args.options.remove(it.key());
@@ -699,7 +703,7 @@ int shibokenMain(int argc, char *argv[])
const std::optional<ApiExtractorResult> apiOpt = extractor.run(apiExtractorFlags);
if (!apiOpt.has_value()) {
- errorPrint(QLatin1String("Error running ApiExtractor."));
+ errorPrint(u"Error running ApiExtractor."_s);
return EXIT_FAILURE;
}
@@ -719,8 +723,8 @@ int shibokenMain(int argc, char *argv[])
const bool ok = g->setup(apiOpt.value()) && g->generate();
ReportHandler::endProgress();
if (!ok) {
- errorPrint(QLatin1String("Error running generator: ")
- + QLatin1String(g->name()) + u'.');
+ errorPrint(u"Error running generator: "_s
+ + QLatin1StringView(g->name()) + u'.');
return EXIT_FAILURE;
}
}
diff --git a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp
index 98144b21f..e47c51488 100644
--- a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp
@@ -48,6 +48,8 @@
#include <qtdocparser.h>
#include <doxygenparser.h>
+#include "qtcompat.h"
+
#include <QtCore/QTextStream>
#include <QtCore/QFile>
#include <QtCore/QDir>
@@ -55,6 +57,8 @@
#include <algorithm>
#include <limits>
+using namespace Qt::StringLiterals;
+
static inline QString additionalDocumentationOption() { return QStringLiteral("additional-documentation"); }
static inline QString none() { return QStringLiteral("None"); }
@@ -118,7 +122,7 @@ QtDocGenerator::~QtDocGenerator() = default;
QString QtDocGenerator::fileNameSuffix()
{
- return u".rst"_qs;
+ return u".rst"_s;
}
bool QtDocGenerator::shouldGenerate(const TypeEntry *te) const
@@ -195,8 +199,8 @@ static void writeInheritedByList(TextStream& s, const AbstractMetaClass* metaCla
s << "**Inherited by:** ";
QStringList classes;
for (auto c : qAsConst(res))
- classes << QLatin1String(":ref:`") + c->name() + u'`';
- s << classes.join(QLatin1String(", ")) << "\n\n";
+ classes << u":ref:`"_s + c->name() + u'`';
+ s << classes.join(u", "_s) << "\n\n";
}
void QtDocGenerator::generateClass(TextStream &s, const GeneratorContext &classContext)
@@ -291,14 +295,14 @@ void QtDocGenerator::writeFunctionList(TextStream& s, const AbstractMetaClass* c
className = func->implementingClass()->enclosingClass()->fullName() + u'.';
QString funcName = getFuncName(func);
- QString str = QLatin1String("def :meth:`");
+ QString str = u"def :meth:`"_s;
str += funcName;
str += u'<';
if (!funcName.startsWith(className))
str += className;
str += funcName;
- str += QLatin1String(">` (");
+ str += u">` ("_s;
str += parseArgDocStyle(cppClass, func);
str += u')';
@@ -319,11 +323,11 @@ void QtDocGenerator::writeFunctionList(TextStream& s, const AbstractMetaClass* c
s << "\nSynopsis\n--------\n\n";
- writeFunctionBlock(s, QLatin1String("Functions"), functionList);
- writeFunctionBlock(s, QLatin1String("Virtual functions"), virtualList);
- writeFunctionBlock(s, QLatin1String("Slots"), slotList);
- writeFunctionBlock(s, QLatin1String("Signals"), signalList);
- writeFunctionBlock(s, QLatin1String("Static functions"), staticFunctionList);
+ writeFunctionBlock(s, u"Functions"_s, functionList);
+ writeFunctionBlock(s, u"Virtual functions"_s, virtualList);
+ writeFunctionBlock(s, u"Slots"_s, slotList);
+ writeFunctionBlock(s, u"Signals"_s, signalList);
+ writeFunctionBlock(s, u"Static functions"_s, staticFunctionList);
}
}
@@ -345,7 +349,7 @@ void QtDocGenerator::writeFunctionBlock(TextStream& s, const QString& title, QSt
void QtDocGenerator::writeEnums(TextStream& s, const AbstractMetaClass* cppClass) const
{
- static const QString section_title = QLatin1String(".. attribute:: ");
+ static const QString section_title = u".. attribute:: "_s;
for (const AbstractMetaEnum &en : cppClass->enums()) {
s << section_title << cppClass->fullName() << '.' << en.name() << "\n\n";
@@ -359,7 +363,7 @@ void QtDocGenerator::writeEnums(TextStream& s, const AbstractMetaClass* cppClass
void QtDocGenerator::writeFields(TextStream& s, const AbstractMetaClass* cppClass) const
{
- static const QString section_title = QLatin1String(".. attribute:: ");
+ static const QString section_title = u".. attribute:: "_s;
for (const AbstractMetaField &field : cppClass->fields()) {
s << section_title << cppClass->fullName() << "." << field.name() << "\n\n";
@@ -369,7 +373,7 @@ void QtDocGenerator::writeFields(TextStream& s, const AbstractMetaClass* cppClas
void QtDocGenerator::writeConstructors(TextStream& s, const AbstractMetaClass* cppClass) const
{
- static const QString sectionTitle = QLatin1String(".. class:: ");
+ static const QString sectionTitle = u".. class:: "_s;
auto lst = cppClass->queryFunctions(FunctionQueryOption::AnyConstructor
| FunctionQueryOption::Visible);
@@ -442,22 +446,22 @@ QString QtDocGenerator::parseArgDocStyle(const AbstractMetaClass* /* cppClass */
}
if (arg.argumentIndex() > 0)
- ret += QLatin1String(", ");
+ ret += u", "_s;
ret += arg.name();
if (thisIsoptional) {
QString defValue = arg.defaultValueExpression();
if (defValue == u"QString()") {
- defValue = QLatin1String("\"\"");
+ defValue = u"\"\""_s;
} else if (defValue == u"QStringList()"
|| defValue.startsWith(u"QVector")
|| defValue.startsWith(u"QList")) {
- defValue = QLatin1String("list()");
+ defValue = u"list()"_s;
} else if (defValue == u"QVariant()") {
defValue = none();
} else {
- defValue.replace(QLatin1String("::"), QLatin1String("."));
+ defValue.replace(u"::"_s, u"."_s);
if (defValue == u"nullptr")
defValue = none();
else if (defValue == u"0" && arg.type().isObject())
@@ -478,10 +482,10 @@ void QtDocGenerator::writeDocSnips(TextStream &s,
{
Indentation indentation(s);
QStringList invalidStrings;
- const static QString startMarkup = QLatin1String("[sphinx-begin]");
- const static QString endMarkup = QLatin1String("[sphinx-end]");
+ const static QString startMarkup = u"[sphinx-begin]"_s;
+ const static QString endMarkup = u"[sphinx-end]"_s;
- invalidStrings << QLatin1String("*") << QLatin1String("//") << QLatin1String("/*") << QLatin1String("*/");
+ invalidStrings << u"*"_s << u"//"_s << u"/*"_s << u"*/"_s;
for (const CodeSnip &snip : codeSnips) {
if ((snip.position != position) ||
@@ -599,16 +603,16 @@ QString QtDocGenerator::translateToPythonType(const AbstractMetaType &type,
static const QMap<QString, QString> typeMap = {
{ cPyObjectT(), pyObjectT() },
{ qStringT(), pyStrT() },
- { QLatin1String("uchar"), pyStrT() },
- { QLatin1String("QStringList"), QLatin1String("list of strings") },
+ { u"uchar"_s, pyStrT() },
+ { u"QStringList"_s, u"list of strings"_s },
{ qVariantT(), pyObjectT() },
- { QLatin1String("quint32"), intT() },
- { QLatin1String("uint32_t"), intT() },
- { QLatin1String("quint64"), intT() },
- { QLatin1String("qint64"), intT() },
- { QLatin1String("size_t"), intT() },
- { QLatin1String("int64_t"), intT() },
- { QLatin1String("qreal"), floatT() }
+ { u"quint32"_s, intT() },
+ { u"uint32_t"_s, intT() },
+ { u"quint64"_s, intT() },
+ { u"qint64"_s, intT() },
+ { u"size_t"_s, intT() },
+ { u"int64_t"_s, intT() },
+ { u"qreal"_s, floatT() }
};
const auto found = typeMap.find(name);
if (found != typeMap.end())
@@ -616,7 +620,7 @@ QString QtDocGenerator::translateToPythonType(const AbstractMetaType &type,
QString strType;
if (type.isConstant() && name == u"char" && type.indirections() == 1) {
- strType = QLatin1String("str");
+ strType = u"str"_s;
} else if (name.startsWith(unsignedShortT())) {
strType = intT();
} else if (name.startsWith(unsignedT())) { // uint and ulong
@@ -626,13 +630,13 @@ QString QtDocGenerator::translateToPythonType(const AbstractMetaType &type,
strType.remove(u'*');
strType.remove(u'>');
strType.remove(u'<');
- strType.replace(QLatin1String("::"), QLatin1String("."));
+ strType.replace(u"::"_s, u"."_s);
if (strType.contains(u"QList") || strType.contains(u"QVector")) {
- strType.replace(QLatin1String("QList"), QLatin1String("list of "));
- strType.replace(QLatin1String("QVector"), QLatin1String("list of "));
+ strType.replace(u"QList"_s, u"list of "_s);
+ strType.replace(u"QVector"_s, u"list of "_s);
} else if (strType.contains(u"QHash") || strType.contains(u"QMap")) {
- strType.remove(QLatin1String("QHash"));
- strType.remove(QLatin1String("QMap"));
+ strType.remove(u"QHash"_s);
+ strType.remove(u"QMap"_s);
QStringList types = strType.split(u',');
strType = QString::fromLatin1("Dictionary with keys of type %1 and values of type %2.")
.arg(types[0], types[1]);
@@ -653,7 +657,7 @@ QString QtDocGenerator::getFuncName(const AbstractMetaFunctionCPtr& cppFunc)
if (!pythonOperator.isEmpty())
return pythonOperator;
}
- result.replace(u"::"_qs, u"."_qs);
+ result.replace(u"::"_s, u"."_s);
return result;
}
@@ -742,7 +746,7 @@ static void writeFancyToc(TextStream& s, const QStringList& items)
QtXmlToSphinx::Table table;
for (auto it = tocMap.cbegin(), end = tocMap.cend(); it != end; ++it) {
QtXmlToSphinx::TableRow row;
- const QString charEntry = QLatin1String("**") + it.key() + QLatin1String("**");
+ const QString charEntry = u"**"_s + it.key() + u"**"_s;
row << QtXmlToSphinx::TableCell(charEntry);
for (const QString &item : qAsConst(it.value())) {
if (row.size() >= numColumns) {
@@ -750,7 +754,7 @@ static void writeFancyToc(TextStream& s, const QStringList& items)
row.clear();
row << QtXmlToSphinx::TableCell(QString{});
}
- const QString entry = QLatin1String("* :doc:`") + item + u'`';
+ const QString entry = u"* :doc:`"_s + item + u'`';
row << QtXmlToSphinx::TableCell(entry);
}
if (row.size() > 1)
@@ -780,7 +784,7 @@ void QtDocGenerator::writeModuleDocumentation()
QString key = it.key();
key.replace(u'.', u'/');
QString outputDir = outputDirectory() + u'/' + key;
- FileOut output(outputDir + QLatin1String("/index.rst"));
+ FileOut output(outputDir + u"/index.rst"_s);
TextStream& s = output.stream;
const QString &title = it.key();
@@ -806,7 +810,7 @@ void QtDocGenerator::writeModuleDocumentation()
}
// Filter for "QtCore.Property.rst", skipping module doc "QtCore.rst"
- const QString filter = moduleName + QLatin1String(".?*.rst");
+ const QString filter = moduleName + u".?*.rst"_s;
const auto fileList =
extraSectionDir.entryInfoList({filter}, QDir::Files, QDir::Name);
for (const auto &fi : fileList) {
@@ -834,7 +838,7 @@ void QtDocGenerator::writeModuleDocumentation()
// module doc is always wrong and C++istic, so go straight to the extra directory!
QFile moduleDoc(m_extraSectionDir + u'/' + moduleName
- + QLatin1String(".rst"));
+ + u".rst"_s);
if (moduleDoc.open(QIODevice::ReadOnly | QIODevice::Text)) {
s << moduleDoc.readAll();
moduleDoc.close();
@@ -968,22 +972,22 @@ Generator::OptionDescriptions QtDocGenerator::options() const
{
auto result = Generator::options();
result.append({
- {QLatin1String("doc-parser=<parser>"),
- QLatin1String("The documentation parser used to interpret the documentation\n"
- "input files (qdoc|doxygen)")},
- {QLatin1String("documentation-code-snippets-dir=<dir>"),
- QLatin1String("Directory used to search code snippets used by the documentation")},
- {u"snippets-path-rewrite=old:new"_qs,
- u"Replacements in code snippet path to find .cpp/.h snippets converted to Python"_qs},
- {QLatin1String("documentation-data-dir=<dir>"),
- QLatin1String("Directory with XML files generated by documentation tool")},
- {QLatin1String("documentation-extra-sections-dir=<dir>"),
- QLatin1String("Directory used to search for extra documentation sections")},
- {QLatin1String("library-source-dir=<dir>"),
- QLatin1String("Directory where library source code is located")},
- {additionalDocumentationOption() + QLatin1String("=<file>"),
- QLatin1String("List of additional XML files to be converted to .rst files\n"
- "(for example, tutorials).")}
+ {u"doc-parser=<parser>"_s,
+ u"The documentation parser used to interpret the documentation\n"
+ "input files (qdoc|doxygen)"_s},
+ {u"documentation-code-snippets-dir=<dir>"_s,
+ u"Directory used to search code snippets used by the documentation"_s},
+ {u"snippets-path-rewrite=old:new"_s,
+ u"Replacements in code snippet path to find .cpp/.h snippets converted to Python"_s},
+ {u"documentation-data-dir=<dir>"_s,
+ u"Directory with XML files generated by documentation tool"_s},
+ {u"documentation-extra-sections-dir=<dir>"_s,
+ u"Directory used to search for extra documentation sections"_s},
+ {u"library-source-dir=<dir>"_s,
+ u"Directory where library source code is located"_s},
+ {additionalDocumentationOption() + u"=<file>"_s,
+ u"List of additional XML files to be converted to .rst files\n"
+ "(for example, tutorials)."_s}
});
return result;
}
diff --git a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp
index 71af92925..fee07a73f 100644
--- a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp
+++ b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.cpp
@@ -32,6 +32,8 @@
#include <codesniphelpers.h>
#include "rstformat.h"
+#include "qtcompat.h"
+
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
@@ -39,6 +41,8 @@
#include <QtCore/QRegularExpression>
#include <QtCore/QXmlStreamReader>
+using namespace Qt::StringLiterals;
+
static inline QString nameAttribute() { return QStringLiteral("name"); }
static inline QString titleAttribute() { return QStringLiteral("title"); }
static inline QString fullTitleAttribute() { return QStringLiteral("fulltitle"); }
@@ -62,11 +66,11 @@ QString msgTagWarning(const QXmlStreamReader &reader, const QString &context,
QString msgFallbackWarning(const QString &location, const QString &identifier,
const QString &fallback)
{
- QString message = QLatin1String("Falling back to \"")
- + QDir::toNativeSeparators(fallback) + QLatin1String("\" for \"")
+ QString message = u"Falling back to \""_s
+ + QDir::toNativeSeparators(fallback) + u"\" for \""_s
+ location + u'"';
if (!identifier.isEmpty())
- message += QLatin1String(" [") + identifier + u']';
+ message += u" ["_s + identifier + u']';
return message;
}
@@ -74,7 +78,7 @@ QString msgSnippetsResolveError(const QString &path, const QStringList &location
{
QString result;
QTextStream(&result) << "Could not resolve \"" << path << R"(" in ")"
- << locations.join(uR"(", ")"_qs);
+ << locations.join(uR"(", ")"_s);
return result;
}
@@ -534,10 +538,10 @@ static QString pySnippetName(const QString &path, SnippetType type)
{
switch (type) {
case SnippetType::CppSource:
- return path.left(path.size() - 3) + u"py"_qs;
+ return path.left(path.size() - 3) + u"py"_s;
break;
case SnippetType::CppHeader:
- return path + u".py"_qs;
+ return path + u".py"_s;
break;
default:
break;
@@ -609,17 +613,17 @@ QString QtXmlToSphinx::readFromLocation(const QString &location, const QString &
return QString(); // null
}
- QString code = QLatin1String(""); // non-null
+ QString code = u""_s; // non-null
if (identifier.isEmpty()) {
while (!inputFile.atEnd())
code += QString::fromUtf8(inputFile.readLine());
return CodeSnipHelpers::fixSpaces(code);
}
- const QRegularExpression searchString(QLatin1String("//!\\s*\\[")
- + identifier + QLatin1String("\\]"));
+ const QRegularExpression searchString(u"//!\\s*\\["_s
+ + identifier + u"\\]"_s);
Q_ASSERT(searchString.isValid());
- static const QRegularExpression codeSnippetCode(QLatin1String("//!\\s*\\[[\\w\\d\\s]+\\]"));
+ static const QRegularExpression codeSnippetCode(u"//!\\s*\\[[\\w\\d\\s]+\\]"_s);
Q_ASSERT(codeSnippetCode.isValid());
bool getCode = false;
@@ -653,7 +657,7 @@ void QtXmlToSphinx::handleHeadingTag(QXmlStreamReader& reader)
static char types[] = { '-', '^' };
QXmlStreamReader::TokenType token = reader.tokenType();
if (token == QXmlStreamReader::StartElement) {
- uint typeIdx = reader.attributes().value(QLatin1String("level")).toUInt();
+ uint typeIdx = reader.attributes().value(u"level"_s).toUInt();
if (typeIdx >= sizeof(types))
type = types[sizeof(types)-1];
else
@@ -794,9 +798,9 @@ static inline QString fixLinkType(QStringView type)
static inline QString linkSourceAttribute(const QString &type)
{
if (type == functionLinkType() || type == classLinkType())
- return QLatin1String("raw");
+ return u"raw"_s;
return type == u"enum" || type == u"page"
- ? type : QLatin1String("href");
+ ? type : u"href"_s;
}
// "See also" links may appear as nested links:
@@ -875,8 +879,8 @@ void QtXmlToSphinx::handleSnippetTag(QXmlStreamReader& reader)
m_output.flush();
m_output.string()->chop(2);
}
- QString location = reader.attributes().value(QLatin1String("location")).toString();
- QString identifier = reader.attributes().value(QLatin1String("identifier")).toString();
+ QString location = reader.attributes().value(u"location"_s).toString();
+ QString identifier = reader.attributes().value(u"identifier"_s).toString();
QString fallbackPath;
if (reader.attributes().hasAttribute(fallbackPathAttribute()))
fallbackPath = reader.attributes().value(fallbackPathAttribute()).toString();
@@ -916,7 +920,7 @@ void QtXmlToSphinx::handleDotsTag(QXmlStreamReader& reader)
m_output << "::\n\n";
}
pushOutputBuffer();
- int indent = reader.attributes().value(QLatin1String("indent")).toInt()
+ int indent = reader.attributes().value(u"indent"_s).toInt()
+ m_output.indentation() * m_output.tabWidth();
for (int i = 0; i < indent; ++i)
m_output << ' ';
@@ -949,7 +953,7 @@ void QtXmlToSphinx::handleTermTag(QXmlStreamReader& reader)
if (token == QXmlStreamReader::StartElement) {
pushOutputBuffer();
} else if (token == QXmlStreamReader::Characters) {
- m_output << reader.text().toString().replace(QLatin1String("::"), QLatin1String("."));
+ m_output << reader.text().toString().replace(u"::"_s, u"."_s);
} else if (token == QXmlStreamReader::EndElement) {
TableCell cell;
cell.data = popOutputBuffer().trimmed();
@@ -966,8 +970,8 @@ void QtXmlToSphinx::handleItemTag(QXmlStreamReader& reader)
m_currentTable.appendRow({});
TableRow& row = m_currentTable.last();
TableCell cell;
- cell.colSpan = reader.attributes().value(QLatin1String("colspan")).toShort();
- cell.rowSpan = reader.attributes().value(QLatin1String("rowspan")).toShort();
+ cell.colSpan = reader.attributes().value(u"colspan"_s).toShort();
+ cell.rowSpan = reader.attributes().value(u"rowspan"_s).toShort();
row << cell;
pushOutputBuffer();
} else if (token == QXmlStreamReader::EndElement) {
@@ -985,7 +989,7 @@ void QtXmlToSphinx::handleHeaderTag(QXmlStreamReader &reader)
// <header> in WebXML is either a table header or a description of a
// C++ header with "name"/"href" attributes.
if (reader.tokenType() == QXmlStreamReader::StartElement
- && !reader.attributes().hasAttribute(u"name"_qs)) {
+ && !reader.attributes().hasAttribute(u"name"_s)) {
m_currentTable.setHeaderEnabled(true);
m_currentTable.appendRow({});
}
@@ -1014,10 +1018,10 @@ void QtXmlToSphinx::handleListTag(QXmlStreamReader& reader)
static ListType listType = BulletList;
QXmlStreamReader::TokenType token = reader.tokenType();
if (token == QXmlStreamReader::StartElement) {
- listType = webXmlListType(reader.attributes().value(QLatin1String("type")));
+ listType = webXmlListType(reader.attributes().value(u"type"_s));
if (listType == EnumeratedList) {
- m_currentTable.appendRow(TableRow{TableCell(QLatin1String("Constant")),
- TableCell(QLatin1String("Description"))});
+ m_currentTable.appendRow(TableRow{TableCell(u"Constant"_s),
+ TableCell(u"Description"_s)});
m_currentTable.setHeaderEnabled(true);
}
m_output.indent();
@@ -1054,7 +1058,7 @@ void QtXmlToSphinx::handleLinkTag(QXmlStreamReader& reader)
case QXmlStreamReader::StartElement: {
// <link> embedded in <see-also> means the characters of <see-also> are no link.
m_seeAlsoContext.reset();
- const QString type = fixLinkType(reader.attributes().value(QLatin1String("type")));
+ const QString type = fixLinkType(reader.attributes().value(u"type"_s));
const QString ref = reader.attributes().value(linkSourceAttribute(type)).toString();
m_linkContext.reset(handleLinkStart(type, ref));
}
@@ -1075,8 +1079,8 @@ void QtXmlToSphinx::handleLinkTag(QXmlStreamReader& reader)
QtXmlToSphinxLink *QtXmlToSphinx::handleLinkStart(const QString &type, QString ref) const
{
- ref.replace(QLatin1String("::"), QLatin1String("."));
- ref.remove(QLatin1String("()"));
+ ref.replace(u"::"_s, u"."_s);
+ ref.remove(u"()"_s);
auto *result = new QtXmlToSphinxLink(ref);
if (m_insideBold)
@@ -1141,7 +1145,7 @@ static QString fixLinkText(const QtXmlToSphinxLink *linkContext,
if (linkContext->linkRef == linktext)
return QString();
if ((linkContext->type & QtXmlToSphinxLink::FunctionMask) != 0
- && (linkContext->linkRef + QLatin1String("()")) == linktext) {
+ && (linkContext->linkRef + u"()"_s) == linktext) {
return QString();
}
return linktext;
@@ -1234,7 +1238,7 @@ void QtXmlToSphinx::handleImageTag(QXmlStreamReader& reader)
{
if (reader.tokenType() != QXmlStreamReader::StartElement)
return;
- const QString href = reader.attributes().value(QLatin1String("href")).toString();
+ const QString href = reader.attributes().value(u"href"_s).toString();
if (copyImage(href))
m_output << ".. image:: " << href << "\n\n";
}
@@ -1243,7 +1247,7 @@ void QtXmlToSphinx::handleInlineImageTag(QXmlStreamReader& reader)
{
if (reader.tokenType() != QXmlStreamReader::StartElement)
return;
- const QString href = reader.attributes().value(QLatin1String("href")).toString();
+ const QString href = reader.attributes().value(u"href"_s).toString();
if (!copyImage(href))
return;
// Handle inline images by substitution references. Insert a unique tag
@@ -1265,7 +1269,7 @@ void QtXmlToSphinx::handleRawTag(QXmlStreamReader& reader)
{
QXmlStreamReader::TokenType token = reader.tokenType();
if (token == QXmlStreamReader::StartElement) {
- QString format = reader.attributes().value(QLatin1String("format")).toString();
+ QString format = reader.attributes().value(u"format"_s).toString();
m_output << ".. raw:: " << format.toLower() << "\n\n";
} else if (token == QXmlStreamReader::Characters) {
Indentation indent(m_output);
@@ -1355,10 +1359,10 @@ void QtXmlToSphinx::handleAnchorTag(QXmlStreamReader& reader)
QXmlStreamReader::TokenType token = reader.tokenType();
if (token == QXmlStreamReader::StartElement) {
QString anchor;
- if (reader.attributes().hasAttribute(QLatin1String("id")))
- anchor = reader.attributes().value(QLatin1String("id")).toString();
- else if (reader.attributes().hasAttribute(QLatin1String("name")))
- anchor = reader.attributes().value(QLatin1String("name")).toString();
+ if (reader.attributes().hasAttribute(u"id"_s))
+ anchor = reader.attributes().value(u"id"_s).toString();
+ else if (reader.attributes().hasAttribute(u"name"_s))
+ anchor = reader.attributes().value(u"name"_s).toString();
if (!anchor.isEmpty() && m_opened_anchor != anchor) {
m_opened_anchor = anchor;
if (!m_context.isEmpty())
@@ -1499,7 +1503,7 @@ void QtXmlToSphinx::Table::format(TextStream& s) const
return; // empty table (table with empty cells)
// create a horizontal line to be used later.
- QString horizontalLine = QLatin1String("+");
+ QString horizontalLine = u"+"_s;
for (auto colWidth : colWidths)
horizontalLine += QString(colWidth, u'-') + u'+';
diff --git a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.h b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.h
index c56f2aad9..0f5c6c791 100644
--- a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.h
+++ b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.h
@@ -31,6 +31,8 @@
#include <textstream.h>
+#include "qtcompat.h"
+
#include <QtCore/QHash>
#include <QtCore/QList>
#include <QtCore/QScopedPointer>
@@ -67,7 +69,7 @@ public:
QString data;
TableCell(const QString& text = QString()) : data(text) {}
- TableCell(const char* text) : data(QLatin1String(text)) {}
+ TableCell(const char* text) : data(QString::fromLatin1(text)) {}
};
using TableRow = QList<TableCell>;
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index a7ce16ca4..136ac4c2d 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -48,6 +48,8 @@
#include <typedatabase.h>
#include <parser/enumvalue.h>
+#include "qtcompat.h"
+
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QMetaObject>
@@ -59,6 +61,8 @@
#include <cstring>
#include <memory>
+using namespace Qt::StringLiterals;
+
static const char CPP_ARG0[] = "cppArg0";
const char *CppGenerator::PYTHON_TO_CPPCONVERSION_STRUCT = "Shiboken::Conversions::PythonToCppConversion";
@@ -134,14 +138,14 @@ static bool contains(const ProtocolEntries &l, const QString &needle)
const ProtocolEntries &mappingProtocols()
{
static const ProtocolEntries result = {
- {QLatin1String("__mlen__"),
- QLatin1String("PyObject *self"),
- QLatin1String("Py_ssize_t")},
- {QLatin1String("__mgetitem__"),
- QLatin1String("PyObject *self, PyObject *_key"),
- QLatin1String("PyObject*")},
- {QLatin1String("__msetitem__"),
- QLatin1String("PyObject *self, PyObject *_key, PyObject *_value"),
+ {u"__mlen__"_s,
+ u"PyObject *self"_s,
+ u"Py_ssize_t"_s},
+ {u"__mgetitem__"_s,
+ u"PyObject *self, PyObject *_key"_s,
+ u"PyObject*"_s},
+ {u"__msetitem__"_s,
+ u"PyObject *self, PyObject *_key, PyObject *_value"_s,
intT()}};
return result;
}
@@ -151,27 +155,27 @@ const ProtocolEntries &mappingProtocols()
const ProtocolEntries &sequenceProtocols()
{
static const ProtocolEntries result = {
- {QLatin1String("__len__"),
- QLatin1String("PyObject *self"),
- QLatin1String("Py_ssize_t")},
- {QLatin1String("__getitem__"),
- QLatin1String("PyObject *self, Py_ssize_t _i"),
- QLatin1String("PyObject*")},
- {QLatin1String("__setitem__"),
- QLatin1String("PyObject *self, Py_ssize_t _i, PyObject *_value"),
+ {u"__len__"_s,
+ u"PyObject *self"_s,
+ u"Py_ssize_t"_s},
+ {u"__getitem__"_s,
+ u"PyObject *self, Py_ssize_t _i"_s,
+ u"PyObject*"_s},
+ {u"__setitem__"_s,
+ u"PyObject *self, Py_ssize_t _i, PyObject *_value"_s,
intT()},
- {QLatin1String("__getslice__"),
- QLatin1String("PyObject *self, Py_ssize_t _i1, Py_ssize_t _i2"),
- QLatin1String("PyObject*")},
- {QLatin1String("__setslice__"),
- QLatin1String("PyObject *self, Py_ssize_t _i1, Py_ssize_t _i2, PyObject *_value"),
+ {u"__getslice__"_s,
+ u"PyObject *self, Py_ssize_t _i1, Py_ssize_t _i2"_s,
+ u"PyObject*"_s},
+ {u"__setslice__"_s,
+ u"PyObject *self, Py_ssize_t _i1, Py_ssize_t _i2, PyObject *_value"_s,
intT()},
- {QLatin1String("__contains__"),
- QLatin1String("PyObject *self, PyObject *_value"),
+ {u"__contains__"_s,
+ u"PyObject *self, PyObject *_value"_s,
intT()},
- {QLatin1String("__concat__"),
- QLatin1String("PyObject *self, PyObject *_other"),
- QLatin1String("PyObject*")}
+ {u"__concat__"_s,
+ u"PyObject *self, PyObject *_other"_s,
+ u"PyObject*"_s}
};
return result;
}
@@ -183,9 +187,9 @@ static QString opaqueContainerCreationFunc(const AbstractMetaType &type)
static_cast<const ContainerTypeEntry *>(type.typeEntry());
const auto *instantiationTypeEntry =
type.instantiations().constFirst().typeEntry();
- QString result = u"create"_qs;
+ QString result = u"create"_s;
if (type.isConstant())
- result += u"Const"_qs;
+ result += u"Const"_s;
result += containerTypeEntry->opaqueContainerName(instantiationTypeEntry->name());
return result;
}
@@ -203,7 +207,7 @@ CppGenerator::CppGenerator() = default;
QString CppGenerator::fileNameForContext(const GeneratorContext &context) const
{
- return fileNameForContextHelper(context, u"_wrapper.cpp"_qs);
+ return fileNameForContextHelper(context, u"_wrapper.cpp"_s);
}
static bool isInplaceAdd(const AbstractMetaFunctionCPtr &func)
@@ -331,9 +335,9 @@ std::optional<AbstractMetaType>
void CppGenerator::clearTpFuncs()
{
m_tpFuncs = {
- {QLatin1String("__str__"), {}}, {QLatin1String("__str__"), {}},
- {reprFunction(), {}}, {QLatin1String("__iter__"), {}},
- {QLatin1String("__next__"), {}}
+ {u"__str__"_s, {}}, {u"__str__"_s, {}},
+ {reprFunction(), {}}, {u"__iter__"_s, {}},
+ {u"__next__"_s, {}}
};
}
@@ -382,7 +386,7 @@ static void writePyGetSetDefEntry(TextStream &s, const QString &name,
const QString &getFunc, const QString &setFunc)
{
s << "{const_cast<char *>(\"" << name << "\"), " << getFunc << ", "
- << (setFunc.isEmpty() ? QLatin1String(NULL_PTR) : setFunc) << "},\n";
+ << (setFunc.isEmpty() ? QLatin1StringView(NULL_PTR) : setFunc) << "},\n";
}
static bool generateRichComparison(const GeneratorContext &c)
@@ -948,7 +952,7 @@ void CppGenerator::writeCacheResetNative(TextStream &s, const GeneratorContext &
void CppGenerator::writeConstructorNative(TextStream &s, const GeneratorContext &classContext,
const AbstractMetaFunctionCPtr &func) const
{
- const QString qualifiedName = classContext.wrapperName() + QLatin1String("::");
+ const QString qualifiedName = classContext.wrapperName() + u"::"_s;
s << functionSignature(func, qualifiedName, QString(),
OriginalTypeDescription | SkipDefaultValues);
s << " : ";
@@ -991,7 +995,7 @@ static bool allArgumentsRemoved(const AbstractMetaFunctionCPtr& func)
QString CppGenerator::getVirtualFunctionReturnTypeName(const AbstractMetaFunctionCPtr &func) const
{
if (func->type().isVoid())
- return QLatin1String("\"\"");
+ return u"\"\""_s;
if (func->isTypeModified())
return u'"' + func->modifiedTypeName() + u'"';
@@ -1004,17 +1008,17 @@ QString CppGenerator::getVirtualFunctionReturnTypeName(const AbstractMetaFunctio
case ContainerTypeEntry::ListContainer:
break;
case ContainerTypeEntry::SetContainer:
- return uR"("set")"_qs;
+ return uR"("set")"_s;
break;
case ContainerTypeEntry::MapContainer:
case ContainerTypeEntry::MultiMapContainer:
- return uR"("dict")"_qs;
+ return uR"("dict")"_s;
break;
case ContainerTypeEntry::PairContainer:
- return uR"("tuple")"_qs;
+ return uR"("tuple")"_s;
break;
}
- return uR"("list")"_qs;
+ return uR"("list")"_s;
}
if (typeEntry->isSmartPointer())
return u'"' + typeEntry->qualifiedCppName() + u'"';
@@ -1028,8 +1032,8 @@ QString CppGenerator::getVirtualFunctionReturnTypeName(const AbstractMetaFunctio
if (func->type().isPrimitive())
return u'"' + func->type().name() + u'"';
- return QLatin1String("reinterpret_cast<PyTypeObject *>(Shiboken::SbkType< ")
- + typeEntry->qualifiedCppName() + QLatin1String(" >())->tp_name");
+ return u"reinterpret_cast<PyTypeObject *>(Shiboken::SbkType< "_s
+ + typeEntry->qualifiedCppName() + u" >())->tp_name"_s;
}
// When writing an overridden method of a wrapper class, write the part
@@ -1075,7 +1079,7 @@ QString CppGenerator::virtualMethodReturn(TextStream &s, const ApiExtractorResul
const FunctionModificationList &functionModifications)
{
if (func->isVoid())
- return QLatin1String("return;");
+ return u"return;"_s;
const AbstractMetaType &returnType = func->type();
for (const FunctionModification &mod : functionModifications) {
for (const ArgumentModification &argMod : mod.argument_mods()) {
@@ -1096,7 +1100,7 @@ QString CppGenerator::virtualMethodReturn(TextStream &s, const ApiExtractorResul
offset = match.capturedStart(1);
}
DefaultValue defaultReturnExpr(DefaultValue::Custom, expr);
- return QLatin1String("return ") + defaultReturnExpr.returnValue()
+ return u"return "_s + defaultReturnExpr.returnValue()
+ u';';
}
}
@@ -1104,7 +1108,7 @@ QString CppGenerator::virtualMethodReturn(TextStream &s, const ApiExtractorResul
QString errorMessage;
const auto defaultReturnExpr = minimalConstructor(api, returnType, &errorMessage);
if (!defaultReturnExpr.has_value()) {
- QString errorMsg = QLatin1String(__FUNCTION__) + u": "_qs
+ QString errorMsg = QLatin1StringView(__FUNCTION__) + u": "_s
+ func->classQualifiedSignature();
errorMsg = msgCouldNotFindMinimalConstructor(errorMsg,
func->type().cppSignature(),
@@ -1115,9 +1119,9 @@ QString CppGenerator::virtualMethodReturn(TextStream &s, const ApiExtractorResul
if (returnType.referenceType() == LValueReference) {
s << "static " << returnType.typeEntry()->qualifiedCppName()
<< " result;\n";
- return QLatin1String("return result;");
+ return u"return result;"_s;
}
- return QLatin1String("return ") + defaultReturnExpr->returnValue()
+ return u"return "_s + defaultReturnExpr->returnValue()
+ u';';
}
@@ -1126,12 +1130,12 @@ void CppGenerator::writeVirtualMethodNative(TextStream &s,
int cacheIndex) const
{
// abbreviations
- const QString pyRetVar = QLatin1String(PYTHON_RETURN_VAR);
- const QString cppRetVar = QLatin1String(CPP_RETURN_VAR);
+ const QString pyRetVar = QLatin1StringView(PYTHON_RETURN_VAR);
+ const QString cppRetVar = QLatin1StringView(CPP_RETURN_VAR);
// skip metaObject function, this will be written manually ahead
if (usePySideExtensions() && func->ownerClass() && func->ownerClass()->isQObject() &&
- ((func->name() == u"metaObject"_qs)
+ ((func->name() == u"metaObject"_s)
|| (func->name() == u"qt_metacall")))
return;
@@ -1139,7 +1143,7 @@ void CppGenerator::writeVirtualMethodNative(TextStream &s,
const QString funcName = func->isOperatorOverload()
? pythonOperatorFunctionName(func) : func->definitionNames().constFirst();
- QString prefix = wrapperName(func->ownerClass()) + QLatin1String("::");
+ QString prefix = wrapperName(func->ownerClass()) + u"::"_s;
s << functionSignature(func, prefix, QString(), Generator::SkipDefaultValues |
Generator::OriginalTypeDescription)
<< "\n{\n" << indent;
@@ -1249,7 +1253,7 @@ void CppGenerator::writeVirtualMethodNative(TextStream &s,
if (!func->conversionRule(TypeSystem::TargetLangCode,
arg.argumentIndex() + 1).isEmpty()) {
// Has conversion rule.
- ac << arg.name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX);
+ ac << arg.name() + QLatin1StringView(CONV_RULE_OUT_VAR_SUFFIX);
} else {
QString argName = arg.name();
if (convert)
@@ -1262,7 +1266,7 @@ void CppGenerator::writeVirtualMethodNative(TextStream &s,
}
s << "Py_BuildValue(\"(" << getFormatUnitString(func, false) << ")\",\n"
- << indent << argConversions.join(u",\n"_qs) << outdent << "\n));\n";
+ << indent << argConversions.join(u",\n"_s) << outdent << "\n));\n";
}
bool invalidateReturn = false;
@@ -1402,8 +1406,8 @@ void CppGenerator::writeVirtualMethodNative(TextStream &s,
if (isProtectedEnum) {
QString typeCast;
if (metaEnum->enclosingClass())
- typeCast += u"::"_qs + metaEnum->enclosingClass()->qualifiedCppName();
- typeCast += u"::"_qs + metaEnum->name();
+ typeCast += u"::"_s + metaEnum->enclosingClass()->qualifiedCppName();
+ typeCast += u"::"_s + metaEnum->name();
s << '(' << typeCast << ')';
}
}
@@ -1437,7 +1441,7 @@ void CppGenerator::writeMetaObjectMethod(TextStream &s,
<< "::qt_metacall(QMetaObject::Call call, int id, void **args)\n";
s << "{\n" << indent;
- const auto list = classContext.metaClass()->queryFunctionsByName(QLatin1String("qt_metacall"));
+ const auto list = classContext.metaClass()->queryFunctionsByName(u"qt_metacall"_s);
CodeSnipList snips;
if (list.size() == 1) {
@@ -1504,7 +1508,7 @@ void CppGenerator::writeEnumConverterFunctions(TextStream &s, const TypeEntry *e
c << ";\n";
writePythonToCppFunction(s, c.toString(), typeName, typeName);
- QString pyTypeCheck = u"PyObject_TypeCheck(pyIn, "_qs + enumPythonType + u')';
+ QString pyTypeCheck = u"PyObject_TypeCheck(pyIn, "_s + enumPythonType + u')';
writeIsPythonConvertibleToCppFunction(s, typeName, typeName, pyTypeCheck);
c.clear();
@@ -1554,8 +1558,8 @@ void CppGenerator::writeEnumConverterFunctions(TextStream &s, const TypeEntry *e
// a PolarOrientation and Qt::AlignmentFlag, which was the main
// issue of the bug.
const QString numberCondition = QStringLiteral("PyNumber_Check(pyIn) && ") + pyTypeCheck;
- writePythonToCppFunction(s, c.toString(), QLatin1String("number"), flagsTypeName);
- writeIsPythonConvertibleToCppFunction(s, QLatin1String("number"), flagsTypeName, numberCondition);
+ writePythonToCppFunction(s, c.toString(), u"number"_s, flagsTypeName);
+ writeIsPythonConvertibleToCppFunction(s, u"number"_s, flagsTypeName, numberCondition);
}
void CppGenerator::writeConverterFunctions(TextStream &s, const AbstractMetaClass *metaClass,
@@ -1586,13 +1590,13 @@ void CppGenerator::writeConverterFunctions(TextStream &s, const AbstractMetaClas
s << "// Python to C++ pointer conversion - returns the C++ object of the Python wrapper (keeps object identity).\n";
QString sourceTypeName = metaClass->name();
- QString targetTypeName = metaClass->name() + QLatin1String("_PTR");
+ QString targetTypeName = metaClass->name() + u"_PTR"_s;
StringStream c(TextStream::Language::Cpp);
c << "Shiboken::Conversions::pythonToCppPointer(" << cpythonType << ", pyIn, cppOut);";
writePythonToCppFunction(s, c.toString(), sourceTypeName, targetTypeName);
// "Is convertible" function for the Python object to C++ pointer conversion.
- const QString pyTypeCheck = u"PyObject_TypeCheck(pyIn, "_qs + cpythonType + u")"_qs;
+ const QString pyTypeCheck = u"PyObject_TypeCheck(pyIn, "_s + cpythonType + u")"_s;
writeIsPythonConvertibleToCppFunction(s, sourceTypeName, targetTypeName, pyTypeCheck, QString(), true);
s << '\n';
@@ -1638,7 +1642,7 @@ return result;)";
s << '\n' << "// C++ to Python copy conversion.\n";
targetTypeName = metaClass->name();
- sourceTypeName = targetTypeName + QLatin1String("_COPY");
+ sourceTypeName = targetTypeName + u"_COPY"_s;
c.clear();
@@ -1655,8 +1659,8 @@ return result;)";
targetTypeName = sourceTypeName + QStringLiteral("_COPY");
c.clear();
- QString pyInVariable = QLatin1String("pyIn");
- const QString outPtr = u"reinterpret_cast<"_qs + typeName + u" *>(cppOut)"_qs;
+ QString pyInVariable = u"pyIn"_s;
+ const QString outPtr = u"reinterpret_cast<"_s + typeName + u" *>(cppOut)"_s;
if (!classContext.forSmartPointer()) {
c << '*' << outPtr << " = *"
<< cpythonWrapperCPtr(typeEntry, pyInVariable) << ';';
@@ -1679,7 +1683,7 @@ return result;)";
// "Is convertible" function for the Python object to C++ value copy conversion.
QString copyTypeCheck = pyTypeCheck;
if (classContext.forSmartPointer())
- copyTypeCheck.prepend(pyInVariable + u" == Py_None || "_qs);
+ copyTypeCheck.prepend(pyInVariable + u" == Py_None || "_s);
writeIsPythonConvertibleToCppFunction(s, sourceTypeName, targetTypeName, copyTypeCheck);
s << '\n';
@@ -1700,7 +1704,7 @@ return result;)";
QString toCppPreConv;
if (conv->isConversionOperator()) {
const AbstractMetaClass *sourceClass = conv->ownerClass();
- typeCheck = u"PyObject_TypeCheck(pyIn, "_qs
+ typeCheck = u"PyObject_TypeCheck(pyIn, "_s
+ cpythonTypeNameExt(sourceClass->typeEntry()) + u')';
toCppConv = u'*' + cpythonWrapperCPtr(sourceClass->typeEntry(),
pyInVariable);
@@ -1713,7 +1717,7 @@ return result;)";
if (sourceType.isWrapperType()) {
if (sourceType.referenceType() == LValueReference
|| !sourceType.isPointerToWrapperType()) {
- toCppConv = u" *"_qs;
+ toCppConv = u" *"_s;
}
toCppConv += cpythonWrapperCPtr(sourceType.typeEntry(), pyInVariable);
}
@@ -1734,14 +1738,14 @@ return result;)";
pc << getFullTypeNameWithoutModifiers(sourceType) << " cppIn"
<< minimalConstructorExpression(api(), sourceType) << ";\n";
writeToCppConversion(pc, sourceType, nullptr, pyInVariable,
- u"cppIn"_qs);
+ u"cppIn"_s);
pc << ';';
toCppPreConv = pc.toString();
- toCppConv.append(QLatin1String("cppIn"));
+ toCppConv.append(u"cppIn"_s);
} else if (!sourceType.isWrapperType()) {
StringStream tcc(TextStream::Language::Cpp);
writeToCppConversion(tcc, sourceType, metaClass, pyInVariable,
- u"/*BOZO-1061*/"_qs);
+ u"/*BOZO-1061*/"_s);
toCppConv = tcc.toString();
}
}
@@ -1779,14 +1783,14 @@ void CppGenerator::writeConverterRegister(TextStream &s, const AbstractMetaClass
{
Indentation indent(s);
QString sourceTypeName = metaClass->name();
- QString targetTypeName = sourceTypeName + QLatin1String("_PTR");
+ QString targetTypeName = sourceTypeName + u"_PTR"_s;
s << pythonToCppFunctionName(sourceTypeName, targetTypeName) << ',' << '\n'
<< convertibleToCppFunctionName(sourceTypeName, targetTypeName) << ',' << '\n';
std::swap(targetTypeName, sourceTypeName);
s << cppToPythonFunctionName(sourceTypeName, targetTypeName);
if (typeEntry->isValue() || typeEntry->isSmartPointer()) {
s << ',' << '\n';
- sourceTypeName = metaClass->name() + QLatin1String("_COPY");
+ sourceTypeName = metaClass->name() + u"_COPY"_s;
s << cppToPythonFunctionName(sourceTypeName, targetTypeName);
}
}
@@ -1803,10 +1807,10 @@ void CppGenerator::writeConverterRegister(TextStream &s, const AbstractMetaClass
auto writeConversionsForType = [writeConversions](const QString &fullTypeName)
{
- QStringList lst = fullTypeName.split(QLatin1String("::"),
+ QStringList lst = fullTypeName.split(u"::"_s,
Qt::SkipEmptyParts);
while (!lst.isEmpty()) {
- QString signature = lst.join(QLatin1String("::"));
+ QString signature = lst.join(u"::"_s);
writeConversions(signature);
lst.removeFirst();
}
@@ -1819,11 +1823,11 @@ void CppGenerator::writeConverterRegister(TextStream &s, const AbstractMetaClass
const QString &smartPointerType = classContext.preciseType().instantiations().at(0).cppSignature();
const QString &smartPointerName = classContext.preciseType().typeEntry()->name();
- QStringList lst = smartPointerType.split(QLatin1String("::"),
+ QStringList lst = smartPointerType.split(u"::"_s,
Qt::SkipEmptyParts);
while (!lst.isEmpty()) {
- QString signature = lst.join(QLatin1String("::"));
- writeConversions(smartPointerName + u'<' + signature + u" >"_qs);
+ QString signature = lst.join(u"::"_s);
+ writeConversions(smartPointerName + u'<' + signature + u" >"_s);
lst.removeFirst();
}
@@ -1852,10 +1856,10 @@ void CppGenerator::writeConverterRegister(TextStream &s, const AbstractMetaClass
// Python to C++ copy (value, not pointer neither reference) conversion.
s << "// Add Python to C++ copy (value, not pointer neither reference) conversion to type converter.\n";
QString sourceTypeName = metaClass->name();
- QString targetTypeName = sourceTypeName + QLatin1String("_COPY");
+ QString targetTypeName = sourceTypeName + u"_COPY"_s;
QString toCpp = pythonToCppFunctionName(sourceTypeName, targetTypeName);
QString isConv = convertibleToCppFunctionName(sourceTypeName, targetTypeName);
- writeAddPythonToCppConversion(s, QLatin1String("converter"), toCpp, isConv);
+ writeAddPythonToCppConversion(s, u"converter"_s, toCpp, isConv);
// User provided implicit conversions.
@@ -1881,10 +1885,10 @@ void CppGenerator::writeConverterRegister(TextStream &s, const AbstractMetaClass
}
QString toCpp = pythonToCppFunctionName(sourceType, targetType);
QString isConv = convertibleToCppFunctionName(sourceType, targetType);
- writeAddPythonToCppConversion(s, QLatin1String("converter"), toCpp, isConv);
+ writeAddPythonToCppConversion(s, u"converter"_s, toCpp, isConv);
}
- writeCustomConverterRegister(s, typeEntry->customConversion(), u"converter"_qs);
+ writeCustomConverterRegister(s, typeEntry->customConversion(), u"converter"_s);
}
void CppGenerator::writeCustomConverterRegister(TextStream &s, const CustomConversion *customConversion,
@@ -2008,7 +2012,7 @@ static const char fullName[] = ")" << fullPythonFunctionName(rfunc, true)
if (overloadData.pythonFunctionWrapperUsesListOfArguments())
s << '[' << maxArgs << ']';
s << ";\n";
- writeUnusedVariableCast(s, QLatin1String(PYTHON_TO_CPP_VAR));
+ writeUnusedVariableCast(s, QLatin1StringView(PYTHON_TO_CPP_VAR));
}
if (initPythonArguments) {
@@ -2288,7 +2292,7 @@ void CppGenerator::writeArgumentsInitializer(TextStream &s, const OverloadData &
{
const auto rfunc = overloadData.referenceFunction();
s << "PyTuple_GET_SIZE(args);\n";
- writeUnusedVariableCast(s, QLatin1String("numArgs"));
+ writeUnusedVariableCast(s, u"numArgs"_s);
int minArgs = overloadData.minArgs();
int maxArgs = overloadData.maxArgs();
@@ -2347,7 +2351,7 @@ void CppGenerator::writeArgumentsInitializer(TextStream &s, const OverloadData &
else
funcName = rfunc->name();
- QString argsVar = overloadData.hasVarargs() ? QLatin1String("nonvarargs") : QLatin1String("args");
+ QString argsVar = overloadData.hasVarargs() ? u"nonvarargs"_s : u"args"_s;
s << "if (!";
if (usesNamedArguments) {
s << "PyArg_ParseTuple(" << argsVar << ", \"|" << QByteArray(maxArgs, 'O')
@@ -2369,7 +2373,7 @@ void CppGenerator::writeCppSelfConversion(TextStream &s, const GeneratorContext
return;
}
- static const QString pythonSelfVar = QLatin1String("self");
+ static const QString pythonSelfVar = u"self"_s;
if (useWrapperClass)
s << "static_cast<" << className << " *>(";
s << cpythonWrapperCPtr(context.metaClass(), pythonSelfVar);
@@ -2381,7 +2385,7 @@ void CppGenerator::writeSmartPointerCppSelfConversion(TextStream &s,
const GeneratorContext &context)
{
Q_ASSERT(context.forSmartPointer());
- s << cpythonWrapperCPtr(context.preciseType(), u"self"_qs);
+ s << cpythonWrapperCPtr(context.preciseType(), u"self"_s);
}
static inline void writeCppSelfVarDef(TextStream &s,
@@ -2399,7 +2403,7 @@ void CppGenerator::writeSmartPointerCppSelfDefinition(TextStream &s,
CppSelfDefinitionFlags flags)
{
Q_ASSERT(context.forSmartPointer());
- writeInvalidPyObjectCheck(s, u"self"_qs, errorReturn);
+ writeInvalidPyObjectCheck(s, u"self"_s, errorReturn);
writeCppSelfVarDef(s, flags);
writeSmartPointerCppSelfConversion(s, context);
s << ";\n";
@@ -2425,9 +2429,9 @@ void CppGenerator::writeCppSelfDefinition(TextStream &s,
Q_ASSERT(!useWrapperClass || context.useWrapper());
const QString className = useWrapperClass
? context.wrapperName()
- : (QLatin1String("::") + metaClass->qualifiedCppName());
+ : (u"::"_s + metaClass->qualifiedCppName());
- writeInvalidPyObjectCheck(s, u"self"_qs, errorReturn);
+ writeInvalidPyObjectCheck(s, u"self"_s, errorReturn);
if (flags.testFlag(CppSelfAsReference)) {
writeCppSelfVarDef(s, flags);
@@ -2442,13 +2446,13 @@ void CppGenerator::writeCppSelfDefinition(TextStream &s,
writeCppSelfVarDef(s, flags);
writeCppSelfConversion(s, context, className, useWrapperClass);
s << ";\n";
- writeUnusedVariableCast(s, QLatin1String(CPP_SELF_VAR));
+ writeUnusedVariableCast(s, QLatin1StringView(CPP_SELF_VAR));
}
return;
}
s << className << " *" << CPP_SELF_VAR << " = nullptr;\n";
- writeUnusedVariableCast(s, QLatin1String(CPP_SELF_VAR));
+ writeUnusedVariableCast(s, QLatin1StringView(CPP_SELF_VAR));
// Checks if the underlying C++ object is valid.
s << "if (self)\n";
@@ -2491,7 +2495,7 @@ void CppGenerator::writeErrorSection(TextStream &s, const OverloadData &overload
s << '\n' << cpythonFunctionName(rfunc) << "_TypeError:\n";
Indentation indentation(s);
QString argsVar = overloadData.pythonFunctionWrapperUsesListOfArguments()
- ? QLatin1String("args") : QLatin1String(PYTHON_ARG);
+ ? u"args"_s : QLatin1StringView(PYTHON_ARG);
s << "Shiboken::setErrorAboutWrongArguments(" << argsVar << ", fullName, errInfo);\n"
<< errorReturn;
}
@@ -2522,11 +2526,11 @@ void CppGenerator::writeInvalidPyObjectCheck(TextStream &s, const QString &pyObj
static QString pythonToCppConverterForArgumentName(const QString &argumentName)
{
- static const QRegularExpression pyArgsRegex(QLatin1String(PYTHON_ARGS)
- + QLatin1String(R"((\[\d+[-]?\d*\]))"));
+ static const QRegularExpression pyArgsRegex(QLatin1StringView(PYTHON_ARGS)
+ + uR"((\[\d+[-]?\d*\]))"_s);
Q_ASSERT(pyArgsRegex.isValid());
const QRegularExpressionMatch match = pyArgsRegex.match(argumentName);
- QString result = QLatin1String(PYTHON_TO_CPP_VAR);
+ QString result = QLatin1StringView(PYTHON_TO_CPP_VAR);
if (match.hasMatch())
result += match.captured(1);
return result;
@@ -2555,16 +2559,16 @@ void CppGenerator::writeTypeCheck(TextStream &s, const AbstractMetaType &argType
// TODO-CONVERTER -----------------------------------------------------------------------
if (!argType.typeEntry()->isCustom()) {
typeCheck = u'(' + pythonToCppConverterForArgumentName(argumentName)
- + u" = "_qs + typeCheck + u"))"_qs;
+ + u" = "_s + typeCheck + u"))"_s;
if (!isNumber && argType.typeEntry()->isCppPrimitive()) {
typeCheck.prepend(cpythonCheckFunction(argType) + u'('
- + argumentName + u") && "_qs);
+ + argumentName + u") && "_s);
}
}
// TODO-CONVERTER -----------------------------------------------------------------------
if (rejectNull)
- typeCheck = u'(' + argumentName + u" != Py_None && "_qs + typeCheck + u')';
+ typeCheck = u'(' + argumentName + u" != Py_None && "_s + typeCheck + u')';
s << typeCheck;
}
@@ -2728,7 +2732,7 @@ qsizetype CppGenerator::writePythonToCppTypeConversion(TextStream &s,
qsizetype indirections = -type.indirectionsV().size();
- QString cppOutAux = cppOut + QLatin1String("_local");
+ QString cppOutAux = cppOut + u"_local"_s;
const bool isPrimitive = typeEntry->isPrimitive();
const bool isEnum = typeEntry->isEnum();
@@ -2766,7 +2770,7 @@ qsizetype CppGenerator::writePythonToCppTypeConversion(TextStream &s,
if (isEnum && avoidProtectedHack()) {
auto metaEnum = api().findAbstractMetaEnum(type.typeEntry());
if (metaEnum.has_value() && metaEnum->isProtected()) {
- typeName = wrapperName(context) + QLatin1String("::")
+ typeName = wrapperName(context) + u"::"_s
+ metaEnum.value().name();
isProtectedEnum = true;
}
@@ -2816,7 +2820,7 @@ qsizetype CppGenerator::writePythonToCppTypeConversion(TextStream &s,
QString pythonToCppFunc = pythonToCppConverterForArgumentName(pyIn);
- QString pythonToCppCall = pythonToCppFunc + u'(' + pyIn + u", &"_qs
+ QString pythonToCppCall = pythonToCppFunc + u'(' + pyIn + u", &"_s
+ cppOut + u')';
if (!valueOrPointer) {
// pythonToCppFunc may be 0 when less parameters are passed and
@@ -2856,10 +2860,10 @@ static void addConversionRuleCodeSnippet(CodeSnipList &snippetList, QString &rul
if (rule.isEmpty())
return;
if (snippetLanguage == TypeSystem::TargetLangCode) {
- rule.replace(QLatin1String("%in"), inputName);
- rule.replace(QLatin1String("%out"), outputName + QLatin1String("_out"));
+ rule.replace(u"%in"_s, inputName);
+ rule.replace(u"%out"_s, outputName + u"_out"_s);
} else {
- rule.replace(QLatin1String("%out"), outputName);
+ rule.replace(u"%out"_s, outputName);
}
CodeSnip snip(snippetLanguage);
snip.position = (snippetLanguage == TypeSystem::NativeCode) ? TypeSystem::CodeSnipPositionAny : TypeSystem::CodeSnipPositionBeginning;
@@ -3023,7 +3027,7 @@ void CppGenerator::writeOverloadedFunctionDecisorEngine(TextStream &s,
QString pyArgName = (usePyArgs && maxArgs > 1)
? pythonArgsAt(child->argPos())
- : QLatin1String(PYTHON_ARG);
+ : QLatin1StringView(PYTHON_ARG);
auto od = child;
int startArg = od->argPos();
int sequenceArgCount = 0;
@@ -3069,16 +3073,16 @@ void CppGenerator::writeOverloadedFunctionDecisorEngine(TextStream &s,
int numArgs = args.size() - OverloadData::numberOfRemovedArguments(refFunc);
if (isVarargs)
--numArgs;
- QString check = (isVarargs ? u"numArgs >= "_qs : u"numArgs == "_qs)
+ QString check = (isVarargs ? u"numArgs >= "_s : u"numArgs == "_s)
+ QString::number(numArgs);
typeChecks.prepend(check);
} else if (usePyArgs && sequenceArgCount > 0) {
- typeChecks.prepend(u"numArgs >= "_qs + QString::number(startArg + sequenceArgCount));
+ typeChecks.prepend(u"numArgs >= "_s + QString::number(startArg + sequenceArgCount));
} else if (refFunc->isOperatorOverload() && !refFunc->isCallOperator()) {
QString check;
if (!refFunc->isReverseOperator())
check.append(u'!');
- check.append(QLatin1String("isReverse"));
+ check.append(u"isReverse"_s);
typeChecks.prepend(check);
}
@@ -3092,7 +3096,7 @@ void CppGenerator::writeOverloadedFunctionDecisorEngine(TextStream &s,
s << "true";
} else {
Indentation indent(s);
- s << typeChecks.join(QLatin1String("\n&& "));
+ s << typeChecks.join(u"\n&& "_s);
}
s << ") {\n";
{
@@ -3146,13 +3150,13 @@ void CppGenerator::writeSingleFunctionCall(TextStream &s,
{
if (func->isDeprecated()) {
s << "Shiboken::warning(PyExc_DeprecationWarning, 1, \"Function: '"
- << func->signature().replace(QLatin1String("::"), QLatin1String("."))
+ << func->signature().replace(u"::"_s, u"."_s)
<< "' is marked as deprecated, please check the documentation for more information.\");\n";
}
if (func->functionType() == AbstractMetaFunction::EmptyFunction) {
s << "PyErr_Format(PyExc_TypeError, \"%s is a private method.\", \""
- << func->signature().replace(QLatin1String("::"), QLatin1String("."))
+ << func->signature().replace(u"::"_s, u"."_s)
<< "\");\n" << errorReturn;
return;
}
@@ -3171,7 +3175,7 @@ void CppGenerator::writeSingleFunctionCall(TextStream &s,
const AbstractMetaArgument &arg = func->arguments().at(argIdx);
if (arg.isModifiedRemoved()) {
if (!arg.defaultValueExpression().isEmpty()) {
- const QString cppArgRemoved = QLatin1String(CPP_ARG_REMOVED)
+ const QString cppArgRemoved = QLatin1StringView(CPP_ARG_REMOVED)
+ QString::number(argIdx);
s << getFullTypeName(arg.type()) << ' ' << cppArgRemoved;
s << " = " << arg.defaultValueExpression() << ";\n";
@@ -3194,8 +3198,9 @@ void CppGenerator::writeSingleFunctionCall(TextStream &s,
continue;
auto argType = getArgumentType(func, argIdx);
int argPos = argIdx - removedArgs;
- QString argName = QLatin1String(CPP_ARG) + QString::number(argPos);
- QString pyArgName = usePyArgs ? pythonArgsAt(argPos) : QLatin1String(PYTHON_ARG);
+ QString argName = QLatin1StringView(CPP_ARG) + QString::number(argPos);
+ QString pyArgName = usePyArgs ? pythonArgsAt(argPos)
+ : QLatin1StringView(PYTHON_ARG);
writeArgumentConversion(s, argType, argName, pyArgName, errorReturn,
func->implementingClass(), arg.defaultValueExpression(),
func->isUserAdded());
@@ -3219,12 +3224,12 @@ QString CppGenerator::cppToPythonFunctionName(const QString &sourceTypeName, QSt
{
if (targetTypeName.isEmpty())
targetTypeName = sourceTypeName;
- return sourceTypeName + QLatin1String("_CppToPython_") + targetTypeName;
+ return sourceTypeName + u"_CppToPython_"_s + targetTypeName;
}
QString CppGenerator::pythonToCppFunctionName(const QString &sourceTypeName, const QString &targetTypeName)
{
- return sourceTypeName + QLatin1String("_PythonToCpp_") + targetTypeName;
+ return sourceTypeName + u"_PythonToCpp_"_s + targetTypeName;
}
QString CppGenerator::pythonToCppFunctionName(const AbstractMetaType &sourceType, const AbstractMetaType &targetType)
{
@@ -3238,8 +3243,8 @@ QString CppGenerator::pythonToCppFunctionName(const CustomConversion::TargetToNa
QString CppGenerator::convertibleToCppFunctionName(const QString &sourceTypeName, const QString &targetTypeName)
{
- return QLatin1String("is_") + sourceTypeName + QLatin1String("_PythonToCpp_")
- + targetTypeName + QLatin1String("_Convertible");
+ return u"is_"_s + sourceTypeName + u"_PythonToCpp_"_s
+ + targetTypeName + u"_Convertible"_s;
}
QString CppGenerator::convertibleToCppFunctionName(const AbstractMetaType &sourceType, const AbstractMetaType &targetType)
{
@@ -3281,10 +3286,10 @@ static void replaceCppToPythonVariables(QString &code, const QString &typeName,
bool constRef = false)
{
CodeSnipAbstract::prependCode(&code, writeCppInRef(typeName, constRef));
- code.replace(QLatin1String("%INTYPE"), typeName);
- code.replace(QLatin1String("%OUTTYPE"), QLatin1String("PyObject *"));
- code.replace(QLatin1String("%in"), QLatin1String("cppInRef"));
- code.replace(QLatin1String("%out"), QLatin1String("pyOut"));
+ code.replace(u"%INTYPE"_s, typeName);
+ code.replace(u"%OUTTYPE"_s, u"PyObject *"_s);
+ code.replace(u"%in"_s, u"cppInRef"_s);
+ code.replace(u"%out"_s, u"pyOut"_s);
}
void CppGenerator::writeCppToPythonFunction(TextStream &s, const CustomConversion *customConversion) const
@@ -3314,8 +3319,8 @@ void CppGenerator::writeCppToPythonFunction(TextStream &s, const AbstractMetaTyp
const AbstractMetaType &type = containerType.instantiations().at(i);
QString typeName = getFullTypeName(type);
if (type.isConstant())
- typeName = QLatin1String("const ") + typeName;
- code.replace(u"%INTYPE_"_qs + QString::number(i), typeName);
+ typeName = u"const "_s + typeName;
+ code.replace(u"%INTYPE_"_s + QString::number(i), typeName);
}
replaceCppToPythonVariables(code, getFullTypeNameWithoutModifiers(containerType), true);
processCodeSnip(code);
@@ -3369,7 +3374,7 @@ void CppGenerator::writePythonToCppConversionFunctions(TextStream &s,
// Python to C++ conversion function.
StringStream c(TextStream::Language::Cpp);
if (conversion.isEmpty())
- conversion = u'*' + cpythonWrapperCPtr(sourceType, QLatin1String("pyIn"));
+ conversion = u'*' + cpythonWrapperCPtr(sourceType, u"pyIn"_s);
if (!preConversion.isEmpty())
c << preConversion << '\n';
const QString fullTypeName = targetType.isSmartPointer()
@@ -3383,7 +3388,7 @@ void CppGenerator::writePythonToCppConversionFunctions(TextStream &s,
// Python to C++ convertible check function.
if (typeCheck.isEmpty())
- typeCheck = u"PyObject_TypeCheck(pyIn, "_qs + sourcePyType + u')';
+ typeCheck = u"PyObject_TypeCheck(pyIn, "_s + sourcePyType + u')';
writeIsPythonConvertibleToCppFunction(s, sourceTypeName, targetTypeName, typeCheck);
s << '\n';
}
@@ -3398,12 +3403,12 @@ void CppGenerator::writePythonToCppConversionFunctions(TextStream &s,
if (toNative->sourceType())
inType = cpythonTypeNameExt(toNative->sourceType());
else
- inType = u'(' + toNative->sourceTypeName() + u"_TypeF())"_qs;
- code.replace(QLatin1String("%INTYPE"), inType);
- code.replace(QLatin1String("%OUTTYPE"), targetType->qualifiedCppName());
- code.replace(QLatin1String("%in"), QLatin1String("pyIn"));
- code.replace(QLatin1String("%out"),
- QLatin1String("*reinterpret_cast<") + getFullTypeName(targetType) + QLatin1String(" *>(cppOut)"));
+ inType = u'(' + toNative->sourceTypeName() + u"_TypeF())"_s;
+ code.replace(u"%INTYPE"_s, inType);
+ code.replace(u"%OUTTYPE"_s, targetType->qualifiedCppName());
+ code.replace(u"%in"_s, u"pyIn"_s);
+ code.replace(u"%out"_s,
+ u"*reinterpret_cast<"_s + getFullTypeName(targetType) + u" *>(cppOut)"_s);
QString sourceTypeName = fixedCppTypeName(toNative);
QString targetTypeName = fixedCppTypeName(targetType);
@@ -3414,11 +3419,11 @@ void CppGenerator::writePythonToCppConversionFunctions(TextStream &s,
if (typeCheck.isEmpty()) {
QString pyTypeName = toNative->sourceTypeName();
if (pyTypeName == u"Py_None" || pyTypeName == u"PyNone")
- typeCheck = QLatin1String("%in == Py_None");
+ typeCheck = u"%in == Py_None"_s;
else if (pyTypeName == u"SbkEnumType")
- typeCheck = QLatin1String("Shiboken::isShibokenEnum(%in)");
+ typeCheck = u"Shiboken::isShibokenEnum(%in)"_s;
else if (pyTypeName == u"SbkObject")
- typeCheck = QLatin1String("Shiboken::Object::checkType(%in)");
+ typeCheck = u"Shiboken::Object::checkType(%in)"_s;
}
if (typeCheck.isEmpty()) {
if (!toNative->sourceType() || toNative->sourceType()->isPrimitive()) {
@@ -3427,10 +3432,10 @@ void CppGenerator::writePythonToCppConversionFunctions(TextStream &s,
<< "' must provide either an input type check function or a non primitive type entry.";
throw Exception(m);
}
- typeCheck = u"PyObject_TypeCheck(%in, "_qs
+ typeCheck = u"PyObject_TypeCheck(%in, "_s
+ cpythonTypeNameExt(toNative->sourceType()) + u')';
}
- typeCheck.replace(QLatin1String("%in"), QLatin1String("pyIn"));
+ typeCheck.replace(u"%in"_s, u"pyIn"_s);
processCodeSnip(typeCheck);
writeIsPythonConvertibleToCppFunction(s, sourceTypeName, targetTypeName, typeCheck);
}
@@ -3450,8 +3455,8 @@ void CppGenerator::writePythonToCppConversionFunctions(TextStream &s, const Abst
// Python to C++ conversion function.
QString cppTypeName = getFullTypeNameWithoutModifiers(containerType);
QString code = toCppConversions.constFirst()->conversion();
- const QString line = QLatin1String("auto &cppOutRef = *reinterpret_cast<")
- + cppTypeName + QLatin1String(" *>(cppOut);");
+ const QString line = u"auto &cppOutRef = *reinterpret_cast<"_s
+ + cppTypeName + u" *>(cppOut);"_s;
CodeSnipAbstract::prependCode(&code, line);
for (qsizetype i = 0; i < containerType.instantiations().size(); ++i) {
const AbstractMetaType &type = containerType.instantiations().at(i);
@@ -3468,22 +3473,22 @@ void CppGenerator::writePythonToCppConversionFunctions(TextStream &s, const Abst
rightCode.replace(varName, u'*' + varName);
code.replace(pos, code.size() - pos, rightCode);
}
- typeName.append(QLatin1String(" *"));
+ typeName.append(u" *"_s);
}
- code.replace(u"%OUTTYPE_"_qs + QString::number(i), typeName);
+ code.replace(u"%OUTTYPE_"_s + QString::number(i), typeName);
}
- code.replace(QLatin1String("%OUTTYPE"), cppTypeName);
- code.replace(QLatin1String("%in"), QLatin1String("pyIn"));
- code.replace(QLatin1String("%out"), QLatin1String("cppOutRef"));
+ code.replace(u"%OUTTYPE"_s, cppTypeName);
+ code.replace(u"%in"_s, u"pyIn"_s);
+ code.replace(u"%out"_s, u"cppOutRef"_s);
QString typeName = fixedCppTypeName(containerType);
writePythonToCppFunction(s, code, typeName, typeName);
// Python to C++ convertible check function.
QString typeCheck = cpythonCheckFunction(containerType);
if (typeCheck.isEmpty())
- typeCheck = QLatin1String("false");
+ typeCheck = u"false"_s;
else
- typeCheck = typeCheck + QLatin1String("pyIn)");
+ typeCheck = typeCheck + u"pyIn)"_s;
writeIsPythonConvertibleToCppFunction(s, typeName, typeName, typeCheck);
s << '\n';
}
@@ -3544,8 +3549,9 @@ void CppGenerator::writeNamedArgumentResolution(TextStream &s, const AbstractMet
for (const AbstractMetaArgument &arg : args) {
const int pyArgIndex = arg.argumentIndex()
- OverloadData::numberOfRemovedArguments(func, arg.argumentIndex());
- QString pyArgName = usePyArgs ? pythonArgsAt(pyArgIndex) : QLatin1String(PYTHON_ARG);
- QString pyKeyName = QLatin1String("key_") + arg.name();
+ QString pyArgName = usePyArgs ? pythonArgsAt(pyArgIndex)
+ : QLatin1StringView(PYTHON_ARG);
+ QString pyKeyName = u"key_"_s + arg.name();
s << "static PyObject *const " << pyKeyName
<< " = Shiboken::String::createStaticString(\"" << arg.name() << "\");\n"
<< "if (PyDict_Contains(kwds, " << pyKeyName << ")) {\n";
@@ -3598,13 +3604,13 @@ QString CppGenerator::argumentNameFromIndex(const ApiExtractorResult &api,
{
switch (argIndex) {
case -1:
- return u"self"_qs;
+ return u"self"_s;
case 0:
- return QLatin1String(PYTHON_RETURN_VAR);
+ return QLatin1StringView(PYTHON_RETURN_VAR);
case 1: { // Single argument?
OverloadData data(getFunctionGroups(func->implementingClass()).value(func->name()), api);
if (!data.pythonFunctionWrapperUsesListOfArguments())
- return QLatin1String(PYTHON_ARG);
+ return QLatin1StringView(PYTHON_ARG);
break;
}
}
@@ -3720,19 +3726,19 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr
// If have conversion rules I will use this for removed args
if (hasConversionRule)
- userArgs << arg.name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX);
+ userArgs << arg.name() + QLatin1StringView(CONV_RULE_OUT_VAR_SUFFIX);
else if (!arg.defaultValueExpression().isEmpty())
- userArgs.append(QLatin1String(CPP_ARG_REMOVED) + QString::number(i));
+ userArgs.append(QLatin1StringView(CPP_ARG_REMOVED) + QString::number(i));
} else {
if (hasConversionRule) {
- userArgs.append(arg.name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX));
+ userArgs.append(arg.name() + QLatin1StringView(CONV_RULE_OUT_VAR_SUFFIX));
} else {
const int idx = arg.argumentIndex() - removedArgs;
const auto deRef = arg.type().shouldDereferenceArgument();
QString argName;
if (deRef > 0)
argName += QString(deRef, u'*');
- argName += QLatin1String(CPP_ARG) + QString::number(idx);
+ argName += QLatin1StringView(CPP_ARG) + QString::number(idx);
userArgs.append(argName);
}
}
@@ -3755,9 +3761,9 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr
argsClear = false;
otherArgsModified |= defValModified || hasConversionRule || arg.isModifiedRemoved();
if (hasConversionRule)
- otherArgs.prepend(arg.name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX));
+ otherArgs.prepend(arg.name() + QLatin1StringView(CONV_RULE_OUT_VAR_SUFFIX));
else
- otherArgs.prepend(QLatin1String(CPP_ARG_REMOVED) + QString::number(i));
+ otherArgs.prepend(QLatin1StringView(CPP_ARG_REMOVED) + QString::number(i));
}
if (otherArgsModified)
userArgs << otherArgs;
@@ -3771,9 +3777,9 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr
QString firstArg(u'(');
if (!func->isPointerOperator()) // no de-reference operator
firstArg += u'*';
- firstArg += QLatin1String(CPP_SELF_VAR);
+ firstArg += QLatin1StringView(CPP_SELF_VAR);
firstArg += u')';
- QString secondArg = QLatin1String(CPP_ARG0);
+ QString secondArg = QLatin1StringView(CPP_ARG0);
if (!func->isUnaryOperator()) {
auto deRef = func->arguments().constFirst().type().shouldDereferenceArgument();
AbstractMetaType::applyDereference(&secondArg, deRef);
@@ -3811,7 +3817,7 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr
<< "(*" << CPP_ARG0 << ')';
} else {
const QString ctorCall = context.effectiveClassName() + u'('
- + userArgs.join(u", "_qs) + u')';
+ + userArgs.join(u", "_s) + u')';
if (usePySideExtensions() && owner->isQObject()) {
s << "void *addr = PySide::nextQObjectMemoryAddr();\n";
uva << "if (addr) {\n";
@@ -3845,19 +3851,20 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr
if (func->isStatic()) {
mc << "::" << methodCallClassName << "::";
} else {
+ const QString cppSelfVar = QLatin1StringView(CPP_SELF_VAR);
const QString selfVarCast = func->ownerClass() == func->implementingClass()
- ? QLatin1String(CPP_SELF_VAR)
- : QLatin1String("reinterpret_cast<") + methodCallClassName
- + QLatin1String(" *>(") + QLatin1String(CPP_SELF_VAR) + u')';
+ ? cppSelfVar
+ : u"reinterpret_cast<"_s + methodCallClassName
+ + u" *>("_s + cppSelfVar + u')';
if (func->isConstant()) {
if (avoidProtectedHack()) {
mc << "const_cast<const ::";
if (ownerClass->cppWrapper().testFlag(AbstractMetaClass::CppProtectedHackWrapper)) {
// PYSIDE-500: Need a special wrapper cast when inherited
const QString selfWrapCast = ownerClass == func->implementingClass()
- ? QLatin1String(CPP_SELF_VAR)
- : QLatin1String("reinterpret_cast<") + wrapperName(ownerClass)
- + QLatin1String(" *>(") + QLatin1String(CPP_SELF_VAR) + u')';
+ ? cppSelfVar
+ : u"reinterpret_cast<"_s + wrapperName(ownerClass)
+ + u" *>("_s + cppSelfVar + u')';
mc << wrapperName(ownerClass);
mc << " *>(" << selfWrapCast << ")->";
}
@@ -3887,21 +3894,21 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr
if (!func->isAbstract())
mc << (func->isProtected() ? wrapperName(func->ownerClass()) :
- QLatin1String("::")
+ u"::"_s
+ methodCallClassName) << "::";
mc << func->originalName() << "_protected";
}
} else {
mc << func->originalName();
}
- mc << '(' << userArgs.join(QLatin1String(", ")) << ')';
+ mc << '(' << userArgs.join(u", "_s) << ')';
if (!func->isAbstract() && func->isVirtual()) {
if (!avoidProtectedHack() || !func->isProtected()) {
QString virtualCall = mc;
QString normalCall = virtualCall;
- virtualCall.replace(QLatin1String("%CLASS_NAME"),
+ virtualCall.replace(u"%CLASS_NAME"_s,
methodCallClassName);
- normalCall.remove(QLatin1String("::%CLASS_NAME::"));
+ normalCall.remove(u"::%CLASS_NAME::"_s);
mc.clear();
mc << "Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject *>(self))\n"
<< " ? " << virtualCall << '\n'
@@ -3935,7 +3942,7 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr
if (metaEnum.has_value()) {
QString enumName;
if (metaEnum->isProtected()) {
- enumName = context.wrapperName() + QLatin1String("::")
+ enumName = context.wrapperName() + u"::"_s
+ metaEnum.value().name();
} else {
enumName = func->type().cppSignature();
@@ -3953,7 +3960,7 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr
s << func->type().cppSignature();
if (func->type().isObjectTypeUsedAsValueType()) {
s << '*';
- methodCall = QLatin1String("new ")
+ methodCall = u"new "_s
+ func->type().typeEntry()->qualifiedCppName()
+ u'(' + mc.toString() + u')';
}
@@ -3971,7 +3978,8 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr
// Convert result
const auto funcType = func->type();
if (!func->conversionRule(TypeSystem::TargetLangCode, 0).isEmpty()) {
- writeConversionRule(s, func, TypeSystem::TargetLangCode, QLatin1String(PYTHON_RETURN_VAR));
+ writeConversionRule(s, func, TypeSystem::TargetLangCode,
+ QLatin1StringView(PYTHON_RETURN_VAR));
} else if (!isCtor && !func->isInplaceOperator() && !func->isVoid()
&& !func->injectedCodeHasReturnValueAttribution(TypeSystem::TargetLangCode)) {
if (func->type().isObjectTypeUsedAsValueType()) {
@@ -3985,7 +3993,8 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr
<< "(&" << CPP_RETURN_VAR << ");\n";
} else {
s << PYTHON_RETURN_VAR << " = ";
- writeToPythonConversion(s, funcType, func->ownerClass(), QLatin1String(CPP_RETURN_VAR));
+ writeToPythonConversion(s, funcType, func->ownerClass(),
+ QLatin1StringView(CPP_RETURN_VAR));
}
s << ";\n";
}
@@ -4057,7 +4066,7 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr
}
const int argIndex = arg_mod.index();
const QString pyArgName = refCount.action == ReferenceCount::Remove
- ? u"Py_None"_qs : argumentNameFromIndex(api(), func, argIndex);
+ ? u"Py_None"_s : argumentNameFromIndex(api(), func, argIndex);
if (refCount.action == ReferenceCount::Add || refCount.action == ReferenceCount::Set)
s << "Shiboken::Object::keepReference(";
@@ -4181,7 +4190,7 @@ void CppGenerator::writeEnumConverterInitialization(TextStream &s, const TypeEnt
{
if (!enumType)
return;
- QString enumFlagName = enumType->isFlags() ? QLatin1String("flag") : QLatin1String("enum");
+ QString enumFlagName = enumType->isFlags() ? u"flag"_s : u"enum"_s;
QString enumPythonType = cpythonTypeNameExt(enumType);
const FlagsTypeEntry *flags = nullptr;
@@ -4204,17 +4213,17 @@ void CppGenerator::writeEnumConverterInitialization(TextStream &s, const TypeEnt
QString enumTypeName = fixedCppTypeName(flags->originator());
QString toCpp = pythonToCppFunctionName(enumTypeName, typeName);
QString isConv = convertibleToCppFunctionName(enumTypeName, typeName);
- writeAddPythonToCppConversion(s, QLatin1String("converter"), toCpp, isConv);
+ writeAddPythonToCppConversion(s, u"converter"_s, toCpp, isConv);
}
QString toCpp = pythonToCppFunctionName(typeName, typeName);
QString isConv = convertibleToCppFunctionName(typeName, typeName);
- writeAddPythonToCppConversion(s, QLatin1String("converter"), toCpp, isConv);
+ writeAddPythonToCppConversion(s, u"converter"_s, toCpp, isConv);
if (flags) {
- QString toCpp = pythonToCppFunctionName(QLatin1String("number"), typeName);
- QString isConv = convertibleToCppFunctionName(QLatin1String("number"), typeName);
- writeAddPythonToCppConversion(s, QLatin1String("converter"), toCpp, isConv);
+ QString toCpp = pythonToCppFunctionName(u"number"_s, typeName);
+ QString isConv = convertibleToCppFunctionName(u"number"_s, typeName);
+ writeAddPythonToCppConversion(s, u"converter"_s, toCpp, isConv);
}
s << "Shiboken::Enum::setTypeConverter(" << enumPythonType
@@ -4318,8 +4327,8 @@ void CppGenerator::writeSmartPointerConverterInitialization(TextStream &s, const
const auto smartTargetType = opt.value();
s << "// Convert to SmartPointer derived class: ["
<< smartTargetType.cppSignature() << "]\n";
- const QString converter = u"Shiboken::Conversions::getConverter(\""_qs
- + smartTargetType.cppSignature() + u"\")"_qs;
+ const QString converter = u"Shiboken::Conversions::getConverter(\""_s
+ + smartTargetType.cppSignature() + u"\")"_s;
writeConversionRegister(type, fixedCppTypeName(smartTargetType), converter);
} else {
s << "// Class not found:" << type.instantiations().at(0).cppSignature();
@@ -4347,7 +4356,7 @@ void CppGenerator::writeExtendedConverterInitialization(TextStream &s, const Typ
QString CppGenerator::multipleInheritanceInitializerFunctionName(const AbstractMetaClass *metaClass)
{
- return cpythonBaseName(metaClass->typeEntry()) + QLatin1String("_mi_init");
+ return cpythonBaseName(metaClass->typeEntry()) + u"_mi_init"_s;
}
bool CppGenerator::supportsMappingProtocol(const AbstractMetaClass *metaClass)
@@ -4438,24 +4447,24 @@ void CppGenerator::writeClassDefinition(TextStream &s,
}
if (!metaClass->baseClass())
- baseClassName = QLatin1String("SbkObject_TypeF()");
+ baseClassName = u"SbkObject_TypeF()"_s;
bool onlyPrivCtor = !metaClass->hasNonPrivateConstructor();
const bool isQApp = usePySideExtensions()
- && metaClass->inheritsFrom(u"QCoreApplication"_qs);
+ && metaClass->inheritsFrom(u"QCoreApplication"_s);
- QString tp_flags = u"Py_TPFLAGS_DEFAULT"_qs;
+ QString tp_flags = u"Py_TPFLAGS_DEFAULT"_s;
if (!metaClass->attributes().testFlag(AbstractMetaClass::FinalCppClass))
- tp_flags += u"|Py_TPFLAGS_BASETYPE"_qs;
+ tp_flags += u"|Py_TPFLAGS_BASETYPE"_s;
if (metaClass->isNamespace() || metaClass->hasPrivateDestructor()) {
tp_dealloc = metaClass->hasPrivateDestructor() ?
- QLatin1String("SbkDeallocWrapperWithPrivateDtor") :
- QLatin1String("Sbk_object_dealloc /* PYSIDE-832: Prevent replacement of \"0\" with subtype_dealloc. */");
+ u"SbkDeallocWrapperWithPrivateDtor"_s :
+ u"Sbk_object_dealloc /* PYSIDE-832: Prevent replacement of \"0\" with subtype_dealloc. */"_s;
tp_init.clear();
} else {
tp_dealloc = isQApp
- ? QLatin1String("&SbkDeallocQAppWrapper") : QLatin1String("&SbkDeallocWrapper");
+ ? u"&SbkDeallocQAppWrapper"_s : u"&SbkDeallocWrapper"_s;
if (!onlyPrivCtor && !ctors.isEmpty())
tp_init = cpythonFunctionName(ctors.constFirst());
}
@@ -4467,7 +4476,7 @@ void CppGenerator::writeClassDefinition(TextStream &s,
? cpythonSetattroFunctionName(metaClass) : QString();
if (metaClass->hasPrivateDestructor() || onlyPrivCtor) {
- // tp_flags = QLatin1String("Py_TPFLAGS_DEFAULT");
+ // tp_flags = u"Py_TPFLAGS_DEFAULT"_s;
// This is not generally possible, because PySide does not care about
// privacy the same way. This worked before the heap types were used,
// because inheritance is not really checked for static types.
@@ -4476,24 +4485,24 @@ void CppGenerator::writeClassDefinition(TextStream &s,
// PYSIDE-595: No idea how to do non-inheritance correctly.
// Since that is only relevant in shiboken, I used a shortcut for
// PySide.
- tp_new = u"SbkObject_tp_new"_qs;
+ tp_new = u"SbkObject_tp_new"_s;
}
else {
- tp_new = QLatin1String("SbkDummyNew /* PYSIDE-595: Prevent replacement "
- "of \"0\" with base->tp_new. */");
+ tp_new = u"SbkDummyNew /* PYSIDE-595: Prevent replacement "
+ "of \"0\" with base->tp_new. */"_s;
}
}
else if (isQApp) {
- tp_new = u"SbkQApp_tp_new"_qs; // PYSIDE-571: need singleton app
+ tp_new = u"SbkQApp_tp_new"_s; // PYSIDE-571: need singleton app
}
else {
- tp_new = u"SbkObject_tp_new"_qs;
+ tp_new = u"SbkObject_tp_new"_s;
}
- tp_flags.append(QLatin1String("|Py_TPFLAGS_HAVE_GC"));
+ tp_flags.append(u"|Py_TPFLAGS_HAVE_GC"_s);
QString tp_richcompare;
if (generateRichComparison(classContext))
- tp_richcompare = cpythonBaseName(metaClass) + QLatin1String("_richcompare");
+ tp_richcompare = cpythonBaseName(metaClass) + u"_richcompare"_s;
QString tp_getset;
if (shouldGenerateGetSetList(metaClass) && !classContext.forSmartPointer())
@@ -4525,14 +4534,14 @@ void CppGenerator::writeClassDefinition(TextStream &s,
"extern \"C\" {\n";
if (!metaClass->typeEntry()->hashFunction().isEmpty())
- tp_hash = u'&' + cpythonBaseName(metaClass) + QLatin1String("_HashFunc");
+ tp_hash = u'&' + cpythonBaseName(metaClass) + u"_HashFunc"_s;
const auto callOp = metaClass->findFunction(u"operator()");
if (!callOp.isNull() && !callOp->isModifiedRemoved())
tp_call = u'&' + cpythonFunctionName(callOp);
- const QString typePtr = QLatin1String("_") + className
- + QLatin1String("_Type");
+ const QString typePtr = u"_"_s + className
+ + u"_Type"_s;
s << "static PyTypeObject *" << typePtr << " = nullptr;\n"
<< "static PyTypeObject *" << className << "_TypeF(void)\n"
<< "{\n" << indent << "return " << typePtr << ";\n" << outdent
@@ -4542,15 +4551,15 @@ void CppGenerator::writeClassDefinition(TextStream &s,
<< pyTypeSlotEntry("Py_tp_repr", m_tpFuncs.value(reprFunction()))
<< pyTypeSlotEntry("Py_tp_hash", tp_hash)
<< pyTypeSlotEntry("Py_tp_call", tp_call)
- << pyTypeSlotEntry("Py_tp_str", m_tpFuncs.value(QLatin1String("__str__")))
+ << pyTypeSlotEntry("Py_tp_str", m_tpFuncs.value(u"__str__"_s))
<< pyTypeSlotEntry("Py_tp_getattro", tp_getattro)
<< pyTypeSlotEntry("Py_tp_setattro", tp_setattro)
- << pyTypeSlotEntry("Py_tp_traverse", className + QLatin1String("_traverse"))
- << pyTypeSlotEntry("Py_tp_clear", className + QLatin1String("_clear"))
+ << pyTypeSlotEntry("Py_tp_traverse", className + u"_traverse"_s)
+ << pyTypeSlotEntry("Py_tp_clear", className + u"_clear"_s)
<< pyTypeSlotEntry("Py_tp_richcompare", tp_richcompare)
- << pyTypeSlotEntry("Py_tp_iter", m_tpFuncs.value(QLatin1String("__iter__")))
- << pyTypeSlotEntry("Py_tp_iternext", m_tpFuncs.value(QLatin1String("__next__")))
- << pyTypeSlotEntry("Py_tp_methods", className + QLatin1String("_methods"))
+ << pyTypeSlotEntry("Py_tp_iter", m_tpFuncs.value(u"__iter__"_s))
+ << pyTypeSlotEntry("Py_tp_iternext", m_tpFuncs.value(u"__next__"_s))
+ << pyTypeSlotEntry("Py_tp_methods", className + u"_methods"_s)
<< pyTypeSlotEntry("Py_tp_getset", tp_getset)
<< pyTypeSlotEntry("Py_tp_init", tp_init)
<< pyTypeSlotEntry("Py_tp_new", tp_new);
@@ -4588,7 +4597,7 @@ void CppGenerator::writeMappingMethods(TextStream &s,
QString funcName = cpythonFunctionName(func);
CodeSnipList snips = func->injectedCodeSnips(TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode);
s << m.returnType << ' ' << funcName << '(' << m.arguments << ")\n{\n";
- writeInvalidPyObjectCheck(s, u"self"_qs, ErrorReturn::Default);
+ writeInvalidPyObjectCheck(s, u"self"_s, ErrorReturn::Default);
writeCppSelfDefinition(s, func, context, ErrorReturn::Default);
@@ -4615,7 +4624,7 @@ void CppGenerator::writeSequenceMethods(TextStream &s,
CodeSnipList snips = func->injectedCodeSnips(TypeSystem::CodeSnipPositionAny, TypeSystem::TargetLangCode);
s << seq.returnType << ' ' << funcName << '(' << seq.arguments << ")\n{\n" << indent;
- writeInvalidPyObjectCheck(s, u"self"_qs, ErrorReturn::Default);
+ writeInvalidPyObjectCheck(s, u"self"_s, ErrorReturn::Default);
writeCppSelfDefinition(s, func, context, ErrorReturn::Default);
@@ -4633,13 +4642,13 @@ void CppGenerator::writeSequenceMethods(TextStream &s,
static const QHash<QString, QString> &sqFuncs()
{
static const QHash<QString, QString> result = {
- {QLatin1String("__concat__"), QLatin1String("sq_concat")},
- {QLatin1String("__contains__"), QLatin1String("sq_contains")},
- {QLatin1String("__getitem__"), QLatin1String("sq_item")},
- {QLatin1String("__getslice__"), QLatin1String("sq_slice")},
- {QLatin1String("__len__"), QLatin1String("sq_length")},
- {QLatin1String("__setitem__"), QLatin1String("sq_ass_item")},
- {QLatin1String("__setslice__"), QLatin1String("sq_ass_slice")}
+ {u"__concat__"_s, u"sq_concat"_s},
+ {u"__contains__"_s, u"sq_contains"_s},
+ {u"__getitem__"_s, u"sq_item"_s},
+ {u"__getslice__"_s, u"sq_slice"_s},
+ {u"__len__"_s, u"sq_length"_s},
+ {u"__setitem__"_s, u"sq_ass_item"_s},
+ {u"__setslice__"_s, u"sq_ass_slice"_s}
};
return result;
}
@@ -4661,9 +4670,9 @@ void CppGenerator::writeTypeAsSequenceDefinition(TextStream &s,
//use default implementation
if (!hasFunctions) {
- funcs[QLatin1String("__len__")] = baseName + QLatin1String("__len__");
- funcs[QLatin1String("__getitem__")] = baseName + QLatin1String("__getitem__");
- funcs[QLatin1String("__setitem__")] = baseName + QLatin1String("__setitem__");
+ funcs[u"__len__"_s] = baseName + u"__len__"_s;
+ funcs[u"__getitem__"_s] = baseName + u"__getitem__"_s;
+ funcs[u"__setitem__"_s] = baseName + u"__setitem__"_s;
}
for (auto it = sqFuncs().cbegin(), end = sqFuncs().cend(); it != end; ++it) {
@@ -4681,19 +4690,19 @@ void CppGenerator::writeTypeAsMappingDefinition(TextStream &s,
{
// Sequence protocol structure members names
static const QHash<QString, QString> mpFuncs{
- {QLatin1String("__mlen__"), QLatin1String("mp_length")},
- {QLatin1String("__mgetitem__"), QLatin1String("mp_subscript")},
- {QLatin1String("__msetitem__"), QLatin1String("mp_ass_subscript")},
+ {u"__mlen__"_s, u"mp_length"_s},
+ {u"__mgetitem__"_s, u"mp_subscript"_s},
+ {u"__msetitem__"_s, u"mp_ass_subscript"_s},
};
QMap<QString, QString> funcs;
for (const auto &m : mappingProtocols()) {
const auto func = metaClass->findFunction(m.name);
if (!func.isNull()) {
- const QString entry = QLatin1String("reinterpret_cast<void *>(&")
+ const QString entry = u"reinterpret_cast<void *>(&"_s
+ cpythonFunctionName(func) + u')';
funcs.insert(m.name, entry);
} else {
- funcs.insert(m.name, QLatin1String(NULL_PTR));
+ funcs.insert(m.name, QLatin1StringView(NULL_PTR));
}
}
@@ -4708,30 +4717,30 @@ void CppGenerator::writeTypeAsMappingDefinition(TextStream &s,
static const QHash<QString, QString> &nbFuncs()
{
static const QHash<QString, QString> result = {
- {QLatin1String("__add__"), QLatin1String("nb_add")},
- {QLatin1String("__sub__"), QLatin1String("nb_subtract")},
- {QLatin1String("__mul__"), QLatin1String("nb_multiply")},
- {QLatin1String("__div__"), QLatin1String("nb_divide")},
- {QLatin1String("__mod__"), QLatin1String("nb_remainder")},
- {QLatin1String("__neg__"), QLatin1String("nb_negative")},
- {QLatin1String("__pos__"), QLatin1String("nb_positive")},
- {QLatin1String("__invert__"), QLatin1String("nb_invert")},
- {QLatin1String("__lshift__"), QLatin1String("nb_lshift")},
- {QLatin1String("__rshift__"), QLatin1String("nb_rshift")},
- {QLatin1String("__and__"), QLatin1String("nb_and")},
- {QLatin1String("__xor__"), QLatin1String("nb_xor")},
- {QLatin1String("__or__"), QLatin1String("nb_or")},
- {QLatin1String("__iadd__"), QLatin1String("nb_inplace_add")},
- {QLatin1String("__isub__"), QLatin1String("nb_inplace_subtract")},
- {QLatin1String("__imul__"), QLatin1String("nb_inplace_multiply")},
- {QLatin1String("__idiv__"), QLatin1String("nb_inplace_divide")},
- {QLatin1String("__imod__"), QLatin1String("nb_inplace_remainder")},
- {QLatin1String("__ilshift__"), QLatin1String("nb_inplace_lshift")},
- {QLatin1String("__irshift__"), QLatin1String("nb_inplace_rshift")},
- {QLatin1String("__iand__"), QLatin1String("nb_inplace_and")},
- {QLatin1String("__ixor__"), QLatin1String("nb_inplace_xor")},
- {QLatin1String("__ior__"), QLatin1String("nb_inplace_or")},
- {boolT(), QLatin1String("nb_nonzero")}
+ {u"__add__"_s, u"nb_add"_s},
+ {u"__sub__"_s, u"nb_subtract"_s},
+ {u"__mul__"_s, u"nb_multiply"_s},
+ {u"__div__"_s, u"nb_divide"_s},
+ {u"__mod__"_s, u"nb_remainder"_s},
+ {u"__neg__"_s, u"nb_negative"_s},
+ {u"__pos__"_s, u"nb_positive"_s},
+ {u"__invert__"_s, u"nb_invert"_s},
+ {u"__lshift__"_s, u"nb_lshift"_s},
+ {u"__rshift__"_s, u"nb_rshift"_s},
+ {u"__and__"_s, u"nb_and"_s},
+ {u"__xor__"_s, u"nb_xor"_s},
+ {u"__or__"_s, u"nb_or"_s},
+ {u"__iadd__"_s, u"nb_inplace_add"_s},
+ {u"__isub__"_s, u"nb_inplace_subtract"_s},
+ {u"__imul__"_s, u"nb_inplace_multiply"_s},
+ {u"__idiv__"_s, u"nb_inplace_divide"_s},
+ {u"__imod__"_s, u"nb_inplace_remainder"_s},
+ {u"__ilshift__"_s, u"nb_inplace_lshift"_s},
+ {u"__irshift__"_s, u"nb_inplace_rshift"_s},
+ {u"__iand__"_s, u"nb_inplace_and"_s},
+ {u"__ixor__"_s, u"nb_inplace_xor"_s},
+ {u"__ior__"_s, u"nb_inplace_or"_s},
+ {boolT(), u"nb_nonzero"_s}
};
return result;
}
@@ -4756,7 +4765,7 @@ void CppGenerator::writeTypeAsNumberDefinition(TextStream &s, const AbstractMeta
QString baseName = cpythonBaseName(metaClass);
if (hasBoolCast(metaClass))
- nb.insert(boolT(), baseName + QLatin1String("___nb_bool"));
+ nb.insert(boolT(), baseName + u"___nb_bool"_s);
for (auto it = nbFuncs().cbegin(), end = nbFuncs().cend(); it != end; ++it) {
const QString &nbName = it.key();
@@ -4765,17 +4774,17 @@ void CppGenerator::writeTypeAsNumberDefinition(TextStream &s, const AbstractMeta
const auto nbIt = nb.constFind(nbName);
if (nbIt != nb.constEnd()) {
const QString fixednbName = nbName == boolT()
- ? QLatin1String("nb_bool") : it.value();
+ ? u"nb_bool"_s : it.value();
s << "{Py_" << fixednbName << ", reinterpret_cast<void *>("
<< nbIt.value() << ")},\n";
}
}
- auto nbIt = nb.constFind(QLatin1String("__div__"));
+ auto nbIt = nb.constFind(u"__div__"_s);
if (nbIt != nb.constEnd())
s << "{Py_nb_true_divide, reinterpret_cast<void *>(" << nbIt.value() << ")},\n";
- nbIt = nb.constFind(QLatin1String("__idiv__"));
+ nbIt = nb.constFind(u"__idiv__"_s);
if (nbIt != nb.constEnd()) {
s << "// This function is unused in Python 3. We reference it here.\n"
<< "{0, reinterpret_cast<void *>(" << nbIt.value() << ")},\n"
@@ -4872,7 +4881,7 @@ void CppGenerator::writeGetterFunction(TextStream &s,
if (fieldType.isCppIntegralPrimitive() || fieldType.isEnum()) {
s << getFullTypeNameWithoutModifiers(fieldType) << " cppOut_local = " << cppField << ";\n";
- cppField = QLatin1String("cppOut_local");
+ cppField = u"cppOut_local"_s;
}
s << "PyObject *pyOut = {};\n";
@@ -4955,7 +4964,7 @@ void CppGenerator::writeSetterFunctionPreamble(TextStream &s, const QString &nam
s << PYTHON_TO_CPPCONVERSION_STRUCT << ' ' << PYTHON_TO_CPP_VAR << ";\n"
<< "if (!";
- writeTypeCheck(s, type, QLatin1String("pyIn"), isNumber(type.typeEntry()));
+ writeTypeCheck(s, type, u"pyIn"_s, isNumber(type.typeEntry()));
s << ") {\n" << indent
<< "PyErr_SetString(PyExc_TypeError, \"wrong type attributed to '"
<< name << "', '" << type.name() << "' or convertible type expected\");\n"
@@ -5023,10 +5032,10 @@ void CppGenerator::writeRichCompareFunctionHeader(TextStream &s,
s << baseName << "_richcompare(PyObject *self, PyObject *" << PYTHON_ARG
<< ", int op)\n{\n" << indent;
writeCppSelfDefinition(s, context, ErrorReturn::Default, CppSelfDefinitionFlag::CppSelfAsReference);
- writeUnusedVariableCast(s, QLatin1String(CPP_SELF_VAR));
+ writeUnusedVariableCast(s, QLatin1StringView(CPP_SELF_VAR));
s << "PyObject *" << PYTHON_RETURN_VAR << "{};\n"
<< PYTHON_TO_CPPCONVERSION_STRUCT << ' ' << PYTHON_TO_CPP_VAR << ";\n";
- writeUnusedVariableCast(s, QLatin1String(PYTHON_TO_CPP_VAR));
+ writeUnusedVariableCast(s, QLatin1StringView(PYTHON_TO_CPP_VAR));
s << '\n';
}
@@ -5074,13 +5083,14 @@ void CppGenerator::writeRichCompareFunction(TextStream &s,
first = false;
}
s << "if (";
- writeTypeCheck(s, argType, QLatin1String(PYTHON_ARG), alternativeNumericTypes == 1 || isPyInt(argType));
+ writeTypeCheck(s, argType, QLatin1StringView(PYTHON_ARG),
+ alternativeNumericTypes == 1 || isPyInt(argType));
s << ") {\n";
{
Indentation indent(s);
s << "// " << func->signature() << '\n';
- writeArgumentConversion(s, argType, QLatin1String(CPP_ARG0),
- QLatin1String(PYTHON_ARG), ErrorReturn::Default,
+ writeArgumentConversion(s, argType, QLatin1StringView(CPP_ARG0),
+ QLatin1StringView(PYTHON_ARG), ErrorReturn::Default,
metaClass,
QString(), func->isUserAdded());
@@ -5107,10 +5117,12 @@ void CppGenerator::writeRichCompareFunction(TextStream &s,
s << QByteArray(deRef, '*');
s << CPP_ARG0 << ");\n"
<< PYTHON_RETURN_VAR << " = ";
- if (!func->isVoid())
- writeToPythonConversion(s, func->type(), metaClass, QLatin1String(CPP_RETURN_VAR));
- else
+ if (!func->isVoid()) {
+ writeToPythonConversion(s, func->type(), metaClass,
+ QLatin1StringView(CPP_RETURN_VAR));
+ } else {
s << "Py_None;\n" << "Py_INCREF(Py_None)";
+ }
s << ";\n";
}
}
@@ -5200,10 +5212,10 @@ void CppGenerator::writeSmartPointerRichCompareFunction(TextStream &s,
writeRichCompareFunctionHeader(s, baseName, context);
s << "if (";
- writeTypeCheck(s, context.preciseType(), QLatin1String(PYTHON_ARG));
+ writeTypeCheck(s, context.preciseType(), QLatin1StringView(PYTHON_ARG));
s << ") {\n" << indent;
- writeArgumentConversion(s, context.preciseType(), QLatin1String(CPP_ARG0),
- QLatin1String(PYTHON_ARG), ErrorReturn::Default, metaClass);
+ writeArgumentConversion(s, context.preciseType(), QLatin1StringView(CPP_ARG0),
+ QLatin1StringView(PYTHON_ARG), ErrorReturn::Default, metaClass);
const auto *te = context.preciseType().typeEntry();
Q_ASSERT(te->isSmartPointer());
@@ -5370,7 +5382,7 @@ QString CppGenerator::signatureParameter(const AbstractMetaArgument &arg) const
if (!arg.defaultValueExpression().isEmpty()) {
s << '=';
QString e = arg.defaultValueExpression();
- e.replace(QLatin1String("::"), QLatin1String("."));
+ e.replace(u"::"_s, u"."_s);
s << e;
}
return result;
@@ -5389,7 +5401,7 @@ void CppGenerator::writeSignatureInfo(TextStream &s, const OverloadData &overloa
// PYSIDE-1328: `self`-ness cannot be computed in Python because there are mixed cases.
// Toplevel functions like `PySide6.QtCore.QEnum` are always self-less.
if (!(f->isStatic()) && f->ownerClass())
- args << QLatin1String("self");
+ args << u"self"_s;
const auto &arguments = f->arguments();
for (qsizetype i = 0, size = arguments.size(); i < size; ++i) {
QString t = f->pyiTypeReplaced(i + 1);
@@ -5446,9 +5458,9 @@ void CppGenerator::writeEnumInitialization(TextStream &s, const AbstractMetaEnum
if (enclosingClass)
enclosingObjectVariable = cpythonTypeName(enclosingClass);
else if (hasUpperEnclosingClass)
- enclosingObjectVariable = QLatin1String("enclosingClass");
+ enclosingObjectVariable = u"enclosingClass"_s;
else
- enclosingObjectVariable = QLatin1String("module");
+ enclosingObjectVariable = u"module"_s;
s << "// Initialization of ";
s << (cppEnum.isAnonymous() ? "anonymous enum identified by enum value" : "enum");
@@ -5492,12 +5504,12 @@ void CppGenerator::writeEnumInitialization(TextStream &s, const AbstractMetaEnum
QString enumValueText;
if (!avoidProtectedHack() || !cppEnum.isProtected()) {
- enumValueText = QLatin1String("(long) ");
+ enumValueText = u"(long) "_s;
if (cppEnum.enclosingClass())
- enumValueText += cppEnum.enclosingClass()->qualifiedCppName() + QLatin1String("::");
+ enumValueText += cppEnum.enclosingClass()->qualifiedCppName() + u"::"_s;
// Fully qualify the value which is required for C++ 11 enum classes.
if (!cppEnum.isAnonymous())
- enumValueText += cppEnum.name() + QLatin1String("::");
+ enumValueText += cppEnum.name() + u"::"_s;
enumValueText += enumValue.name();
} else {
enumValueText += enumValue.value().toString();
@@ -5606,11 +5618,11 @@ void CppGenerator::writeFlagsNonZero(TextStream &s, const AbstractMetaEnum &cppE
void CppGenerator::writeFlagsMethods(TextStream &s, const AbstractMetaEnum &cppEnum)
{
- writeFlagsBinaryOperator(s, cppEnum, QLatin1String("and"), QLatin1String("&"));
- writeFlagsBinaryOperator(s, cppEnum, QLatin1String("or"), QLatin1String("|"));
- writeFlagsBinaryOperator(s, cppEnum, QLatin1String("xor"), QLatin1String("^"));
+ writeFlagsBinaryOperator(s, cppEnum, u"and"_s, u"&"_s);
+ writeFlagsBinaryOperator(s, cppEnum, u"or"_s, u"|"_s);
+ writeFlagsBinaryOperator(s, cppEnum, u"xor"_s, u"^"_s);
- writeFlagsUnaryOperator(s, cppEnum, QLatin1String("invert"), QLatin1String("~"));
+ writeFlagsUnaryOperator(s, cppEnum, u"invert"_s, u"~"_s);
writeFlagsToLong(s, cppEnum);
writeFlagsNonZero(s, cppEnum);
@@ -5669,7 +5681,7 @@ void CppGenerator::writeFlagsBinaryOperator(TextStream &s, const AbstractMetaEnu
<< "return nullptr;\n" << outdent
<< "cppResult = " << CPP_SELF_VAR << " " << cppOpName << " cppArg;\n"
<< "return ";
- writeToPythonConversion(s, flagsType, nullptr, QLatin1String("cppResult"));
+ writeToPythonConversion(s, flagsType, nullptr, u"cppResult"_s);
s << ";\n" << outdent << "}\n\n";
}
@@ -5696,7 +5708,7 @@ void CppGenerator::writeFlagsUnaryOperator(TextStream &s, const AbstractMetaEnum
if (boolResult)
s << "PyBool_FromLong(cppResult)";
else
- writeToPythonConversion(s, flagsType, nullptr, QLatin1String("cppResult"));
+ writeToPythonConversion(s, flagsType, nullptr, u"cppResult"_s);
s << ";\n" << outdent << "}\n\n";
}
@@ -5707,14 +5719,14 @@ QString CppGenerator::getSimpleClassInitFunctionName(const AbstractMetaClass *me
if (metaClass->isNamespace())
initFunctionName += moduleName();
initFunctionName += metaClass->qualifiedCppName();
- initFunctionName.replace(QLatin1String("::"), QLatin1String("_"));
+ initFunctionName.replace(u"::"_s, u"_"_s);
return initFunctionName;
}
QString CppGenerator::getSimpleClassStaticFieldsInitFunctionName(const AbstractMetaClass *metaClass)
{
- return QLatin1String("init_") + getSimpleClassInitFunctionName(metaClass)
- + QLatin1String("StaticFields");
+ return u"init_"_s + getSimpleClassInitFunctionName(metaClass)
+ + u"StaticFields"_s;
}
QString CppGenerator::getInitFunctionName(const GeneratorContext &context)
@@ -5768,7 +5780,7 @@ void CppGenerator::writeClassRegister(TextStream &s,
const ComplexTypeEntry *classTypeEntry = metaClass->typeEntry();
const AbstractMetaClass *enc = metaClass->targetLangEnclosingClass();
- QString enclosingObjectVariable = enc ? QLatin1String("enclosingClass") : QLatin1String("module");
+ QString enclosingObjectVariable = enc ? u"enclosingClass"_s : u"module"_s;
QString pyTypeName = cpythonTypeName(metaClass);
QString initFunctionName = getInitFunctionName(classContext);
@@ -5779,7 +5791,7 @@ void CppGenerator::writeClassRegister(TextStream &s,
s << "(PyObject *" << enclosingObjectVariable << ")\n{\n" << indent;
// Multiple inheritance
- QString pyTypeBasesVariable = chopType(pyTypeName) + QLatin1String("_Type_bases");
+ QString pyTypeBasesVariable = chopType(pyTypeName) + u"_Type_bases"_s;
const auto &baseClasses = metaClass->typeSystemBaseClasses();
if (metaClass->baseClassNames().size() > 1) {
s << "PyObject *" << pyTypeBasesVariable
@@ -5795,8 +5807,8 @@ void CppGenerator::writeClassRegister(TextStream &s,
}
// Create type and insert it in the module or enclosing class.
- const QString typePtr = QLatin1String("_") + chopType(pyTypeName)
- + QLatin1String("_Type");
+ const QString typePtr = u"_"_s + chopType(pyTypeName)
+ + u"_Type"_s;
s << typePtr << " = Shiboken::ObjectType::introduceWrapperType(\n";
{
@@ -5973,7 +5985,7 @@ void CppGenerator::writeInitQtMetaTypeFunctionBody(TextStream &s, const Generato
const AbstractMetaClass *enclosingClass = metaClass->enclosingClass();
while (enclosingClass) {
if (enclosingClass->typeEntry()->generateCode())
- nameVariants << (enclosingClass->name() + QLatin1String("::") + nameVariants.constLast());
+ nameVariants << (enclosingClass->name() + u"::"_s + nameVariants.constLast());
enclosingClass = enclosingClass->enclosingClass();
}
@@ -6030,10 +6042,10 @@ void CppGenerator::writeTypeDiscoveryFunction(TextStream &s, const AbstractMetaC
<< "_typeDiscovery(void *cptr, PyTypeObject *instanceType)\n{\n" << indent;
if (!polymorphicExpr.isEmpty()) {
- polymorphicExpr = polymorphicExpr.replace(QLatin1String("%1"),
- QLatin1String(" reinterpret_cast< ::")
+ polymorphicExpr = polymorphicExpr.replace(u"%1"_s,
+ u" reinterpret_cast< ::"_s
+ metaClass->qualifiedCppName()
- + QLatin1String(" *>(cptr)"));
+ + u" *>(cptr)"_s);
s << " if (" << polymorphicExpr << ")\n";
{
Indentation indent(s);
@@ -6093,7 +6105,7 @@ void CppGenerator::writeSetattroFunction(TextStream &s, AttroCheck attroCheck,
if (attroCheck.testFlag(AttroCheckFlag::SetattroMethodOverride)
&& context.useWrapper()) {
s << "if (value && PyCallable_Check(value)) {\n" << indent
- << "auto plain_inst = " << cpythonWrapperCPtr(metaClass, QLatin1String("self")) << ";\n"
+ << "auto plain_inst = " << cpythonWrapperCPtr(metaClass, u"self"_s) << ";\n"
<< "auto inst = dynamic_cast<" << context.wrapperName() << " *>(plain_inst);\n"
<< "if (inst)\n" << indent
<< "inst->resetPyMethodCache();\n" << outdent << outdent
@@ -6114,7 +6126,7 @@ void CppGenerator::writeSetattroFunction(TextStream &s, AttroCheck attroCheck,
{
Indentation indent(s);
s << "auto " << CPP_SELF_VAR << " = "
- << cpythonWrapperCPtr(metaClass, QLatin1String("self")) << ";\n";
+ << cpythonWrapperCPtr(metaClass, u"self"_s) << ";\n";
writeClassCodeSnips(s, func->injectedCodeSnips(), TypeSystem::CodeSnipPositionAny,
TypeSystem::TargetLangCode, context);
}
@@ -6155,9 +6167,9 @@ QString CppGenerator::qObjectGetAttroFunction() const
if (result.isEmpty()) {
auto qobjectClass = AbstractMetaClass::findClass(api().classes(), qObjectT());
Q_ASSERT(qobjectClass);
- result = QLatin1String("PySide::getMetaDataFromQObject(")
- + cpythonWrapperCPtr(qobjectClass, QLatin1String("self"))
- + QLatin1String(", self, name)");
+ result = u"PySide::getMetaDataFromQObject("_s
+ + cpythonWrapperCPtr(qobjectClass, u"self"_s)
+ + u", self, name)"_s;
}
return result;
}
@@ -6174,7 +6186,7 @@ void CppGenerator::writeGetattroFunction(TextStream &s, AttroCheck attroCheck,
s << "PySide::Feature::Select(self);\n";
const QString getattrFunc = usePySideExtensions() && metaClass->isQObject()
- ? qObjectGetAttroFunction() : QLatin1String("PyObject_GenericGetAttr(self, name)");
+ ? qObjectGetAttroFunction() : u"PyObject_GenericGetAttr(self, name)"_s;
if (attroCheck.testFlag(AttroCheckFlag::GetattroOverloads)) {
s << "// Search the method in the instance dict\n"
@@ -6235,7 +6247,7 @@ void CppGenerator::writeGetattroFunction(TextStream &s, AttroCheck attroCheck,
{
Indentation indent(s);
s << "auto " << CPP_SELF_VAR << " = "
- << cpythonWrapperCPtr(metaClass, QLatin1String("self")) << ";\n";
+ << cpythonWrapperCPtr(metaClass, u"self"_s) << ";\n";
writeClassCodeSnips(s, func->injectedCodeSnips(), TypeSystem::CodeSnipPositionAny,
TypeSystem::TargetLangCode, context);
}
@@ -6399,7 +6411,7 @@ bool CppGenerator::finishGeneration()
}
QString moduleFileName(outputDirectory() + u'/' + subDirectoryForPackage(packageName()));
- moduleFileName += u'/' + moduleName().toLower() + QLatin1String("_module_wrapper.cpp");
+ moduleFileName += u'/' + moduleName().toLower() + u"_module_wrapper.cpp"_s;
FileOut file(moduleFileName);
@@ -6687,9 +6699,9 @@ bool CppGenerator::finishGeneration()
continue;
const TypeEntry *referencedType = pte->basicReferencedTypeEntry();
QString converter = converterObject(referencedType);
- QStringList cppSignature = pte->qualifiedCppName().split(QLatin1String("::"), Qt::SkipEmptyParts);
+ QStringList cppSignature = pte->qualifiedCppName().split(u"::"_s, Qt::SkipEmptyParts);
while (!cppSignature.isEmpty()) {
- QString signature = cppSignature.join(QLatin1String("::"));
+ QString signature = cppSignature.join(u"::"_s);
s << "Shiboken::Conversions::registerConverterName("
<< converter << ", \"" << signature << "\");\n";
cppSignature.removeFirst();
@@ -6778,25 +6790,25 @@ bool CppGenerator::writeParentChildManagement(TextStream &s, const AbstractMetaF
<< "Argument index for parent tag out of bounds: " << func->signature();
if (action == ArgumentOwner::Remove) {
- parentVariable = QLatin1String("Py_None");
+ parentVariable = u"Py_None"_s;
} else {
if (parentIndex == 0) {
- parentVariable = QLatin1String(PYTHON_RETURN_VAR);
+ parentVariable = QLatin1StringView(PYTHON_RETURN_VAR);
} else if (parentIndex == -1) {
- parentVariable = QLatin1String("self");
+ parentVariable = u"self"_s;
} else {
parentVariable = usePyArgs
- ? pythonArgsAt(parentIndex - 1) : QLatin1String(PYTHON_ARG);
+ ? pythonArgsAt(parentIndex - 1) : QLatin1StringView(PYTHON_ARG);
}
}
if (childIndex == 0) {
- childVariable = QLatin1String(PYTHON_RETURN_VAR);
+ childVariable = QLatin1StringView(PYTHON_RETURN_VAR);
} else if (childIndex == -1) {
- childVariable = QLatin1String("self");
+ childVariable = u"self"_s;
} else {
childVariable = usePyArgs
- ? pythonArgsAt(childIndex - 1) : QLatin1String(PYTHON_ARG);
+ ? pythonArgsAt(childIndex - 1) : QLatin1StringView(PYTHON_ARG);
}
s << "Shiboken::Object::setParent(" << parentVariable << ", " << childVariable << ");\n";
@@ -6874,7 +6886,7 @@ void CppGenerator::writeDefaultSequenceMethods(TextStream &s,
s << "PyObject *" << namePrefix
<< "__getitem__(PyObject *self, Py_ssize_t _i)\n{\n" << indent;
writeCppSelfDefinition(s, context, errorReturn);
- writeIndexError(s, u"index out of bounds"_qs, errorReturn);
+ writeIndexError(s, u"index out of bounds"_s, errorReturn);
s << metaClass->qualifiedCppName() << "::const_iterator _item = "
<< CPP_SELF_VAR << "->begin();\n"
@@ -6891,7 +6903,7 @@ void CppGenerator::writeDefaultSequenceMethods(TextStream &s,
const AbstractMetaType &itemType = instantiations.constFirst();
s << "return ";
- writeToPythonConversion(s, itemType, metaClass, QLatin1String("*_item"));
+ writeToPythonConversion(s, itemType, metaClass, u"*_item"_s);
s << ";\n" << outdent << "}\n";
// __setitem__
@@ -6900,11 +6912,11 @@ void CppGenerator::writeDefaultSequenceMethods(TextStream &s,
<< indent;
errorReturn = ErrorReturn::MinusOne;
writeCppSelfDefinition(s, context, errorReturn);
- writeIndexError(s, u"list assignment index out of range"_qs, errorReturn);
+ writeIndexError(s, u"list assignment index out of range"_s, errorReturn);
s << PYTHON_TO_CPPCONVERSION_STRUCT << ' ' << PYTHON_TO_CPP_VAR << ";\n"
<< "if (!";
- writeTypeCheck(s, itemType, QLatin1String("pyArg"), isNumber(itemType.typeEntry()));
+ writeTypeCheck(s, itemType, u"pyArg"_s, isNumber(itemType.typeEntry()));
s << ") {\n";
{
Indentation indent(s);
@@ -6913,8 +6925,8 @@ void CppGenerator::writeDefaultSequenceMethods(TextStream &s,
<< "return -1;\n";
}
s << "}\n";
- writeArgumentConversion(s, itemType, u"cppValue"_qs,
- u"pyArg"_qs, errorReturn, metaClass);
+ writeArgumentConversion(s, itemType, u"cppValue"_s,
+ u"pyArg"_s, errorReturn, metaClass);
s << metaClass->qualifiedCppName() << "::iterator _item = "
<< CPP_SELF_VAR << "->begin();\n"
diff --git a/sources/shiboken6/generator/shiboken/headergenerator.cpp b/sources/shiboken6/generator/shiboken/headergenerator.cpp
index cce1b14f3..4aafda5af 100644
--- a/sources/shiboken6/generator/shiboken/headergenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/headergenerator.cpp
@@ -40,6 +40,8 @@
#include <fileout.h>
#include "parser/codemodel.h"
+#include "qtcompat.h"
+
#include <algorithm>
#include <QtCore/QDir>
@@ -47,9 +49,11 @@
#include <QtCore/QVariant>
#include <QtCore/QDebug>
+using namespace Qt::StringLiterals;
+
QString HeaderGenerator::headerFileNameForContext(const GeneratorContext &context)
{
- return fileNameForContextHelper(context, u"_wrapper.h"_qs);
+ return fileNameForContextHelper(context, u"_wrapper.h"_s);
}
QString HeaderGenerator::fileNameForContext(const GeneratorContext &context) const
@@ -256,7 +260,7 @@ void HeaderGenerator::writeFunction(TextStream &s, const AbstractMetaFunctionCPt
if (avoidProtectedHack() && func->isProtected() && !func->isConstructor()
&& !func->isOperatorOverload()) {
- writeMemberFunctionWrapper(s, func, QLatin1String("_protected"));
+ writeMemberFunctionWrapper(s, func, u"_protected"_s);
}
// pure virtual functions need a default implementation
@@ -447,7 +451,7 @@ bool HeaderGenerator::finishGeneration()
const auto ptrName = smp.type.typeEntry()->entryName();
int pos = indexName.indexOf(ptrName, 0, Qt::CaseInsensitive);
if (pos >= 0) {
- indexName.insert(pos + ptrName.size() + 1, QLatin1String("CONST"));
+ indexName.insert(pos + ptrName.size() + 1, u"CONST"_s);
_writeTypeIndexValue(macrosStream, indexName, smartPointerCountIndex);
macrosStream << ", // (const)\n";
}
@@ -456,7 +460,7 @@ bool HeaderGenerator::finishGeneration()
}
_writeTypeIndexValue(macrosStream,
- QLatin1String("SBK_") + moduleName() + QLatin1String("_IDX_COUNT"),
+ u"SBK_"_s + moduleName() + u"_IDX_COUNT"_s,
getMaxTypeIndex() + smartPointerCount);
macrosStream << "\n};\n";
@@ -552,7 +556,7 @@ bool HeaderGenerator::finishGeneration()
+ subDirectoryForPackage(packageName()) + u'/';
const QString moduleHeaderFileName(moduleHeaderDir + getModuleHeaderFileName());
- QString includeShield(QLatin1String("SBK_") + moduleName().toUpper() + QLatin1String("_PYTHON_H"));
+ QString includeShield(u"SBK_"_s + moduleName().toUpper() + u"_PYTHON_H"_s);
FileOut file(moduleHeaderFileName);
TextStream &s = file.stream;
diff --git a/sources/shiboken6/generator/shiboken/overloaddata.cpp b/sources/shiboken6/generator/shiboken/overloaddata.cpp
index c865e4baa..a8c067df7 100644
--- a/sources/shiboken6/generator/shiboken/overloaddata.cpp
+++ b/sources/shiboken6/generator/shiboken/overloaddata.cpp
@@ -41,6 +41,8 @@
#include "exception.h"
#include "messages.h"
+#include "qtcompat.h"
+
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QTemporaryFile>
@@ -48,6 +50,8 @@
#include <algorithm>
#include <utility>
+using namespace Qt::StringLiterals;
+
static QString getTypeName(const AbstractMetaType &type)
{
const TypeEntry *typeEntry = type.typeEntry();
@@ -62,7 +66,7 @@ static QString getTypeName(const AbstractMetaType &type)
typeEntry = typeEntry->asPrimitive()->basicReferencedTypeEntry();
types << typeEntry->name();
}
- typeName += u'<' + types.join(u',') + QLatin1String(" >");
+ typeName += u'<' + types.join(u',') + u" >"_s;
}
return typeName;
}
@@ -109,7 +113,7 @@ static QString getImplicitConversionTypeName(const AbstractMetaType &containerTy
types << (otherType == instantiation ? impConv : getTypeName(otherType));
return containerType.typeEntry()->qualifiedCppName() + u'<'
- + types.join(QLatin1String(", ")) + QLatin1String(" >");
+ + types.join(u", "_s) + u" >"_s;
}
static inline int overloadNumber(const OverloadDataNodePtr &o)
@@ -372,7 +376,7 @@ void OverloadDataRootNode::sortNextOverloads(const ApiExtractorResult &api)
funcName.prepend(owner->name() + u'.');
// Dump overload graph
- QString graphName = QDir::tempPath() + u'/' + funcName + QLatin1String(".dot");
+ QString graphName = QDir::tempPath() + u'/' + funcName + u".dot"_s;
graph.dumpDot(graphName, [] (const QString &n) { return n; });
AbstractMetaFunctionCList cyclic;
for (const auto &typeName : unmappedResult.cyclic) {
@@ -742,9 +746,9 @@ bool OverloadData::showGraph() const
static inline QString toHtml(QString s)
{
- s.replace(u'<', QLatin1String("&lt;"));
- s.replace(u'>', QLatin1String("&gt;"));
- s.replace(u'&', QLatin1String("&amp;"));
+ s.replace(u'<', u"&lt;"_s);
+ s.replace(u'>', u"&gt;"_s);
+ s.replace(u'&', u"&amp;"_s);
return s;
}
@@ -823,7 +827,7 @@ void OverloadDataRootNode::dumpRootGraph(QTextStream &s, int minArgs, int maxArg
void OverloadDataNode::dumpNodeGraph(QTextStream &s) const
{
- QString argId = QLatin1String("arg_") + QString::number(quintptr(this));
+ QString argId = u"arg_"_s + QString::number(quintptr(this));
s << argId << ";\n";
s << " \"" << argId << "\" [shape=\"plaintext\" style=\"filled,bold\" margin=\"0\" fontname=\"freemono\" fillcolor=\"white\" penwidth=1 ";
diff --git a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp
index 8137ec3df..bf089bbcb 100644
--- a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp
@@ -48,12 +48,16 @@
#include <abstractmetabuilder.h>
#include <iostream>
+#include "qtcompat.h"
+
#include <QtCore/QDir>
#include <QtCore/QDebug>
#include <QtCore/QRegularExpression>
#include <limits>
#include <memory>
+using namespace Qt::StringLiterals;
+
static const char PARENT_CTOR_HEURISTIC[] = "enable-parent-ctor-heuristic";
static const char RETURN_VALUE_HEURISTIC[] = "enable-return-value-heuristic";
static const char DISABLE_VERBOSE_ERROR_MESSAGES[] = "disable-verbose-error-messages";
@@ -101,10 +105,10 @@ const ShibokenGenerator::TypeSystemConverterRegExps &
ShibokenGenerator::typeSystemConvRegExps()
{
static const TypeSystemConverterRegExps result = {
- QRegularExpression(QLatin1String(CHECKTYPE_REGEX)),
- QRegularExpression(QLatin1String(ISCONVERTIBLE_REGEX)),
- QRegularExpression(QLatin1String(CONVERTTOCPP_REGEX)),
- QRegularExpression(QLatin1String(CONVERTTOPYTHON_REGEX))
+ QRegularExpression(QLatin1StringView(CHECKTYPE_REGEX)),
+ QRegularExpression(QLatin1StringView(ISCONVERTIBLE_REGEX)),
+ QRegularExpression(QLatin1StringView(CONVERTTOCPP_REGEX)),
+ QRegularExpression(QLatin1StringView(CONVERTTOPYTHON_REGEX))
};
return result;
}
@@ -117,32 +121,32 @@ ShibokenGenerator::~ShibokenGenerator() = default;
static const QHash<QString, QString> &primitiveTypesCorrespondences()
{
static const QHash<QString, QString> result = {
- {QLatin1String("bool"), pyBoolT()},
- {QLatin1String("char"), sbkCharT()},
- {QLatin1String("signed char"), sbkCharT()},
- {QLatin1String("unsigned char"), sbkCharT()},
+ {u"bool"_s, pyBoolT()},
+ {u"char"_s, sbkCharT()},
+ {u"signed char"_s, sbkCharT()},
+ {u"unsigned char"_s, sbkCharT()},
{intT(), pyIntT()},
- {QLatin1String("signed int"), pyIntT()},
- {QLatin1String("uint"), pyIntT()},
- {QLatin1String("unsigned int"), pyIntT()},
+ {u"signed int"_s, pyIntT()},
+ {u"uint"_s, pyIntT()},
+ {u"unsigned int"_s, pyIntT()},
{shortT(), pyIntT()},
- {QLatin1String("ushort"), pyIntT()},
- {QLatin1String("signed short"), pyIntT()},
- {QLatin1String("signed short int"), pyIntT()},
+ {u"ushort"_s, pyIntT()},
+ {u"signed short"_s, pyIntT()},
+ {u"signed short int"_s, pyIntT()},
{unsignedShortT(), pyIntT()},
- {QLatin1String("unsigned short int"), pyIntT()},
+ {u"unsigned short int"_s, pyIntT()},
{longT(), pyIntT()},
{doubleT(), pyFloatT()},
{floatT(), pyFloatT()},
- {QLatin1String("unsigned long"), pyLongT()},
- {QLatin1String("signed long"), pyLongT()},
- {QLatin1String("ulong"), pyLongT()},
- {QLatin1String("unsigned long int"), pyLongT()},
- {QLatin1String("long long"), pyLongT()},
- {QLatin1String("__int64"), pyLongT()},
- {QLatin1String("unsigned long long"), pyLongT()},
- {QLatin1String("unsigned __int64"), pyLongT()},
- {QLatin1String("size_t"), pyLongT()}
+ {u"unsigned long"_s, pyLongT()},
+ {u"signed long"_s, pyLongT()},
+ {u"ulong"_s, pyLongT()},
+ {u"unsigned long int"_s, pyLongT()},
+ {u"long long"_s, pyLongT()},
+ {u"__int64"_s, pyLongT()},
+ {u"unsigned long long"_s, pyLongT()},
+ {u"unsigned __int64"_s, pyLongT()},
+ {u"size_t"_s, pyLongT()}
};
return result;
}
@@ -151,20 +155,20 @@ static const QHash<QString, QString> &primitiveTypesCorrespondences()
const QHash<QString, QString> &ShibokenGenerator::formatUnits()
{
static const QHash<QString, QString> result = {
- {QLatin1String("char"), QLatin1String("b")},
- {QLatin1String("unsigned char"), QLatin1String("B")},
- {intT(), QLatin1String("i")},
- {QLatin1String("unsigned int"), QLatin1String("I")},
- {shortT(), QLatin1String("h")},
- {unsignedShortT(), QLatin1String("H")},
- {longT(), QLatin1String("l")},
- {unsignedLongLongT(), QLatin1String("k")},
- {longLongT(), QLatin1String("L")},
- {QLatin1String("__int64"), QLatin1String("L")},
- {unsignedLongLongT(), QLatin1String("K")},
- {QLatin1String("unsigned __int64"), QLatin1String("K")},
- {doubleT(), QLatin1String("d")},
- {floatT(), QLatin1String("f")},
+ {u"char"_s, u"b"_s},
+ {u"unsigned char"_s, u"B"_s},
+ {intT(), u"i"_s},
+ {u"unsigned int"_s, u"I"_s},
+ {shortT(), u"h"_s},
+ {unsignedShortT(), u"H"_s},
+ {longT(), u"l"_s},
+ {unsignedLongLongT(), u"k"_s},
+ {longLongT(), u"L"_s},
+ {u"__int64"_s, u"L"_s},
+ {unsignedLongLongT(), u"K"_s},
+ {u"unsigned __int64"_s, u"K"_s},
+ {doubleT(), u"d"_s},
+ {floatT(), u"f"_s},
};
return result;
}
@@ -173,8 +177,10 @@ QString ShibokenGenerator::translateTypeForWrapperMethod(const AbstractMetaType
const AbstractMetaClass *context,
Options options) const
{
- if (cType.isArray())
- return translateTypeForWrapperMethod(*cType.arrayElementType(), context, options) + QLatin1String("[]");
+ if (cType.isArray()) {
+ return translateTypeForWrapperMethod(*cType.arrayElementType(), context, options)
+ + u"[]"_s;
+ }
if (avoidProtectedHack() && cType.isEnum()) {
auto metaEnum = api().findAbstractMetaEnum(cType.typeEntry());
@@ -224,8 +230,8 @@ QString ShibokenGenerator::wrapperName(const AbstractMetaClass *metaClass) const
Q_ASSERT(shouldGenerateCppWrapper(metaClass));
QString result = metaClass->name();
if (metaClass->enclosingClass()) // is a inner class
- result.replace(QLatin1String("::"), QLatin1String("_"));
- return result + QLatin1String("Wrapper");
+ result.replace(u"::"_s, u"_"_s);
+ return result + u"Wrapper"_s;
}
QString ShibokenGenerator::fullPythonClassName(const AbstractMetaClass *metaClass)
@@ -253,7 +259,7 @@ QString ShibokenGenerator::fullPythonFunctionName(const AbstractMetaFunctionCPtr
if (func->isConstructor()) {
funcName = fullClassName;
if (forceFunc)
- funcName.append(QLatin1String(".__init__"));
+ funcName.append(u".__init__"_s);
}
else {
funcName.prepend(fullClassName + u'.');
@@ -269,8 +275,8 @@ QString ShibokenGenerator::protectedEnumSurrogateName(const AbstractMetaEnum &me
{
QString result = metaEnum.fullName();
result.replace(u'.', u'_');
- result.replace(QLatin1String("::"), QLatin1String("_"));
- return result + QLatin1String("_Surrogate");
+ result.replace(u"::"_s, u"_"_s);
+ return result + u"_Surrogate"_s;
}
QString ShibokenGenerator::cpythonFunctionName(const AbstractMetaFunctionCPtr &func)
@@ -282,16 +288,16 @@ QString ShibokenGenerator::cpythonFunctionName(const AbstractMetaFunctionCPtr &f
if (func->implementingClass()) {
result = cpythonBaseName(func->implementingClass()->typeEntry());
if (func->isConstructor()) {
- result += QLatin1String("_Init");
+ result += u"_Init"_s;
} else {
- result += QLatin1String("Func_");
+ result += u"Func_"_s;
if (func->isOperatorOverload())
result += ShibokenGenerator::pythonOperatorFunctionName(func);
else
result += func->name();
}
} else {
- result = QLatin1String("Sbk") + moduleName() + QLatin1String("Module_") + func->name();
+ result = u"Sbk"_s + moduleName() + u"Module_"_s + func->name();
}
return result;
@@ -301,24 +307,24 @@ QString ShibokenGenerator::cpythonMethodDefinitionName(const AbstractMetaFunctio
{
if (!func->ownerClass())
return QString();
- return cpythonBaseName(func->ownerClass()->typeEntry()) + QLatin1String("Method_")
+ return cpythonBaseName(func->ownerClass()->typeEntry()) + u"Method_"_s
+ func->name();
}
QString ShibokenGenerator::cpythonGettersSettersDefinitionName(const AbstractMetaClass *metaClass)
{
- return cpythonBaseName(metaClass) + QLatin1String("_getsetlist");
+ return cpythonBaseName(metaClass) + u"_getsetlist"_s;
}
QString ShibokenGenerator::cpythonSetattroFunctionName(const AbstractMetaClass *metaClass)
{
- return cpythonBaseName(metaClass) + QLatin1String("_setattro");
+ return cpythonBaseName(metaClass) + u"_setattro"_s;
}
QString ShibokenGenerator::cpythonGetattroFunctionName(const AbstractMetaClass *metaClass)
{
- return cpythonBaseName(metaClass) + QLatin1String("_getattro");
+ return cpythonBaseName(metaClass) + u"_getattro"_s;
}
QString ShibokenGenerator::cpythonGetterFunctionName(const QString &name,
@@ -358,8 +364,8 @@ QString ShibokenGenerator::cpythonSetterFunctionName(const QPropertySpec &proper
static QString cpythonEnumFlagsName(const QString &moduleName,
const QString &qualifiedCppName)
{
- QString result = QLatin1String("Sbk") + moduleName + u'_' + qualifiedCppName;
- result.replace(QLatin1String("::"), QLatin1String("_"));
+ QString result = u"Sbk"_s + moduleName + u'_' + qualifiedCppName;
+ result.replace(u"::"_s, u"_"_s);
return result;
}
@@ -392,7 +398,7 @@ QString ShibokenGenerator::cpythonFlagsName(const AbstractMetaEnum *metaEnum)
QString ShibokenGenerator::cpythonSpecialCastFunctionName(const AbstractMetaClass *metaClass)
{
- return cpythonBaseName(metaClass->typeEntry()) + QLatin1String("SpecialCastFunction");
+ return cpythonBaseName(metaClass->typeEntry()) + u"SpecialCastFunction"_s;
}
QString ShibokenGenerator::cpythonWrapperCPtr(const AbstractMetaClass *metaClass,
@@ -406,9 +412,9 @@ QString ShibokenGenerator::cpythonWrapperCPtr(const AbstractMetaType &metaType,
{
if (!metaType.isWrapperType())
return QString();
- return QLatin1String("reinterpret_cast< ::") + metaType.cppSignature()
- + QLatin1String(" *>(Shiboken::Conversions::cppPointer(") + cpythonTypeNameExt(metaType)
- + QLatin1String(", reinterpret_cast<SbkObject *>(") + argName + QLatin1String(")))");
+ return u"reinterpret_cast< ::"_s + metaType.cppSignature()
+ + u" *>(Shiboken::Conversions::cppPointer("_s + cpythonTypeNameExt(metaType)
+ + u", reinterpret_cast<SbkObject *>("_s + argName + u")))"_s;
}
QString ShibokenGenerator::cpythonWrapperCPtr(const TypeEntry *type,
@@ -416,9 +422,9 @@ QString ShibokenGenerator::cpythonWrapperCPtr(const TypeEntry *type,
{
if (!type->isWrapperType())
return QString();
- return QLatin1String("reinterpret_cast< ::") + type->qualifiedCppName()
- + QLatin1String(" *>(Shiboken::Conversions::cppPointer(") + cpythonTypeNameExt(type)
- + QLatin1String(", reinterpret_cast<SbkObject *>(") + argName + QLatin1String(")))");
+ return u"reinterpret_cast< ::"_s + type->qualifiedCppName()
+ + u" *>(Shiboken::Conversions::cppPointer("_s + cpythonTypeNameExt(type)
+ + u", reinterpret_cast<SbkObject *>("_s + argName + u")))"_s;
}
void ShibokenGenerator::writeToPythonConversion(TextStream & s, const AbstractMetaType &type,
@@ -512,7 +518,7 @@ QString ShibokenGenerator::getFormatUnitString(const AbstractMetaFunctionCPtr &f
QString ShibokenGenerator::cpythonBaseName(const AbstractMetaType &type)
{
if (type.isCString())
- return QLatin1String("PyString");
+ return u"PyString"_s;
return cpythonBaseName(type.typeEntry());
}
@@ -525,7 +531,7 @@ QString ShibokenGenerator::cpythonBaseName(const TypeEntry *type)
{
QString baseName;
if (type->isWrapperType() || type->isNamespace()) { // && type->referenceType() == NoReference) {
- baseName = QLatin1String("Sbk_") + type->name();
+ baseName = u"Sbk_"_s + type->name();
} else if (type->isPrimitive()) {
const auto *ptype = type->asPrimitive()->basicReferencedTypeEntry();
baseName = ptype->hasTargetLangApiType()
@@ -545,11 +551,11 @@ QString ShibokenGenerator::cpythonBaseName(const TypeEntry *type)
baseName = cPySequenceT();
break;
case ContainerTypeEntry::SetContainer:
- baseName = QLatin1String("PySet");
+ baseName = u"PySet"_s;
break;
case ContainerTypeEntry::MapContainer:
case ContainerTypeEntry::MultiMapContainer:
- baseName = QLatin1String("PyDict");
+ baseName = u"PyDict"_s;
break;
default:
Q_ASSERT(false);
@@ -557,7 +563,7 @@ QString ShibokenGenerator::cpythonBaseName(const TypeEntry *type)
} else {
baseName = cPyObjectT();
}
- return baseName.replace(QLatin1String("::"), QLatin1String("_"));
+ return baseName.replace(u"::"_s, u"_"_s);
}
QString ShibokenGenerator::cpythonTypeName(const AbstractMetaClass *metaClass)
@@ -567,7 +573,7 @@ QString ShibokenGenerator::cpythonTypeName(const AbstractMetaClass *metaClass)
QString ShibokenGenerator::cpythonTypeName(const TypeEntry *type)
{
- return cpythonBaseName(type) + QLatin1String("_TypeF()");
+ return cpythonBaseName(type) + u"_TypeF()"_s;
}
QString ShibokenGenerator::cpythonTypeNameExt(const TypeEntry *type)
@@ -579,14 +585,14 @@ QString ShibokenGenerator::cpythonTypeNameExt(const TypeEntry *type)
QString ShibokenGenerator::converterObject(const AbstractMetaType &type)
{
if (type.isCString())
- return QLatin1String("Shiboken::Conversions::PrimitiveTypeConverter<const char *>()");
+ return u"Shiboken::Conversions::PrimitiveTypeConverter<const char *>()"_s;
if (type.isVoidPointer())
- return QLatin1String("Shiboken::Conversions::PrimitiveTypeConverter<void *>()");
+ return u"Shiboken::Conversions::PrimitiveTypeConverter<void *>()"_s;
const AbstractMetaTypeList nestedArrayTypes = type.nestedArrayTypes();
if (!nestedArrayTypes.isEmpty() && nestedArrayTypes.constLast().isCppPrimitive()) {
return QStringLiteral("Shiboken::Conversions::ArrayTypeConverter<")
+ nestedArrayTypes.constLast().minimalSignature()
- + QLatin1String(">(") + QString::number(nestedArrayTypes.size())
+ + u">("_s + QString::number(nestedArrayTypes.size())
+ u')';
}
@@ -626,8 +632,8 @@ QString ShibokenGenerator::converterObject(const TypeEntry *type)
}
pte = pte->basicReferencedTypeEntry();
if (pte->isPrimitive() && !pte->isCppPrimitive() && !pte->customConversion()) {
- return u"Shiboken::Conversions::PrimitiveTypeConverter<"_qs
- + pte->qualifiedCppName() + u">()"_qs;
+ return u"Shiboken::Conversions::PrimitiveTypeConverter<"_s
+ + pte->qualifiedCppName() + u">()"_s;
}
return convertersVariableName(type->targetLangPackage())
@@ -660,9 +666,9 @@ static QString _fixedCppTypeName(QString typeName)
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"));
+ typeName.replace(u"::"_s, u"_"_s);
+ typeName.replace(u"*"_s, u"PTR"_s);
+ typeName.replace(u"&"_s, u"REF"_s);
return typeName;
}
QString ShibokenGenerator::fixedCppTypeName(const TypeEntry *type, QString typeName)
@@ -681,7 +687,7 @@ QString ShibokenGenerator::pythonPrimitiveTypeName(const QString &cppTypeName)
const auto &mapping = primitiveTypesCorrespondences();
const auto it = mapping.constFind(cppTypeName);
if (it == mapping.cend())
- throw Exception(u"Primitive type not found: "_qs + cppTypeName);
+ throw Exception(u"Primitive type not found: "_s + cppTypeName);
return it.value();
}
@@ -694,9 +700,9 @@ QString ShibokenGenerator::pythonOperatorFunctionName(const AbstractMetaFunction
}
if (func->arguments().isEmpty()) {
if (op == u"__sub__")
- op = QLatin1String("__neg__");
+ op = u"__neg__"_s;
else if (op == u"__add__")
- op = QLatin1String("__pos__");
+ op = u"__pos__"_s;
} 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.
@@ -784,30 +790,30 @@ QString ShibokenGenerator::cpythonCheckFunction(AbstractMetaType metaType)
if (metaType.isExtendedCppPrimitive()) {
if (metaType.isCString())
- return QLatin1String("Shiboken::String::check");
+ return u"Shiboken::String::check"_s;
if (metaType.isVoidPointer())
- return u"true"_qs;
+ return u"true"_s;
return cpythonCheckFunction(typeEntry);
}
if (typeEntry->isContainer()) {
- QString typeCheck = QLatin1String("Shiboken::Conversions::");
+ QString typeCheck = u"Shiboken::Conversions::"_s;
ContainerTypeEntry::ContainerKind type =
static_cast<const ContainerTypeEntry *>(typeEntry)->containerKind();
if (type == ContainerTypeEntry::ListContainer
|| type == ContainerTypeEntry::SetContainer) {
const QString containerType = type == ContainerTypeEntry::SetContainer
- ? u"Iterable"_qs : u"Sequence"_qs;
+ ? u"Iterable"_s : u"Sequence"_s;
const AbstractMetaType &type = metaType.instantiations().constFirst();
if (type.isPointerToWrapperType()) {
- typeCheck += u"check"_qs + containerType + u"Types("_qs
- + cpythonTypeNameExt(type) + u", "_qs;
+ typeCheck += u"check"_s + containerType + u"Types("_s
+ + cpythonTypeNameExt(type) + u", "_s;
} else if (type.isWrapperType()) {
- typeCheck += u"convertible"_qs + containerType
- + u"Types("_qs + cpythonTypeNameExt(type) + u", "_qs;
+ typeCheck += u"convertible"_s + containerType
+ + u"Types("_s + cpythonTypeNameExt(type) + u", "_s;
} else {
- typeCheck += u"convertible"_qs + containerType
- + u"Types("_qs + converterObject(type) + u", "_qs;
+ typeCheck += u"convertible"_s + containerType
+ + u"Types("_s + converterObject(type) + u", "_s;
}
} else if (type == ContainerTypeEntry::MapContainer
|| type == ContainerTypeEntry::MultiMapContainer
@@ -815,11 +821,11 @@ QString ShibokenGenerator::cpythonCheckFunction(AbstractMetaType metaType)
QString pyType;
if (type == ContainerTypeEntry::PairContainer)
- pyType = u"Pair"_qs;
+ pyType = u"Pair"_s;
else if (type == ContainerTypeEntry::MultiMapContainer)
- pyType = u"MultiDict"_qs;
+ pyType = u"MultiDict"_s;
else
- pyType = u"Dict"_qs;
+ pyType = u"Dict"_s;
const AbstractMetaType &firstType = metaType.instantiations().constFirst();
const AbstractMetaType &secondType = metaType.instantiations().constLast();
@@ -851,7 +857,7 @@ QString ShibokenGenerator::cpythonCheckFunction(const TypeEntry *type)
}
if (type->isEnum() || type->isFlags() || type->isWrapperType())
- return u"SbkObject_TypeCheck("_qs + cpythonTypeNameExt(type) + u", "_qs;
+ return u"SbkObject_TypeCheck("_s + cpythonTypeNameExt(type) + u", "_s;
if (type->isPrimitive())
type = type->asPrimitive()->basicReferencedTypeEntry();
@@ -863,8 +869,7 @@ QString ShibokenGenerator::cpythonCheckFunction(const TypeEntry *type)
if (type->isExtendedCppPrimitive()) {
const auto *pte = type->asPrimitive();
- return pythonPrimitiveTypeName(pte->name())
- + QLatin1String("_Check");
+ return pythonPrimitiveTypeName(pte->name()) + u"_Check"_s;
}
return cpythonIsConvertibleFunction(type);
@@ -873,17 +878,15 @@ QString ShibokenGenerator::cpythonCheckFunction(const TypeEntry *type)
QString ShibokenGenerator::cpythonIsConvertibleFunction(const TypeEntry *type)
{
if (type->isWrapperType()) {
- QString result = QLatin1String("Shiboken::Conversions::");
+ QString result = u"Shiboken::Conversions::"_s;
bool isValue = false;
if (type->isValue()) {
const auto *cte = static_cast<const ComplexTypeEntry *>(type);
isValue = !cte->isValueTypeWithCopyConstructorOnly();
}
- result += isValue
- ? QLatin1String("isPythonToCppValueConvertible")
- : QLatin1String("isPythonToCppPointerConvertible");
- result += QLatin1String("(")
- + cpythonTypeNameExt(type) + QLatin1String(", ");
+ result += isValue ? u"isPythonToCppValueConvertible"_s
+ : u"isPythonToCppPointerConvertible"_s;
+ result += u"("_s + cpythonTypeNameExt(type) + u", "_s;
return result;
}
return QString::fromLatin1("Shiboken::Conversions::isPythonToCppConvertible(%1, ")
@@ -900,33 +903,33 @@ QString ShibokenGenerator::cpythonIsConvertibleFunction(AbstractMetaType metaTyp
throw Exception(msgUnknownCheckFunction(typeEntry));
}
- QString result = QLatin1String("Shiboken::Conversions::");
+ QString result = u"Shiboken::Conversions::"_s;
if (metaType.generateOpaqueContainer()) {
- result += u"pythonToCppReferenceConversion("_qs
- + converterObject(metaType) + u", "_qs;
+ result += u"pythonToCppReferenceConversion("_s
+ + converterObject(metaType) + u", "_s;
return result;
}
if (metaType.isWrapperType()) {
if (metaType.isPointer() || metaType.isValueTypeWithCopyConstructorOnly())
- result += u"pythonToCppPointerConversion"_qs;
+ result += u"pythonToCppPointerConversion"_s;
else if (metaType.referenceType() == LValueReference)
- result += u"pythonToCppReferenceConversion"_qs;
+ result += u"pythonToCppReferenceConversion"_s;
else
- result += u"pythonToCppValueConversion"_qs;
- result += u'(' + cpythonTypeNameExt(metaType) + u", "_qs;
+ result += u"pythonToCppValueConversion"_s;
+ result += u'(' + cpythonTypeNameExt(metaType) + u", "_s;
return result;
}
- result += u"pythonToCppConversion("_qs + converterObject(metaType);
+ result += u"pythonToCppConversion("_s + converterObject(metaType);
// Write out array sizes if known
const AbstractMetaTypeList nestedArrayTypes = metaType.nestedArrayTypes();
if (!nestedArrayTypes.isEmpty() && nestedArrayTypes.constLast().isCppPrimitive()) {
const int dim1 = metaType.arrayElementCount();
const int dim2 = nestedArrayTypes.constFirst().isArray()
? nestedArrayTypes.constFirst().arrayElementCount() : -1;
- result += QLatin1String(", ") + QString::number(dim1)
- + QLatin1String(", ") + QString::number(dim2);
+ result += u", "_s + QString::number(dim1)
+ + u", "_s + QString::number(dim2);
}
- result += QLatin1String(", ");
+ result += u", "_s;
return result;
}
@@ -937,17 +940,17 @@ QString ShibokenGenerator::cpythonIsConvertibleFunction(const AbstractMetaArgume
QString ShibokenGenerator::cpythonToCppConversionFunction(const AbstractMetaClass *metaClass)
{
- return QLatin1String("Shiboken::Conversions::pythonToCppPointer(")
- + cpythonTypeNameExt(metaClass->typeEntry()) + QLatin1String(", ");
+ return u"Shiboken::Conversions::pythonToCppPointer("_s
+ + cpythonTypeNameExt(metaClass->typeEntry()) + u", "_s;
}
QString ShibokenGenerator::cpythonToCppConversionFunction(const AbstractMetaType &type,
const AbstractMetaClass * /* context */)
{
if (type.isWrapperType()) {
- return QLatin1String("Shiboken::Conversions::pythonToCpp")
- + (type.isPointer() ? QLatin1String("Pointer") : QLatin1String("Copy"))
- + u'(' + cpythonTypeNameExt(type) + QLatin1String(", ");
+ return u"Shiboken::Conversions::pythonToCpp"_s
+ + (type.isPointer() ? u"Pointer"_s : u"Copy"_s)
+ + u'(' + cpythonTypeNameExt(type) + u", "_s;
}
return QStringLiteral("Shiboken::Conversions::pythonToCppCopy(%1, ")
.arg(converterObject(type));
@@ -960,22 +963,22 @@ QString ShibokenGenerator::cpythonToPythonConversionFunction(const AbstractMetaT
QString conversion;
if (type.referenceType() == LValueReference
&& !(type.isValue() && type.isConstant()) && !type.isPointer()) {
- conversion = QLatin1String("reference");
+ conversion = u"reference"_s;
} else if (type.isValue() || type.isSmartPointer()) {
- conversion = QLatin1String("copy");
+ conversion = u"copy"_s;
} else {
- conversion = QLatin1String("pointer");
+ conversion = u"pointer"_s;
}
- QString result = QLatin1String("Shiboken::Conversions::") + conversion
- + QLatin1String("ToPython(")
- + cpythonTypeNameExt(type) + QLatin1String(", ");
+ QString result = u"Shiboken::Conversions::"_s + conversion
+ + u"ToPython("_s
+ + cpythonTypeNameExt(type) + u", "_s;
if (conversion != u"pointer")
result += u'&';
return result;
}
return QStringLiteral("Shiboken::Conversions::copyToPython(%1, %2")
.arg(converterObject(type),
- (type.isCString() || type.isVoidPointer()) ? QString() : QLatin1String("&"));
+ (type.isCString() || type.isVoidPointer()) ? QString() : u"&"_s);
}
QString ShibokenGenerator::cpythonToPythonConversionFunction(const AbstractMetaClass *metaClass)
@@ -986,17 +989,17 @@ QString ShibokenGenerator::cpythonToPythonConversionFunction(const AbstractMetaC
QString ShibokenGenerator::cpythonToPythonConversionFunction(const TypeEntry *type)
{
if (type->isWrapperType()) {
- const QString conversion = type->isValue() ? QLatin1String("copy") : QLatin1String("pointer");
- QString result = QLatin1String("Shiboken::Conversions::") + conversion
- + QLatin1String("ToPython(") + cpythonTypeNameExt(type)
- + QLatin1String(", ");
+ const QString conversion = type->isValue() ? u"copy"_s : u"pointer"_s;
+ QString result = u"Shiboken::Conversions::"_s + conversion
+ + u"ToPython("_s + cpythonTypeNameExt(type)
+ + u", "_s;
if (conversion != u"pointer")
result += u'&';
return result;
}
- return u"Shiboken::Conversions::copyToPython("_qs
- + converterObject(type) + u", &"_qs;
+ return u"Shiboken::Conversions::copyToPython("_s
+ + converterObject(type) + u", &"_s;
}
QString ShibokenGenerator::argumentString(const AbstractMetaFunctionCPtr &func,
@@ -1023,13 +1026,13 @@ QString ShibokenGenerator::argumentString(const AbstractMetaFunctionCPtr &func,
{
QString default_value = argument.originalDefaultValueExpression();
if (default_value == u"NULL")
- default_value = QLatin1String(NULL_PTR);
+ default_value = QLatin1StringView(NULL_PTR);
//WORKAROUND: fix this please
if (default_value.startsWith(u"new "))
default_value.remove(0, 4);
- arg += QLatin1String(" = ") + default_value;
+ arg += u" = "_s + default_value;
}
return arg;
@@ -1261,11 +1264,11 @@ void ShibokenGenerator::processClassCodeSnip(QString &code, const GeneratorConte
auto metaClass = context.metaClass();
// Replace template variable by the Python Type object
// for the class context in which the variable is used.
- code.replace(QLatin1String("%PYTHONTYPEOBJECT"),
- u"(*"_qs + cpythonTypeName(metaClass) + u')');
+ code.replace(u"%PYTHONTYPEOBJECT"_s,
+ u"(*"_s + cpythonTypeName(metaClass) + u')');
const QString className = context.effectiveClassName();
- code.replace(QLatin1String("%TYPE"), className);
- code.replace(QLatin1String("%CPPTYPE"), metaClass->name());
+ code.replace(u"%TYPE"_s, className);
+ code.replace(u"%CPPTYPE"_s, metaClass->name());
processCodeSnip(code);
}
@@ -1303,19 +1306,19 @@ ShibokenGenerator::ArgumentVarReplacementList
if (argRemoved)
++removed;
if (argRemoved && hasConversionRule)
- argValue = arg.name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX);
+ argValue = arg.name() + QLatin1StringView(CONV_RULE_OUT_VAR_SUFFIX);
else if (argRemoved || (lastArg && arg.argumentIndex() > lastArg->argumentIndex()))
- argValue = QLatin1String(CPP_ARG_REMOVED) + QString::number(i);
+ argValue = QLatin1StringView(CPP_ARG_REMOVED) + QString::number(i);
if (!argRemoved && argValue.isEmpty()) {
int argPos = i - removed;
AbstractMetaType type = arg.modifiedType();
if (type.typeEntry()->isCustom()) {
argValue = usePyArgs
- ? pythonArgsAt(argPos) : QLatin1String(PYTHON_ARG);
+ ? pythonArgsAt(argPos) : QLatin1StringView(PYTHON_ARG);
} else {
argValue = hasConversionRule
- ? arg.name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX)
- : QLatin1String(CPP_ARG) + QString::number(argPos);
+ ? arg.name() + QLatin1StringView(CONV_RULE_OUT_VAR_SUFFIX)
+ : QLatin1StringView(CPP_ARG) + QString::number(argPos);
auto deRef = type.shouldDereferenceArgument();
AbstractMetaType::applyDereference(&argValue, deRef);
}
@@ -1357,8 +1360,8 @@ void ShibokenGenerator::writeCodeSnips(TextStream &s,
static void replacePyArg0(TypeSystem::Language language, QString *code)
{
- static const QString pyArg0 = u"%PYARG_0"_qs;
- static const QString pyReturn = QLatin1String(PYTHON_RETURN_VAR);
+ static const QString pyArg0 = u"%PYARG_0"_s;
+ static const QString pyReturn = QLatin1StringView(PYTHON_RETURN_VAR);
if (!code->contains(pyArg0))
return;
@@ -1372,7 +1375,7 @@ static void replacePyArg0(TypeSystem::Language language, QString *code)
// situations (fex _PyVarObject_CAST(op) defined as ((PyVarObject*)(op))).
// Append ".object()" unless it is followed by a '.' indicating explicit
// AutoDecRef member invocation.
- static const QString pyObject = pyReturn + u".object()"_qs;
+ static const QString pyObject = pyReturn + u".object()"_s;
qsizetype pos{};
while ( (pos = code->indexOf(pyArg0)) >= 0) {
const auto next = pos + pyArg0.size();
@@ -1401,7 +1404,7 @@ void ShibokenGenerator::writeCodeSnips(TextStream &s,
Q_ASSERT(pyArgsRegex.isValid());
if (language == TypeSystem::TargetLangCode) {
if (usePyArgs) {
- code.replace(pyArgsRegex, QLatin1String(PYTHON_ARGS) + QLatin1String("[\\1-1]"));
+ code.replace(pyArgsRegex, QLatin1StringView(PYTHON_ARGS) + u"[\\1-1]"_s);
} else {
static const QRegularExpression pyArgsRegexCheck(QStringLiteral("%PYARG_([2-9]+)"));
Q_ASSERT(pyArgsRegexCheck.isValid());
@@ -1411,24 +1414,24 @@ void ShibokenGenerator::writeCodeSnips(TextStream &s,
<< msgWrongIndex("%PYARG", match.captured(1), func.data());
return;
}
- code.replace(QLatin1String("%PYARG_1"), QLatin1String(PYTHON_ARG));
+ code.replace(u"%PYARG_1"_s, QLatin1StringView(PYTHON_ARG));
}
} else {
// Replaces the simplest case of attribution to a
// Python argument on the binding virtual method.
static const QRegularExpression pyArgsAttributionRegex(QStringLiteral("%PYARG_(\\d+)\\s*=[^=]\\s*([^;]+)"));
Q_ASSERT(pyArgsAttributionRegex.isValid());
- code.replace(pyArgsAttributionRegex, QLatin1String("PyTuple_SET_ITEM(")
- + QLatin1String(PYTHON_ARGS) + QLatin1String(", \\1-1, \\2)"));
- code.replace(pyArgsRegex, QLatin1String("PyTuple_GET_ITEM(")
- + QLatin1String(PYTHON_ARGS) + QLatin1String(", \\1-1)"));
+ code.replace(pyArgsAttributionRegex, u"PyTuple_SET_ITEM("_s
+ + QLatin1StringView(PYTHON_ARGS) + u", \\1-1, \\2)"_s);
+ code.replace(pyArgsRegex, u"PyTuple_GET_ITEM("_s
+ + QLatin1StringView(PYTHON_ARGS) + u", \\1-1)"_s);
}
// Replace %ARG#_TYPE variables.
const AbstractMetaArgumentList &arguments = func->arguments();
for (const AbstractMetaArgument &arg : arguments) {
- QString argTypeVar = u"%ARG"_qs + QString::number(arg.argumentIndex() + 1)
- + u"_TYPE"_qs;
+ QString argTypeVar = u"%ARG"_s + QString::number(arg.argumentIndex() + 1)
+ + u"_TYPE"_s;
QString argTypeVal = arg.type().cppSignature();
code.replace(argTypeVar, argTypeVal);
}
@@ -1444,65 +1447,67 @@ void ShibokenGenerator::writeCodeSnips(TextStream &s,
// Replace template variable for return variable name.
if (func->isConstructor()) {
- code.replace(QLatin1String("%0."), QLatin1String("cptr->"));
- code.replace(QLatin1String("%0"), QLatin1String("cptr"));
+ code.replace(u"%0."_s, u"cptr->"_s);
+ code.replace(u"%0"_s, u"cptr"_s);
} else if (!func->isVoid()) {
QString returnValueOp = func->type().isPointerToWrapperType()
- ? QLatin1String("%1->") : QLatin1String("%1.");
+ ? u"%1->"_s : u"%1."_s;
if (func->type().isWrapperType())
- code.replace(QLatin1String("%0."), returnValueOp.arg(QLatin1String(CPP_RETURN_VAR)));
- code.replace(QLatin1String("%0"), QLatin1String(CPP_RETURN_VAR));
+ code.replace(u"%0."_s, returnValueOp.arg(QLatin1StringView(CPP_RETURN_VAR)));
+ code.replace(u"%0"_s, QLatin1StringView(CPP_RETURN_VAR));
}
// Replace template variable for self Python object.
QString pySelf = language == TypeSystem::NativeCode
- ? QLatin1String("pySelf") : QLatin1String("self");
- code.replace(QLatin1String("%PYSELF"), pySelf);
+ ? u"pySelf"_s : u"self"_s;
+ code.replace(u"%PYSELF"_s, pySelf);
// Replace template variable for a pointer to C++ of this object.
if (func->implementingClass()) {
- QString replacement = func->isStatic() ? QLatin1String("%1::") : QLatin1String("%1->");
+ QString replacement = func->isStatic() ? u"%1::"_s : u"%1->"_s;
QString cppSelf;
if (func->isStatic())
cppSelf = func->ownerClass()->qualifiedCppName();
else if (language == TypeSystem::NativeCode)
- cppSelf = QLatin1String("this");
+ cppSelf = u"this"_s;
else
- cppSelf = QLatin1String(CPP_SELF_VAR);
+ cppSelf = QLatin1StringView(CPP_SELF_VAR);
// On comparison operator CPP_SELF_VAR is always a reference.
if (func->isComparisonOperator())
- replacement = QLatin1String("%1.");
+ replacement = u"%1."_s;
if (func->isVirtual() && !func->isAbstract() && (!avoidProtectedHack() || !func->isProtected())) {
QString methodCallArgs = getArgumentsFromMethodCall(code);
if (!methodCallArgs.isEmpty()) {
- const QString pattern = u"%CPPSELF.%FUNCTION_NAME("_qs + methodCallArgs + u')';
- QString replacement = u"(Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject *>("_qs
- + pySelf + u")) ? "_qs;
+ const QString pattern = u"%CPPSELF.%FUNCTION_NAME("_s + methodCallArgs + u')';
+ QString replacement = u"(Shiboken::Object::hasCppWrapper(reinterpret_cast<SbkObject *>("_s
+ + pySelf + u")) ? "_s;
if (func->name() == u"metaObject") {
QString wrapperClassName = wrapperName(func->ownerClass());
QString cppSelfVar = avoidProtectedHack()
- ? u"%CPPSELF"_qs
- : u"reinterpret_cast<"_qs + wrapperClassName + u" *>(%CPPSELF)"_qs;
- replacement += cppSelfVar + u"->::"_qs + wrapperClassName
- + u"::%FUNCTION_NAME("_qs + methodCallArgs
- + u") : %CPPSELF.%FUNCTION_NAME("_qs + methodCallArgs + u"))"_qs;
+ ? u"%CPPSELF"_s
+ : u"reinterpret_cast<"_s + wrapperClassName + u" *>(%CPPSELF)"_s;
+ replacement += cppSelfVar + u"->::"_s + wrapperClassName
+ + u"::%FUNCTION_NAME("_s + methodCallArgs
+ + u") : %CPPSELF.%FUNCTION_NAME("_s + methodCallArgs + u"))"_s;
} else {
- replacement += u"%CPPSELF->::%TYPE::%FUNCTION_NAME("_qs + methodCallArgs
- + u") : %CPPSELF.%FUNCTION_NAME("_qs + methodCallArgs + u"))"_qs;
+ replacement += u"%CPPSELF->::%TYPE::%FUNCTION_NAME("_s + methodCallArgs
+ + u") : %CPPSELF.%FUNCTION_NAME("_s + methodCallArgs + u"))"_s;
}
code.replace(pattern, replacement);
}
}
- code.replace(QLatin1String("%CPPSELF."), replacement.arg(cppSelf));
- code.replace(QLatin1String("%CPPSELF"), cppSelf);
+ code.replace(u"%CPPSELF."_s, replacement.arg(cppSelf));
+ code.replace(u"%CPPSELF"_s, cppSelf);
if (code.indexOf(u"%BEGIN_ALLOW_THREADS") > -1) {
- if (code.count(QLatin1String("%BEGIN_ALLOW_THREADS")) == code.count(QLatin1String("%END_ALLOW_THREADS"))) {
- code.replace(QLatin1String("%BEGIN_ALLOW_THREADS"), QLatin1String(BEGIN_ALLOW_THREADS));
- code.replace(QLatin1String("%END_ALLOW_THREADS"), QLatin1String(END_ALLOW_THREADS));
+ if (code.count(u"%BEGIN_ALLOW_THREADS"_s) == code.count(u"%END_ALLOW_THREADS"_s)) {
+ code.replace(u"%BEGIN_ALLOW_THREADS"_s,
+ QLatin1StringView(BEGIN_ALLOW_THREADS));
+ code.replace(u"%END_ALLOW_THREADS"_s,
+ QLatin1StringView(END_ALLOW_THREADS));
} else {
qCWarning(lcShiboken) << "%BEGIN_ALLOW_THREADS and %END_ALLOW_THREADS mismatch";
}
@@ -1511,11 +1516,11 @@ void ShibokenGenerator::writeCodeSnips(TextStream &s,
// replace template variable for the Python Type object for the
// class implementing the method in which the code snip is written
if (func->isStatic()) {
- code.replace(QLatin1String("%PYTHONTYPEOBJECT"),
- u"(*"_qs + cpythonTypeName(func->implementingClass()) + u')');
+ code.replace(u"%PYTHONTYPEOBJECT"_s,
+ u"(*"_s + cpythonTypeName(func->implementingClass()) + u')');
} else {
- code.replace(QLatin1String("%PYTHONTYPEOBJECT."), pySelf + QLatin1String("->ob_type->"));
- code.replace(QLatin1String("%PYTHONTYPEOBJECT"), pySelf + QLatin1String("->ob_type"));
+ code.replace(u"%PYTHONTYPEOBJECT."_s, pySelf + u"->ob_type->"_s);
+ code.replace(u"%PYTHONTYPEOBJECT"_s, pySelf + u"->ob_type"_s);
}
}
@@ -1525,11 +1530,11 @@ void ShibokenGenerator::writeCodeSnips(TextStream &s,
QStringList args;
for (const ArgumentVarReplacementPair &pair : argReplacements) {
- if (pair.second.startsWith(QLatin1String(CPP_ARG_REMOVED)))
+ if (pair.second.startsWith(QLatin1StringView(CPP_ARG_REMOVED)))
continue;
args << pair.second;
}
- code.replace(QLatin1String("%ARGUMENT_NAMES"), args.join(QLatin1String(", ")));
+ code.replace(u"%ARGUMENT_NAMES"_s, args.join(u", "_s));
for (const ArgumentVarReplacementPair &pair : argReplacements) {
const AbstractMetaArgument &arg = pair.first;
@@ -1540,7 +1545,7 @@ void ShibokenGenerator::writeCodeSnips(TextStream &s,
if (type.shouldDereferenceArgument() > 0)
AbstractMetaType::stripDereference(&replacement);
if (type.referenceType() == LValueReference || type.isPointer())
- code.replace(u'%' + QString::number(idx) + u'.', replacement + u"->"_qs);
+ code.replace(u'%' + QString::number(idx) + u'.', replacement + u"->"_s);
}
code.replace(CodeSnipAbstract::placeHolderRegex(idx), pair.second);
}
@@ -1549,11 +1554,11 @@ void ShibokenGenerator::writeCodeSnips(TextStream &s,
// Replaces template %PYTHON_ARGUMENTS variable with a pointer to the Python tuple
// containing the converted virtual method arguments received from C++ to be passed
// to the Python override.
- code.replace(QLatin1String("%PYTHON_ARGUMENTS"), QLatin1String(PYTHON_ARGS));
+ code.replace(u"%PYTHON_ARGUMENTS"_s, QLatin1StringView(PYTHON_ARGS));
// replace variable %PYTHON_METHOD_OVERRIDE for a pointer to the Python method
// override for the C++ virtual method in which this piece of code was inserted
- code.replace(QLatin1String("%PYTHON_METHOD_OVERRIDE"), QLatin1String(PYTHON_OVERRIDE_VAR));
+ code.replace(u"%PYTHON_METHOD_OVERRIDE"_s, QLatin1StringView(PYTHON_OVERRIDE_VAR));
}
if (avoidProtectedHack()) {
@@ -1573,19 +1578,19 @@ void ShibokenGenerator::writeCodeSnips(TextStream &s,
}
if (isProtected) {
- code.replace(QLatin1String("%TYPE::%FUNCTION_NAME"),
+ code.replace(u"%TYPE::%FUNCTION_NAME"_s,
QStringLiteral("%1::%2_protected")
.arg(wrapperName(func->ownerClass()), func->originalName()));
- code.replace(QLatin1String("%FUNCTION_NAME"),
- func->originalName() + QLatin1String("_protected"));
+ code.replace(u"%FUNCTION_NAME"_s,
+ func->originalName() + u"_protected"_s);
}
}
if (func->isConstructor() && shouldGenerateCppWrapper(func->ownerClass()))
- code.replace(QLatin1String("%TYPE"), wrapperName(func->ownerClass()));
+ code.replace(u"%TYPE"_s, wrapperName(func->ownerClass()));
if (func->ownerClass())
- code.replace(QLatin1String("%CPPTYPE"), func->ownerClass()->name());
+ code.replace(u"%CPPTYPE"_s, func->ownerClass()->name());
replaceTemplateVariables(code, func);
@@ -1650,10 +1655,10 @@ static QString getConverterTypeSystemVariableArgument(const QString &code, int p
const QHash<int, QString> &ShibokenGenerator::typeSystemConvName()
{
static const QHash<int, QString> result = {
- {TypeSystemCheckFunction, QLatin1String("checkType")},
- {TypeSystemIsConvertibleFunction, QLatin1String("isConvertible")},
- {TypeSystemToCppFunction, QLatin1String("toCpp")},
- {TypeSystemToPythonFunction, QLatin1String("toPython")}
+ {TypeSystemCheckFunction, u"checkType"_s},
+ {TypeSystemIsConvertibleFunction, u"isConvertible"_s},
+ {TypeSystemToCppFunction, u"toCpp"_s},
+ {TypeSystemToPythonFunction, u"toPython"_s}
};
return result;
}
@@ -1737,7 +1742,7 @@ void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVa
}
if (conversion.contains(u"%in")) {
conversion.prepend(u'(');
- conversion.replace(QLatin1String("%in"), arg);
+ conversion.replace(u"%in"_s, arg);
} else {
conversion += arg;
}
@@ -1756,7 +1761,7 @@ bool ShibokenGenerator::injectedCodeCallsCppFunction(const GeneratorContext &con
return true;
QString funcCall = func->originalName() + u'(';
if (func->isConstructor())
- funcCall.prepend(QLatin1String("new "));
+ funcCall.prepend(u"new "_s);
if (func->injectedCodeContains(funcCall))
return true;
if (!func->isConstructor())
@@ -1766,7 +1771,7 @@ bool ShibokenGenerator::injectedCodeCallsCppFunction(const GeneratorContext &con
const auto owner = func->ownerClass();
if (!owner->isPolymorphic())
return false;
- const QString wrappedCtorCall = u"new "_qs + context.effectiveClassName() + u'(';
+ const QString wrappedCtorCall = u"new "_s + context.effectiveClassName() + u'(';
return func->injectedCodeContains(wrappedCtorCall);
}
@@ -2078,24 +2083,24 @@ Generator::OptionDescriptions ShibokenGenerator::options() const
{
auto result = Generator::options();
result.append({
- {QLatin1String(DISABLE_VERBOSE_ERROR_MESSAGES),
- QLatin1String("Disable verbose error messages. Turn the python code hard to debug\n"
- "but safe few kB on the generated bindings.")},
- {QLatin1String(PARENT_CTOR_HEURISTIC),
- QLatin1String("Enable heuristics to detect parent relationship on constructors.")},
- {QLatin1String(RETURN_VALUE_HEURISTIC),
- QLatin1String("Enable heuristics to detect parent relationship on return values\n"
- "(USE WITH CAUTION!)")},
- {QLatin1String(USE_ISNULL_AS_NB_NONZERO),
- QLatin1String("If a class have an isNull() const method, it will be used to compute\n"
- "the value of boolean casts")},
- {QLatin1String(USE_OPERATOR_BOOL_AS_NB_NONZERO),
- QLatin1String("If a class has an operator bool, it will be used to compute\n"
- "the value of boolean casts")},
- {QLatin1String(NO_IMPLICIT_CONVERSIONS),
- u"Do not generate implicit_conversions for function arguments."_qs},
- {QLatin1String(WRAPPER_DIAGNOSTICS),
- QLatin1String("Generate diagnostic code around wrappers")}
+ {QLatin1StringView(DISABLE_VERBOSE_ERROR_MESSAGES),
+ u"Disable verbose error messages. Turn the python code hard to debug\n"
+ "but safe few kB on the generated bindings."_s},
+ {QLatin1StringView(PARENT_CTOR_HEURISTIC),
+ u"Enable heuristics to detect parent relationship on constructors."_s},
+ {QLatin1StringView(RETURN_VALUE_HEURISTIC),
+ u"Enable heuristics to detect parent relationship on return values\n"
+ "(USE WITH CAUTION!)"_s},
+ {QLatin1StringView(USE_ISNULL_AS_NB_NONZERO),
+ u"If a class have an isNull() const method, it will be used to compute\n"
+ "the value of boolean casts"_s},
+ {QLatin1StringView(USE_OPERATOR_BOOL_AS_NB_NONZERO),
+ u"If a class has an operator bool, it will be used to compute\n"
+ "the value of boolean casts"_s},
+ {QLatin1StringView(NO_IMPLICIT_CONVERSIONS),
+ u"Do not generate implicit_conversions for function arguments."_s},
+ {QLatin1StringView(WRAPPER_DIAGNOSTICS),
+ u"Generate diagnostic code around wrappers"_s}
});
return result;
}
@@ -2104,21 +2109,21 @@ bool ShibokenGenerator::handleOption(const QString &key, const QString &value)
{
if (Generator::handleOption(key, value))
return true;
- if (key == QLatin1String(PARENT_CTOR_HEURISTIC))
+ if (key == QLatin1StringView(PARENT_CTOR_HEURISTIC))
return (m_useCtorHeuristic = true);
- if (key == QLatin1String(RETURN_VALUE_HEURISTIC))
+ if (key == QLatin1StringView(RETURN_VALUE_HEURISTIC))
return (m_userReturnValueHeuristic = true);
- if (key == QLatin1String(DISABLE_VERBOSE_ERROR_MESSAGES))
+ if (key == QLatin1StringView(DISABLE_VERBOSE_ERROR_MESSAGES))
return (m_verboseErrorMessagesDisabled = true);
- if (key == QLatin1String(USE_ISNULL_AS_NB_NONZERO))
+ if (key == QLatin1StringView(USE_ISNULL_AS_NB_NONZERO))
return (m_useIsNullAsNbNonZero = true);
- if (key == QLatin1String(USE_OPERATOR_BOOL_AS_NB_NONZERO))
+ if (key == QLatin1StringView(USE_OPERATOR_BOOL_AS_NB_NONZERO))
return (m_useOperatorBoolAsNbNonZero = true);
- if (key == QLatin1String(NO_IMPLICIT_CONVERSIONS)) {
+ if (key == QLatin1StringView(NO_IMPLICIT_CONVERSIONS)) {
return m_generateImplicitConversions = false;
return true;
}
- if (key == QLatin1String(WRAPPER_DIAGNOSTICS))
+ if (key == QLatin1StringView(WRAPPER_DIAGNOSTICS))
return (m_wrapperDiagnostics = true);
return false;
}
@@ -2162,21 +2167,19 @@ QString ShibokenGenerator::moduleCppPrefix(const QString &moduleName)
QString ShibokenGenerator::cppApiVariableName(const QString &moduleName)
{
- return QLatin1String("Sbk") + moduleCppPrefix(moduleName)
- + QLatin1String("Types");
+ return u"Sbk"_s + moduleCppPrefix(moduleName) + u"Types"_s;
}
QString ShibokenGenerator::pythonModuleObjectName(const QString &moduleName)
{
- return QLatin1String("Sbk") + moduleCppPrefix(moduleName)
- + QLatin1String("ModuleObject");
+ return u"Sbk"_s + moduleCppPrefix(moduleName) + u"ModuleObject"_s;
}
QString ShibokenGenerator::convertersVariableName(const QString &moduleName)
{
QString result = cppApiVariableName(moduleName);
result.chop(1);
- result.append(QLatin1String("Converters"));
+ result.append(u"Converters"_s);
return result;
}
@@ -2202,7 +2205,7 @@ QString ShibokenGenerator::getTypeAlternateTemplateIndexVariableName(const Abstr
{
const AbstractMetaClass *templateBaseClass = metaClass->templateBaseClass();
Q_ASSERT(templateBaseClass);
- QString result = QLatin1String("SBK_")
+ QString result = u"SBK_"_s
+ _fixedCppTypeName(templateBaseClass->typeEntry()->qualifiedCppName()).toUpper();
for (const auto &instantiation : metaClass->templateBaseClassInstantiations())
result += processInstantiationsVariableName(instantiation);
@@ -2218,7 +2221,7 @@ QString ShibokenGenerator::getTypeIndexVariableName(const TypeEntry *type)
{
if (type->isCppPrimitive())
type = type->asPrimitive()->basicReferencedTypeEntry();
- QString result = QLatin1String("SBK_");
+ QString result = u"SBK_"_s;
// Disambiguate namespaces per module to allow for extending them.
if (type->isNamespace()) {
QString package = type->targetLangPackage();
@@ -2231,7 +2234,7 @@ QString ShibokenGenerator::getTypeIndexVariableName(const TypeEntry *type)
}
QString ShibokenGenerator::getTypeIndexVariableName(const AbstractMetaType &type)
{
- QString result = QLatin1String("SBK");
+ QString result = u"SBK"_s;
if (type.typeEntry()->isContainer())
result += u'_' + moduleName().toUpper();
result += processInstantiationsVariableName(type);
@@ -2264,10 +2267,10 @@ QString ShibokenGenerator::minimalConstructorExpression(const ApiExtractorResult
return ctor->initialization();
const QString message =
- msgCouldNotFindMinimalConstructor(QLatin1String(__FUNCTION__),
+ msgCouldNotFindMinimalConstructor(QLatin1StringView(__FUNCTION__),
type.cppSignature(), errorMessage);
qCWarning(lcShiboken()).noquote() << message;
- return u";\n#error "_qs + message + u'\n';
+ return u";\n#error "_s + message + u'\n';
}
QString ShibokenGenerator::minimalConstructorExpression(const ApiExtractorResult &api,
@@ -2279,15 +2282,16 @@ QString ShibokenGenerator::minimalConstructorExpression(const ApiExtractorResult
if (ctor.has_value())
return ctor->initialization();
- const QString message = msgCouldNotFindMinimalConstructor(QLatin1String(__FUNCTION__),
- type->qualifiedCppName());
+ const QString message =
+ msgCouldNotFindMinimalConstructor(QLatin1StringView(__FUNCTION__),
+ type->qualifiedCppName());
qCWarning(lcShiboken()).noquote() << message;
- return u";\n#error "_qs + message + u'\n';
+ return u";\n#error "_s + message + u'\n';
}
QString ShibokenGenerator::pythonArgsAt(int i)
{
- return QLatin1String(PYTHON_ARGS) + u'[' + QString::number(i) + u']';
+ return QLatin1StringView(PYTHON_ARGS) + u'[' + QString::number(i) + u']';
}
void ShibokenGenerator::replaceTemplateVariables(QString &code,
@@ -2295,25 +2299,25 @@ void ShibokenGenerator::replaceTemplateVariables(QString &code,
{
const AbstractMetaClass *cpp_class = func->ownerClass();
if (cpp_class)
- code.replace(QLatin1String("%TYPE"), cpp_class->name());
+ code.replace(u"%TYPE"_s, cpp_class->name());
const AbstractMetaArgumentList &argument = func->arguments();
for (const AbstractMetaArgument &arg : argument)
code.replace(u'%' + QString::number(arg.argumentIndex() + 1), arg.name());
//template values
- code.replace(QLatin1String("%RETURN_TYPE"), translateType(func->type(), cpp_class));
- code.replace(QLatin1String("%FUNCTION_NAME"), func->originalName());
+ code.replace(u"%RETURN_TYPE"_s, translateType(func->type(), cpp_class));
+ code.replace(u"%FUNCTION_NAME"_s, func->originalName());
if (code.contains(u"%ARGUMENT_NAMES")) {
StringStream aux_stream;
writeArgumentNames(aux_stream, func, Generator::SkipRemovedArguments);
- code.replace(QLatin1String("%ARGUMENT_NAMES"), aux_stream);
+ code.replace(u"%ARGUMENT_NAMES"_s, aux_stream);
}
if (code.contains(u"%ARGUMENTS")) {
StringStream aux_stream;
writeFunctionArguments(aux_stream, func, Options(SkipDefaultValues) | SkipRemovedArguments);
- code.replace(QLatin1String("%ARGUMENTS"), aux_stream);
+ code.replace(u"%ARGUMENTS"_s, aux_stream);
}
}
diff --git a/sources/shiboken6/generator/shiboken/shibokengenerator.h b/sources/shiboken6/generator/shiboken/shibokengenerator.h
index 74e6a460f..2b0c81426 100644
--- a/sources/shiboken6/generator/shiboken/shibokengenerator.h
+++ b/sources/shiboken6/generator/shiboken/shibokengenerator.h
@@ -259,7 +259,7 @@ protected:
static QString cpythonSetterFunctionName(const QPropertySpec &property,
const AbstractMetaClass *metaClass);
static QString cpythonWrapperCPtr(const AbstractMetaClass *metaClass,
- const QString &argName = QLatin1String("self"));
+ const QString &argName = QStringLiteral("self"));
static QString cpythonWrapperCPtr(const AbstractMetaType &metaType,
const QString &argName);
static QString cpythonWrapperCPtr(const TypeEntry *type, const QString &argName);