aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-02-10 17:51:40 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:13:54 -0300
commit3f76e757d035c0bfc1985ce29aa69c02616d3178 (patch)
treea2728361d7246810e8c5e1e4c0ca2f4dc4af8691
parent8319d6e8cb0d448997730b5cb08b48dc7d946250 (diff)
The heuristics for return value parenting should be overridden by user changes.
Whatever the user puts in the type system XML will take precedence over the generator heuristics. Reviewed by Hugo Parente <hugo.lima@openbossa.org> Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r--generator/cppgenerator.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 3ff11744d..bc623e63b 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -3844,22 +3844,22 @@ void CppGenerator::finishGeneration()
}
}
+static ArgumentOwner getArgumentOwner(const AbstractMetaFunction* func, int argIndex)
+{
+ ArgumentOwner argOwner = func->argumentOwner(func->ownerClass(), argIndex);
+ if (argOwner.index == ArgumentOwner::InvalidIndex)
+ argOwner = func->argumentOwner(func->declaringClass(), argIndex);
+ return argOwner;
+}
+
bool CppGenerator::writeParentChildManagement(QTextStream& s, const AbstractMetaFunction* func, int argIndex, bool useHeuristicPolicy)
{
const int numArgs = func->arguments().count();
- const AbstractMetaClass* cppClass = func->ownerClass();
- const AbstractMetaClass* dClass = func->declaringClass();
bool ctorHeuristicEnabled = func->isConstructor() && useCtorHeuristic() && useHeuristicPolicy;
- QString parentVariable;
- QString childVariable;
- ArgumentOwner argOwner = func->argumentOwner(cppClass, argIndex);
-
- if (argOwner.index == -2) //invalid
- argOwner = func->argumentOwner(dClass, argIndex);
-
bool usePyArgs = pythonFunctionWrapperUsesListOfArguments(OverloadData(getFunctionGroups(func->implementingClass())[func->name()], this));
+ ArgumentOwner argOwner = getArgumentOwner(func, argIndex);
ArgumentOwner::Action action = argOwner.action;
int parentIndex = argOwner.index;
int childIndex = argIndex;
@@ -3872,6 +3872,8 @@ bool CppGenerator::writeParentChildManagement(QTextStream& s, const AbstractMeta
}
}
+ QString parentVariable;
+ QString childVariable;
if (action != ArgumentOwner::Invalid) {
if (!usePyArgs && argIndex > 1)
ReportHandler::warning("Argument index for parent tag out of bounds: "+func->signature());
@@ -3926,6 +3928,9 @@ void CppGenerator::writeReturnValueHeuristics(QTextStream& s, const AbstractMeta
return;
}
+ ArgumentOwner argOwner = getArgumentOwner(func, ArgumentOwner::ReturnIndex);
+ if (argOwner.action == ArgumentOwner::Invalid || argOwner.index != ArgumentOwner::ThisIndex)
+
if (type->isQObject() || type->isObject() || type->isValuePointer())
s << INDENT << "Shiboken::Object::setParent(" << self << ", " PYTHON_RETURN_VAR ");" << endl;
}