aboutsummaryrefslogtreecommitdiffstats
path: root/generator/cppgenerator.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-08-06 11:12:09 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:17:08 -0300
commite19d6475f600b27ea878a8d5e6dc5f599820c842 (patch)
tree7aa6c7f2aabe3e88dfe147a7855d40455527a26b /generator/cppgenerator.cpp
parentbaf2a5bf56620134d751b54a514159221d4e11d4 (diff)
The result of rich comparisons are stored in a return variable before converting them to Python.
Diffstat (limited to 'generator/cppgenerator.cpp')
-rw-r--r--generator/cppgenerator.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 687a24499..44d62f4f6 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -3023,15 +3023,16 @@ void CppGenerator::writeRichCompareFunction(QTextStream& s, const AbstractMetaCl
QString expression = QString("%1%2 %3 " CPP_ARG0)
.arg(func->isPointerOperator() ? "&" : "")
.arg(CPP_SELF_VAR).arg(op);
+ s << INDENT;
+ if (func->type())
+ s << func->type()->cppSignature() << " " CPP_RETURN_VAR " = ";
+ s << expression << ';' << endl;
s << INDENT << PYTHON_RETURN_VAR " = ";
- if (!func->type()) {
- s << "Py_None;" << endl;
- s << INDENT << "Py_INCREF(Py_None);" << endl;
- s << INDENT << expression << "; // This operator returns void." << endl;
- } else {
- writeToPythonConversion(s, func->type(), metaClass, expression);
- s << ';' << endl;
- }
+ if (func->type())
+ writeToPythonConversion(s, func->type(), metaClass, CPP_RETURN_VAR);
+ else
+ s << "Py_None;" << endl << INDENT << "Py_INCREF(Py_None)";
+ s << ';' << endl;
}
}
s << INDENT << '}';