diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-09-07 10:12:50 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-09-10 18:41:56 +0000 |
commit | 253553022f1ea1692795a28efe3a62b39b4f6bb9 (patch) | |
tree | 4d2e7b6fff5c67e8c5597f00d261bc60ea1d6527 /sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp | |
parent | 1eb5d0e205ba9f69bd9bd19183c8254c7c6e02ae (diff) |
shiboken: Centralize most msg* functions in a separate file
This makes it easier to maintain a consistent style,
unclutters the source and allows for re-using formatting helpers.
Change-Id: I4f29637a22afb457f629272e2d86f14bedb36008
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp | 158 |
1 files changed, 1 insertions, 157 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp index 85bb1b789..251d674a9 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include "abstractmetabuilder_p.h" +#include "messages.h" #include "reporthandler.h" #include "typedatabase.h" @@ -159,32 +160,6 @@ AbstractMetaEnumList AbstractMetaBuilder::globalEnums() const return d->m_globalEnums; } -static QString msgNoFunctionForModification(const QString &signature, - const QString &originalSignature, - const QString &className, - const QStringList &possibleSignatures, - const AbstractMetaFunctionList &allFunctions) -{ - QString result; - QTextStream str(&result); - str << "signature '" << signature << '\''; - if (!originalSignature.isEmpty() && originalSignature != signature) - str << " (specified as '" << originalSignature << "')"; - str << " for function modification in '" - << className << "' not found."; - if (possibleSignatures.isEmpty()) { - str << " No candidates were found. Member functions: "; - for (int f = 0, size = allFunctions.size(); f < size; ++f) { - if (f) - str << ", "; - str << allFunctions.at(f)->minimalSignature(); - } - } else { - str << " Possible candidates: " << possibleSignatures.join(QLatin1String(", ")); - } - return result; -} - void AbstractMetaBuilderPrivate::checkFunctionModifications() { const auto &entries = TypeDatabase::instance()->entries(); @@ -863,66 +838,6 @@ AbstractMetaClass *AbstractMetaBuilderPrivate::traverseNamespace(const FileModel return metaClass; } -template <class Stream> -static void msgFormatEnumType(Stream &str, - const EnumModelItem &enumItem, - const QString &className) -{ - switch (enumItem->enumKind()) { - case CEnum: - str << "Enum '" << enumItem->qualifiedName().join(colonColon()) << '\''; - break; - case AnonymousEnum: { - const EnumeratorList &values = enumItem->enumerators(); - str << "Anonymous enum ("; - switch (values.size()) { - case 0: - break; - case 1: - str << values.constFirst()->name(); - break; - case 2: - str << values.at(0)->name() << ", " << values.at(1)->name(); - break; - default: - str << values.at(0)->name() << ", ... , " - << values.at(values.size() - 1)->name(); - break; - } - str << ')'; - } - break; - case EnumClass: - str << "Scoped enum '" << enumItem->qualifiedName().join(colonColon()) << '\''; - break; - } - if (!className.isEmpty()) - str << " (class: " << className << ')'; -} - -static inline QString msgNoEnumTypeEntry(const EnumModelItem &enumItem, - const QString &className) -{ - QString result; - QTextStream str(&result); - msgFormatEnumType(str, enumItem, className); - str << " does not have a type entry"; - return result; -} - -static QString msgNoEnumTypeConflict(const EnumModelItem &enumItem, - const QString &className, - const TypeEntry *t) -{ - QString result; - QDebug debug(&result); // Use the debug operator for TypeEntry::Type - debug.noquote(); - debug.nospace(); - msgFormatEnumType(debug, enumItem, className); - debug << " is not an enum (type: " << t->type() << ')'; - return result; -} - AbstractMetaEnum *AbstractMetaBuilderPrivate::traverseEnum(const EnumModelItem &enumItem, AbstractMetaClass *enclosing, const QSet<QString> &enumsDeclarations) @@ -1894,44 +1809,6 @@ static inline QString qualifiedFunctionSignatureWithType(const FunctionModelItem result += functionSignature(functionItem); return result; } - -static inline QString msgUnmatchedParameterType(const ArgumentModelItem &arg, int n, - const QString &why) -{ - QString result; - QTextStream str(&result); - str << "unmatched type '" << arg->type().toString() << "' in parameter #" - << (n + 1); - if (!arg->name().isEmpty()) - str << " \"" << arg->name() << '"'; - str << ": " << why; - return result; -} - -static inline QString msgUnmatchedReturnType(const FunctionModelItem &functionItem, - const QString &why) -{ - return QLatin1String("unmatched return type '") - + functionItem->type().toString() - + QLatin1String("': ") + why; -} - -static QString msgSkippingFunction(const FunctionModelItem &functionItem, - const QString &signature, const QString &why) -{ - QString result; - QTextStream str(&result); - str << "skipping "; - if (functionItem->isAbstract()) - str << "abstract "; - str << "function '" << signature << "', " << why; - if (functionItem->isAbstract()) { - str << "\nThis will lead to compilation errors due to not " - "being able to instantiate the wrapper."; - } - return result; -} - static inline AbstractMetaFunction::FunctionType functionTypeFromCodeModel(CodeModel::FunctionType ft) { AbstractMetaFunction::FunctionType result = AbstractMetaFunction::NormalFunction; @@ -1960,12 +1837,6 @@ static inline AbstractMetaFunction::FunctionType functionTypeFromCodeModel(CodeM return result; } -static inline 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; -} - bool AbstractMetaBuilderPrivate::setArrayArgumentType(AbstractMetaFunction *func, const FunctionModelItem &functionItem, int i) @@ -2332,33 +2203,6 @@ static const TypeEntry* findTypeEntryUsingContext(const AbstractMetaClass* metaC return type; } -static QString msgUnableToTranslateType(const QString &t, const QString &why) -{ - return QLatin1String("Unable to translate type \"") - + t + QLatin1String("\": ") + why; -} - -static inline QString msgUnableToTranslateType(const TypeInfo &typeInfo, - const QString &why) -{ - return msgUnableToTranslateType(typeInfo.toString(), why); -} - -static inline QString msgCannotFindTypeEntry(const QString &t) -{ - return QLatin1String("Cannot find type entry for \"") + t + QLatin1String("\"."); -} - -static inline QString msgCannotTranslateTemplateArgument(int i, - const TypeInfo &typeInfo, - const QString &why) -{ - QString result; - QTextStream(&result) << "Unable to translate template argument " - << (i + 1) << typeInfo.toString() << ": " << why; - return result; -} - AbstractMetaType *AbstractMetaBuilderPrivate::translateType(const TypeInfo &_typei, bool resolveType, QString *errorMessage) |