diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-10-22 12:27:33 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-10-22 12:44:08 (GMT) |
commit | dbff78d964d1a034459074f168b505b41bab0c98 (patch) | |
tree | 93ceb643948e36cdc1a0933a3043faea05b44469 /src/script | |
parent | f51e6e91c92810deff7029c8d1edf9b11f03a908 (diff) | |
download | Qt-dbff78d964d1a034459074f168b505b41bab0c98.zip Qt-dbff78d964d1a034459074f168b505b41bab0c98.tar.gz Qt-dbff78d964d1a034459074f168b505b41bab0c98.tar.bz2 |
Use the qsreal type instead of double when working with QtScript numbers
The idea is that qsreal can be typedef'ed to float on platforms where it's
appropriate. Since the QScriptValue ctor takes a qsreal, we should not
convert it to a double internally.
Reviewed-by: Olivier Goffart
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/api/qscriptengine.cpp | 2 | ||||
-rw-r--r-- | src/script/api/qscriptengine_p.h | 2 | ||||
-rw-r--r-- | src/script/api/qscriptvalue.cpp | 6 | ||||
-rw-r--r-- | src/script/api/qscriptvalue_p.h | 4 |
4 files changed, 7 insertions, 7 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index c3c8caf..3f2c9b4 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2577,7 +2577,7 @@ QScriptValue QScriptEnginePrivate::create(int type, const void *ptr) #endif break; case QMetaType::Double: - result = QScriptValue(*reinterpret_cast<const double*>(ptr)); + result = QScriptValue(qsreal(*reinterpret_cast<const double*>(ptr))); break; case QMetaType::QString: result = QScriptValue(q_func(), *reinterpret_cast<const QString*>(ptr)); diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index cde116d..3766559 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -451,7 +451,7 @@ inline void QScriptValuePrivate::initFrom(JSC::JSValue value) engine->registerScriptValue(this); } -inline void QScriptValuePrivate::initFrom(double value) +inline void QScriptValuePrivate::initFrom(qsreal value) { type = Number; numberValue = value; diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index b8340a7..26cd314 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -213,7 +213,7 @@ qint32 ToInt32(qsreal n) if (qIsNaN(n) || qIsInf(n) || (n == 0)) return 0; - double sign = (n < 0) ? -1.0 : 1.0; + qsreal sign = (n < 0) ? -1.0 : 1.0; qsreal abs_n = fabs(n); n = ::fmod(sign * ::floor(abs_n), D32); @@ -233,7 +233,7 @@ quint32 ToUint32(qsreal n) if (qIsNaN(n) || qIsInf(n) || (n == 0)) return 0; - double sign = (n < 0) ? -1.0 : 1.0; + qsreal sign = (n < 0) ? -1.0 : 1.0; qsreal abs_n = fabs(n); n = ::fmod(sign * ::floor(abs_n), D32); @@ -251,7 +251,7 @@ quint16 ToUint16(qsreal n) if (qIsNaN(n) || qIsInf(n) || (n == 0)) return 0; - double sign = (n < 0) ? -1.0 : 1.0; + qsreal sign = (n < 0) ? -1.0 : 1.0; qsreal abs_n = fabs(n); n = ::fmod(sign * ::floor(abs_n), D16); diff --git a/src/script/api/qscriptvalue_p.h b/src/script/api/qscriptvalue_p.h index 77b5084..9634515 100644 --- a/src/script/api/qscriptvalue_p.h +++ b/src/script/api/qscriptvalue_p.h @@ -81,7 +81,7 @@ public: inline ~QScriptValuePrivate(); inline void initFrom(JSC::JSValue value); - inline void initFrom(double value); + inline void initFrom(qsreal value); inline void initFrom(const QString &value); inline bool isJSC() const; @@ -124,7 +124,7 @@ public: QScriptEnginePrivate *engine; Type type; JSC::JSValue jscValue; - double numberValue; + qsreal numberValue; QString stringValue; // linked list of engine's script values |