summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-02-10 17:51:40 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2011-02-11 14:40:31 -0300
commit0374b254dfd955686856d2d13ce5d6b051224130 (patch)
treed02ddb6d632377b6fa8c29923708b09b71b38b28
parentb1b32623845a15e6c20ac229c3f9fef7c7b2124a (diff)
downloadshiboken-0374b254dfd955686856d2d13ce5d6b051224130.tar.gz
shiboken-0374b254dfd955686856d2d13ce5d6b051224130.tar.xz
shiboken-0374b254dfd955686856d2d13ce5d6b051224130.zip
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 201d52e3..65ec116d 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -3846,22 +3846,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;
@@ -3874,6 +3874,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());
@@ -3928,6 +3930,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;
}