aboutsummaryrefslogtreecommitdiffstats
path: root/headergenerator.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-03-01 14:01:27 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2010-03-01 14:01:27 -0300
commitdb7ce37a0de3e52f2940d8823e4308e89ffbb052 (patch)
tree31a2c3cf3e8a0dcfaef6f5094f6aafd976da5b77 /headergenerator.cpp
parent083d500b97e2ad5ac85402f7a6df068ca2ecbd73 (diff)
Generator noew handles implicit conversions that are conversion operators.
Previously all implicit conversions were constructors, now they could be conversion operators, with no explicit arguments except for the owner class where they where defined.
Diffstat (limited to 'headergenerator.cpp')
-rw-r--r--headergenerator.cpp27
1 files changed, 20 insertions, 7 deletions
diff --git a/headergenerator.cpp b/headergenerator.cpp
index 2d5bbf52e..111809758 100644
--- a/headergenerator.cpp
+++ b/headergenerator.cpp
@@ -471,7 +471,10 @@ void HeaderGenerator::writeTypeConverterImpl(QTextStream& s, const TypeEntry* ty
isFirst = false;
else
s << endl << INDENT << " || ";
- s << cpythonCheckFunction(ctor->arguments().first()->type());
+ if (ctor->isConversionOperator())
+ s << cpythonCheckFunction(ctor->ownerClass()->typeEntry());
+ else
+ s << cpythonCheckFunction(ctor->arguments().first()->type());
s << "(pyobj)";
}
s << ';' << endl;
@@ -496,18 +499,28 @@ void HeaderGenerator::writeTypeConverterImpl(QTextStream& s, const TypeEntry* ty
Indentation indent(INDENT);
s << INDENT;
-
- const AbstractMetaType* argType = ctor->arguments().first()->type();
if (firstImplicitIf)
firstImplicitIf = false;
else
s << "else ";
- s << "if (" << cpythonCheckFunction(argType) << "(pyobj))" << endl;
+
+ QString typeCheck;
+ QString toCppConv;
+ QTextStream tcc(&toCppConv);
+ if (ctor->isConversionOperator()) {
+ const AbstractMetaClass* metaClass = ctor->ownerClass();
+ typeCheck = cpythonCheckFunction(metaClass->typeEntry());
+ writeToCppConversion(tcc, metaClass, "pyobj");
+ } else {
+ const AbstractMetaType* argType = ctor->arguments().first()->type();
+ typeCheck = cpythonCheckFunction(argType);
+ writeToCppConversion(tcc, argType, 0, "pyobj");
+ }
+
+ s << "if (" << typeCheck << "(pyobj))" << endl;
{
Indentation indent(INDENT);
- s << INDENT << "return " << type->name() << '(';
- writeToCppConversion(s, argType, 0, "pyobj");
- s << ");" << endl;
+ s << INDENT << "return " << type->name() << '(' << toCppConv << ");" << endl;
}
}
s << INDENT << '}' << endl;