diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-02-11 12:37:20 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-02-11 12:43:00 -0300 |
commit | 973de3370cc5c97531faf5cf57f5cb58d951bda0 (patch) | |
tree | c87599478c8c4f3d9d6aa167d577d36bafdde3ca | |
parent | 03c865ebe0222f09099344dc3d08d1c54349080c (diff) |
Fixes problem with CppGenerator::writeTypeCheck due to a bad rebasing.
Reviewed by Renato Araújo <renato.filho@openbossa.org>
-rw-r--r-- | cppgenerator.cpp | 26 | ||||
-rw-r--r-- | cppgenerator.h | 2 |
2 files changed, 12 insertions, 16 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp index 49fb4f2ed..5f85149a4 100644 --- a/cppgenerator.cpp +++ b/cppgenerator.cpp @@ -1011,7 +1011,7 @@ void CppGenerator::writeInvalidCppObjectCheck(QTextStream& s, QString pyArgName, } } -void CppGenerator::writeTypeCheck(QTextStream& s, const AbstractMetaType* argType, QString argumentName, QString customCheck) +void CppGenerator::writeTypeCheck(QTextStream& s, const AbstractMetaType* argType, QString argumentName, bool isNumber, QString customType) { bool isPairContainer = argType->isContainer() && ((ContainerTypeEntry*)argType->typeEntry())->type() == ContainerTypeEntry::PairContainer; @@ -1025,14 +1025,14 @@ void CppGenerator::writeTypeCheck(QTextStream& s, const AbstractMetaType* argTyp if (isPairContainer) s << '('; - if (!customCheck.isEmpty()) - s << customCheck; + if (!customType.isEmpty()) + s << guessCPythonCheckFunction(customType); else if (argType->typeEntry()->isFlags()) s << cpythonCheckFunction(((FlagsTypeEntry*) argType->typeEntry())->originator(), true); else if (argType->isEnum()) s << cpythonCheckFunction(argType, false, true); - else // Should be treated as a generic number in the case the type is one - s << cpythonCheckFunction(argType, true); + else + s << cpythonCheckFunction(argType, isNumber); s << '(' << argumentName << ')'; @@ -1047,24 +1047,20 @@ void CppGenerator::writeTypeCheck(QTextStream& s, const OverloadData* overloadDa { const AbstractMetaType* argType = overloadData->argType(); - int alternativeNumericTypes = 0; + QSet<const TypeEntry*> numericTypes; foreach (OverloadData* pd, overloadData->overloadDataOnPosition(overloadData->argPos())) { if (!pd->argType()->isPrimitive()) continue; if (ShibokenGenerator::isNumber(pd->argType()->typeEntry())) - alternativeNumericTypes++; + numericTypes << pd->argType()->typeEntry(); } // This condition trusts that the OverloadData object will arrange for // PyInt type to come after the more precise numeric types (e.g. float) - bool numberType = alternativeNumericTypes == 1 || ShibokenGenerator::isPyInt(argType); - - QString customCheck; - if (overloadData->hasArgumentTypeReplace()) - customCheck = guessCPythonCheckFunction(overloadData->argumentTypeReplaced()); - else if (!numberType) - customCheck = cpythonCheckFunction(argType, numberType); - writeTypeCheck(s, argType, argumentName, customCheck); + bool numberType = numericTypes.count() == 1 || ShibokenGenerator::isPyInt(argType); + + QString customType = (overloadData->hasArgumentTypeReplace() ? overloadData->argumentTypeReplaced() : ""); + writeTypeCheck(s, argType, argumentName, numberType, customType); } void CppGenerator::writeArgumentConversion(QTextStream& s, diff --git a/cppgenerator.h b/cppgenerator.h index 7652719a9..7ed0ee5e5 100644 --- a/cppgenerator.h +++ b/cppgenerator.h @@ -65,7 +65,7 @@ private: * \param type the TypeEntry passed when the validity check must confirm the type of the Python wrapper to be checked */ void writeInvalidCppObjectCheck(QTextStream& s, QString pyArgName = "self", const TypeEntry* type = 0); - void writeTypeCheck(QTextStream& s, const AbstractMetaType* argType, QString argumentName, QString customCheck = ""); + void writeTypeCheck(QTextStream& s, const AbstractMetaType* argType, QString argumentName, bool isNumber = false, QString customType = ""); void writeTypeCheck(QTextStream& s, const OverloadData* overloadData, QString argumentName); void writeTypeConverterImpl(QTextStream& s, const TypeEntry* type); |