aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator/shiboken2
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-09-07 10:12:50 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-09-10 18:41:56 +0000
commit253553022f1ea1692795a28efe3a62b39b4f6bb9 (patch)
tree4d2e7b6fff5c67e8c5597f00d261bc60ea1d6527 /sources/shiboken2/generator/shiboken2
parent1eb5d0e205ba9f69bd9bd19183c8254c7c6e02ae (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/generator/shiboken2')
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp3
-rw-r--r--sources/shiboken2/generator/shiboken2/overloaddata.cpp1
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.cpp42
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.h2
4 files changed, 4 insertions, 44 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index f5ed529b2..b992a5ca8 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -31,6 +31,7 @@
#include "cppgenerator.h"
#include "overloaddata.h"
#include <abstractmetalang.h>
+#include <messages.h>
#include <reporthandler.h>
#include <typedatabase.h>
@@ -763,7 +764,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun
if (const AbstractMetaClass *c = func->implementingClass())
errorMsg += c->qualifiedCppName() + QLatin1String("::");
errorMsg += func->signature();
- errorMsg = ShibokenGenerator::msgCouldNotFindMinimalConstructor(errorMsg, func->type()->cppSignature());
+ errorMsg = msgCouldNotFindMinimalConstructor(errorMsg, func->type()->cppSignature());
qCWarning(lcShiboken).noquote().nospace() << errorMsg;
s << endl << INDENT << "#error " << errorMsg << endl;
}
diff --git a/sources/shiboken2/generator/shiboken2/overloaddata.cpp b/sources/shiboken2/generator/shiboken2/overloaddata.cpp
index 333ee00c6..b22512fc6 100644
--- a/sources/shiboken2/generator/shiboken2/overloaddata.cpp
+++ b/sources/shiboken2/generator/shiboken2/overloaddata.cpp
@@ -152,6 +152,7 @@ static QString getImplicitConversionTypeName(const AbstractMetaType* containerTy
+ types.join(QLatin1String(", ")) + QLatin1String(" >");
}
+// overloaddata.cpp
static QString msgCyclicDependency(const QString &funcName, const QString &graphName,
const OverloadData::MetaFunctionList &involvedConversions)
{
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
index 12f797a7c..6a7cef6ef 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
@@ -28,6 +28,7 @@
#include "shibokengenerator.h"
#include <abstractmetalang.h>
+#include <messages.h>
#include "overloaddata.h"
#include <reporthandler.h>
#include <typedatabase.h>
@@ -881,14 +882,6 @@ QString ShibokenGenerator::cpythonTypeNameExt(const AbstractMetaType* type)
+ getTypeIndexVariableName(type) + QLatin1Char(']');
}
-static 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();
- return result;
-}
-
static inline QString unknownOperator() { return QStringLiteral("__UNKNOWN_OPERATOR__"); }
QString ShibokenGenerator::fixedCppTypeName(const CustomConversion::TargetToNativeConversion* toNative)
@@ -1700,17 +1693,6 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s,
s << INDENT << "// End of code injection" << endl;
}
-static QString msgWrongIndex(const char *varName, const QString &capture, const AbstractMetaFunction *func)
-{
- QString result;
- QTextStream str(&result);
- str << "Wrong index for " << varName << " variable (" << capture << ") on ";
- if (const AbstractMetaClass *c = func->implementingClass())
- str << c->name() << "::";
- str << func->signature();
- return result;
-}
-
void ShibokenGenerator::writeCodeSnips(QTextStream& s,
const CodeSnipList& codeSnips,
TypeSystem::CodeSnipPosition position,
@@ -1990,16 +1972,6 @@ static QString getConverterTypeSystemVariableArgument(const QString& code, int p
}
typedef QPair<QString, QString> StringPair;
-static QString msgCannotFindType(const QString &type, const QString &variable,
- const QString &why)
-{
- QString result;
- QTextStream(&result) << "Could not find type '"
- << type << "' for use in '" << variable << "' conversion: " << why
- << "\nMake sure to use the full C++ name, e.g. 'Namespace::Class'.";
- return result;
-}
-
void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVariable converterVariable, QString& code)
{
QVector<StringPair> replacements;
@@ -2289,12 +2261,6 @@ bool ShibokenGenerator::isCopyable(const AbstractMetaClass *metaClass)
return metaClass->typeEntry()->copyable() == ComplexTypeEntry::CopyableSet;
}
-static inline QString msgCannotBuildMetaType(const QString &s)
-{
- return QLatin1String("Unable to build meta type for \"")
- + s + QLatin1String("\": ");
-}
-
AbstractMetaType *ShibokenGenerator::buildAbstractMetaTypeFromString(QString typeSignature,
QString *errorMessage)
{
@@ -2731,12 +2697,6 @@ bool ShibokenGenerator::isCppIntegralPrimitive(const AbstractMetaType* type)
return isCppIntegralPrimitive(type->typeEntry());
}
-QString ShibokenGenerator::msgCouldNotFindMinimalConstructor(const QString &where, const QString &type)
-{
- return where + QLatin1String(": Could not find a minimal constructor for type '") + type
- + QLatin1String("'. This will result in a compilation error.");
-}
-
QString ShibokenGenerator::pythonArgsAt(int i)
{
return QLatin1String(PYTHON_ARGS) + QLatin1Char('[')
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.h b/sources/shiboken2/generator/shiboken2/shibokengenerator.h
index 829e6231f..76f71827a 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.h
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.h
@@ -430,8 +430,6 @@ protected:
static QString pythonArgsAt(int i);
- static QString msgCouldNotFindMinimalConstructor(const QString &where, const QString &type);
-
static QHash<QString, QString> m_pythonPrimitiveTypeName;
static QHash<QString, QString> m_pythonOperators;
static QHash<QString, QString> m_formatUnits;