diff options
author | Hugo Lima <hugo.lima@openbossa.org> | 2010-03-05 15:43:14 -0300 |
---|---|---|
committer | Hugo Lima <hugo.lima@openbossa.org> | 2010-03-18 19:45:07 -0300 |
commit | dc8dcf70f06304105d9a4e6467d98a266dbfe78f (patch) | |
tree | b78dba3e4b94ba3528cdcc7dd7f2e01224b684bf /shibokengenerator.cpp | |
parent | f52951862649d104abf664da5d456b0e0bb987fd (diff) |
Changed the semantic of Converter<T>::isConvertible method.
The new semantic is:
Returns true when the type can be converted to T OR the type is T.
The old semantic was:
Returns true when the type can be converted to T and false if the
type is T, however int and float converters did not follow this
rule, because they used PyNumber_Check on their isConvertible implementation.
Diffstat (limited to 'shibokengenerator.cpp')
-rw-r--r-- | shibokengenerator.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/shibokengenerator.cpp b/shibokengenerator.cpp index 653e8ddb6..4fd54f746 100644 --- a/shibokengenerator.cpp +++ b/shibokengenerator.cpp @@ -590,6 +590,7 @@ bool ShibokenGenerator::shouldDereferenceAbstractMetaTypePointer(const AbstractM 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" : "")); @@ -597,9 +598,18 @@ static QString checkFunctionName(QString baseName, bool genericNumberType, bool QString ShibokenGenerator::cpythonCheckFunction(const AbstractMetaType* metaType, bool genericNumberType, bool checkExact) { - if (metaType->typeEntry()->isCustom()) + QString baseName = cpythonBaseName(metaType); + if (metaType->typeEntry()->isCustom()) { return guessCPythonCheckFunction(metaType->typeEntry()->name()); - return checkFunctionName(cpythonBaseName(metaType), genericNumberType, checkExact); + } else if (isNumber(baseName)) { + return genericNumberType ? "PyNumber_Check" : baseName+"_Check"; + } else { + QString str; + QTextStream s(&str); + writeBaseConversion(s, metaType, 0); + s.flush(); + return str + "isConvertible"; + } } QString ShibokenGenerator::cpythonCheckFunction(const TypeEntry* type, bool genericNumberType, bool checkExact) |