diff options
author | Lauro Neto <lauro.neto@openbossa.org> | 2011-03-28 16:13:44 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:15:19 -0300 |
commit | 7c35c7788ab02d2d77cbc022d6cf181e7542d995 (patch) | |
tree | 5587b475fcfec792066dd9da7844c63c6a7996de /generator | |
parent | 55c0296417d146c999d0b2ba067c6e488bc6f416 (diff) |
Reverse operators raise NotImplemented error.
If it's a reverse operator and the OverloadDecisor fails,
raise NotImplementedError instead of TypeError.
Diffstat (limited to 'generator')
-rw-r--r-- | generator/cppgenerator.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp index c2a6476c4..3be548832 100644 --- a/generator/cppgenerator.cpp +++ b/generator/cppgenerator.cpp @@ -1590,12 +1590,25 @@ void CppGenerator::writeNoneReturn(QTextStream& s, const AbstractMetaFunction* f void CppGenerator::writeOverloadedFunctionDecisor(QTextStream& s, const OverloadData& overloadData) { s << INDENT << "// Overloaded function decisor" << endl; + const AbstractMetaFunction* rfunc = overloadData.referenceFunction(); QList<const AbstractMetaFunction*> functionOverloads = overloadData.overloadsWithoutRepetition(); for (int i = 0; i < functionOverloads.count(); i++) s << INDENT << "// " << i << ": " << functionOverloads.at(i)->minimalSignature() << endl; writeOverloadedFunctionDecisorEngine(s, &overloadData); s << endl; + // Ensure that the direct overload that called this reverse + // is called. + if (rfunc->isOperatorOverload()) { + s << INDENT << "if (isReverse && overloadId == -1) {" << endl; + { + Indentation indent(INDENT); + s << INDENT << "PyErr_SetString(PyExc_NotImplementedError, \"reverse operator not implemented.\");" << endl; + s << INDENT << "return 0;" << endl; + } + s << INDENT << "}" << endl << endl; + } + s << INDENT << "// Function signature not found." << endl; s << INDENT << "if (overloadId == -1) goto " << cpythonFunctionName(overloadData.referenceFunction()) << "_TypeError;" << endl; s << endl; |