aboutsummaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-04-15 16:49:31 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:15:21 -0300
commit4936232cec98614069cf72b55497c50b450a71e8 (patch)
treeffa5c781972486023745d18b439fa8ac3f0620d3 /generator
parente27fed1a8e7c173e0dc08e929671b9f289c3b4f1 (diff)
Return false when a overload wasn't found on __eq__ and true when an overload wasn't found on __ne__.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'generator')
-rw-r--r--generator/cppgenerator.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index a8d6c32ae..bd3d6631c 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -3011,7 +3011,8 @@ void CppGenerator::writeRichCompareFunction(QTextStream& s, const AbstractMetaCl
OverloadData overloadData(overloads, this);
const AbstractMetaFunction* rfunc = overloads[0];
- s << INDENT << "case " << ShibokenGenerator::pythonRichCompareOperatorId(rfunc) << ':' << endl;
+ QString operatorId = ShibokenGenerator::pythonRichCompareOperatorId(rfunc);
+ s << INDENT << "case " << operatorId << ':' << endl;
Indentation indent(INDENT);
@@ -3078,8 +3079,16 @@ void CppGenerator::writeRichCompareFunction(QTextStream& s, const AbstractMetaCl
s << INDENT << '}';
}
- s << " else goto " << baseName << "_RichComparison_TypeError;" << endl;
- s << endl;
+ s << " else {" << endl;
+ if (operatorId == "Py_EQ" || operatorId == "Py_NE") {
+ Indentation indent(INDENT);
+ s << INDENT << PYTHON_RETURN_VAR " = " << (operatorId == "Py_EQ" ? "Py_False" : "Py_True") << ';' << endl;
+ s << INDENT << "Py_INCREF(" PYTHON_RETURN_VAR ");" << endl;
+ } else {
+ Indentation indent(INDENT);
+ s << INDENT << "goto " << baseName << "_RichComparison_TypeError;" << endl;
+ }
+ s << INDENT << '}' << endl << endl;
s << INDENT << "break;" << endl;
}