diff options
author | Renato Araujo Oliveira Filho <renato.filho@openbossa.org> | 2009-08-25 11:00:49 -0300 |
---|---|---|
committer | Renato Araujo Oliveira Filho <renato.filho@openbossa.org> | 2009-08-25 11:00:49 -0300 |
commit | 252ff87489c02fe1b26d650ad855d111042c6490 (patch) | |
tree | 1007b73d82d29ca4674a18518980400d61479cc4 | |
parent | e31d726e5e71c628a30deca6f33dc8a8c133a8c2 (diff) |
Removed use of return_const_prt.
This not work, because some c++ object does not have a copy constructor.
-rw-r--r-- | cppgenerator.cpp | 32 | ||||
-rw-r--r-- | hppgenerator.cpp | 7 |
2 files changed, 14 insertions, 25 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp index 1349ed323..36bd067cf 100644 --- a/cppgenerator.cpp +++ b/cppgenerator.cpp @@ -243,29 +243,28 @@ QString CppGenerator::writeFunctionCast(QTextStream &s, QString CppGenerator::verifyDefaultReturnPolicy(const AbstractMetaFunction *cppFunction, const QString& callPolicy) { + AbstractMetaType *type = cppFunction->type(); + //If return type replaced, the return policy need be set manually. - if (!cppFunction->typeReplaced(0).isEmpty()) + if (!type || !cppFunction->typeReplaced(0).isEmpty()) return QString(); - AbstractMetaType *type = cppFunction->type(); - QString returnPolicy; + //avoid natives types + if (!type->name().startsWith("Q")) + return QString(); - if (type && type->isConstant()) { - returnPolicy = "python::return_value_policy<"; + QString returnPolicy; - 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 (type->isConstant() && type->isReference()) { + returnPolicy = "python::return_value_policy<python::copy_const_reference"; if (!callPolicy.isEmpty()) returnPolicy += ", " + callPolicy; returnPolicy += " >()"; - } else if (type && (type->isReference() || type->isQObject() || type->isObject())) { - if (cppFunction->isStatic()) { - returnPolicy = "python::return_value_policy<PySide::return_ptr_object<false> >()"; + } else if (type->isReference() || type->isQObject() || type->isObject() || type->isNativePointer()) { + 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()) { returnPolicy = QString("PySide::return_object<1, 0, %1, %2 %3 %4 >()") .arg(getArgumentType(cppFunction->ownerClass(), cppFunction, -1)) @@ -912,11 +911,8 @@ void CppGenerator::writeBoostDeclaration(QTextStream& s, const AbstractMetaClass s << INDENT << "python::scope " << wrapperName << "_scope(python_cls);" << endl; if (cppClass->templateBaseClass() && cppClass->templateBaseClass()->typeEntry()->isContainer()) { - //const ContainerTypeEntry *type = static_cast<const ContainerTypeEntry*>(cppClass->templateBaseClass()->typeEntry()); - //if (type->type() == ContainerTypeEntry::ListContainer) { s << endl << INDENT << "//Index suite for QContainer" << endl << INDENT << "python_cls.def(qcontainer_indexing_suite< " << cppClass->qualifiedCppName() << " >());" << endl << endl; - //} } if (isCopyable(cppClass) && !cppClass->isNamespace()) { diff --git a/hppgenerator.cpp b/hppgenerator.cpp index 0fd5cab6a..f6d576d08 100644 --- a/hppgenerator.cpp +++ b/hppgenerator.cpp @@ -83,13 +83,6 @@ void HppGenerator::generateClass(QTextStream &s, const AbstractMetaClass *cppCla CodeSnip::Declaration, TypeSystem::NativeCode); if (cppClass->isPolymorphic() && !cppClass->hasPrivateDestructor()) { - /* - if (!held_type.isEmpty()) { - s << "// held type forward decalration" << endl; - s << "template<typename T> class " << held_type << ';' << endl; - } - */ - // Class s << "class PYSIDE_LOCAL " << wrapperName; if (create_wrapper) { |