diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-08-11 09:50:01 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:17:11 -0300 |
commit | e5d7ccddfee37eb10e3c594f96bdddb49864c340 (patch) | |
tree | 0a403a34910674b17cce820a721b0b92e1a0609d | |
parent | 81307ef0b1255143e2eb560bc80d80d9dda796ed (diff) |
CppGenerator's writeCopyFunction method now uses cpythonToPythonConversionFunction.
The new overload of cpythonToPythonConversionFunction, that is.
Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
Reviewed by Renato Araújo <renato.filho@openbossa.org>
-rw-r--r-- | generator/cppgenerator.cpp | 12 | ||||
-rw-r--r-- | generator/shibokengenerator.cpp | 17 | ||||
-rw-r--r-- | generator/shibokengenerator.h | 2 |
3 files changed, 22 insertions, 9 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp index 07c94efbc..8dd54cc79 100644 --- a/generator/cppgenerator.cpp +++ b/generator/cppgenerator.cpp @@ -2833,18 +2833,14 @@ void CppGenerator::writeTpClearFunction(QTextStream& s, const AbstractMetaClass* s << '}' << endl; } -void CppGenerator::writeCopyFunction(QTextStream& s, const AbstractMetaClass *metaClass) +void CppGenerator::writeCopyFunction(QTextStream& s, const AbstractMetaClass* metaClass) { QString className = cpythonTypeName(metaClass).replace(QRegExp("_Type$"), ""); s << "static PyObject* " << className << "___copy__(PyObject* " PYTHON_SELF_VAR ")" << endl; s << "{" << endl; - - writeCppSelfDefinition(s, metaClass); - - s << INDENT << "PyObject* " << PYTHON_RETURN_VAR << " = "; - s << "Shiboken::Converter< ::" << metaClass->qualifiedCppName() << " >::toPython(*"; - s << CPP_SELF_VAR << ");" << endl; - s << endl; + writeCppSelfDefinition(s, metaClass, false, true); + s << INDENT << "PyObject* " << PYTHON_RETURN_VAR << " = " << cpythonToPythonConversionFunction(metaClass); + s << "(" CPP_SELF_VAR ");" << endl; writeFunctionReturnErrorCheckSection(s); s << INDENT << "return " PYTHON_RETURN_VAR ";" << endl; s << "}" << endl; diff --git a/generator/shibokengenerator.cpp b/generator/shibokengenerator.cpp index 2d317c650..0be94bc6f 100644 --- a/generator/shibokengenerator.cpp +++ b/generator/shibokengenerator.cpp @@ -547,7 +547,7 @@ void ShibokenGenerator::writeBaseConversion(QTextStream& s, const TypeEntry* typ if (metaEnum && metaEnum->isProtected()) typeName = protectedEnumSurrogateName(metaEnum); } else { - typeName = type->qualifiedCppName().trimmed(); + typeName = getFullTypeName(type).trimmed(); if (isObjectType(type)) typeName.append('*'); } @@ -563,6 +563,8 @@ void ShibokenGenerator::writeBaseConversion(QTextStream& s, const AbstractMetaTy if (ptype->basicAliasedTypeEntry()) ptype = ptype->basicAliasedTypeEntry(); typeName = ptype->name(); + if (!ptype->isCppPrimitive()) + typeName.prepend("::"); } else { if (!isCString(type)) { options |= Generator::ExcludeConst; @@ -1018,6 +1020,19 @@ QString ShibokenGenerator::cpythonToPythonConversionFunction(const AbstractMetaT return QString("%1toPython").arg(base); } +QString ShibokenGenerator::cpythonToPythonConversionFunction(const AbstractMetaClass* metaClass) +{ + return cpythonToPythonConversionFunction(metaClass->typeEntry()); +} + +QString ShibokenGenerator::cpythonToPythonConversionFunction(const TypeEntry* type) +{ + QString base; + QTextStream b(&base); + writeBaseConversion(b, type); + return QString("%1toPython").arg(base); +} + QString ShibokenGenerator::argumentString(const AbstractMetaFunction *func, const AbstractMetaArgument *argument, Options options) const diff --git a/generator/shibokengenerator.h b/generator/shibokengenerator.h index 226450231..ca1a273a0 100644 --- a/generator/shibokengenerator.h +++ b/generator/shibokengenerator.h @@ -338,6 +338,8 @@ public: QString cpythonToCppConversionFunction(const AbstractMetaClass* metaClass); QString cpythonToCppConversionFunction(const AbstractMetaType* type, const AbstractMetaClass* context = 0); QString cpythonToPythonConversionFunction(const AbstractMetaType* type, const AbstractMetaClass* context = 0); + QString cpythonToPythonConversionFunction(const AbstractMetaClass* metaClass); + QString cpythonToPythonConversionFunction(const TypeEntry* type); QString cpythonFunctionName(const AbstractMetaFunction* func); QString cpythonMethodDefinitionName(const AbstractMetaFunction* func); |