aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4value_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-02-14 22:46:41 +0100
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-04-24 15:20:43 +0000
commit0a499043fbaccc0a83ba59f81f64993552d7b13b (patch)
tree805009e85cd5b7b2df39234dd4ad532ed3df1530 /src/qml/jsruntime/qv4value_p.h
parent3e4cf5498b6605b1953cbe1b041bdff10154a0ce (diff)
Get rid of qv4value_inl_p.h and replace it by qv4typedvalue_p.h
This is a cleaner separation and further reduces include dependencies in the definitions of our basic data structured. Change-Id: I18aa86cdea0c0dfbc16075d4d617af97e638811e Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/jsruntime/qv4value_p.h')
-rw-r--r--src/qml/jsruntime/qv4value_p.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index aeaefb3d70..7454cbfff4 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -334,7 +334,9 @@ struct Q_QML_PRIVATE_EXPORT Value
}
inline uint asArrayIndex() const;
+#ifndef V4_BOOTSTRAP
uint asArrayLength(bool *ok) const;
+#endif
ReturnedValue asReturnedValue() const { return val; }
static Value fromReturnedValue(ReturnedValue val) { Value v; v.val = val; return v; }
@@ -389,6 +391,45 @@ inline bool Value::isPrimitive() const
return !isObject();
}
+inline double Value::toNumber() const
+{
+ if (isInteger())
+ return int_32;
+ if (isDouble())
+ return doubleValue();
+ return toNumberImpl();
+}
+
+
+#ifndef V4_BOOTSTRAP
+inline uint Value::asArrayIndex() const
+{
+#if QT_POINTER_SIZE == 8
+ if (!isNumber())
+ return UINT_MAX;
+ if (isInteger())
+ return int_32 >= 0 ? (uint)int_32 : UINT_MAX;
+#else
+ if (isInteger() && int_32 >= 0)
+ return (uint)int_32;
+ if (!isDouble())
+ return UINT_MAX;
+#endif
+ double d = doubleValue();
+ uint idx = (uint)d;
+ if (idx != d)
+ return UINT_MAX;
+ return idx;
+}
+#endif
+
+inline
+ReturnedValue Heap::Base::asReturnedValue() const
+{
+ return Value::fromHeapObject(const_cast<Heap::Base *>(this)).asReturnedValue();
+}
+
+
struct Q_QML_PRIVATE_EXPORT Primitive : public Value
{
@@ -523,6 +564,27 @@ private:
template<typename T>
ReturnedValue value_convert(ExecutionEngine *e, const Value &v);
+inline int Value::toInt32() const
+{
+ if (isInteger())
+ return int_32;
+ double d = isNumber() ? doubleValue() : toNumberImpl();
+
+ const double D32 = 4294967296.0;
+ const double D31 = D32 / 2.0;
+
+ if ((d >= -D31 && d < D31))
+ return static_cast<int>(d);
+
+ return Primitive::toInt32(d);
+}
+
+inline unsigned int Value::toUInt32() const
+{
+ return (unsigned int)toInt32();
+}
+
+
}
QT_END_NAMESPACE