aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/generator/shiboken2/cppgenerator.cpp')
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp89
1 files changed, 2 insertions, 87 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 99bfae9f0..a62a0ac27 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -2083,93 +2083,8 @@ void CppGenerator::writeErrorSection(QTextStream& s, OverloadData& overloadData)
QString argsVar = pythonFunctionWrapperUsesListOfArguments(overloadData)
? QLatin1String("args") : QLatin1String(PYTHON_ARG);
- if (verboseErrorMessagesDisabled()) {
- s << INDENT << "Shiboken::setErrorAboutWrongArguments(" << argsVar << ", \"" << funcName << "\", 0);" << endl;
- } else {
- QStringList overloadSignatures;
- const OverloadData::MetaFunctionList &overloads = overloadData.overloads();
- for (const AbstractMetaFunction *f : overloads) {
- QStringList args;
- const AbstractMetaArgumentList &arguments = f->arguments();
- for (AbstractMetaArgument *arg : arguments) {
- QString strArg;
- AbstractMetaType* argType = arg->type();
- if (isCString(argType)) {
- strArg = QLatin1String("\" SBK_BYTES_NAME \"");
- } else if (argType->isPrimitive()) {
- const PrimitiveTypeEntry* ptp = reinterpret_cast<const PrimitiveTypeEntry*>(argType->typeEntry());
- while (ptp->referencedTypeEntry())
- ptp = ptp->referencedTypeEntry();
- strArg = ptp->name();
- if (strArg == QLatin1String("QString")) {
- strArg = QLatin1String("unicode");
- } else if (strArg == QLatin1String("QChar")) {
- strArg = QLatin1String("1-unicode");
- } else {
- strArg = ptp->name();
- static const QRegularExpression regex(QStringLiteral("^signed\\s+"));
- Q_ASSERT(regex.isValid());
- strArg.remove(regex);
- if (strArg == QLatin1String("double"))
- strArg = QLatin1String("float");
- }
- } else if (argType->typeEntry()->isContainer()) {
- strArg = argType->fullName();
- if (strArg == QLatin1String("QList") || strArg == QLatin1String("QVector")
- || strArg == QLatin1String("QLinkedList") || strArg == QLatin1String("QStack")
- || strArg == QLatin1String("QQueue")) {
- strArg = QLatin1String("list");
- } else if (strArg == QLatin1String("QMap") || strArg == QLatin1String("QHash")
- || strArg == QLatin1String("QMultiMap") || strArg == QLatin1String("QMultiHash")) {
- strArg = QLatin1String("dict");
- } else if (strArg == QLatin1String("QPair")) {
- strArg = QLatin1String("2-tuple");
- }
- } else {
- strArg = argType->fullName();
- if (strArg == QLatin1String("PyUnicode"))
- strArg = QLatin1String("unicode");
- else if (strArg == QLatin1String("PyString"))
- strArg = QLatin1String("str");
- else if (strArg == QLatin1String("PyBytes"))
- strArg = QLatin1String("\" SBK_BYTES_NAME \"");
- else if (strArg == QLatin1String("PyByteArray"))
- strArg = QLatin1String("bytearray");
- else if (strArg == QLatin1String("PySequence"))
- strArg = QLatin1String("list");
- else if (strArg == QLatin1String("PyTuple"))
- strArg = QLatin1String("tuple");
- else if (strArg == QLatin1String("PyDict"))
- strArg = QLatin1String("dict");
- else if (strArg == QLatin1String("PyObject"))
- strArg = QLatin1String("object");
- else if (strArg == QLatin1String("PyCallable"))
- strArg = QLatin1String("callable");
- else if (strArg == QLatin1String("uchar"))
- strArg = QLatin1String("buffer"); // This depends on an inject code to be true, but if it's not true
- // the function wont work at all, so it must be true.
- }
- if (!arg->defaultValueExpression().isEmpty()) {
- strArg += QLatin1String(" = ");
- if ((isCString(argType) || isPointerToWrapperType(argType))
- && arg->defaultValueExpression() == QLatin1String("0")) {
- strArg += QLatin1String("None");
- } else {
- QString e = arg->defaultValueExpression();
- e.replace(QLatin1String("::"), QLatin1String("."));
- e.replace(QLatin1String("\""), QLatin1String("\\\""));
- strArg += e;
- }
- }
- args << strArg;
- }
- overloadSignatures << QLatin1Char('"') + args.join(QLatin1String(", ")) + QLatin1Char('"');
- }
- s << INDENT << "const char* overloads[] = {" << overloadSignatures.join(QLatin1String(", "))
- << ", 0};" << endl;
- s << INDENT << "Shiboken::setErrorAboutWrongArguments(" << argsVar << ", \"" << funcName << "\", overloads);" << endl;
- }
- s << INDENT << returnStatement(m_currentErrorCode) << endl;
+ s << INDENT << "Shiboken::setErrorAboutWrongArguments(" << argsVar << ", \"" << funcName << "\");" << endl;
+ s << INDENT << "return " << m_currentErrorCode << ';' << endl;
}
void CppGenerator::writeFunctionReturnErrorCheckSection(QTextStream& s, bool hasReturnValue)