diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-10-23 13:27:33 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-10-23 13:27:33 -0300 |
commit | 869d3372b55f542d32f6f6220566507e7d8a2cb8 (patch) | |
tree | 6ae0e59217d33ca48aeeaf0b5bef6f05c2a2c4a9 | |
parent | 70ba8b2ea9fcad7a6f88938c1675b45dec320a31 (diff) |
Revert "modified the generator do deal with all value type conversions in"
This reverts commit 4213b0176ae9af91221dbe38e1dead10638ff054.
-rw-r--r-- | cppgenerator.cpp | 21 | ||||
-rw-r--r-- | headergenerator.cpp | 18 | ||||
-rw-r--r-- | shibokengenerator.cpp | 33 |
3 files changed, 20 insertions, 52 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp index 596a10951..254f39ed1 100644 --- a/cppgenerator.cpp +++ b/cppgenerator.cpp @@ -362,8 +362,6 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFu if (!returnKeyword.isEmpty()) { s << INDENT << returnKeyword; - if (func->type()->isValue()) - s << '*'; writeToCppConversion(s, func->type(), func->implementingClass(), "method_result"); s << ';' << endl; } @@ -818,8 +816,6 @@ void CppGenerator::writeOverloadedMethodDecisor(QTextStream& s, OverloadData* pa pyArgName = QString("pyargs[%1]").arg(i); const AbstractMetaType* type = func->arguments()[i + removed]->type(); s << INDENT << translateTypeForWrapperMethod(type, func->implementingClass()); - if (type->isValue()) - s << "* "; s << ' ' << argName << " = "; writeToCppConversion(s, type, func->implementingClass(), pyArgName); s << ';' << endl; @@ -880,8 +876,7 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f userArgs << arg->defaultValueExpression(); } else { QString argName = QString("cpp_arg%1").arg(arg->argumentIndex() - removed); - if ((arg->type()->typeEntry()->isObject() && arg->type()->isReference()) - || arg->type()->isValue()){ + if (arg->type()->typeEntry()->isObject() && arg->type()->isReference()) { argName.prepend("(*"); argName.append(')'); } @@ -927,11 +922,8 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f s << "::" << func->minimalSignature(); s << "\" with the modifications provided on typesystem file" << endl; } else if (func->isOperatorOverload()) { - QString star; - if (!func->arguments().isEmpty() && func->arguments().at(0)->type()->isValue()) - star = QString('*'); - QString firstArg(star + "cpp_arg0"); - QString secondArg(firstArg); + QString firstArg("cpp_arg0"); + QString secondArg("cpp_arg0"); QString selfArg = QString("(*%1)").arg(cpythonWrapperCPtr(func->ownerClass())); if (ShibokenGenerator::isReverseOperator(func) || func->isUnaryOperator()) @@ -957,13 +949,10 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f isCtor = true; s << "cptr = new " << wrapperName(func->ownerClass()); s << '('; - if (func->isCopyConstructor() && maxArgs == 1) { - if (func->arguments().at(0)->type()->isValue()) - s << '*'; + if (func->isCopyConstructor() && maxArgs == 1) s << "cpp_arg0"; - } else { + else s << userArgs.join(", "); - } s << ')'; } else { s << INDENT; diff --git a/headergenerator.cpp b/headergenerator.cpp index 6fcf1faf2..4bdad7b16 100644 --- a/headergenerator.cpp +++ b/headergenerator.cpp @@ -192,10 +192,7 @@ void HeaderGenerator::writeTypeConverterDecl(QTextStream& s, const TypeEntry* ty if (type->isObject()) s << "const "; s << cppName << " cppobj);" << endl; - s << INDENT << "static " << cppName; - if (type->isValue()) - s << '*'; - s << " toCpp(PyObject* pyobj);" << endl; + s << INDENT << "static " << cppName << " toCpp(PyObject* pyobj);" << endl; s << "};" << endl; } @@ -246,10 +243,7 @@ void HeaderGenerator::writeTypeConverterImpl(QTextStream& s, const TypeEntry* ty s << INDENT << "return pyobj;" << endl; s << '}' << endl << endl; - s << "inline " << cppName; - if (type->isValue()) - s << '*'; - s << " Converter< " << cppName << " >::toCpp(PyObject* pyobj)" << endl; + s << "inline " << cppName << " Converter< " << cppName << " >::toCpp(PyObject* pyobj)" << endl; s << '{' << endl; if (type->isValue()) { @@ -273,10 +267,8 @@ void HeaderGenerator::writeTypeConverterImpl(QTextStream& s, const TypeEntry* ty s << "if (" << cpythonCheckFunction(argType) << "(pyobj))" << endl; { Indentation indent(INDENT); - s << INDENT << "return "; - if (type->isValue()) - s << "new "; - s << cppName << "(Converter< " << argType->cppSignature() << " >::toCpp(pyobj));" << endl; + s << INDENT << "return " << cppName; + s << "(Converter< " << argType->cppSignature() << " >::toCpp(pyobj));" << endl; } } } @@ -285,6 +277,8 @@ void HeaderGenerator::writeTypeConverterImpl(QTextStream& s, const TypeEntry* ty if (type->isEnum() || type->isFlags()) { s << '(' << type->qualifiedCppName() << ") ((Shiboken::PyEnumObject*)pyobj)->ob_ival"; } else { + if (type->isValue()) + s << '*'; s << "((" << cppName; if (type->isValue()) s << '*'; diff --git a/shibokengenerator.cpp b/shibokengenerator.cpp index e5ca98900..721cbe877 100644 --- a/shibokengenerator.cpp +++ b/shibokengenerator.cpp @@ -223,6 +223,11 @@ QString ShibokenGenerator::getFunctionReturnType(const AbstractMetaFunction* fun return func->ownerClass()->qualifiedCppName() + '*'; return translateTypeForWrapperMethod(func->type(), func->implementingClass()); + + //TODO: check these lines + //QString modifiedReturnType = QString(func->typeReplaced(0)); + //return modifiedReturnType.isNull() ? + //translateType(func->type(), func->implementingClass()) : modifiedReturnType; } QString ShibokenGenerator::writeBaseConversion(QTextStream& s, const AbstractMetaType* type, @@ -270,24 +275,9 @@ void ShibokenGenerator::writeToPythonConversion(QTextStream& s, const AbstractMe void ShibokenGenerator::writeToCppConversion(QTextStream& s, const AbstractMetaType* type, const AbstractMetaClass* context, QString argumentName) { - QString typeName; - if (type->isPrimitive()) { - const PrimitiveTypeEntry* ptype = (const PrimitiveTypeEntry*) type->typeEntry(); - if (ptype->basicAliasedTypeEntry()) - ptype = ptype->basicAliasedTypeEntry(); - typeName = ptype->name(); - } else { - typeName = translateTypeForWrapperMethod(type, context); - } - - if (type->isObject() || type->isQObject()) { - if (typeName.startsWith("const ")) - typeName.remove(0, 6); - if (!typeName.endsWith('*')) - typeName.append('*'); - } - - s << "Shiboken::Converter< " << typeName << " >::"; + if (type->isValuePointer()) + s << '&'; + writeBaseConversion(s, type, context); s << "toCpp(" << argumentName << ')'; } @@ -831,10 +821,7 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s, for (int i = 0; i < func->arguments().size(); i++) { if (func->argumentRemoved(i+1)) removed++; - QString star; - if (func->arguments().at(i)->type()->isValue()) - star = QString('*'); - code.replace("%" + QString::number(i+1), QString(star + "cpp_arg%1").arg(i - removed)); + code.replace("%" + QString::number(i+1), QString("cpp_arg%1").arg(i - removed)); } // replace template variables for not removed arguments @@ -845,8 +832,6 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s, continue; if (i > 0) argumentNames += ", "; - if (arg->type()->isValue()) - argumentNames += '*'; argumentNames += QString("cpp_arg%1").arg(i++); } code.replace("%ARGUMENT_NAMES", argumentNames); |