aboutsummaryrefslogtreecommitdiffstats
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
parent50a75628a9d5ca8dc516c466d97ca0d0cd4004ca (diff)
Implemented support to conversion-rule tag.
Reviwed by: Marcelo Lira <marcelo.lira@openbossa.org>
-rw-r--r--generators/boostpython/boostpythongenerator.cpp14
-rw-r--r--generators/boostpython/cppgenerator.cpp32
-rw-r--r--generators/boostpython/hppgenerator.cpp2
3 files changed, 38 insertions, 10 deletions
diff --git a/generators/boostpython/boostpythongenerator.cpp b/generators/boostpython/boostpythongenerator.cpp
index 9c64a510b..d266d395a 100644
--- a/generators/boostpython/boostpythongenerator.cpp
+++ b/generators/boostpython/boostpythongenerator.cpp
@@ -51,7 +51,7 @@ QString BoostPythonGenerator::argumentString(const AbstractMetaFunction *cppFunc
QString modifiedType = cppFunction->typeReplaced(cppArgument->argumentIndex() + 1);
QString arg;
- if (modifiedType.isEmpty())
+ if ((options & OriginalTypeDescription) || modifiedType.isEmpty())
arg = translateType(cppArgument->type(), cppFunction->implementingClass(), options);
else
arg = modifiedType.replace('$', '.');
@@ -196,13 +196,21 @@ void BoostPythonGenerator::writeArgumentNames(QTextStream &s,
if (argCount > 0)
s << ", ";
+ QString argName = arguments.at(j)->argumentName();
+ if (((options & Generator::VirtualCall) == 0) &&
+ (!func->conversionRule(TypeSystem::NativeCode, arguments.at(j)->argumentIndex() + 1).isEmpty() ||
+ !func->conversionRule(TypeSystem::TargetLangCode, arguments.at(j)->argumentIndex() + 1).isEmpty())
+ )
+ argName += "_out";
+
if ((options & Generator::BoxedPrimitive) &&
!arguments.at(j)->type()->isReference() &&
(arguments.at(j)->type()->isQObject() ||
arguments.at(j)->type()->isObject())) {
- s << "PySide::ptr( " << arguments.at(j)->argumentName() << ")";
+
+ s << "PySide::ptr( " << argName << ")";
} else {
- s << arguments.at(j)->argumentName();
+ s << argName;
}
argCount++;
}
diff --git a/generators/boostpython/cppgenerator.cpp b/generators/boostpython/cppgenerator.cpp
index e3c3b75b8..f144e297a 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),
diff --git a/generators/boostpython/hppgenerator.cpp b/generators/boostpython/hppgenerator.cpp
index 2bdfae454..334cee505 100644
--- a/generators/boostpython/hppgenerator.cpp
+++ b/generators/boostpython/hppgenerator.cpp
@@ -170,7 +170,7 @@ void HppGenerator::writeFunction(QTextStream &s, const AbstractMetaFunction* fun
if (func->isVirtual() && !func->isAbstract() && !func->isConstructor()
&& !func->ownerClass()->hasPrivateDestructor()
&& func->implementingClass() == func->ownerClass()) {
- s << INDENT << "static " << signatureForDefaultVirtualMethod(func, "", "_default", Generator::SkipName) << ';' << endl;
+ s << INDENT << "static " << signatureForDefaultVirtualMethod(func, "", "_default", Generator::Options( Generator::SkipName | Generator::SkipRemovedArguments) ) << ';' << endl;
}
if (func->isConstructor()) {