aboutsummaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-08-18 17:00:32 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:17:12 -0300
commite5fb8ee50dbcb0eab68260efe95c985ddc979e00 (patch)
tree73d8cb3b7b5a7e6a048dfbd9c058249bad19e860 /generator
parentb7169ca7fe92c5874076ff47f9b4ec7954acc480 (diff)
Fixed generator to consider conversion rules for the return type of wrapper methods.
Tests were added. Reviewed by Hugo Parente <hugo.lima@openbossa.org> Reviewed by Lauro Moura <lauro.neto@openbossa.org>
Diffstat (limited to 'generator')
-rw-r--r--generator/cppgenerator.cpp14
-rw-r--r--generator/cppgenerator.h4
2 files changed, 10 insertions, 8 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 8dd54cc79..6ca6c4775 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -814,7 +814,7 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun
if (!func->conversionRule(TypeSystem::NativeCode, 0).isEmpty()) {
// Has conversion rule.
- writeConversionRule(s, func, CPP_RETURN_VAR);
+ writeConversionRule(s, func, TypeSystem::NativeCode, CPP_RETURN_VAR);
} else if (!injectedCodeHasReturnValueAttribution(func, TypeSystem::NativeCode)) {
writePythonToCppTypeConversion(s, func->type(), PYTHON_RETURN_VAR, CPP_RETURN_VAR, func->implementingClass());
}
@@ -1617,12 +1617,12 @@ void CppGenerator::writeConversionRule(QTextStream& s, const AbstractMetaFunctio
writeCodeSnips(s, snippets, CodeSnip::Beginning, TypeSystem::TargetLangCode, func);
}
-void CppGenerator::writeConversionRule(QTextStream& s, const AbstractMetaFunction* func, const QString& outputVar)
+void CppGenerator::writeConversionRule(QTextStream& s, const AbstractMetaFunction* func, TypeSystem::Language language, const QString& outputVar)
{
CodeSnipList snippets;
- QString rule = func->conversionRule(TypeSystem::NativeCode, 0);
- addConversionRuleCodeSnippet(snippets, rule, TypeSystem::NativeCode, TypeSystem::NativeCode, outputVar);
- writeCodeSnips(s, snippets, CodeSnip::Any, TypeSystem::NativeCode, func);
+ QString rule = func->conversionRule(language, 0);
+ addConversionRuleCodeSnippet(snippets, rule, language, language, outputVar);
+ writeCodeSnips(s, snippets, CodeSnip::Any, language, func);
}
void CppGenerator::writeNoneReturn(QTextStream& s, const AbstractMetaFunction* func, bool thereIsReturnValue)
@@ -2217,7 +2217,9 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
s << methodCall << ';' << endl;
s << INDENT << END_ALLOW_THREADS << endl;
- if (!isCtor && !func->isInplaceOperator() && func->type()
+ if (!func->conversionRule(TypeSystem::TargetLangCode, 0).isEmpty()) {
+ writeConversionRule(s, func, TypeSystem::TargetLangCode, PYTHON_RETURN_VAR);
+ } else if (!isCtor && !func->isInplaceOperator() && func->type()
&& !injectedCodeHasReturnValueAttribution(func, TypeSystem::TargetLangCode)) {
s << INDENT << PYTHON_RETURN_VAR " = ";
writeToPythonConversion(s, func->type(), func->ownerClass(), CPP_RETURN_VAR);
diff --git a/generator/cppgenerator.h b/generator/cppgenerator.h
index 18eb01be0..82e89dece 100644
--- a/generator/cppgenerator.h
+++ b/generator/cppgenerator.h
@@ -113,8 +113,8 @@ private:
/// Writes the conversion rule for arguments of regular and virtual methods.
void writeConversionRule(QTextStream& s, const AbstractMetaFunction* func, TypeSystem::Language language);
- /// Writes the conversion rule for the return value of a virtual method.
- void writeConversionRule(QTextStream& s, const AbstractMetaFunction* func, const QString& outputVar);
+ /// Writes the conversion rule for the return value of a method.
+ void writeConversionRule(QTextStream& s, const AbstractMetaFunction* func, TypeSystem::Language language, const QString& outputVar);
/**
* Set the Python method wrapper return value variable to Py_None if