From e5d7ccddfee37eb10e3c594f96bdddb49864c340 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Thu, 11 Aug 2011 09:50:01 -0300 Subject: CppGenerator's writeCopyFunction method now uses cpythonToPythonConversionFunction. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new overload of cpythonToPythonConversionFunction, that is. Reviewed by Luciano Wolf Reviewed by Renato Araújo --- generator/cppgenerator.cpp | 12 ++++-------- generator/shibokengenerator.cpp | 17 ++++++++++++++++- 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); -- cgit v1.2.3