summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-11-26 17:01:12 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-11-26 17:01:12 -0300
commita3574b9365f0ba24f2d53d3b615ac926457ebb06 (patch)
treecd8ab9307de4c0c7214e38bff620ab8e96983bbb
parentc98a8d83110459e486f623919deafd604f1424e4 (diff)
downloadshiboken-a3574b9365f0ba24f2d53d3b615ac926457ebb06.tar.gz
shiboken-a3574b9365f0ba24f2d53d3b615ac926457ebb06.tar.xz
shiboken-a3574b9365f0ba24f2d53d3b615ac926457ebb06.zip
Wrapped C++ object validity checks now consider implicit conversions.
When CppGenerator::writeInvalidCppObjectCheck if called for a function parameter and said parameter has implicit conversions that use other wrapped C++ classes the validity check is written for them too.
-rw-r--r--cppgenerator.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp
index 75ee859a..0d2d27f8 100644
--- a/cppgenerator.cpp
+++ b/cppgenerator.cpp
@@ -678,8 +678,20 @@ void CppGenerator::writeErrorSection(QTextStream& s, OverloadData& overloadData)
void CppGenerator::writeInvalidCppObjectCheck(QTextStream& s, QString pyArgName, const TypeEntry* type)
{
s << INDENT << "if (";
- if (type)
- s << cpythonCheckFunction(type) << '(' << pyArgName << ") && ";
+ if (type) {
+ QString implicitChecks;
+ QTextStream ic(&implicitChecks);
+ foreach (const AbstractMetaFunction* ctor, implicitConversions(type)) {
+ const TypeEntry* te = ctor->arguments().first()->type()->typeEntry();
+ if (te->isValue() || te->isObject())
+ ic << " || " << cpythonCheckFunction(te) << '(' << pyArgName << ')';
+ }
+ s << (!implicitChecks.isEmpty() ? "(" : "");
+ s << cpythonCheckFunction(type) << '(' << pyArgName << ')';
+ if (!implicitChecks.isEmpty())
+ s << implicitChecks << ')';
+ s << " && ";
+ }
s << "Shiboken::cppObjectIsInvalid(" << pyArgName << "))" << endl;
{
Indentation indent(INDENT);