aboutsummaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
Diffstat (limited to 'generator')
-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)) {