aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4value_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-04-03 15:23:07 +0200
committerLars Knoll <lars.knoll@qt.io>2018-05-02 14:18:36 +0000
commitbab5e5adf578fb37402ff03f4bd5e9ed3ce4c2d2 (patch)
tree1bbc320c5594faf5d2156385088c12222b9542b8 /src/qml/jsruntime/qv4value_p.h
parenta6da23bb5f6004e13d22838c7db1246169874930 (diff)
Partial Symbol support
Added basic infrastructure to create symbols and convert them back to strings. In addition, storing and retrieving of symbol based properties in Objects works. Change-Id: I185f7aa46e7afa19db5a801102142892e03b7bf1 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4value_p.h')
-rw-r--r--src/qml/jsruntime/qv4value_p.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index 85c345f645..b89011a9a0 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -365,7 +365,17 @@ public:
QML_NEARLY_ALWAYS_INLINE String *stringValue() const {
if (!isString())
return nullptr;
- return reinterpret_cast<String*>(const_cast<Value *>(this));
+ return reinterpret_cast<String *>(const_cast<Value *>(this));
+ }
+ QML_NEARLY_ALWAYS_INLINE StringOrSymbol *stringOrSymbolValue() const {
+ if (!isStringOrSymbol())
+ return nullptr;
+ return reinterpret_cast<StringOrSymbol *>(const_cast<Value *>(this));
+ }
+ QML_NEARLY_ALWAYS_INLINE Symbol *symbolValue() const {
+ if (!isSymbol())
+ return nullptr;
+ return reinterpret_cast<Symbol *>(const_cast<Value *>(this));
}
QML_NEARLY_ALWAYS_INLINE Object *objectValue() const {
if (!isObject())
@@ -411,6 +421,11 @@ public:
return reinterpret_cast<Heap::String *>(m());
return toString(e, *this);
}
+ Heap::StringOrSymbol *toStringOrSymbol(ExecutionEngine *e) const {
+ if (isStringOrSymbol())
+ return reinterpret_cast<Heap::StringOrSymbol *>(m());
+ return reinterpret_cast<Heap::StringOrSymbol *>(toString(e, *this));
+ }
static Heap::String *toString(ExecutionEngine *e, Value val);
Heap::Object *toObject(ExecutionEngine *e) const {
if (isObject())
@@ -518,7 +533,9 @@ bool Value::isSymbol() const
Heap::Base *b = heapObject();
return b && b->internalClass->vtable->isStringOrSymbol && !b->internalClass->vtable->isString;
}
+
inline bool Value::isObject() const
+
{
Heap::Base *b = heapObject();
return b && b->internalClass->vtable->isObject;