diff options
author | renatofilho <renato.filho@openbossa.org> | 2010-09-29 11:02:40 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:07:19 -0300 |
commit | 822bd79f87ad237b9e24b53f9048308200f06859 (patch) | |
tree | 17cb35ed6e334396725edb75c18ce750c85b7986 /generator | |
parent | 1f1fc9f504285c916785dd9daec557e24b332135 (diff) |
Implement support to object list on ownserhsip functions.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'generator')
-rw-r--r-- | generator/cppgenerator.cpp | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp index cd7f14eca..8e805ea7d 100644 --- a/generator/cppgenerator.cpp +++ b/generator/cppgenerator.cpp @@ -29,6 +29,7 @@ #include <QtCore/QTextStream> #include <QtCore/QDebug> +// utiliy functions inline CodeSnipList getConversionRule(TypeSystem::Language lang, const AbstractMetaFunction *function) { CodeSnipList list; @@ -50,7 +51,6 @@ inline CodeSnipList getConversionRule(TypeSystem::Language lang, const AbstractM return list; } -// utiliy functions inline CodeSnipList getReturnConversionRule(TypeSystem::Language lang, const AbstractMetaFunction *function, const QString& inputName, @@ -73,6 +73,17 @@ inline CodeSnipList getReturnConversionRule(TypeSystem::Language lang, return list; } +inline AbstractMetaType* getTypeWithoutContainer(AbstractMetaType* arg) +{ + if (arg && arg->typeEntry()->isContainer()) { + AbstractMetaTypeList lst = arg->instantiations(); + // only support containers with 1 type + if (lst.size() == 1) + return lst[0]; + } + return arg; +} + CppGenerator::CppGenerator() : m_currentErrorCode(0) { @@ -1778,20 +1789,25 @@ QString CppGenerator::argumentNameFromIndex(const AbstractMetaFunction* func, in pyArgName = QString("self"); *wrappedClass = func->implementingClass(); } else if (argIndex == 0) { - if (func->type()) { + AbstractMetaType* returnType = getTypeWithoutContainer(func->type()); + if (returnType) { pyArgName = PYTHON_RETURN_VAR; - *wrappedClass = classes().findClass(func->type()->typeEntry()->name()); + *wrappedClass = classes().findClass(returnType->typeEntry()->name()); } else { ReportHandler::warning("Invalid Argument index on function modification: " + func->name()); } } else { int realIndex = argIndex - 1 - OverloadData::numberOfRemovedArguments(func, argIndex - 1); - *wrappedClass = classes().findClass(func->arguments().at(realIndex)->type()->typeEntry()->name()); - if (argIndex == 1 - && OverloadData::isSingleArgument(getFunctionGroups(func->implementingClass())[func->name()])) - pyArgName = QString("arg"); - else - pyArgName = QString("pyargs[%1]").arg(argIndex - 1); + AbstractMetaType* argType = getTypeWithoutContainer(func->arguments().at(realIndex)->type()); + + if (argType) { + *wrappedClass = classes().findClass(argType->typeEntry()->name()); + if (argIndex == 1 + && OverloadData::isSingleArgument(getFunctionGroups(func->implementingClass())[func->name()])) + pyArgName = QString("arg"); + else + pyArgName = QString("pyargs[%1]").arg(argIndex - 1); + } } return pyArgName; } |