diff options
author | Renato Araujo Oliveira Filho <renato.filho@openbossa.org> | 2009-08-24 18:00:38 -0300 |
---|---|---|
committer | Renato Araujo Oliveira Filho <renato.filho@openbossa.org> | 2009-08-24 18:00:38 -0300 |
commit | 29052684cf78ad4bbe0614c5bde0411208336c03 (patch) | |
tree | 4645b423a000a6accae13e1ba03af9da9cc271e0 | |
parent | dc419f4a5767a0a64e4e9a2446668370528c1343 (diff) |
Use of return_const_ptr_object for functions with const pointer return.
-rw-r--r-- | cppgenerator.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp index 9a7fdf5ff..9c19c3ec3 100644 --- a/cppgenerator.cpp +++ b/cppgenerator.cpp @@ -243,19 +243,29 @@ QString CppGenerator::writeFunctionCast(QTextStream &s, QString CppGenerator::verifyDefaultReturnPolicy(const AbstractMetaFunction *cppFunction, const QString& callPolicy) { + //If return type replaced, the return policy need be set manually. + if (!cppFunction->typeReplaced(0).isEmpty()) + return QString(); + AbstractMetaType *type = cppFunction->type(); QString returnPolicy; - if (type && type->isReference() && type->isConstant()) { - returnPolicy = "python::return_value_policy<python::copy_const_reference"; + if (type && type->isConstant()) { + returnPolicy = "python::return_value_policy<"; + + if (type->isQObject() || type->isObject() || type->isNativePointer()) { + returnPolicy += "PySide::return_const_ptr_object"; + } else if (type->isReference()) { + returnPolicy += "python::copy_const_reference"; + } else { + returnPolicy += "python::return_by_value"; + } if (!callPolicy.isEmpty()) returnPolicy += ", " + callPolicy; returnPolicy += " >()"; } else if (type && (type->isReference() || type->isQObject() || type->isObject())) { - bool cppOwnership = type->isConstant(); - if (cppFunction->isStatic() || cppOwnership) { - returnPolicy = "python::return_value_policy<PySide::return_ptr_object< " - + (cppOwnership ? QString("true") : QString("false")) + "> >()"; + if (cppFunction->isStatic()) { + returnPolicy = "python::return_value_policy<PySide::return_ptr_object<false> >()"; } else if (type->isQObject() || type->isObject()) { returnPolicy = QString("PySide::return_object<1, 0, %1, %2 %3 %4 >()") .arg(getArgumentType(cppFunction->ownerClass(), cppFunction, -1)) |