aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/messages.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/ApiExtractor/messages.cpp')
-rw-r--r--sources/shiboken6/ApiExtractor/messages.cpp553
1 files changed, 366 insertions, 187 deletions
diff --git a/sources/shiboken6/ApiExtractor/messages.cpp b/sources/shiboken6/ApiExtractor/messages.cpp
index 92d3a97c5..b1f0b240e 100644
--- a/sources/shiboken6/ApiExtractor/messages.cpp
+++ b/sources/shiboken6/ApiExtractor/messages.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 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$
-**
-****************************************************************************/
+// Copyright (C) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "messages.h"
#include "abstractmetaenum.h"
@@ -34,21 +9,40 @@
#include "modifications.h"
#include "sourcelocation.h"
#include "typedatabase.h"
-#include "typesystem.h"
+#include "functiontypeentry.h"
+#include "enumtypeentry.h"
+#include "smartpointertypeentry.h"
#include <codemodel.h>
-#include <QtCore/QCoreApplication>
+#include "qtcompat.h"
+
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QStringList>
#include <QtCore/QXmlStreamReader>
-static inline QString colonColon() { return QStringLiteral("::"); }
+using namespace Qt::StringLiterals;
// abstractmetabuilder.cpp
-QString msgNoFunctionForModification(const AbstractMetaClass *klass,
+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,
const QStringList &possibleSignatures,
@@ -68,8 +62,8 @@ QString msgNoFunctionForModification(const AbstractMetaClass *klass,
str << " " << s << '\n';
} else if (!allFunctions.isEmpty()) {
str << "\n No candidates were found. Member functions:\n";
- const int maxCount = qMin(10, allFunctions.size());
- for (int f = 0; f < maxCount; ++f)
+ const auto maxCount = qMin(qsizetype(10), allFunctions.size());
+ for (qsizetype f = 0; f < maxCount; ++f)
str << " " << allFunctions.at(f)->minimalSignature() << '\n';
if (maxCount < allFunctions.size())
str << " ...\n";
@@ -77,6 +71,67 @@ QString msgNoFunctionForModification(const AbstractMetaClass *klass,
return result;
}
+QString msgArgumentIndexOutOfRange(const AbstractMetaFunction *func, int index)
+{
+ QString result;
+ QTextStream str(&result);
+ str <<"Index " << index << " out of range for " << func->classQualifiedSignature() << '.';
+ return result;
+}
+
+QString msgTypeModificationFailed(const QString &type, int n,
+ const AbstractMetaFunction *func,
+ const QString &why)
+{
+ QString result;
+ QTextStream str(&result);
+ str << "Unable to modify the ";
+ if (n == 0)
+ str << "return type";
+ else
+ str << "type of argument " << n;
+
+ str << " of ";
+ if (auto c = func->ownerClass())
+ str << c->name() << "::";
+ str << func->signature() << " to \"" << type << "\": " << why;
+ return result;
+}
+
+QString msgInvalidArgumentModification(const AbstractMetaFunctionCPtr &func,
+ int argIndex)
+{
+ QString result;
+ QTextStream str(&result);
+ str << "Invalid ";
+ if (argIndex == 0)
+ str << "return type modification";
+ else
+ str << "modification of argument " << argIndex;
+ str << " for " << func->classQualifiedSignature();
+ return result;
+}
+
+QString msgArgumentOutOfRange(int number, int minValue, int maxValue)
+{
+ QString result;
+ QTextStream(&result) << "Argument number " << number
+ << " out of range " << minValue << ".." << maxValue << '.';
+ return result;
+}
+
+QString msgArgumentRemovalFailed(const AbstractMetaFunction *func, int n,
+ const QString &why)
+{
+ QString result;
+ QTextStream str(&result);
+ str << "Unable to remove argument " << n << " of ";
+ if (auto c = func->ownerClass())
+ str << c->name() << "::";
+ str << func->signature() << ": " << why;
+ return result;
+}
+
template <class Stream>
static void msgFormatEnumType(Stream &str,
const EnumModelItem &enumItem,
@@ -84,7 +139,7 @@ static void msgFormatEnumType(Stream &str,
{
switch (enumItem->enumKind()) {
case CEnum:
- str << "Enum '" << enumItem->qualifiedName().join(colonColon()) << '\'';
+ str << "Enum '" << enumItem->qualifiedName().join(u"::"_s) << '\'';
break;
case AnonymousEnum: {
const EnumeratorList &values = enumItem->enumerators();
@@ -107,7 +162,7 @@ static void msgFormatEnumType(Stream &str,
}
break;
case EnumClass:
- str << "Scoped enum '" << enumItem->qualifiedName().join(colonColon()) << '\'';
+ str << "Scoped enum '" << enumItem->qualifiedName().join(u"::"_s) << '\'';
break;
}
if (!className.isEmpty())
@@ -115,7 +170,7 @@ static void msgFormatEnumType(Stream &str,
}
static void formatAddedFuncError(const QString &addedFuncName,
- const AbstractMetaClass *context,
+ const AbstractMetaClassCPtr &context,
QTextStream &str)
{
if (context) {
@@ -131,12 +186,12 @@ static void formatAddedFuncError(const QString &addedFuncName,
QString msgAddedFunctionInvalidArgType(const QString &addedFuncName,
const QStringList &typeName,
int pos, const QString &why,
- const AbstractMetaClass *context)
+ const AbstractMetaClassCPtr &context)
{
QString result;
QTextStream str(&result);
formatAddedFuncError(addedFuncName, context, str);
- str << "Unable to translate type \"" << typeName.join(colonColon())
+ str << "Unable to translate type \"" << typeName.join(u"::"_s)
<< "\" of argument " << pos << " of added function \""
<< addedFuncName << "\": " << why;
return result;
@@ -144,18 +199,18 @@ QString msgAddedFunctionInvalidArgType(const QString &addedFuncName,
QString msgAddedFunctionInvalidReturnType(const QString &addedFuncName,
const QStringList &typeName, const QString &why,
- const AbstractMetaClass *context)
+ const AbstractMetaClassCPtr &context)
{
QString result;
QTextStream str(&result);
formatAddedFuncError(addedFuncName, context, str);
- str << "Unable to translate return type \"" << typeName.join(colonColon())
+ str << "Unable to translate return type \"" << typeName.join(u"::"_s)
<< "\" of added function \"" << addedFuncName << "\": "
<< why;
return result;
}
-QString msgUnnamedArgumentDefaultExpression(const AbstractMetaClass *context,
+QString msgUnnamedArgumentDefaultExpression(const AbstractMetaClassCPtr &context,
int n, const QString &className,
const AbstractMetaFunction *f)
{
@@ -168,7 +223,7 @@ QString msgUnnamedArgumentDefaultExpression(const AbstractMetaClass *context,
return result;
}
-QString msgClassOfEnumNotFound(const EnumTypeEntry *entry)
+QString msgClassOfEnumNotFound(const EnumTypeEntryCPtr &entry)
{
QString result;
QTextStream str(&result);
@@ -185,13 +240,14 @@ 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;
}
QString msgNoEnumTypeConflict(const EnumModelItem &enumItem,
const QString &className,
- const TypeEntry *t)
+ const TypeEntryCPtr &t)
{
QString result;
QDebug debug(&result); // Use the debug operator for TypeEntry::Type
@@ -209,22 +265,28 @@ 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;
}
-QString msgAmbiguousVaryingTypesFound(const QString &qualifiedName, const TypeEntries &te)
+QString msgNamespaceNotFound(const QString &name)
{
- QString result = QLatin1String("Ambiguous types of varying types found for \"") + qualifiedName
- + QLatin1String("\": ");
+ return u"namespace '"_s + name + u"' not found."_s;
+}
+
+QString msgAmbiguousVaryingTypesFound(const QString &qualifiedName, const TypeEntryCList &te)
+{
+ 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 msgAmbiguousTypesFound(const QString &qualifiedName, const TypeEntryCList &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;
}
@@ -245,9 +307,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,
@@ -255,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.";
}
@@ -272,13 +336,12 @@ QString msgShadowingFunction(const AbstractMetaFunction *f1,
auto f2Class = f2->implementingClass();
QString result;
QTextStream str(&result);
- str << f2Class->sourceLocation() << "Shadowing: " << f1->implementingClass()->name()
- << "::" << f1->signature() << " and " << f2Class->name() << "::"
- << f2->signature();
+ str << f2Class->sourceLocation() << "Shadowing: " << f1->classQualifiedSignature()
+ << " and " << f2->classQualifiedSignature();
return result;
}
-QString msgSignalOverloaded(const AbstractMetaClass *c,
+QString msgSignalOverloaded(const AbstractMetaClassCPtr &c,
const AbstractMetaFunction *f)
{
QString result;
@@ -293,47 +356,59 @@ 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;
}
static const char msgCompilationError[] =
"This could potentially lead to compilation errors.";
-QString msgTypeNotDefined(const TypeEntry *entry)
+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;
}
-QString msgGlobalFunctionNotDefined(const FunctionTypeEntry *fte,
- const QString &signature)
+QString msgGlobalFunctionNotDefined(const FunctionTypeEntryCPtr &fte,
+ const QString &signature,
+ const QStringList &candidates)
{
QString result;
QTextStream str(&result);
str << fte->sourceLocation() << "Global function '" << signature
- << "' is specified in typesystem, but not defined. " << msgCompilationError;
+ << "' is specified in typesystem, but not defined.";
+ if (!candidates.isEmpty())
+ str << " Candidates are: " << candidates.join(u", "_s);
+ str << ' ' << msgCompilationError;
return result;
}
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;
}
-QString msgEnumNotDefined(const EnumTypeEntry *t)
+QString msgEnumNotDefined(const EnumTypeEntryCPtr &t)
{
QString result;
QTextStream str(&result);
@@ -342,7 +417,7 @@ QString msgEnumNotDefined(const EnumTypeEntry *t)
return result;
}
-QString msgUnknownBase(const AbstractMetaClass *metaClass,
+QString msgUnknownBase(const AbstractMetaClassCPtr &metaClass,
const QString &baseClassName)
{
QString result;
@@ -352,7 +427,7 @@ QString msgUnknownBase(const AbstractMetaClass *metaClass,
return result;
}
-QString msgBaseNotInTypeSystem(const AbstractMetaClass *metaClass,
+QString msgBaseNotInTypeSystem(const AbstractMetaClassCPtr &metaClass,
const QString &baseClassName)
{
QString result;
@@ -375,20 +450,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,
@@ -399,24 +472,39 @@ 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 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 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,
@@ -442,9 +530,9 @@ 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 ")
- + packageName + QLatin1Char('.');
+ return u"The namespace '"_s + namespaceName
+ + u"' to be extended cannot be found in package "_s
+ + packageName + u'.';
}
QString msgPropertyTypeParsingFailed(const QString &name, const QString &typeName,
@@ -459,12 +547,11 @@ 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,
+QString msgFunctionVisibilityModified(const AbstractMetaClassCPtr &c,
const AbstractMetaFunction *f)
{
QString result;
@@ -474,7 +561,7 @@ QString msgFunctionVisibilityModified(const AbstractMetaClass *c,
return result;
}
-QString msgUsingMemberClassNotFound(const AbstractMetaClass *c,
+QString msgUsingMemberClassNotFound(const AbstractMetaClassCPtr &c,
const QString &baseClassName,
const QString &memberName)
{
@@ -492,40 +579,73 @@ QString msgCannotFindDocumentation(const QString &fileName,
const QString &query)
{
QString result;
- QTextStream(&result) << "Cannot find documentation for " << what
- << ' ' << name << " in:\n " << QDir::toNativeSeparators(fileName)
- << "\n using query:\n " << query;
+ QTextStream str(&result);
+ str << "Cannot find documentation for " << what
+ << ' ' << name << " in:\n " << QDir::toNativeSeparators(fileName);
+ if (!query.isEmpty())
+ str << "\n using query:\n " << query;
+ return result;
+}
+
+QString msgFallbackForDocumentation(const QString &fileName,
+ const char *what, const QString &name,
+ const QString &query)
+{
+ QString result;
+ QTextStream str(&result);
+ str << "Fallback used while trying to find documentation for " << what
+ << ' ' << name << " in:\n " << QDir::toNativeSeparators(fileName);
+ if (!query.isEmpty())
+ str << "\n using query:\n " << query;
+ return result;
+}
+
+static QString functionDescription(const AbstractMetaFunction *function)
+{
+ QString result = u'"' + function->classQualifiedSignature() + u'"';
+ if (function->flags().testFlag(AbstractMetaFunction::Flag::HiddenFriend))
+ result += u" (hidden friend)"_s;
+ if (function->flags().testFlag(AbstractMetaFunction::Flag::InheritedFromTemplate))
+ result += u" (inherited from template)"_s;
return result;
}
QString msgCannotFindDocumentation(const QString &fileName,
- const AbstractMetaClass *metaClass,
const AbstractMetaFunction *function,
const QString &query)
{
- const QString name = metaClass->name() + QLatin1String("::")
- + function->minimalSignature();
- return msgCannotFindDocumentation(fileName, "function", name, query);
+ return msgCannotFindDocumentation(fileName, "function",
+ functionDescription(function), query);
+}
+
+QString msgFallbackForDocumentation(const QString &fileName,
+ const AbstractMetaFunction *function,
+ const QString &query)
+{
+ return msgFallbackForDocumentation(fileName, "function",
+ functionDescription(function), query);
}
QString msgCannotFindDocumentation(const QString &fileName,
- const AbstractMetaClass *metaClass,
+ const AbstractMetaClassCPtr &metaClass,
const AbstractMetaEnum &e,
const QString &query)
{
- return msgCannotFindDocumentation(fileName, "enum",
- metaClass->name() + QLatin1String("::") + 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,
- const AbstractMetaClass *metaClass,
+ const AbstractMetaClassCPtr &metaClass,
const AbstractMetaField &f,
const QString &query)
{
- return msgCannotFindDocumentation(fileName, "field",
- metaClass->name() + QLatin1String("::") + 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,
@@ -553,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());
}
@@ -576,80 +696,64 @@ 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)
+QString msgCannotFindSmartPointerGetter(const SmartPointerTypeEntryCPtr &te)
{
- 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;
+ return u"Getter \""_s + te->getter() + u"()\" of smart pointer \""_s
+ + te->name() + u"\" not found."_s;
}
-QString msgCannotFindSmartPointer(const QString &instantiationType,
- const AbstractMetaClassCList &pointers)
+QString msgCannotFindSmartPointerMethod(const SmartPointerTypeEntryCPtr &te, const QString &m)
{
- QString result;
- QTextStream str(&result);
- str << "Unable to find smart pointer type for " << instantiationType << " (known types:";
- for (auto t : pointers) {
- auto typeEntry = t->typeEntry();
- str << ' ' << typeEntry->targetLangName() << '/' << typeEntry->qualifiedCppName();
- }
- str << ").";
- return result;
+ return u"Method \""_s + m + u"()\" of smart pointer \""_s
+ + te->name() + u"\" not found."_s;
+}
+
+QString msgMethodNotFound(const AbstractMetaClassCPtr &klass, const QString &name)
+{
+ return u"Method \""_s + name + u"\" not found in class "_s
+ + klass->name() + u'.';
}
// 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(QLatin1Char(' '));
+ str << "shiboken: Unprocessed arguments: " << remainingArgs
+ << "\nCommand line: " << argV.join(u' ');
return message;
}
QString msgInvalidVersion(const QString &package, const QString &version)
{
- return QLatin1String("Invalid version \"") + version
- + QLatin1String("\" specified for package ") + package + QLatin1Char('.');
+ return u"Invalid version \""_s + version
+ + u"\" specified for package "_s + package + u'.';
}
QString msgCyclicDependency(const QString &funcName, const QString &graphName,
- const QList<const AbstractMetaFunction *> &involvedConversions)
+ const AbstractMetaFunctionCList &cyclic,
+ const AbstractMetaFunctionCList &involvedConversions)
{
QString result;
QTextStream str(&result);
str << "Cyclic dependency found on overloaddata for \"" << funcName
- << "\" method! The graph boy saved the graph at \""
- << QDir::toNativeSeparators(graphName) << "\".";
- if (const int count = involvedConversions.size()) {
+ << "\" method! The graph boy saved the graph at \"" << QDir::toNativeSeparators(graphName)
+ << "\". Cyclic functions:";
+ for (const auto &c : cyclic)
+ str << ' ' << c->signature();
+ if (const auto count = involvedConversions.size()) {
str << " Implicit conversions (" << count << "): ";
- for (int i = 0; i < count; ++i) {
+ for (qsizetype i = 0; i < count; ++i) {
if (i)
str << ", \"";
str << involvedConversions.at(i)->signature() << '"';
- if (const AbstractMetaClass *c = involvedConversions.at(i)->implementingClass())
+ if (const auto c = involvedConversions.at(i)->implementingClass())
str << '(' << c->name() << ')';
}
}
@@ -658,19 +762,28 @@ QString msgCyclicDependency(const QString &funcName, const QString &graphName,
// shibokengenerator.cpp
-QString msgClassNotFound(const TypeEntry *t)
+QString msgClassNotFound(const TypeEntryCPtr &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 TypeEntryCPtr &t)
+{
+ QString result;
+ QTextStream str(&result);
+ str << "Warning: Enclosing class \"" << t->parent()->name()
+ << "\" of class \"" << t->name() << "\" not found.";
+ return result;
}
-QString msgUnknownOperator(const AbstractMetaFunction* func)
+QString msgUnknownOperator(const AbstractMetaFunction *func)
{
- QString result = QLatin1String("Unknown operator: \"") + func->originalName()
- + QLatin1Char('"');
- if (const AbstractMetaClass *c = func->implementingClass())
- result += QLatin1String(" in class: ") + c->name();
+ QString result = u"Unknown operator: \""_s + func->originalName()
+ + u'"';
+ if (const auto c = func->implementingClass())
+ result += u" in class: "_s + c->name();
return result;
}
@@ -680,7 +793,7 @@ QString msgWrongIndex(const char *varName, const QString &capture,
QString result;
QTextStream str(&result);
str << "Wrong index for " << varName << " variable (" << capture << ") on ";
- if (const AbstractMetaClass *c = func->implementingClass())
+ if (const auto c = func->implementingClass())
str << c->name() << "::";
str << func->signature();
return result;
@@ -698,8 +811,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)
@@ -723,21 +835,19 @@ 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;
- case TypeRejection::Invalid:
- break;
}
return result;
}
@@ -747,36 +857,60 @@ 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)
+{
+ QString result;
+ QTextStream str(&result);
+ str << "Cannot find snippet \"" << snippetLabel << "\" in "
+ << QDir::toNativeSeparators(file) << '.';
+ 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
@@ -805,14 +939,59 @@ QString msgUnknownTypeInArgumentTypeReplacement(const QString &typeReplaced,
return result;
}
-QString msgRegisterMetaTypeUnqualifiedName(const AbstractMetaClass *c,
- const char *file, int line)
+QString msgDuplicateBuiltInTypeEntry(const QString &name)
+{
+ 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: '"_s + name + u"'."_s;
+}
+
+QString msgInvalidTargetLanguageApiName(const QString &name)
+{
+ return u"Invalid target language API name \""_s
+ + name + u"\"."_s;
+}
+
+QString msgUnknownCheckFunction(const TypeEntryCPtr &t)
+{
+ return u"Unknown check function for type: '"_s
+ + t->qualifiedCppName() + u"'."_s;
+}
+
+QString msgArgumentClassNotFound(const AbstractMetaFunctionCPtr &func,
+ const TypeEntryCPtr &t)
{
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!";
+ QTextStream(&result) << "Internal Error: Class \"" << t->qualifiedCppName()
+ << "\" for \"" << func->classQualifiedSignature() << "\" not found!";
+ return result;
+}
+
+QString msgMissingCustomConversion(const TypeEntryCPtr &t)
+{
+ QString result;
+ QTextStream(&result) << "Entry \"" << t->qualifiedCppName()
+ << "\" is missing a custom conversion.";
return result;
}
+
+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;
+}