aboutsummaryrefslogtreecommitdiffstats
path: root/cppgenerator.cpp
diff options
context:
space:
mode:
authorLauro Neto <lauro.neto@openbossa.org>2010-03-22 16:23:58 -0300
committerLauro Neto <lauro.neto@openbossa.org>2010-03-22 16:23:58 -0300
commitc8ee3423948143cf1123586e6a95ebaa5578dc14 (patch)
tree29a12869471850cac46cc667313c606126bab61c /cppgenerator.cpp
parenta50c2a87185d0caeada88a658547c58f87a9d0bb (diff)
parentfb5d06e1fed8942ffc934f2ae77c9464e0f8ad40 (diff)
Merge branch 'operator'
Diffstat (limited to 'cppgenerator.cpp')
-rw-r--r--cppgenerator.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp
index d9cd0bf46..23ce9ca38 100644
--- a/cppgenerator.cpp
+++ b/cppgenerator.cpp
@@ -863,6 +863,38 @@ void CppGenerator::writeMethodWrapper(QTextStream& s, const AbstractMetaFunction
writeArgumentsInitializer(s, overloadData);
}
+ /*
+ * Make sure reverse <</>> operators defined in other classes (specially from other modules)
+ * are called. A proper and generic solution would require an reengineering in the operator
+ * system like the extended converters.
+ *
+ * Solves #119 - QDataStream <</>> operators not working for QPixmap
+ * http://bugs.openbossa.org/show_bug.cgi?id=119
+ */
+ if (hasReturnValue && !rfunc->isInplaceOperator() && rfunc->isOperatorOverload()) {
+ QString opName = ShibokenGenerator::pythonOperatorFunctionName(rfunc);
+ if (opName == "__rshift__" || opName == "__lshift__") {
+ s << INDENT << "if (!isReverse && SbkBaseWrapper_Check(arg)) {" << endl;
+ {
+ Indentation indent(INDENT);
+ // This PyObject_CallMethod call will emit lots of warnings like
+ // "deprecated conversion from string constant to char *" during compilation
+ // due to the method name argument being declared as "char*" instead of "const char*"
+ // issue 6952 http://bugs.python.org/issue6952
+ s << INDENT << PYTHON_RETURN_VAR << " = PyObject_CallMethod(arg, const_cast<char*>(\"" << opName.insert(2, 'r') << "\"), \"O\", self);" << endl;
+ s << INDENT << "if (PyErr_Occurred() && (PyErr_ExceptionMatches(PyExc_NotImplementedError) ||";
+ s << "PyErr_ExceptionMatches(PyExc_AttributeError))) {" << endl;
+ s << INDENT << INDENT << "PyErr_Clear();" << endl;
+ s << INDENT << "} else {" << endl;
+ s << INDENT << INDENT << "return " << PYTHON_RETURN_VAR << "; // Propagate the error" << endl;
+ s << INDENT << "}" << endl;
+
+ }
+ s << INDENT << "}" << endl;
+ }
+ }
+
+
writeOverloadedMethodDecisor(s, &overloadData);
s << endl << INDENT << "if (PyErr_Occurred()";