aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/pyside6/PySide6/QtCore/typesystem_core_common.xml25
-rw-r--r--sources/pyside6/doc/tutorials/basictutorial/qrcfiles.rst5
-rw-r--r--sources/shiboken6/tests/samplebinding/typesystem_sample.xml6
-rw-r--r--sources/shiboken6_generator/ApiExtractor/abstractmetabuilder.cpp214
-rw-r--r--sources/shiboken6_generator/ApiExtractor/abstractmetabuilder_p.h15
-rw-r--r--sources/shiboken6_generator/ApiExtractor/abstractmetafunction.cpp25
-rw-r--r--sources/shiboken6_generator/ApiExtractor/abstractmetalang.cpp1
-rw-r--r--sources/shiboken6_generator/ApiExtractor/apiextractor.cpp4
-rw-r--r--sources/shiboken6_generator/ApiExtractor/fileout.cpp6
-rw-r--r--sources/shiboken6_generator/ApiExtractor/messages.cpp6
-rw-r--r--sources/shiboken6_generator/ApiExtractor/typesystemparser.cpp22
-rw-r--r--sources/shiboken6_generator/generator/generator.cpp2
-rw-r--r--sources/shiboken6_generator/generator/qtdoc/qtdocgenerator.cpp4
-rw-r--r--sources/shiboken6_generator/generator/shiboken/shibokengenerator.cpp5
14 files changed, 190 insertions, 150 deletions
diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml
index acf9202cb..e4b39ed0a 100644
--- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml
+++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml
@@ -2101,17 +2101,14 @@
<!-- ### These overloads must be removed accept strings with \x00 in their contents -->
<modify-function signature="append(const char*)" remove="all"/>
<modify-function signature="prepend(const char*)" remove="all"/>
- <modify-function signature="operator==(const char*,QByteArray)" remove="all"/>
- <modify-function signature="operator==(QByteArray,const char*)" remove="all"/>
- <modify-function signature="operator>(const char*,QByteArray)" remove="all"/>
- <modify-function signature="operator>(QByteArray,const char*)" remove="all"/>
- <modify-function signature="operator>=(const char*,QByteArray)" remove="all"/>
- <modify-function signature="operator>=(QByteArray,const char*)" remove="all"/>
- <modify-function signature="operator&lt;(const char*,QByteArray)" remove="all"/>
- <modify-function signature="operator&lt;=(const char*,QByteArray)" remove="all"/>
- <modify-function signature="operator&lt;=(QByteArray,const char*)" remove="all"/>
- <modify-function signature="operator!=(const char*,QByteArray)" remove="all"/>
- <modify-function signature="operator!=(QByteArray,const char*)" remove="all"/>
+ <modify-function signature="operator==(const char*)const" remove="all"/>
+ <modify-function signature="operator>(const char*)const" remove="all"/>
+ <modify-function signature="operator>(const char*)const" remove="all"/>
+ <modify-function signature="operator>=(const char*)const" remove="all"/>
+ <modify-function signature="operator>=(const char*)const" remove="all"/>
+ <modify-function signature="operator&lt;(const char*)const" remove="all"/>
+ <modify-function signature="operator&lt;=(const char*)const" remove="all"/>
+ <modify-function signature="operator!=(const char*)const" remove="all"/>
<modify-function signature="operator+=(const char*)" remove="all"/>
<modify-function signature="operator+(QByteArray,const char*)" remove="all"/>
<modify-function signature="operator+(const char*,QByteArray)" remove="all"/>
@@ -2190,12 +2187,6 @@
<modify-function signature="number(qulonglong,int)" remove="all"/>
<modify-function signature="operator+=(const char*)" remove="all"/>
<modify-function signature="operator+(char,QByteArray)" remove="all"/>
- <modify-function signature="operator==(const char*,QByteArray)" remove="all"/>
- <modify-function signature="operator!=(const char*,QByteArray)" remove="all"/>
- <modify-function signature="operator&lt;(const char*,QByteArray)" remove="all"/>
- <modify-function signature="operator&lt;=(const char*,QByteArray)" remove="all"/>
- <modify-function signature="operator>(const char*,QByteArray)" remove="all"/>
- <modify-function signature="operator>=(const char*,QByteArray)" remove="all"/>
<!-- Those types have the same representation in Python, an overload
would be useless and cause overflow errors. -->
<modify-function signature="setNum(uint,int)" remove="all"/>
diff --git a/sources/pyside6/doc/tutorials/basictutorial/qrcfiles.rst b/sources/pyside6/doc/tutorials/basictutorial/qrcfiles.rst
index b6861f920..2666f854f 100644
--- a/sources/pyside6/doc/tutorials/basictutorial/qrcfiles.rst
+++ b/sources/pyside6/doc/tutorials/basictutorial/qrcfiles.rst
@@ -75,6 +75,11 @@ To use the generated file, add the following import at the top of your main Pyth
import rc_icons
+.. note:: The tool uses `Zstandard` as a compression algorithm, which at its default
+ compression level (implementation-defined) may produce results that are
+ not usable on other platforms. To ensure the files are usable on all
+ platforms, the compression level should be reduced or `zlib` should
+ be chosen as compression algorithm (see ``pyside6-rcc --help``).
Changes in the code
===================
diff --git a/sources/shiboken6/tests/samplebinding/typesystem_sample.xml b/sources/shiboken6/tests/samplebinding/typesystem_sample.xml
index 305448b93..55309ab04 100644
--- a/sources/shiboken6/tests/samplebinding/typesystem_sample.xml
+++ b/sources/shiboken6/tests/samplebinding/typesystem_sample.xml
@@ -1900,10 +1900,8 @@
<!-- Functions removed to proper deal with strings containing zeroes -->
<modify-function signature="append(const char*)" remove="all" />
<modify-function signature="append(const char*,int)" remove="all" />
- <modify-function signature="operator==(const char*,ByteArray)" remove="all" />
- <modify-function signature="operator==(ByteArray,const char*)" remove="all" />
- <modify-function signature="operator!=(const char*,ByteArray)" remove="all" />
- <modify-function signature="operator!=(ByteArray,const char*)" remove="all" />
+ <modify-function signature="operator==(const char*)const" remove="all" />
+ <modify-function signature="operator!=(const char*)const" remove="all" />
<modify-function signature="operator+(ByteArray,const char*)" remove="all" />
<modify-function signature="operator+(const char*,ByteArray)" remove="all" />
<modify-function signature="operator+=(const char*)" remove="all" />
diff --git a/sources/shiboken6_generator/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken6_generator/ApiExtractor/abstractmetabuilder.cpp
index deb6acbec..2413cc1ad 100644
--- a/sources/shiboken6_generator/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken6_generator/ApiExtractor/abstractmetabuilder.cpp
@@ -160,6 +160,14 @@ const QMultiHash<QString, QString> &AbstractMetaBuilder::typedefTargetToName() c
return d->m_typedefTargetToName;
}
+static inline bool warnAboutConstMismatch(const AbstractMetaFunctionCPtr &function,
+ const QString &signature)
+{
+ return function->isConstant() && !signature.startsWith(u'^') && signature.endsWith(u')')
+ // An operator synthesized from a free operator?
+ && !(function->isOperatorOverload() && signature.contains(u','));
+}
+
// Check whether a function modification can be found in a class, else
// warn with candidates.
static void checkModification(const FunctionModification &modification,
@@ -176,7 +184,7 @@ static void checkModification(const FunctionModification &modification,
const QString &signature = modification.signature();
auto it = std::find_if(functions.cbegin(), functions.cend(), modificationPredicate);
if (it != functions.cend()) {
- if ((*it)->isConstant() && signature.endsWith(u')')) // Warn about missing const
+ if (warnAboutConstMismatch(*it, signature))
qCWarning(lcShiboken, "%s", qPrintable(msgModificationConstMismatch(*it, signature)));
return;
}
@@ -348,6 +356,8 @@ void AbstractMetaBuilderPrivate::traverseFreeOperatorFunction(const FunctionMode
flags.setFlag(InternalFunctionFlag::OperatorClassArgumentByValue);
}
metaFunction->setFlags(flags);
+ if (metaFunction->isComparisonOperator())
+ metaFunction->setConstant(true);
metaFunction->setAccess(Access::Public);
AbstractMetaClass::addFunction(baseoperandClass, metaFunction);
ReportHandler::addGeneralMessage(msgSynthesizedFunction(metaFunction, item));
@@ -1273,7 +1283,10 @@ void AbstractMetaBuilderPrivate::traverseScopeMembers(const ScopeModelItem &item
{
// Classes/Namespace members
traverseFields(item, metaClass);
- traverseFunctions(item, metaClass);
+ if (item->kind() == _CodeModelItem::Kind_Class)
+ traverseClassFunctions(item, metaClass);
+ else
+ traverseNameSpaceFunctions(item, metaClass);
// Inner classes
const ClassList &innerClasses = item->classes();
@@ -1442,113 +1455,126 @@ void AbstractMetaBuilderPrivate::fixReturnTypeOfConversionOperator(const Abstrac
metaFunction->setType(metaType);
}
-AbstractMetaFunctionList
- AbstractMetaBuilderPrivate::classFunctionList(const ScopeModelItem &scopeItem,
- AbstractMetaClass::Attributes *constructorAttributes,
- const AbstractMetaClassPtr &currentClass)
+void AbstractMetaBuilderPrivate::traverseNameSpaceFunctions(const ScopeModelItem& scopeItem,
+ const AbstractMetaClassPtr &currentClass)
+
{
- *constructorAttributes = {};
- AbstractMetaFunctionList result;
+ Q_ASSERT(currentClass);
+ AbstractMetaFunctionList functions;
const FunctionList &scopeFunctionList = scopeItem->functions();
- result.reserve(scopeFunctionList.size());
- const bool isNamespace = currentClass->isNamespace();
+ functions.reserve(scopeFunctionList.size());
for (const FunctionModelItem &function : scopeFunctionList) {
- if (isNamespace && function->isOperator()) {
+ if (function->isOperator()) {
traverseFreeOperatorFunction(function, currentClass);
- } else if (function->isSpaceshipOperator() && !function->isDeleted()) {
- if (currentClass) {
- AbstractMetaClass::addSynthesizedComparisonOperators(currentClass,
- InternalFunctionFlag::OperatorCpp20Spaceship);
- }
} else if (auto metaFunction = traverseFunction(function, currentClass)) {
- result.append(metaFunction);
- } else if (!function->isDeleted() && function->functionType() == CodeModel::Constructor) {
- // traverseFunction() failed: mark rejected constructors
- auto arguments = function->arguments();
- *constructorAttributes |= AbstractMetaClass::HasRejectedConstructor;
- if (arguments.isEmpty() || arguments.constFirst()->defaultValue())
- *constructorAttributes |= AbstractMetaClass::HasRejectedDefaultConstructor;
+ metaFunction->setCppAttribute(FunctionAttribute::Static);
+ functions.append(metaFunction);
+ AbstractMetaClass::addFunction(currentClass, metaFunction);
+ applyFunctionModifications(metaFunction);
}
}
- return result;
+ fillAddedFunctions(currentClass);
}
-void AbstractMetaBuilderPrivate::traverseFunctions(const ScopeModelItem& scopeItem,
- const AbstractMetaClassPtr &metaClass)
+void AbstractMetaBuilderPrivate::traverseClassFunction(const AbstractMetaFunctionPtr &metaFunction,
+ const AbstractMetaClassPtr &metaClass)
{
- AbstractMetaClass::Attributes constructorAttributes;
- const AbstractMetaFunctionList functions =
- classFunctionList(scopeItem, &constructorAttributes, metaClass);
- metaClass->setAttributes(metaClass->attributes() | constructorAttributes);
-
- for (const auto &metaFunction : functions) {
- if (metaClass->isNamespace())
- metaFunction->setCppAttribute(FunctionAttribute::Static);
-
- const auto propertyFunction = metaClass->searchPropertyFunction(metaFunction->name());
- if (propertyFunction.index >= 0) {
- QPropertySpec prop = metaClass->propertySpecs().at(propertyFunction.index);
- switch (propertyFunction.function) {
- case AbstractMetaClass::PropertyFunction::Read:
- // Property reader must be in the form "<type> name()"
- if (!metaFunction->isSignal()
- && prop.typeEntry() == metaFunction->type().typeEntry()
- && metaFunction->arguments().isEmpty()) {
- *metaFunction += AbstractMetaFunction::PropertyReader;
- metaFunction->setPropertySpecIndex(propertyFunction.index);
- }
- break;
- case AbstractMetaClass::PropertyFunction::Write:
- // Property setter must be in the form "void name(<type>)"
- // Make sure the function was created with all arguments; some
- // argument can be missing during the parsing because of errors
- // in the typesystem.
- if (metaFunction->isVoid() && metaFunction->arguments().size() == 1
- && (prop.typeEntry() == metaFunction->arguments().at(0).type().typeEntry())) {
- *metaFunction += AbstractMetaFunction::PropertyWriter;
- metaFunction->setPropertySpecIndex(propertyFunction.index);
- }
- break;
- case AbstractMetaClass::PropertyFunction::Reset:
- // Property resetter must be in the form "void name()"
- if (metaFunction->isVoid() && metaFunction->arguments().isEmpty()) {
- *metaFunction += AbstractMetaFunction::PropertyResetter;
- metaFunction->setPropertySpecIndex(propertyFunction.index);
- }
- break;
- case AbstractMetaClass::PropertyFunction::Notify:
- if (metaFunction->isSignal()) {
- *metaFunction += AbstractMetaFunction::PropertyNotify;
- metaFunction->setPropertySpecIndex(propertyFunction.index);
- }
+ const auto propertyFunction = metaClass->searchPropertyFunction(metaFunction->name());
+ if (propertyFunction.index >= 0) {
+ QPropertySpec prop = metaClass->propertySpecs().at(propertyFunction.index);
+ switch (propertyFunction.function) {
+ case AbstractMetaClass::PropertyFunction::Read:
+ // Property reader must be in the form "<type> name()"
+ if (!metaFunction->isSignal()
+ && prop.typeEntry() == metaFunction->type().typeEntry()
+ && metaFunction->arguments().isEmpty()) {
+ *metaFunction += AbstractMetaFunction::PropertyReader;
+ metaFunction->setPropertySpecIndex(propertyFunction.index);
+ }
+ break;
+ case AbstractMetaClass::PropertyFunction::Write:
+ // Property setter must be in the form "void name(<type>)"
+ // Make sure the function was created with all arguments; some
+ // argument can be missing during the parsing because of errors
+ // in the typesystem.
+ if (metaFunction->isVoid() && metaFunction->arguments().size() == 1
+ && (prop.typeEntry() == metaFunction->arguments().at(0).type().typeEntry())) {
+ *metaFunction += AbstractMetaFunction::PropertyWriter;
+ metaFunction->setPropertySpecIndex(propertyFunction.index);
+ }
+ break;
+ case AbstractMetaClass::PropertyFunction::Reset:
+ // Property resetter must be in the form "void name()"
+ if (metaFunction->isVoid() && metaFunction->arguments().isEmpty()) {
+ *metaFunction += AbstractMetaFunction::PropertyResetter;
+ metaFunction->setPropertySpecIndex(propertyFunction.index);
+ }
+ break;
+ case AbstractMetaClass::PropertyFunction::Notify:
+ if (metaFunction->isSignal()) {
+ *metaFunction += AbstractMetaFunction::PropertyNotify;
+ metaFunction->setPropertySpecIndex(propertyFunction.index);
}
}
+ }
- if (metaFunction->functionType() == AbstractMetaFunction::ConstructorFunction
- && metaFunction->isPrivate()) {
- metaClass->setHasPrivateConstructor(true);
- }
- if (metaFunction->isConstructor() && !metaFunction->isPrivate()) // Including Copy CT
- metaClass->setHasNonPrivateConstructor(true);
+ if (metaFunction->isPrivate() && metaFunction->functionType() == AbstractMetaFunction::ConstructorFunction) {
+ metaClass->setHasPrivateConstructor(true);
+ return;
+ }
- if (!metaFunction->isDestructor()
- && !(metaFunction->isPrivate() && metaFunction->functionType() == AbstractMetaFunction::ConstructorFunction)) {
+ if (metaFunction->isConstructor() && !metaFunction->isPrivate()) // Including Copy CT
+ metaClass->setHasNonPrivateConstructor(true);
- if (metaFunction->isSignal() && metaClass->hasSignal(metaFunction.get()))
- ReportHandler::addGeneralMessage(msgSignalOverloaded(metaClass, metaFunction.get()));
+ if (metaFunction->isDestructor()) {
+ metaClass->setHasPrivateDestructor(metaFunction->isPrivate());
+ metaClass->setHasProtectedDestructor(metaFunction->isProtected());
+ metaClass->setHasVirtualDestructor(metaFunction->isVirtual());
+ return;
+ }
- if (metaFunction->isConversionOperator())
- fixReturnTypeOfConversionOperator(metaFunction);
+ if (metaFunction->isSignal() && metaClass->hasSignal(metaFunction.get()))
+ ReportHandler::addGeneralMessage(msgSignalOverloaded(metaClass, metaFunction.get()));
- AbstractMetaClass::addFunction(metaClass, metaFunction);
- applyFunctionModifications(metaFunction);
- } else if (metaFunction->isDestructor()) {
- metaClass->setHasPrivateDestructor(metaFunction->isPrivate());
- metaClass->setHasProtectedDestructor(metaFunction->isProtected());
- metaClass->setHasVirtualDestructor(metaFunction->isVirtual());
+ if (metaFunction->isConversionOperator())
+ fixReturnTypeOfConversionOperator(metaFunction);
+
+ AbstractMetaClass::addFunction(metaClass, metaFunction);
+ applyFunctionModifications(metaFunction);
+}
+
+void AbstractMetaBuilderPrivate::traverseClassFunction(const ScopeModelItem& scopeItem,
+ const FunctionModelItem &function,
+ const AbstractMetaFunctionPtr &metaFunction,
+ const AbstractMetaClassPtr &metaClass) const
+{
+ Q_UNUSED(scopeItem)
+ Q_UNUSED(function)
+ traverseClassFunction(metaFunction, metaClass);
+}
+
+void AbstractMetaBuilderPrivate::traverseClassFunctions(const ScopeModelItem& scopeItem,
+ const AbstractMetaClassPtr &metaClass)
+{
+ Q_ASSERT(metaClass);
+ AbstractMetaClass::Attributes constructorAttributes;
+ for (const FunctionModelItem &function : scopeItem->functions()) {
+ if (function->isSpaceshipOperator() && !function->isDeleted()) {
+ AbstractMetaClass::addSynthesizedComparisonOperators(metaClass,
+ InternalFunctionFlag::OperatorCpp20Spaceship);
+ } else if (auto metaFunction = traverseFunction(function, metaClass)) {
+ traverseClassFunction(scopeItem, function, metaFunction, metaClass);
+ } else if (!function->isDeleted() && function->functionType() == CodeModel::Constructor) {
+ // traverseFunction() failed: mark rejected constructors
+ auto arguments = function->arguments();
+ constructorAttributes |= AbstractMetaClass::HasRejectedConstructor;
+ if (arguments.isEmpty() || arguments.constFirst()->defaultValue())
+ constructorAttributes |= AbstractMetaClass::HasRejectedDefaultConstructor;
}
}
+ metaClass->setAttributes(metaClass->attributes() | constructorAttributes);
+
fillAddedFunctions(metaClass);
}
@@ -1803,12 +1829,10 @@ AbstractMetaFunctionPtr
// Check if it's a reverse operator
if (metaArguments[1].type().typeEntry() == metaClass->typeEntry()) {
metaFunction->setReverseOperator(true);
- // we need to call these two function to cache the old signature (with two args)
- // we do this buggy behaviour to comply with the original apiextractor buggy behaviour.
- metaFunction->signature();
- metaFunction->minimalSignature();
- metaArguments.removeLast();
- metaFunction->setArguments(metaArguments);
+ // Cache the old signature (with two args) for modifications
+ QString minimalSignature = metaFunction->minimalSignature();
+ metaFunction->takeArgument(1);
+ metaFunction->setUnresolvedSignatures({minimalSignature});
} else {
qCWarning(lcShiboken) << "Operator overload can have two arguments only if it's a reverse operator!";
}
diff --git a/sources/shiboken6_generator/ApiExtractor/abstractmetabuilder_p.h b/sources/shiboken6_generator/ApiExtractor/abstractmetabuilder_p.h
index 5dc934934..b503f4b33 100644
--- a/sources/shiboken6_generator/ApiExtractor/abstractmetabuilder_p.h
+++ b/sources/shiboken6_generator/ApiExtractor/abstractmetabuilder_p.h
@@ -102,11 +102,16 @@ public:
std::optional<AbstractMetaEnum>
traverseTypedefedEnum(const FileModelItem &dom, const TypeDefModelItem &typeDefItem,
const AbstractMetaClassPtr &enclosing);
- AbstractMetaFunctionList classFunctionList(const ScopeModelItem &scopeItem,
- AbstractMetaClass::Attributes *constructorAttributes,
- const AbstractMetaClassPtr &currentClass);
- void traverseFunctions(const ScopeModelItem& item,
- const AbstractMetaClassPtr &parent);
+ void traverseClassFunction(const ScopeModelItem& scopeItem,
+ const FunctionModelItem &function,
+ const AbstractMetaFunctionPtr &metaFunction,
+ const AbstractMetaClassPtr &metaClass) const;
+ static void traverseClassFunction(const AbstractMetaFunctionPtr &metaFunction,
+ const AbstractMetaClassPtr &metaClass);
+ void traverseNameSpaceFunctions(const ScopeModelItem& scopeItem,
+ const AbstractMetaClassPtr &metaClass);
+ void traverseClassFunctions(const ScopeModelItem& item,
+ const AbstractMetaClassPtr &parent);
static void applyFunctionModifications(const AbstractMetaFunctionPtr &func);
void traverseFields(const ScopeModelItem &item, const AbstractMetaClassPtr &parent);
bool traverseStreamOperator(const FunctionModelItem &functionItem,
diff --git a/sources/shiboken6_generator/ApiExtractor/abstractmetafunction.cpp b/sources/shiboken6_generator/ApiExtractor/abstractmetafunction.cpp
index 6157738a6..f63a923de 100644
--- a/sources/shiboken6_generator/ApiExtractor/abstractmetafunction.cpp
+++ b/sources/shiboken6_generator/ApiExtractor/abstractmetafunction.cpp
@@ -53,7 +53,7 @@ public:
{
}
- void fixArgumentIndexes();
+ void signatureChanged();
QString signature() const;
QString formatMinimalSignature() const;
@@ -104,10 +104,12 @@ public:
TypeSystem::ExceptionHandling m_exceptionHandlingModification = TypeSystem::ExceptionHandling::Unspecified;
};
-void AbstractMetaFunctionPrivate::fixArgumentIndexes()
+void AbstractMetaFunctionPrivate::signatureChanged()
{
for (qsizetype i = 0, size = m_arguments.size(); i < size; ++i)
m_arguments[i].setArgumentIndex(i);
+ m_cachedMinimalSignature.clear();
+ m_cachedSignature.clear();
}
AbstractMetaFunction::AbstractMetaFunction(const QString &name) :
@@ -579,7 +581,10 @@ bool AbstractMetaFunction::isConstant() const
void AbstractMetaFunction::setConstant(bool constant)
{
- d->m_constant = constant;
+ if (d->m_constant != constant) {
+ d->m_constant = constant;
+ d->signatureChanged();
+ }
}
bool AbstractMetaFunction::isUserAdded() const
@@ -727,6 +732,7 @@ AbstractMetaArgumentList &AbstractMetaFunction::arguments()
void AbstractMetaFunction::setArguments(const AbstractMetaArgumentList &arguments)
{
d->m_arguments = arguments;
+ d->signatureChanged();
}
void AbstractMetaFunction::setArgumentName(qsizetype a, const QString &name)
@@ -737,6 +743,7 @@ void AbstractMetaFunction::setArgumentName(qsizetype a, const QString &name)
void AbstractMetaFunction::addArgument(const AbstractMetaArgument &argument)
{
d->m_arguments << argument;
+ d->signatureChanged();
}
AbstractMetaArgument AbstractMetaFunction::takeArgument(qsizetype a)
@@ -744,15 +751,17 @@ AbstractMetaArgument AbstractMetaFunction::takeArgument(qsizetype a)
AbstractMetaArgument result;
if (a >= 0 && a < d->m_arguments.size()) {
result = d->m_arguments.takeAt(a);
- d->fixArgumentIndexes();
+ d->signatureChanged();
}
return result;
}
void AbstractMetaFunction::reverseArguments()
{
- std::reverse(d->m_arguments.begin(), d->m_arguments.end());
- d->fixArgumentIndexes();
+ if (d->m_arguments.size() > 1) {
+ std::reverse(d->m_arguments.begin(), d->m_arguments.end());
+ d->signatureChanged();
+ }
}
static bool modifiedDeprecated(const FunctionModification &mod)
@@ -1062,6 +1071,10 @@ QString AbstractMetaFunctionPrivate::signatureComment(const AbstractMetaFunction
if (!q->isVoid())
str << "->" << (q->isTypeModified() ? q->modifiedTypeName() : q->type().minimalSignature());
+ if (q->isUserAdded())
+ str << " [user added]";
+ else if (q->isUserDeclared())
+ str << " [user declared]";
if (q->isOperatorOverload()) {
if (QString opDescr = msgSynthesizedOperatorDescription(q); !opDescr.isEmpty())
str << ' ' << opDescr;
diff --git a/sources/shiboken6_generator/ApiExtractor/abstractmetalang.cpp b/sources/shiboken6_generator/ApiExtractor/abstractmetalang.cpp
index 35abbcdc0..837ce0d1a 100644
--- a/sources/shiboken6_generator/ApiExtractor/abstractmetalang.cpp
+++ b/sources/shiboken6_generator/ApiExtractor/abstractmetalang.cpp
@@ -945,6 +945,7 @@ void AbstractMetaClass::addSynthesizedComparisonOperators(const AbstractMetaClas
Access::Public, arguments,
returnType, c);
f->setFlags(f->flags() | flags);
+ f->setConstant(true);
AbstractMetaFunctionCPtr newFunction(f);
c->d->addFunction(newFunction);
ReportHandler::addGeneralMessage(msgSynthesizedFunction(newFunction));
diff --git a/sources/shiboken6_generator/ApiExtractor/apiextractor.cpp b/sources/shiboken6_generator/ApiExtractor/apiextractor.cpp
index 90f4f5dd9..1c398313b 100644
--- a/sources/shiboken6_generator/ApiExtractor/apiextractor.cpp
+++ b/sources/shiboken6_generator/ApiExtractor/apiextractor.cpp
@@ -613,8 +613,8 @@ ApiExtractorPrivate::addInstantiatedContainersAndSmartPointers(InstantiationColl
if (type.hasTemplateChildren()) {
const auto piece = isContainer ? "container"_L1 : "smart pointer"_L1;
QString warning =
- QString::fromLatin1("Skipping instantiation of %1 '%2' because it has template"
- " arguments.").arg(piece, type.originalTypeDescription());
+ "Skipping instantiation of %1 '%2' because it has template"
+ " arguments."_L1.arg(piece, type.originalTypeDescription());
if (!contextName.isEmpty())
warning.append(" Calling context: "_L1 + contextName);
diff --git a/sources/shiboken6_generator/ApiExtractor/fileout.cpp b/sources/shiboken6_generator/ApiExtractor/fileout.cpp
index 9bf33f94f..575f9bd7e 100644
--- a/sources/shiboken6_generator/ApiExtractor/fileout.cpp
+++ b/sources/shiboken6_generator/ApiExtractor/fileout.cpp
@@ -12,6 +12,8 @@
#include <cstdio>
+using namespace Qt::StringLiterals;
+
bool FileOut::m_dryRun = false;
bool FileOut::m_diff = false;
@@ -175,8 +177,8 @@ FileOut::State FileOut::done()
if (!FileOut::m_dryRun) {
QDir dir(info.absolutePath());
if (!dir.mkpath(dir.absolutePath())) {
- const QString message = QString::fromLatin1("Unable to create directory '%1'")
- .arg(QDir::toNativeSeparators(dir.absolutePath()));
+ const QString message = "Unable to create directory '%1'"_L1
+ .arg(QDir::toNativeSeparators(dir.absolutePath()));
throw Exception(message);
}
diff --git a/sources/shiboken6_generator/ApiExtractor/messages.cpp b/sources/shiboken6_generator/ApiExtractor/messages.cpp
index 54b0f1ee8..aee58c950 100644
--- a/sources/shiboken6_generator/ApiExtractor/messages.cpp
+++ b/sources/shiboken6_generator/ApiExtractor/messages.cpp
@@ -716,13 +716,13 @@ QString msgXpathDocModificationError(const DocModificationList& mods,
QString msgCannotOpenForReading(const QFile &f)
{
- return QString::fromLatin1("Failed to open file '%1' for reading: %2")
+ return "Failed to open file '%1' for reading: %2"_L1
.arg(QDir::toNativeSeparators(f.fileName()), f.errorString());
}
QString msgCannotOpenForWriting(const QFile &f)
{
- return QString::fromLatin1("Failed to open file '%1' for writing: %2")
+ return "Failed to open file '%1' for writing: %2"_L1
.arg(QDir::toNativeSeparators(f.fileName()), f.errorString());
}
@@ -1022,7 +1022,7 @@ QString msgUnknownArrayPointerConversion(const QString &s)
QString msgMissingProjectFileMarker(const QString &name, const QByteArray &startMarker)
{
return u"First line of project file \""_s + QDir::toNativeSeparators(name)
- + u"\" must be the string \""_s + QString::fromLatin1(startMarker) + u"\"."_s;
+ + u"\" must be the string \""_s + QLatin1StringView(startMarker) + u"\"."_s;
}
QString msgInvalidLanguageLevel(const QString &l)
diff --git a/sources/shiboken6_generator/ApiExtractor/typesystemparser.cpp b/sources/shiboken6_generator/ApiExtractor/typesystemparser.cpp
index 9a8611589..a4dfe5e6c 100644
--- a/sources/shiboken6_generator/ApiExtractor/typesystemparser.cpp
+++ b/sources/shiboken6_generator/ApiExtractor/typesystemparser.cpp
@@ -1179,10 +1179,10 @@ bool TypeSystemParser::importFileElement(const QXmlStreamAttributes &atts)
}
}
if (!foundFromOk || !foundToOk) {
- QString fromError = QString::fromLatin1("Could not find quote-after-line='%1' in file '%2'.")
- .arg(quoteFrom.toString(), fileName);
- QString toError = QString::fromLatin1("Could not find quote-before-line='%1' in file '%2'.")
- .arg(quoteTo.toString(), fileName);
+ QString fromError = "Could not find quote-after-line='%1' in file '%2'."_L1
+ .arg(quoteFrom.toString(), fileName);
+ QString toError = "Could not find quote-before-line='%1' in file '%2'."_L1
+ .arg(quoteTo.toString(), fileName);
if (!foundToOk)
m_error = toError;
@@ -2487,7 +2487,7 @@ static bool parseIndex(const QString &index, int *result, QString *errorMessage)
bool ok = false;
*result = index.toInt(&ok);
if (!ok)
- *errorMessage = QString::fromLatin1("Cannot convert '%1' to integer").arg(index);
+ *errorMessage = "Cannot convert '%1' to integer"_L1.arg(index);
return ok;
}
@@ -2699,8 +2699,8 @@ bool TypeSystemParser::parseAddFunction(const ConditionalStreamReader &,
|| topElement == StackElement::Root
|| topElement == StackElement::ContainerTypeEntry;
if (!validParent) {
- m_error = QString::fromLatin1("Add/Declare function requires a complex/container type or a root tag as parent"
- ", was=%1").arg(tagFromElement(topElement));
+ m_error = "Add/Declare function requires a complex/container type or a root tag as parent, was=%1"_L1
+ + tagFromElement(topElement);
return false;
}
@@ -2831,8 +2831,8 @@ bool TypeSystemParser::parseProperty(const ConditionalStreamReader &, StackEleme
QXmlStreamAttributes *attributes)
{
if (!isComplexTypeEntry(topElement)) {
- m_error = QString::fromLatin1("Add property requires a complex type as parent"
- ", was=%1").arg(tagFromElement(topElement));
+ m_error = "Add property requires a complex type as parent, was=%1"_L1
+ + tagFromElement(topElement);
return false;
}
@@ -2930,8 +2930,8 @@ bool TypeSystemParser::parseModifyFunction(const ConditionalStreamReader &reader
|| topElement == StackElement::TypedefTypeEntry
|| topElement == StackElement::FunctionTypeEntry;
if (!validParent) {
- m_error = QString::fromLatin1("Modify function requires complex type as parent"
- ", was=%1").arg(tagFromElement(topElement));
+ m_error = "Modify function requires complex type as parent, was=%1"_L1
+ + tagFromElement(topElement);
return false;
}
diff --git a/sources/shiboken6_generator/generator/generator.cpp b/sources/shiboken6_generator/generator/generator.cpp
index 7e37a1924..314cee227 100644
--- a/sources/shiboken6_generator/generator/generator.cpp
+++ b/sources/shiboken6_generator/generator/generator.cpp
@@ -366,7 +366,7 @@ QString Generator::getFullTypeName(const AbstractMetaType &type)
typeName = getFullTypeNameWithoutModifiers(type);
else
typeName = getFullTypeName(type.typeEntry());
- return typeName + QString::fromLatin1("*").repeated(type.indirections());
+ return typeName + QString(type.indirections(), u'*');
}
QString Generator::getFullTypeName(const AbstractMetaClassCPtr &metaClass)
diff --git a/sources/shiboken6_generator/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken6_generator/generator/qtdoc/qtdocgenerator.cpp
index 9a1a28ef2..574f8de6f 100644
--- a/sources/shiboken6_generator/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken6_generator/generator/qtdoc/qtdocgenerator.cpp
@@ -964,8 +964,8 @@ QString QtDocGenerator::translateToPythonType(const AbstractMetaType &type,
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]);
+ strType = "Dictionary with keys of type %1 and values of type %2."_L1
+ .arg(types[0], types[1]);
}
return strType;
}
diff --git a/sources/shiboken6_generator/generator/shiboken/shibokengenerator.cpp b/sources/shiboken6_generator/generator/shiboken/shibokengenerator.cpp
index 8e45d000b..f6ea09b0d 100644
--- a/sources/shiboken6_generator/generator/shiboken/shibokengenerator.cpp
+++ b/sources/shiboken6_generator/generator/shiboken/shibokengenerator.cpp
@@ -988,8 +988,9 @@ QString ShibokenGenerator::cpythonIsConvertibleFunction(const TypeEntryCPtr &typ
result += u"("_s + cpythonTypeNameExt(type) + u", "_s;
return result;
}
- return QString::fromLatin1("Shiboken::Conversions::isPythonToCppConvertible(%1, ")
- .arg(converterObject(type));
+
+ return "Shiboken::Conversions::isPythonToCppConvertible("_L1
+ + converterObject(type) + ", "_L1;
}
QString ShibokenGenerator::cpythonIsConvertibleFunction(const AbstractMetaType &metaType)