summaryrefslogtreecommitdiffstats
path: root/generators/boostpython/cppgenerator.cpp
diff options
context:
space:
mode:
authorrenato araujo <renato@renato-mac.osmtc.indt.org.br>2009-10-21 10:47:15 -0300
committerrenato araujo <renato@renato-mac.osmtc.indt.org.br>2009-10-21 15:24:06 -0300
commit17a82a3123c8f0d21aa4e32e295f729d862e65f4 (patch)
tree14377df30f7cbd799bad158dbf8231cab40832ad /generators/boostpython/cppgenerator.cpp
parent50a75628a9d5ca8dc516c466d97ca0d0cd4004ca (diff)
downloadgeneratorrunner-17a82a3123c8f0d21aa4e32e295f729d862e65f4.tar.gz
generatorrunner-17a82a3123c8f0d21aa4e32e295f729d862e65f4.tar.xz
generatorrunner-17a82a3123c8f0d21aa4e32e295f729d862e65f4.zip
Implemented support to conversion-rule tag.
Reviwed by: Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'generators/boostpython/cppgenerator.cpp')
-rw-r--r--generators/boostpython/cppgenerator.cpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/generators/boostpython/cppgenerator.cpp b/generators/boostpython/cppgenerator.cpp
index e3c3b75..f144e29 100644
--- a/generators/boostpython/cppgenerator.cpp
+++ b/generators/boostpython/cppgenerator.cpp
@@ -35,6 +35,16 @@
static Indentor INDENT;
// utiliy functions
+inline void writeConversionRule(QTextStream &s, TypeSystem::Language lang, const AbstractMetaFunction *function, const AbstractMetaArgument *arg)
+{
+ QString convRule = function->conversionRule(lang, arg->argumentIndex() + 1);
+ if (!convRule.isEmpty()) {
+ convRule.replace("%in", arg->argumentName());
+ convRule.replace("%out", arg->argumentName() + "_out");
+ s << convRule;
+ }
+}
+
inline QString getMethodPointerString(const AbstractMetaFunction* func)
{
QString className;
@@ -685,8 +695,12 @@ void CppGenerator::writeVirtualMethodImplHead(QTextStream& s, const AbstractMeta
if (func->type())
s << "python::object __result = ";
- s << "method(";
- writeArgumentNames(s, func, BoxedPrimitive);
+ foreach(AbstractMetaArgument *arg, func->arguments()) {
+ writeConversionRule(s, TypeSystem::TargetLangCode, func, arg);
+ }
+
+ s << INDENT << "method(";
+ writeArgumentNames(s, func, Generator::Options(Generator::BoxedPrimitive | Generator::SkipRemovedArguments));
s << ");" << endl;
QString typeName = getFunctionReturnType(func);
@@ -741,7 +755,7 @@ void CppGenerator::writeVirtualMethodImpl(QTextStream& s, const AbstractMetaFunc
QString prefix = getWrapperName(func->ownerClass()) + "::";
s << functionSignature(func, prefix, "",
- Options(Generator::OriginalTypeDescription) | Generator::SkipDefaultValues)
+ Options(Generator::OriginalTypeDescription) | Generator::SkipDefaultValues | Generator::VirtualCall)
<< endl << "{" << endl;
writeVirtualMethodImplHead(s, func);
@@ -782,7 +796,7 @@ void CppGenerator::writeVirtualMethodImplFoot(QTextStream& s, const AbstractMeta
s << INDENT << "py_allow_threads allow_threads;" << endl;
s << INDENT << returnKeyword << func->implementingClass()->qualifiedCppName() << "::";
- writeFunctionCall(s, func);
+ writeFunctionCall(s, func, Generator::VirtualCall);
s << ';' << endl;
}
s << INDENT << '}' << endl;
@@ -792,7 +806,9 @@ void CppGenerator::writeVirtualDefaultFunction(QTextStream &s, const AbstractMet
{
Indentation indentation(INDENT);
QString returnKeyword = func->type() ? QLatin1String("return ") : QString();
- QString defaultMethodSignature = signatureForDefaultVirtualMethod(func, getWrapperName(func->ownerClass()) + "::", "_default", Generator::SkipDefaultValues);
+ Generator::Options opt = Generator::Options(Generator::SkipDefaultValues);
+ QString defaultMethodSignature = signatureForDefaultVirtualMethod(func, getWrapperName(func->ownerClass()) + "::", "_default",
+ opt | Generator::SkipRemovedArguments | Generator::VirtualCall);
s << defaultMethodSignature << endl << '{' << endl;
if (func->allowThread())
@@ -807,9 +823,13 @@ void CppGenerator::writeVirtualDefaultFunction(QTextStream &s, const AbstractMet
}
}
+ foreach(AbstractMetaArgument *arg, func->arguments()) {
+ writeConversionRule(s, TypeSystem::NativeCode, func, arg);
+ }
+
if (!hasVirtualEndCode) {
s << INDENT << returnKeyword << "self." << func->implementingClass()->qualifiedCppName() << "::";
- writeFunctionCall(s, func);
+ writeFunctionCall(s, func, opt);
s << ";" << endl;
} else {
writeCodeSnips(s, getCodeSnips(func),