aboutsummaryrefslogtreecommitdiffstats
path: root/shibokengenerator.cpp
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-09-01 14:40:15 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2010-09-01 16:38:59 -0300
commit7d38f877d69fe44dbe7c36fb15cd477acccb4500 (patch)
tree6a5972b53afc68327047785937a3ed53cf67b79d /shibokengenerator.cpp
parent2a5ad3e48e5a148bc87bd6dbb74c695dd352a79a (diff)
Fix bug#316 - "QAbstractItemModel.createIndex is broken"
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<T>::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 <luciano.wolf@openbossa.org> Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'shibokengenerator.cpp')
-rw-r--r--shibokengenerator.cpp29
1 files changed, 15 insertions, 14 deletions
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);