aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-05-18 16:16:52 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-05-18 16:17:21 +0200
commitba47a265cc4ea881f758704058ac5bbbb547c4ec (patch)
tree6e4ff89b5f20001a4ef2c1d5499a85cf0164744f
parent47e3a993965c0bc47e006914abecf98c5ad796fe (diff)
parent51cb9304647fed901f3a19849d6758a757ce2d62 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.9
-rw-r--r--generator/shiboken2/cppgenerator.cpp6
-rw-r--r--generator/shiboken2/shibokengenerator.cpp27
-rw-r--r--generator/shiboken2/shibokengenerator.h4
3 files changed, 28 insertions, 9 deletions
diff --git a/generator/shiboken2/cppgenerator.cpp b/generator/shiboken2/cppgenerator.cpp
index cb432fe..6aa2c83 100644
--- a/generator/shiboken2/cppgenerator.cpp
+++ b/generator/shiboken2/cppgenerator.cpp
@@ -710,7 +710,11 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun
if (defaultReturnExpr.isEmpty())
defaultReturnExpr = minimalConstructor(func->type());
if (defaultReturnExpr.isEmpty()) {
- QString errorMsg = QString::fromLatin1(MIN_CTOR_ERROR_MSG).arg(func->type()->cppSignature());
+ QString errorMsg = QLatin1String(__FUNCTION__) + QLatin1String(": ");
+ if (const AbstractMetaClass *c = func->implementingClass())
+ errorMsg += c->qualifiedCppName() + QLatin1String("::");
+ errorMsg += func->signature();
+ errorMsg = ShibokenGenerator::msgCouldNotFindMinimalConstructor(errorMsg, func->type()->cppSignature());
qCWarning(lcShiboken).noquote().nospace() << errorMsg;
s << endl << INDENT << "#error " << errorMsg << endl;
}
diff --git a/generator/shiboken2/shibokengenerator.cpp b/generator/shiboken2/shibokengenerator.cpp
index 2dd8f06..4768ddc 100644
--- a/generator/shiboken2/shibokengenerator.cpp
+++ b/generator/shiboken2/shibokengenerator.cpp
@@ -2680,9 +2680,13 @@ void ShibokenGenerator::writeMinimalConstructorExpression(QTextStream& s, const
if (defaultCtor.isEmpty() && isCppPrimitive(type))
return;
QString ctor = defaultCtor.isEmpty() ? minimalConstructor(type) : defaultCtor;
- if (ctor.isEmpty())
- qFatal(qPrintable(QString::fromLatin1(MIN_CTOR_ERROR_MSG).arg(type->cppSignature())), NULL);
- s << " = " << ctor;
+ if (ctor.isEmpty()) {
+ const QString message = msgCouldNotFindMinimalConstructor(QLatin1String(__FUNCTION__), type->cppSignature());
+ qCWarning(lcShiboken()).noquote() << message;
+ s << ";\n#error " << message << '\n';
+ } else {
+ s << " = " << ctor;
+ }
}
void ShibokenGenerator::writeMinimalConstructorExpression(QTextStream& s, const TypeEntry* type, const QString& defaultCtor)
@@ -2690,9 +2694,14 @@ void ShibokenGenerator::writeMinimalConstructorExpression(QTextStream& s, const
if (defaultCtor.isEmpty() && isCppPrimitive(type))
return;
QString ctor = defaultCtor.isEmpty() ? minimalConstructor(type) : defaultCtor;
- if (ctor.isEmpty())
- qFatal(qPrintable(QString::fromLatin1(MIN_CTOR_ERROR_MSG).arg(type->qualifiedCppName())), NULL);
- s << " = " << ctor;
+
+ if (ctor.isEmpty()) {
+ const QString message = msgCouldNotFindMinimalConstructor(QLatin1String(__FUNCTION__), type->qualifiedCppName());
+ qCWarning(lcShiboken()).noquote() << message;
+ s << ";\n#error " << message << endl;
+ } else {
+ s << " = " << ctor;
+ }
}
bool ShibokenGenerator::isCppIntegralPrimitive(const TypeEntry* type)
@@ -2711,3 +2720,9 @@ 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.");
+}
diff --git a/generator/shiboken2/shibokengenerator.h b/generator/shiboken2/shibokengenerator.h
index cf2af04..1be56ed 100644
--- a/generator/shiboken2/shibokengenerator.h
+++ b/generator/shiboken2/shibokengenerator.h
@@ -43,8 +43,6 @@
#define THREAD_STATE_SAVER_VAR "threadStateSaver"
#define BEGIN_ALLOW_THREADS "PyThreadState* _save = PyEval_SaveThread(); // Py_BEGIN_ALLOW_THREADS"
#define END_ALLOW_THREADS "PyEval_RestoreThread(_save); // Py_END_ALLOW_THREADS"
-#define MIN_CTOR_ERROR_MSG "Could not find a minimal constructor for type '%1'. "\
- "This will result in a compilation error."
#define PYTHON_TO_CPP_VAR "pythonToCpp"
#define SMART_POINTER_GETTER "kSmartPointerGetter"
@@ -537,6 +535,8 @@ protected:
};
void replaceConverterTypeSystemVariable(TypeSystemConverterVariable converterVariable, QString& code);
+ static QString msgCouldNotFindMinimalConstructor(const QString &where, const QString &type);
+
private:
bool m_useCtorHeuristic;
bool m_userReturnValueHeuristic;