aboutsummaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-07-29 03:51:14 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:17:06 -0300
commit4e839b8209e31ea48b264622240b3c4939e6cefd (patch)
treea486b62fcd84a50bf9b3640af9cb427a6fef4b09 /generator
parent6af928412c947d219f8a04258301e685826934ef (diff)
Sanitized CppGenerator's writeToPythonFunction() method.
Diffstat (limited to 'generator')
-rw-r--r--generator/cppgenerator.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 16b4cd6f2..165506a14 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -226,19 +226,26 @@ void CppGenerator::writeRegisterType(QTextStream& s, const AbstractMetaEnum* met
void CppGenerator::writeToPythonFunction(QTextStream& s, const AbstractMetaClass* metaClass)
{
+ int previousErrorCode = m_currentErrorCode;
+ m_currentErrorCode = 0;
s << "static PyObject* " << cpythonBaseName(metaClass) << "_ToPythonFunc(PyObject* self)" << endl;
- s << "{" << endl;
- s << INDENT << metaClass->qualifiedCppName() << "* cppSelf = Shiboken::Converter< ::" << metaClass->qualifiedCppName() << "* >::toCpp(self);" << endl;
- s << INDENT << "PyObject* pyResult = Shiboken::PythonConverter< ::" << metaClass->qualifiedCppName() << " >::transformToPython(cppSelf);" << endl;
- s << INDENT << "if (PyErr_Occurred() || !pyResult) {" << endl;
+ s << '{' << endl;
+ writeCppSelfDefinition(s, metaClass);
+
+ s << INDENT << "PyObject* " PYTHON_RETURN_VAR " = Shiboken::PythonConverter< ::" << metaClass->qualifiedCppName();
+ s << " >::transformToPython(" CPP_SELF_VAR ");" << endl;
+
+ s << INDENT << "if (PyErr_Occurred() || !" PYTHON_RETURN_VAR ") {" << endl;
{
Indentation indentation(INDENT);
- s << INDENT << INDENT << "Py_XDECREF(pyResult);" << endl;
- s << INDENT << INDENT << "return 0;" << endl;
+ s << INDENT << "Py_XDECREF(" PYTHON_RETURN_VAR ");" << endl;
+ s << INDENT << "return 0;" << endl;
}
- s << INDENT << "}" << endl;
- s << INDENT << "return pyResult;" << endl;
- s << "}" << endl;
+ s << INDENT << '}' << endl;
+
+ s << INDENT << "return " PYTHON_RETURN_VAR ";" << endl;
+ s << '}' << endl;
+ m_currentErrorCode = previousErrorCode;
}
bool CppGenerator::hasBoolCast(const AbstractMetaClass* metaClass) const