diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-23 20:08:40 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-07-02 19:29:32 +0000 |
commit | 56602df447c5f16257874f2e97b078dcf76f2467 (patch) | |
tree | 901c76eb6262dad80e6ab94af810c645355cb6d5 /src/qml/jsruntime/qv4identifier_p.h | |
parent | db695c5b1d07275f208446dad178b1131b20bb0a (diff) |
Cleanups in the Identifier API
Rename from/asHeapObject to from/asStringOrSymbol and fix
the signature.
Add a isStringOrSymbol() method and redefine isValid() to also
include array indices.
Change-Id: Ic8272bfbe84d15421e2ebe86ddda7fdaa8db4f3e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4identifier_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4identifier_p.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4identifier_p.h b/src/qml/jsruntime/qv4identifier_p.h index 58eddcc4bb..bf6d5cb7f6 100644 --- a/src/qml/jsruntime/qv4identifier_p.h +++ b/src/qml/jsruntime/qv4identifier_p.h @@ -67,12 +67,13 @@ struct Identifier static Identifier invalid() { return Identifier{ 0 }; } static Identifier fromArrayIndex(uint idx) { return Identifier{ (quint64(idx) << 1) | 1 }; } - bool isValid() const { return id && !(id & 1); } + bool isStringOrSymbol() const { return id && !(id & 1); } uint asArrayIndex() const { return (id & 1) ? (id >> 1) : std::numeric_limits<uint>::max(); } uint isArrayIndex() const { return (id & 1); } - static Identifier fromHeapObject(Heap::Base *b) { return Identifier{ reinterpret_cast<quintptr>(b) }; } - Heap::Base *asHeapObject() const { return (id & 1) ? nullptr : reinterpret_cast<Heap::Base *>(id); } + static Identifier fromStringOrSymbol(Heap::StringOrSymbol *b) { return Identifier{ reinterpret_cast<quintptr>(b) }; } + Heap::StringOrSymbol *asStringOrSymbol() const { return (id & 1) ? nullptr : reinterpret_cast<Heap::StringOrSymbol *>(id); } + bool isValid() const { return id != 0; } bool isString() const; bool isSymbol() const; |