diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-08-08 19:15:54 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:17:09 -0300 |
commit | f02e7bd726a5560542e7c078b925f289a9d6a75d (patch) | |
tree | 4a9ab69f582474090658aa2a0f95dead1f7bb8b3 /generator/cppgenerator.cpp | |
parent | 05e7ecede5304ee56a805c7b5a10d3df11cf8952 (diff) |
Method buildAbstractMetaTypeFromString now uses a cache for the types it builds.
Diffstat (limited to 'generator/cppgenerator.cpp')
-rw-r--r-- | generator/cppgenerator.cpp | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp index 4446ff2a7..f0c19e3ff 100644 --- a/generator/cppgenerator.cpp +++ b/generator/cppgenerator.cpp @@ -1471,15 +1471,12 @@ void CppGenerator::writeInvalidPyObjectCheck(QTextStream& s, const QString& pyOb void CppGenerator::writeTypeCheck(QTextStream& s, const AbstractMetaType* argType, QString argumentName, bool isNumber, QString customType, bool rejectNull) { - AbstractMetaType* metaType; - std::auto_ptr<AbstractMetaType> metaType_autoptr; QString customCheck; if (!customType.isEmpty()) { + AbstractMetaType* metaType; customCheck = guessCPythonCheckFunction(customType, &metaType); - if (metaType) { - metaType_autoptr = std::auto_ptr<AbstractMetaType>(metaType); + if (metaType) argType = metaType; - } } QString typeCheck; @@ -1532,10 +1529,8 @@ void CppGenerator::writeArgumentConversion(QTextStream& s, writePythonToCppTypeConversion(s, argType, pyArgName, argName, context, defaultValue); } -const AbstractMetaType* CppGenerator::getArgumentType(const AbstractMetaFunction* func, int argPos, bool* newType) +const AbstractMetaType* CppGenerator::getArgumentType(const AbstractMetaFunction* func, int argPos) { - *newType = false; - if (argPos < 0 || argPos > func->arguments().size()) { ReportHandler::warning(QString("Argument index for function '%1' out of range.").arg(func->signature())); return 0; @@ -1543,12 +1538,10 @@ const AbstractMetaType* CppGenerator::getArgumentType(const AbstractMetaFunction const AbstractMetaType* argType = 0; QString typeReplaced = func->typeReplaced(argPos); - if (typeReplaced.isEmpty()) { + if (typeReplaced.isEmpty()) argType = (argPos == 0) ? func->type() : func->arguments().at(argPos-1)->type(); - } else { + else argType = buildAbstractMetaTypeFromString(typeReplaced); - *newType = (bool)argType; - } if (!argType && !m_knownPythonTypes.contains(typeReplaced)) { ReportHandler::warning(QString("Unknown type '%1' used as argument type replacement "\ "in function '%2', the generated code may be broken.") @@ -1862,16 +1855,11 @@ void CppGenerator::writeSingleFunctionCall(QTextStream& s, const OverloadData& o if (!func->conversionRule(TypeSystem::NativeCode, argIdx + 1).isEmpty()) continue; - bool newType; - const AbstractMetaType* argType = getArgumentType(func, argIdx + 1, &newType); + const AbstractMetaType* argType = getArgumentType(func, argIdx + 1); if (!argType) continue; - std::auto_ptr<const AbstractMetaType> argType_autoptr; - if (newType) - argType_autoptr = std::auto_ptr<const AbstractMetaType>(argType); - int argPos = argIdx - removedArgs; QString argName = QString(CPP_ARG"%1").arg(argPos); QString pyArgName = usePyArgs ? QString(PYTHON_ARGS "[%1]").arg(argPos) : PYTHON_ARG; @@ -2996,16 +2984,11 @@ void CppGenerator::writeRichCompareFunction(QTextStream& s, const AbstractMetaCl if (func->isStatic()) continue; - bool newType; - const AbstractMetaType* argType = getArgumentType(func, 1, &newType); + const AbstractMetaType* argType = getArgumentType(func, 1); if (!argType) continue; - std::auto_ptr<const AbstractMetaType> argType_autoptr; - if (newType) - argType_autoptr = std::auto_ptr<const AbstractMetaType>(argType); - bool numberType = alternativeNumericTypes == 1 || ShibokenGenerator::isPyInt(argType); if (!first) { |