Make sure QML type "real" always maps to C++ type "double"
authorKent Hansen <kent.hansen@nokia.com>
Mon, 5 Mar 2012 10:54:01 +0000 (11:54 +0100)
committerQt by Nokia <qt-info@nokia.com>
Wed, 7 Mar 2012 11:10:27 +0000 (12:10 +0100)
commitaed15e776277410fb43ce2d2a9a8924359a58653
tree426dfd76e6db21616beaea518b13224844ac9e51
parent3f3850e954aac35b916c01546c69783183824b35
Make sure QML type "real" always maps to C++ type "double"

The type "real" was documented to be a single-precision float, but
that's incorrect. It's always been double.

However, signal parameters of type "real" would be mapped to the C++
type "qreal", which can be either float or double depending on the
platform.

Since JavaScript floating point numbers have double precision, QML
should use the same, to avoid potential loss of precision.

With this change, "real" behaves the same as the QML "double" type
(which already guaranteed double precision). Even though it's
redundant, "double" is kept to preserve compatibility.

Added tests for the "double" type to the QML meta-object autotest,
and a test for the "real" type that ensures there's no loss of
precision.

Change-Id: I1a77f1fd45082ff670684a935e17d1a46ea75d84
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
doc/src/qml/basictypes.qdoc
src/qml/qml/qqmlscript.cpp
tests/auto/qml/qqmlecmascript/data/realTypePrecision.qml [new file with mode: 0644]
tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
tests/auto/qml/qqmlmetaobject/data/property.double.qml [new file with mode: 0644]
tests/auto/qml/qqmlmetaobject/data/property.real.qml
tests/auto/qml/qqmlmetaobject/data/signal.6.qml [new file with mode: 0644]
tests/auto/qml/qqmlmetaobject/tst_qqmlmetaobject.cpp