diff options
-rw-r--r-- | sources/pyside6/PySide6/QtCore/typesystem_core_common.xml | 2 | ||||
-rw-r--r-- | sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp | 45 | ||||
-rw-r--r-- | sources/shiboken6/ApiExtractor/abstractmetafunction.cpp | 32 | ||||
-rw-r--r-- | sources/shiboken6/ApiExtractor/abstractmetalang.cpp | 19 | ||||
-rw-r--r-- | sources/shiboken6/ApiExtractor/messages.cpp | 110 | ||||
-rw-r--r-- | sources/shiboken6/ApiExtractor/messages.h | 26 | ||||
-rw-r--r-- | sources/shiboken6/ApiExtractor/typesystemparser.cpp | 2 | ||||
-rw-r--r-- | sources/shiboken6/generator/generator.cpp | 4 | ||||
-rw-r--r-- | sources/shiboken6/generator/shiboken/cppgenerator.cpp | 19 |
9 files changed, 176 insertions, 83 deletions
diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml index 2f8ce57b4..e865691dc 100644 --- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml +++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml @@ -2958,7 +2958,7 @@ <suppress-warning text="Unable to decide type of property: 'QLibrary::LoadHints' in class 'QPluginLoader'"/> <suppress-warning text="enum '_ISalnum' does not have a type entry or is not an enum"/> <suppress-warning text="enum 'Qt::Initialization' does not have a type entry or is not an enum"/> - <suppress-warning text="visibility of function '*' modified in class '*'"/> + <suppress-warning text="Visibility of function '*' modified in class '*'"/> <suppress-warning text="hiding of function '*' in class '*'"/> <suppress-warning text="namespace '*' does not have a type entry"/> <suppress-warning text="Shadowing: QObject::parent()const and QAbstractItemModel::parent() const"/> diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp index d8776d2db..61899c9ea 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp @@ -482,20 +482,14 @@ void AbstractMetaBuilderPrivate::traverseDom(const FileModelItem &dom) for (AbstractMetaClass *cls : qAsConst(m_metaClasses)) { cls->fixFunctions(); - if (!cls->typeEntry()) { - qCWarning(lcShiboken).noquote().nospace() - << QStringLiteral("class '%1' does not have an entry in the type system") - .arg(cls->name()); - } else { - const bool couldAddDefaultCtors = cls->isConstructible() - && !cls->isNamespace() - && (cls->attributes() & AbstractMetaAttributes::HasRejectedConstructor) == 0; - if (couldAddDefaultCtors) { - if (!cls->hasConstructors()) - cls->addDefaultConstructor(); - if (cls->typeEntry()->isValue() && !cls->isAbstract() && !cls->hasCopyConstructor()) - cls->addDefaultCopyConstructor(ancestorHasPrivateCopyConstructor(cls)); - } + const bool couldAddDefaultCtors = cls->isConstructible() + && !cls->isNamespace() + && (cls->attributes() & AbstractMetaAttributes::HasRejectedConstructor) == 0; + if (couldAddDefaultCtors) { + if (!cls->hasConstructors()) + cls->addDefaultConstructor(); + if (cls->typeEntry()->isValue() && !cls->isAbstract() && !cls->hasCopyConstructor()) + cls->addDefaultCopyConstructor(ancestorHasPrivateCopyConstructor(cls)); } } const auto &allEntries = types->entries(); @@ -1327,11 +1321,8 @@ void AbstractMetaBuilderPrivate::traverseFunctions(ScopeModelItem scopeItem, setupFunctionDefaults(metaFunction, metaClass); - if (metaFunction->isSignal() && metaClass->hasSignal(metaFunction)) { - qCWarning(lcShiboken).noquote().nospace() - << QStringLiteral("signal '%1' in class '%2' is overloaded.") - .arg(metaFunction->name(), metaClass->name()); - } + if (metaFunction->isSignal() && metaClass->hasSignal(metaFunction)) + qCWarning(lcShiboken, "%s", qPrintable(msgSignalOverloaded(metaClass, metaFunction))); if (metaFunction->isConversionOperator()) fixReturnTypeOfConversionOperator(metaFunction); @@ -1440,13 +1431,13 @@ bool AbstractMetaBuilderPrivate::setupInheritance(AbstractMetaClass *metaClass) auto typeEntry = types->findType(baseClassName); if (typeEntry == nullptr || !typeEntry->isComplex()) { qCWarning(lcShiboken, "%s", - qPrintable(msgUnknownBase(metaClass, baseClassName))); + qPrintable(msgBaseNotInTypeSystem(metaClass, baseClassName))); return false; } auto baseClass = AbstractMetaClass::findClass(m_metaClasses, typeEntry); if (!baseClass) { - qCWarning(lcShiboken).noquote().nospace() - << QStringLiteral("class not found for setup inheritance '%1'").arg(baseClassName); + qCWarning(lcShiboken, "%s", + qPrintable(msgUnknownBase(metaClass, baseClassName))); return false; } metaClass->addBaseClass(baseClass); @@ -1929,9 +1920,9 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio && !metaFunction->isOperatorOverload() && !metaFunction->isSignal() && metaFunction->argumentName(i + 1, false, currentClass).isEmpty()) { - qCWarning(lcShiboken).noquote().nospace() - << QStringLiteral("Argument %1 on function '%2::%3' has default expression but does not have name.") - .arg(i+1).arg(className, metaFunction->minimalSignature()); + qCWarning(lcShiboken, "%s", + qPrintable(msgUnnamedArgumentDefaultExpression(currentClass, i + 1, + className, metaFunction))); } } @@ -2859,9 +2850,7 @@ static void writeRejectLogFile(const QString &name, { QFile f(name); if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) { - qCWarning(lcShiboken).noquote().nospace() - << QStringLiteral("failed to write log file: '%1'") - .arg(QDir::toNativeSeparators(f.fileName())); + qCWarning(lcShiboken, "%s", qPrintable(msgCannotOpenForWriting(f))); return; } diff --git a/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp b/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp index 1b50aeb38..73146aa6d 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp @@ -370,19 +370,12 @@ QString AbstractMetaFunctionPrivate::signature() const for (int i = 0; i < m_arguments.count(); ++i) { const AbstractMetaArgument &a = m_arguments.at(i); const AbstractMetaType &t = a.type(); - if (!t.isVoid()) { - if (i > 0) - m_cachedSignature += QLatin1String(", "); - m_cachedSignature += t.cppSignature(); - // We need to have the argument names in the qdoc files - m_cachedSignature += QLatin1Char(' '); - m_cachedSignature += a.name(); - } else { - qCWarning(lcShiboken).noquote().nospace() - << QString::fromLatin1("No abstract meta type found for argument '%1' while" - "constructing signature for function '%2'.") - .arg(a.name(), m_name); - } + if (i > 0) + m_cachedSignature += QLatin1String(", "); + m_cachedSignature += t.cppSignature(); + // We need to have the argument names in the qdoc files + m_cachedSignature += QLatin1Char(' '); + m_cachedSignature += a.name(); } m_cachedSignature += QLatin1Char(')'); @@ -689,16 +682,9 @@ QString AbstractMetaFunctionPrivate::minimalSignature() const QString minimalSignature = m_originalName + QLatin1Char('('); for (int i = 0; i < m_arguments.count(); ++i) { const AbstractMetaType &t = m_arguments.at(i).type(); - if (!t.isVoid()) { - if (i > 0) - minimalSignature += QLatin1Char(','); - minimalSignature += t.minimalSignature(); - } else { - qCWarning(lcShiboken).noquote().nospace() - << QString::fromLatin1("No abstract meta type found for argument '%1' while constructing" - " minimal signature for function '%2'.") - .arg(m_arguments.at(i).name(), m_name); - } + if (i > 0) + minimalSignature += QLatin1Char(','); + minimalSignature += t.minimalSignature(); } minimalSignature += QLatin1Char(')'); if (m_constant) diff --git a/sources/shiboken6/ApiExtractor/abstractmetalang.cpp b/sources/shiboken6/ApiExtractor/abstractmetalang.cpp index 971047727..eb01ee2e1 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetalang.cpp @@ -32,6 +32,7 @@ #include "abstractmetafunction.h" #include "abstractmetafield.h" #include "documentation.h" +#include "messages.h" #include "modifications.h" #include "propertyspec.h" #include "reporthandler.h" @@ -1170,9 +1171,8 @@ void AbstractMetaClass::fixFunctions() } if (f->visibility() != sf->visibility()) { - QString warn = QStringLiteral("visibility of function '%1' modified in class '%2'") - .arg(f->name(), name()); - qCWarning(lcShiboken).noquote().nospace() << warn; + qCWarning(lcShiboken, "%s", + qPrintable(msgFunctionVisibilityModified(this, f))); #if 0 // If new visibility is private, we can't // do anything. If it isn't, then we @@ -1215,10 +1215,8 @@ void AbstractMetaClass::fixFunctions() } if (!hasNonFinalModifier && !isBaseImplPrivate) { - qCWarning(lcShiboken).noquote().nospace() - << QStringLiteral("Shadowing: %1::%2 and %3::%4") - .arg(sf->implementingClass()->name(), sf->signature(), - f->implementingClass()->name(), f->signature()); + qCWarning(lcShiboken, "%s", + qPrintable(msgShadowingFunction(sf, f))); } } } @@ -1308,9 +1306,7 @@ std::optional<AbstractMetaEnum> auto scopeEntry = entry->parent(); AbstractMetaClass *metaClass = AbstractMetaClass::findClass(classes, scopeEntry); if (!metaClass) { - qCWarning(lcShiboken).noquote().nospace() - << QStringLiteral("AbstractMeta::findEnum(), unknown class '%1' in '%2'") - .arg(scopeEntry->qualifiedCppName(), entry->qualifiedCppName()); + qCWarning(lcShiboken, "%s", qPrintable(msgClassOfEnumNotFound(entry))); return {}; } @@ -1339,8 +1335,7 @@ std::optional<AbstractMetaEnumValue> return enumValue; } - qCWarning(lcShiboken).noquote().nospace() - << QStringLiteral("no matching enum '%1'").arg(name); + qCWarning(lcShiboken, "no matching enum '%s'", qPrintable(name)); return {}; } diff --git a/sources/shiboken6/ApiExtractor/messages.cpp b/sources/shiboken6/ApiExtractor/messages.cpp index 85759472c..2e72b95bc 100644 --- a/sources/shiboken6/ApiExtractor/messages.cpp +++ b/sources/shiboken6/ApiExtractor/messages.cpp @@ -143,6 +143,29 @@ QString msgAddedFunctionInvalidReturnType(const QString &addedFuncName, return result; } +QString msgUnnamedArgumentDefaultExpression(const AbstractMetaClass *context, + int n, const QString &className, + const AbstractMetaFunction *f) +{ + QString result; + QTextStream str(&result); + if (context) + str << context->sourceLocation(); + str << "Argument " << n << " on function '" << className << "::" + << f->minimalSignature() << "' has default expression but does not have name."; + return result; +} + +QString msgClassOfEnumNotFound(const EnumTypeEntry *entry) +{ + QString result; + QTextStream str(&result); + str << entry->sourceLocation() << "AbstractMeta::findEnum(), unknown class '" + << entry->parent()->qualifiedCppName() << "' in '" + << entry->qualifiedCppName() << '\''; + return result; +} + QString msgNoEnumTypeEntry(const EnumModelItem &enumItem, const QString &className) { @@ -231,6 +254,28 @@ QString msgSkippingFunction(const FunctionModelItem &functionItem, return result; } +QString msgShadowingFunction(const AbstractMetaFunction *f1, + const AbstractMetaFunction *f2) +{ + auto f2Class = f2->implementingClass(); + QString result; + QTextStream str(&result); + str << f2Class->sourceLocation() << "Shadowing: " << f1->implementingClass()->name() + << "::" << f1->signature() << " and " << f2Class->name() << "::" + << f2->signature(); + return result; +} + +QString msgSignalOverloaded(const AbstractMetaClass *c, + const AbstractMetaFunction *f) +{ + QString result; + QTextStream str(&result); + str << c->sourceLocation() << "signal '" << f->name() << "' in class '" + << c->name() << "' is overloaded."; + return result; +} + QString msgSkippingField(const VariableModelItem &field, const QString &className, const QString &type) { @@ -285,12 +330,23 @@ QString msgEnumNotDefined(const EnumTypeEntry *t) return result; } -QString msgUnknownBase(const AbstractMetaClass *metaClass, const QString &baseClassName) +QString msgUnknownBase(const AbstractMetaClass *metaClass, + const QString &baseClassName) +{ + QString result; + QTextStream str(&result); + str << metaClass->sourceLocation() << "Base class '" << baseClassName << "' of class '" + << metaClass->name() << "' not found in the code for setting up inheritance."; + return result; +} + +QString msgBaseNotInTypeSystem(const AbstractMetaClass *metaClass, + const QString &baseClassName) { QString result; QTextStream str(&result); - str << metaClass->sourceLocation() << "class '" << metaClass->name() - << "' inherits from unknown base class '" << baseClassName << "'"; + str << metaClass->sourceLocation() << "Base class '" << baseClassName << "' of class '" + << metaClass->name() << "' not found in the type system for setting up inheritance."; return result; } @@ -396,6 +452,16 @@ QString msgPropertyExists(const QString &className, const QString &name) + QLatin1String("\" (defined by Q_PROPERTY)."); } +QString msgFunctionVisibilityModified(const AbstractMetaClass *c, + const AbstractMetaFunction *f) +{ + QString result; + QTextStream str(&result); + str << c->sourceLocation() << "Visibility of function '" << f->name() + << "' modified in class '"<< c->name() << '\''; + return result; +} + // docparser.cpp QString msgCannotFindDocumentation(const QString &fileName, @@ -680,6 +746,44 @@ QString msgCannotFindView(const QString &viewedName, const QString &name) + QLatin1String(" for ") + name; } +// cppgenerator.cpp + +QString msgPureVirtualFunctionRemoved(const AbstractMetaFunction *f) +{ + QString result; + auto klass = f->ownerClass(); + QTextStream str(&result); + str << klass->sourceLocation() << "Pure virtual method '" << klass->name() + << "::"<< f->minimalSignature() + << "' must be implemented but was completely removed on type system."; + return result; +} + +QString msgUnknownTypeInArgumentTypeReplacement(const QString &typeReplaced, + const AbstractMetaFunction *f) +{ + QString result; + QTextStream str(&result); + if (auto klass = f->ownerClass()) + str << klass->sourceLocation(); + str << "Unknown type '" << typeReplaced + << "' used as argument type replacement in function '" << f->signature() + << "', the generated code may be broken."; + return result; +} + +QString msgRegisterMetaTypeUnqualifiedName(const AbstractMetaClass *c, + const char *file, int line) +{ + QString result; + QTextStream str(&result); + str << c->sourceLocation() << " (" << file << ':' << line << ") FIXME:\n" + << " The code tried to qRegisterMetaType the unqualified name " + << "'iterator' (" << c->qualifiedCppName() + << "). This is currently fixed by a hack(ct) and needs improvement!"; + return result; +} + // qtdocgenerator.cpp QString msgTagWarning(const QXmlStreamReader &reader, const QString &context, diff --git a/sources/shiboken6/ApiExtractor/messages.h b/sources/shiboken6/ApiExtractor/messages.h index 3d3551156..6610a318a 100644 --- a/sources/shiboken6/ApiExtractor/messages.h +++ b/sources/shiboken6/ApiExtractor/messages.h @@ -56,12 +56,18 @@ QString msgAddedFunctionInvalidReturnType(const QString &addedFuncName, const QStringList &typeName, const QString &why, const AbstractMetaClass *context = nullptr); +QString msgUnnamedArgumentDefaultExpression(const AbstractMetaClass *context, + int n, const QString &className, + const AbstractMetaFunction *f); + QString msgNoFunctionForModification(const AbstractMetaClass *klass, const QString &signature, const QString &originalSignature, const QStringList &possibleSignatures, const AbstractMetaFunctionList &allFunctions); +QString msgClassOfEnumNotFound(const EnumTypeEntry *entry); + QString msgNoEnumTypeEntry(const EnumModelItem &enumItem, const QString &className); @@ -82,6 +88,12 @@ QString msgUnmatchedParameterType(const ArgumentModelItem &arg, int n, QString msgUnmatchedReturnType(const FunctionModelItem &functionItem, const QString &why); +QString msgShadowingFunction(const AbstractMetaFunction *f1, + const AbstractMetaFunction *f2); + +QString msgSignalOverloaded(const AbstractMetaClass *c, + const AbstractMetaFunction *f); + QString msgSkippingFunction(const FunctionModelItem &functionItem, const QString &signature, const QString &why); @@ -102,6 +114,9 @@ QString msgEnumNotDefined(const EnumTypeEntry *t); QString msgUnknownBase(const AbstractMetaClass *metaClass, const QString &baseClassName); +QString msgBaseNotInTypeSystem(const AbstractMetaClass *metaClass, + const QString &baseClassName); + QString msgArrayModificationFailed(const FunctionModelItem &functionItem, const QString &className, const QString &errorMessage); @@ -133,6 +148,9 @@ QString msgPropertyTypeParsingFailed(const QString &name, const QString &typeNam const QString &why); QString msgPropertyExists(const QString &className, const QString &name); +QString msgFunctionVisibilityModified(const AbstractMetaClass *c, + const AbstractMetaFunction *f); + QString msgCannotFindDocumentation(const QString &fileName, const char *what, const QString &name, const QString &query); @@ -203,6 +221,14 @@ QString msgCouldNotFindMinimalConstructor(const QString &where, const QString &t QString msgRejectReason(const TypeRejection &r, const QString &needle = QString()); +QString msgPureVirtualFunctionRemoved(const AbstractMetaFunction *f); + +QString msgUnknownTypeInArgumentTypeReplacement(const QString &typeReplaced, + const AbstractMetaFunction *f); + +QString msgRegisterMetaTypeUnqualifiedName(const AbstractMetaClass *c, + const char *file, int line); + QString msgTagWarning(const QXmlStreamReader &reader, const QString &context, const QString &tag, const QString &message); diff --git a/sources/shiboken6/ApiExtractor/typesystemparser.cpp b/sources/shiboken6/ApiExtractor/typesystemparser.cpp index 6fac1a74b..530be15ab 100644 --- a/sources/shiboken6/ApiExtractor/typesystemparser.cpp +++ b/sources/shiboken6/ApiExtractor/typesystemparser.cpp @@ -995,7 +995,7 @@ bool TypeSystemParser::importFileElement(const QXmlStreamAttributes &atts) if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { file.setFileName(QLatin1String(":/trolltech/generator/") + fileName); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - m_error = QString::fromLatin1("Could not open file: '%1'").arg(QDir::toNativeSeparators(fileName)); + m_error = msgCannotOpenForReading(file); return false; } } diff --git a/sources/shiboken6/generator/generator.cpp b/sources/shiboken6/generator/generator.cpp index cb1e22384..e41570991 100644 --- a/sources/shiboken6/generator/generator.cpp +++ b/sources/shiboken6/generator/generator.cpp @@ -521,8 +521,8 @@ void verifyDirectoryFor(const QString &file) QDir dir = QFileInfo(file).absoluteDir(); if (!dir.exists()) { if (!dir.mkpath(dir.absolutePath())) { - qCWarning(lcShiboken).noquote().nospace() - << QStringLiteral("unable to create directory '%1'").arg(dir.absolutePath()); + qCWarning(lcShiboken, "Unable to create directory '%s'", + qPrintable(QDir::toNativeSeparators(dir.absolutePath()))); } } } diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index 1ae93e612..949382ef7 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -981,10 +981,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, const QString returnStatement = virtualMethodReturn(s, func, functionModifications); if (func->isAbstract() && func->isModifiedRemoved()) { - qCWarning(lcShiboken).noquote().nospace() - << QString::fromLatin1("Pure virtual method '%1::%2' must be implement but was "\ - "completely removed on type system.") - .arg(func->ownerClass()->name(), func->minimalSignature()); + qCWarning(lcShiboken, "%s", qPrintable(msgPureVirtualFunctionRemoved(func))); s << INDENT << returnStatement << "\n}\n\n"; return; } @@ -2491,10 +2488,8 @@ std::optional<AbstractMetaType> auto argType = buildAbstractMetaTypeFromString(typeReplaced); if (!argType.has_value() && !m_knownPythonTypes.contains(typeReplaced)) { - qCWarning(lcShiboken).noquote().nospace() - << QString::fromLatin1("Unknown type '%1' used as argument type replacement "\ - "in function '%2', the generated code may be broken.") - .arg(typeReplaced, func->signature()); + qCWarning(lcShiboken, "%s", + qPrintable(msgUnknownTypeInArgumentTypeReplacement(typeReplaced, func))); } return argType; } @@ -5571,11 +5566,9 @@ void CppGenerator::writeInitQtMetaTypeFunctionBody(QTextStream &s, const Generat if (canBeValue) { for (const QString &name : qAsConst(nameVariants)) { if (name == QLatin1String("iterator")) { - qCWarning(lcShiboken).noquote().nospace() - << QString::fromLatin1("%1:%2 FIXME:\n" - " The code tried to qRegisterMetaType the unqualified name " - "'iterator'. This is currently fixed by a hack(ct) and needs improvement!") - .arg(QFile::decodeName(__FILE__)).arg(__LINE__); + qCWarning(lcShiboken, "%s", + qPrintable(msgRegisterMetaTypeUnqualifiedName(context.metaClass(), + __FILE__, __LINE__))); continue; } s << INDENT << "qRegisterMetaType< ::" << className << " >(\"" << name << "\");\n"; |