From 3f76e757d035c0bfc1985ce29aa69c02616d3178 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Thu, 10 Feb 2011 17:51:40 -0300 Subject: 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 Reviewed by Luciano Wolf --- generator/cppgenerator.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'generator/cppgenerator.cpp') 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; } -- cgit v1.2.3