diff options
Diffstat (limited to 'JavaScriptCore/qt/api/qscriptvalue_p.h')
-rw-r--r-- | JavaScriptCore/qt/api/qscriptvalue_p.h | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/JavaScriptCore/qt/api/qscriptvalue_p.h b/JavaScriptCore/qt/api/qscriptvalue_p.h index dea2298..8db43a7 100644 --- a/JavaScriptCore/qt/api/qscriptvalue_p.h +++ b/JavaScriptCore/qt/api/qscriptvalue_p.h @@ -525,26 +525,37 @@ bool QScriptValuePrivate::toBool() const qsreal QScriptValuePrivate::toInteger() const { - // TODO it is not true implementation! - return toNumber(); + qsreal result = toNumber(); + if (qIsNaN(result)) + return 0; + if (qIsInf(result)) + return result; + return (result > 0) ? qFloor(result) : -1 * qFloor(-result); } qint32 QScriptValuePrivate::toInt32() const { - // TODO it is not true implementation! - return toNumber(); + qsreal result = toInteger(); + // Orginaly it should look like that (result == 0 || qIsInf(result) || qIsNaN(result)), but + // some of these operation are invoked in toInteger subcall. + if (qIsInf(result)) + return 0; + return result; } quint32 QScriptValuePrivate::toUInt32() const { - // TODO it is not true implementation! - return toNumber(); + qsreal result = toInteger(); + // Orginaly it should look like that (result == 0 || qIsInf(result) || qIsNaN(result)), but + // some of these operation are invoked in toInteger subcall. + if (qIsInf(result)) + return 0; + return result; } quint16 QScriptValuePrivate::toUInt16() const { - // TODO it is not true implementation! - return toNumber(); + return toInt32(); } |