From 7d38f877d69fe44dbe7c36fb15cd477acccb4500 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Wed, 1 Sep 2010 14:40:15 -0300 Subject: Fix bug#316 - "QAbstractItemModel.createIndex is broken" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use SbkNumber_Check instead of PyNumber_Check, because PyNumber_Check returns true for all user types. This commit also disable the generation of _Check macros and replaces all entries with Converter::checkType. Those changes are on the same commit because SbkNumber_Check conflicts with a macro generated by "other" binding which binds a type named "Number". Reviewer: Luciano Wolf Renato Araújo --- shibokengenerator.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'shibokengenerator.cpp') diff --git a/shibokengenerator.cpp b/shibokengenerator.cpp index 0f862f525..b6edd6a31 100644 --- a/shibokengenerator.cpp +++ b/shibokengenerator.cpp @@ -779,21 +779,13 @@ bool ShibokenGenerator::visibilityModifiedToPrivate(const AbstractMetaFunction* return false; } -static QString checkFunctionName(QString baseName, bool genericNumberType, bool checkExact) -{ - // TODO: Remove checkExact argument. - return QString("%1_Check%2") - .arg((genericNumberType && ShibokenGenerator::isNumber(baseName) ? "PyNumber" : baseName)) - .arg((checkExact && !genericNumberType ? "Exact" : "")); -} - QString ShibokenGenerator::cpythonCheckFunction(const AbstractMetaType* metaType, bool genericNumberType) { QString baseName = cpythonBaseName(metaType); if (metaType->typeEntry()->isCustom()) { return guessCPythonCheckFunction(metaType->typeEntry()->name()); } else if (isNumber(baseName)) { - return genericNumberType ? "PyNumber_Check" : baseName+"_Check"; + return genericNumberType ? "SbkNumber_Check" : baseName+"_Check"; } else { QString str; QTextStream s(&str); @@ -803,11 +795,20 @@ QString ShibokenGenerator::cpythonCheckFunction(const AbstractMetaType* metaType } } -QString ShibokenGenerator::cpythonCheckFunction(const TypeEntry* type, bool genericNumberType, bool checkExact) +QString ShibokenGenerator::cpythonCheckFunction(const TypeEntry* type, bool genericNumberType) { - if (type->isCustom()) + QString baseName = cpythonBaseName(type); + if (type->isCustom()) { return guessCPythonCheckFunction(type->name()); - return checkFunctionName(cpythonBaseName(type), genericNumberType, checkExact); + } else if (isNumber(baseName)) { + return genericNumberType ? "SbkNumber_Check" : baseName+"_Check"; + } else { + QString str; + QTextStream s(&str); + writeBaseConversion(s, type); + s.flush(); + return str + "checkType"; + } } QString ShibokenGenerator::guessCPythonCheckFunction(const QString& type) @@ -846,7 +847,7 @@ QString ShibokenGenerator::guessCPythonIsConvertible(const QString& type) QString ShibokenGenerator::cpythonIsConvertibleFunction(const TypeEntry* type, bool genericNumberType, bool checkExact) { if (checkExact) - return cpythonCheckFunction(type, genericNumberType, checkExact); + return cpythonCheckFunction(type, genericNumberType); if (type->isCustom()) return guessCPythonIsConvertible(type->name()); QString baseName; @@ -864,7 +865,7 @@ QString ShibokenGenerator::cpythonIsConvertibleFunction(const AbstractMetaType* if (metaType->typeEntry()->isCustom()) { return guessCPythonCheckFunction(metaType->typeEntry()->name()); } else if (isNumber(baseName)) { - return genericNumberType ? "PyNumber_Check" : baseName+"_Check"; + return genericNumberType ? "SbkNumber_Check" : baseName+"_Check"; } else { QString str; QTextStream s(&str); -- cgit v1.2.3