aboutsummaryrefslogtreecommitdiffstats
path: root/generators
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2009-08-28 13:15:11 -0300
committerRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2009-08-28 13:15:11 -0300
commit06b1408262174c6bbfc4113f2c68fa692f19def3 (patch)
tree0f1e77daeffde89f29c2f050ba87d5dc0ed70537 /generators
parent9375ce7bd1f622de9a0eef9e6ea111f37581a01b (diff)
Fixed default return policy for functions which return references.
Diffstat (limited to 'generators')
-rw-r--r--generators/boostpython/cppgenerator.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/generators/boostpython/cppgenerator.cpp b/generators/boostpython/cppgenerator.cpp
index a1becff17..c621aac41 100644
--- a/generators/boostpython/cppgenerator.cpp
+++ b/generators/boostpython/cppgenerator.cpp
@@ -246,31 +246,35 @@ QString CppGenerator::verifyDefaultReturnPolicy(const AbstractMetaFunction *cppF
AbstractMetaType *type = cppFunction->type();
//If return type replaced, the return policy need be set manually.
- if (!type || !cppFunction->typeReplaced(0).isEmpty() || type->isNativePointer())
+ if (!type || !cppFunction->typeReplaced(0).isEmpty()) {
return QString();
+ }
QString returnPolicy;
- if (type->isConstant() && type->isReference()) {
- returnPolicy = "python::return_value_policy<python::copy_const_reference";
+ if (type->isReference()) {
+ QString detail;
+ if (type->isConstant()) {
+ detail = "copy_const_reference";
+ } else {
+ detail = "copy_non_const_reference";
+ }
+
+ returnPolicy = "python::return_value_policy<python::" + detail;
if (!callPolicy.isEmpty())
returnPolicy += ", " + callPolicy;
returnPolicy += " >()";
- } else if (type->isReference() || type->isQObject() || type->isObject() || type->isValuePointer()) {
+ } else if (type->isQObject() || type->isObject() || type->isValuePointer()) {
bool cppOwnership = type->isConstant();
if (cppFunction->isStatic() || cppOwnership) {
returnPolicy = QString("python::return_value_policy<PySide::return_ptr_object<")
+ (cppOwnership ? "true" : "false") + QString("> >()");
- } else if (type->isQObject() || type->isObject()) {
+ } else {
returnPolicy = QString("PySide::return_object<1, 0, %1, %2 %3 %4 >()")
.arg(getArgumentType(cppFunction->ownerClass(), cppFunction, -1))
.arg(getArgumentType(cppFunction->ownerClass(), cppFunction, 0))
.arg(callPolicy.isEmpty() ? "" : ",")
.arg(callPolicy);
- } else {
- returnPolicy = QString("python::return_internal_reference<%1 %2>()")
- .arg(callPolicy.isEmpty() ? "" : ",")
- .arg(callPolicy);
}
} else if (!callPolicy.isEmpty()) {
returnPolicy = callPolicy + "()";