diff options
Diffstat (limited to 'sources/shiboken6/ApiExtractor/messages.cpp')
-rw-r--r-- | sources/shiboken6/ApiExtractor/messages.cpp | 150 |
1 files changed, 102 insertions, 48 deletions
diff --git a/sources/shiboken6/ApiExtractor/messages.cpp b/sources/shiboken6/ApiExtractor/messages.cpp index e7af80fe3..170595660 100644 --- a/sources/shiboken6/ApiExtractor/messages.cpp +++ b/sources/shiboken6/ApiExtractor/messages.cpp @@ -16,7 +16,6 @@ #include "qtcompat.h" -#include <QtCore/QCoreApplication> #include <QtCore/QDebug> #include <QtCore/QDir> #include <QtCore/QFile> @@ -27,6 +26,22 @@ using namespace Qt::StringLiterals; // abstractmetabuilder.cpp +static QTextStream &operator<<(QTextStream &s, Access a) +{ + switch (a) { + case Access::Public: + s << "public"; + break; + case Access::Protected: + s << "protected"; + break; + case Access::Private: + s << "private"; + break; + } + return s; +} + QString msgNoFunctionForModification(const AbstractMetaClassCPtr &klass, const QString &signature, const QString &originalSignature, @@ -225,7 +240,8 @@ QString msgNoEnumTypeEntry(const EnumModelItem &enumItem, QTextStream str(&result); str << enumItem->sourceLocation(); msgFormatEnumType(str, enumItem, className); - str << " does not have a type entry"; + str << " does not have a type entry (type systems: " + << TypeDatabase::instance()->loadedTypeSystemNames() << ')'; return result; } @@ -249,7 +265,8 @@ QString msgNamespaceNoTypeEntry(const NamespaceModelItem &item, QString result; QTextStream str(&result); str << item->sourceLocation() << "namespace '" << fullName - << "' does not have a type entry"; + << "' does not have a type entry (type systems: " + << TypeDatabase::instance()->loadedTypeSystemNames() << ')'; return result; } @@ -300,11 +317,13 @@ QString msgSkippingFunction(const FunctionModelItem &functionItem, { QString result; QTextStream str(&result); - str << functionItem->sourceLocation() << "skipping "; - if (functionItem->isAbstract()) + str << functionItem->sourceLocation() << "skipping " + << functionItem->accessPolicy() << ' '; + const bool isAbstract = functionItem->attributes().testFlag(FunctionAttribute::Abstract); + if (isAbstract) str << "abstract "; str << "function '" << signature << "', " << why; - if (functionItem->isAbstract()) { + if (isAbstract) { str << "\nThis will lead to compilation errors due to not " "being able to instantiate the wrapper."; } @@ -337,8 +356,9 @@ QString msgSkippingField(const VariableModelItem &field, const QString &classNam { QString result; QTextStream str(&result); - str << field->sourceLocation() << "skipping field '" << className - << "::" << field->name() << "' with unmatched type '" << type << '\''; + str << field->sourceLocation() << "skipping " << field->accessPolicy() + << " field '" << className << "::" << field->name() + << "' with unmatched type '" << type << '\''; return result; } @@ -349,8 +369,14 @@ QString msgTypeNotDefined(const TypeEntryCPtr &entry) { QString result; QTextStream str(&result); + const bool hasConfigCondition = entry->isComplex() + && std::static_pointer_cast<const ConfigurableTypeEntry>(entry)->hasConfigCondition(); str << entry->sourceLocation() << "type '" <<entry->qualifiedCppName() - << "' is specified in typesystem, but not defined. " << msgCompilationError; + << "' is specified in typesystem, but not defined"; + if (hasConfigCondition) + str << " (disabled by configuration?)."; + else + str << ". " << msgCompilationError; return result; } @@ -370,14 +396,15 @@ QString msgGlobalFunctionNotDefined(const FunctionTypeEntryCPtr &fte, QString msgStrippingArgument(const FunctionModelItem &f, int i, const QString &originalSignature, - const ArgumentModelItem &arg) + const ArgumentModelItem &arg, + const QString &reason) { QString result; QTextStream str(&result); str << f->sourceLocation() << "Stripping argument #" << (i + 1) << " of " << originalSignature << " due to unmatched type \"" << arg->type().toString() << "\" with default expression \"" - << arg->defaultValueExpression() << "\"."; + << arg->defaultValueExpression() << "\": " << reason; return result; } @@ -454,6 +481,21 @@ QString msgCannotFindTypeEntryForSmartPointer(const QString &t, const QString &s + u"\" for instantiation of \""_s +smartPointerType + u"\"."_s; } +QString msgInheritTemplateIssue(const AbstractMetaClassPtr &subclass, + const TypeInfo &info, + const QString &what) +{ + return "While inheriting template "_L1 + subclass->name() + + " from "_L1 + info.toString() + ": "_L1 + what; +} + +QString msgIgnoringTemplateParameter(const QString &typeName, + const char *why) +{ + return "Ignoring template parameter "_L1 + typeName + + ": "_L1 + QLatin1StringView(why); +} + QString msgInvalidSmartPointerType(const TypeInfo &i) { return u"Invalid smart pointer type \""_s +i.toString() + u"\"."_s; @@ -589,9 +631,10 @@ QString msgCannotFindDocumentation(const QString &fileName, const AbstractMetaEnum &e, const QString &query) { - return msgCannotFindDocumentation(fileName, "enum", - metaClass->name() + u"::"_s + e.name(), - query); + QString name = e.name(); + if (metaClass != nullptr) + name.prepend(metaClass->name() + "::"_L1); + return msgCannotFindDocumentation(fileName, "enum", name, query); } QString msgCannotFindDocumentation(const QString &fileName, @@ -599,9 +642,10 @@ QString msgCannotFindDocumentation(const QString &fileName, const AbstractMetaField &f, const QString &query) { - return msgCannotFindDocumentation(fileName, "field", - metaClass->name() + u"::"_s + f.name(), - query); + QString name = f.name(); + if (metaClass != nullptr) + name.prepend(metaClass->name() + "::"_L1); + return msgCannotFindDocumentation(fileName, "field", name, query); } QString msgXpathDocModificationError(const DocModificationList& mods, @@ -629,13 +673,13 @@ QString msgXpathDocModificationError(const DocModificationList& mods, QString msgCannotOpenForReading(const QFile &f) { - return QStringLiteral("Failed to open file '%1' for reading: %2") + return QString::fromLatin1("Failed to open file '%1' for reading: %2") .arg(QDir::toNativeSeparators(f.fileName()), f.errorString()); } QString msgCannotOpenForWriting(const QFile &f) { - return QStringLiteral("Failed to open file '%1' for writing: %2") + return QString::fromLatin1("Failed to open file '%1' for writing: %2") .arg(QDir::toNativeSeparators(f.fileName()), f.errorString()); } @@ -657,23 +701,6 @@ QString msgCannotUseEnumAsInt(const QString &name) "Compilation errors may occur when used as a function argument."_s; } -QString msgConversionTypesDiffer(const QString &varType, const QString &conversionType) -{ - QString result; - QTextStream str(&result); - str << "Types of receiver variable ('" << varType - << "') and %%CONVERTTOCPP type system variable ('" << conversionType - << "') differ"; - QString strippedVarType = varType; - QString strippedConversionType = conversionType; - TypeInfo::stripQualifiers(&strippedVarType); - TypeInfo::stripQualifiers(&strippedConversionType); - if (strippedVarType == strippedConversionType) - str << " in qualifiers. Please make sure the type is a distinct token"; - str << '.'; - return result; -} - QString msgCannotFindSmartPointerGetter(const SmartPointerTypeEntryCPtr &te) { return u"Getter \""_s + te->getter() + u"()\" of smart pointer \""_s @@ -694,18 +721,12 @@ QString msgMethodNotFound(const AbstractMetaClassCPtr &klass, const QString &nam // main.cpp -QString msgLeftOverArguments(const QVariantMap &remainingArgs) +QString msgLeftOverArguments(const QString &remainingArgs, const QStringList &argV) { QString message; QTextStream str(&message); - str << "shiboken: Called with wrong arguments:"; - for (auto it = remainingArgs.cbegin(), end = remainingArgs.cend(); it != end; ++it) { - str << ' ' << it.key(); - const QString value = it.value().toString(); - if (!value.isEmpty()) - str << ' ' << value; - } - str << "\nCommand line: " << QCoreApplication::arguments().join(u' '); + str << "shiboken: Unprocessed arguments: " << remainingArgs + << "\nCommand line: " << argV.join(u' '); return message; } @@ -814,17 +835,17 @@ QString msgRejectReason(const TypeRejection &r, const QString &needle) QTextStream str(&result); switch (r.matchType) { case TypeRejection::ExcludeClass: - str << " matches class exclusion \"" << r.className.pattern() << '"'; + str << "matches class exclusion \"" << r.className.pattern() << '"'; break; case TypeRejection::Function: case TypeRejection::Field: case TypeRejection::Enum: - str << " matches class \"" << r.className.pattern() << "\" and \"" + str << "matches class \"" << r.className.pattern() << "\" and \"" << r.pattern.pattern() << '"'; break; case TypeRejection::ArgumentType: case TypeRejection::ReturnType: - str << " matches class \"" << r.className.pattern() << "\" and \"" + str << "matches class \"" << r.className.pattern() << "\" and \"" << needle << "\" matches \"" << r.pattern.pattern() << '"'; break; } @@ -877,6 +898,21 @@ QString msgCannotFindSnippet(const QString &file, const QString &snippetLabel) return result; } +QString msgSnippetError(const QString &context, const char *what) +{ + return "Error processing code snippet of "_L1 + context + + ": "_L1 + QString::fromUtf8(what); +} + +QString msgUnableToResolveTypedef(const QString &sourceType, const QString &sourceName) +{ + QString result; + QTextStream(&result) << "Unable to resolve typedef \"" << sourceType + << "\": Could not find a value, container, object or smart pointer type named \"" + << sourceName << "\"."; + return result; +} + // cppgenerator.cpp QString msgPureVirtualFunctionRemoved(const AbstractMetaFunction *f) @@ -948,3 +984,21 @@ QString msgUnknownArrayPointerConversion(const QString &s) return u"Warning: Falling back to pointer conversion for unknown array type \""_s + s + u"\""_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; +} + +QString msgInvalidLanguageLevel(const QString &l) +{ + return u"Invalid argument for language level: \""_s + l + u"\"."_s; +} + +QString msgCannotFindImage(const QString &href, const QString &context, + const QString &candidate) +{ + return "Cannot resolve image "_L1 + href + " for "_L1 + context + + " (tried "_L1 + QDir::toNativeSeparators(candidate) + ")."_L1; +} |