aboutsummaryrefslogtreecommitdiffstats
path: root/generator/cppgenerator.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-07-29 03:43:52 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:17:06 -0300
commit6af928412c947d219f8a04258301e685826934ef (patch)
tree493396e1aaabfe6cb1d8ad9c05d213174ff82c4d /generator/cppgenerator.cpp
parent29183ffe770ff7738c5eebc5480ca956c4fe086f (diff)
Modified the generation of 'nb_bool' functions to use standard functions.
Instead of writing everything on its own.
Diffstat (limited to 'generator/cppgenerator.cpp')
-rw-r--r--generator/cppgenerator.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 716ca6e66..16b4cd6f2 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -456,16 +456,18 @@ void CppGenerator::generateClass(QTextStream &s, const AbstractMetaClass *metaCl
}
if (hasBoolCast(metaClass)) {
- s << "static int " << cpythonBaseName(metaClass) << "___nb_bool(PyObject* pyObj)\n{\n";
- writeInvalidPyObjectCheck(s, "pyObj", -1);
- s << INDENT << "const ::" << metaClass->qualifiedCppName() << "* cppSelf = ";
- s << "Shiboken::Converter< ::" << metaClass->qualifiedCppName() << "*>::toCpp(pyObj);" << endl;
+ int previousErrorCode = m_currentErrorCode;
+ m_currentErrorCode = -1;
+ s << "static int " << cpythonBaseName(metaClass) << "___nb_bool(PyObject* self)" << endl;
+ s << '{' << endl;
+ writeCppSelfDefinition(s, metaClass);
s << INDENT << "int result;" << endl;
s << INDENT << BEGIN_ALLOW_THREADS << endl;
- s << INDENT << "result = !cppSelf->isNull();" << endl;
+ s << INDENT << "result = !" CPP_SELF_VAR "->isNull();" << endl;
s << INDENT << END_ALLOW_THREADS << endl;
s << INDENT << "return result;" << endl;
s << '}' << endl << endl;
+ m_currentErrorCode = previousErrorCode;
}
if (supportsNumberProtocol(metaClass)) {