diff options
Diffstat (limited to 'src/qml/jsruntime/qv4value_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4value_p.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 6a6df3eb6d..e4be6b99dd 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -408,6 +408,7 @@ public: } static bool toBooleanImpl(Value val); double toInteger() const; + inline ReturnedValue convertedToNumber() const; inline double toNumber() const; static double toNumberImpl(Value v); double toNumberImpl() const { return toNumberImpl(*this); } @@ -554,6 +555,15 @@ inline double Value::toNumber() const return toNumberImpl(); } +inline ReturnedValue Value::convertedToNumber() const +{ + if (isInteger() || isDouble()) + return asReturnedValue(); + Value v; + v.setDouble(toNumberImpl()); + return v.asReturnedValue(); +} + inline ReturnedValue Heap::Base::asReturnedValue() const { |