aboutsummaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-08-10 17:50:36 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:17:11 -0300
commit81307ef0b1255143e2eb560bc80d80d9dda796ed (patch)
tree70714ed0f2c83ed168b343c1fbc2bd90f5ec3296 /generator
parenta6eb186fa5a349af171295d0ea9d60c4aec049b3 (diff)
CppGenerator's method writeReprFunction now uses writeCppSelfDefinition.
Diffstat (limited to 'generator')
-rw-r--r--generator/cppgenerator.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 979cc532a..07c94efbc 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -4159,35 +4159,32 @@ QString CppGenerator::writeReprFunction(QTextStream& s, const AbstractMetaClass*
QString funcName = cpythonBaseName(metaClass) + "__repr__";
s << "extern \"C\"" << endl;
s << '{' << endl;
- s << "static PyObject* " << funcName << "(PyObject* pyObj)" << endl;
+ s << "static PyObject* " << funcName << "(PyObject* self)" << endl;
s << '{' << endl;
+ writeCppSelfDefinition(s, metaClass);
s << INDENT << "QBuffer buffer;" << endl;
s << INDENT << "buffer.open(QBuffer::ReadWrite);" << endl;
s << INDENT << "QDebug dbg(&buffer);" << endl;
- s << INDENT << "dbg << ";
- writeToCppConversion(s, metaClass, "pyObj");
- s << ';' << endl;
+ s << INDENT << "dbg << " CPP_SELF_VAR ";" << endl;
s << INDENT << "buffer.close();" << endl;
s << INDENT << "QByteArray str = buffer.data();" << endl;
s << INDENT << "int idx = str.indexOf('(');" << endl;
s << INDENT << "if (idx >= 0)" << endl;
{
Indentation indent(INDENT);
- s << INDENT << "str.replace(0, idx, Py_TYPE(pyObj)->tp_name);" << endl;
+ s << INDENT << "str.replace(0, idx, Py_TYPE(self)->tp_name);" << endl;
}
-
- s << INDENT << "PyObject* mod = PyDict_GetItemString(Py_TYPE(pyObj)->tp_dict, \"__module__\");" << endl;
+ s << INDENT << "PyObject* mod = PyDict_GetItemString(Py_TYPE(self)->tp_dict, \"__module__\");" << endl;
s << INDENT << "if (mod)" << endl;
{
Indentation indent(INDENT);
- s << INDENT << "return PyString_FromFormat(\"<%s.%s at %p>\", PyString_AS_STRING(mod), str.constData(), pyObj);" << endl;
+ s << INDENT << "return PyString_FromFormat(\"<%s.%s at %p>\", PyString_AS_STRING(mod), str.constData(), self);" << endl;
}
s << INDENT << "else" << endl;
{
Indentation indent(INDENT);
- s << INDENT << "return PyString_FromFormat(\"<%s at %p>\", str.constData(), pyObj);" << endl;
+ s << INDENT << "return PyString_FromFormat(\"<%s at %p>\", str.constData(), self);" << endl;
}
-
s << '}' << endl;
s << "} // extern C" << endl << endl;;
return funcName;