diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-09-23 11:15:52 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-09-27 08:33:52 +0000 |
commit | 1804fea8893c355dbd585e373cb9644387410a92 (patch) | |
tree | a1e0a43a74f9137b7bc1c9da0332e6c2e3984cde /src/qml/jsruntime/qv4internalclass_p.h | |
parent | 7fb4fc2ac7b56d3f60ceb8ae1175bd4596436cc7 (diff) |
Refactor InternalClass::find()
Specialize find() into several methods for different purposes.
Prepares for further cleanups and being able to split up
getter and setter for accessor properties.
Change-Id: Id4ec5509ac1a1361e2170bbfc2347b89b520c782
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4internalclass_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4internalclass_p.h | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4internalclass_p.h b/src/qml/jsruntime/qv4internalclass_p.h index 58aca42d6e..82ace19d30 100644 --- a/src/qml/jsruntime/qv4internalclass_p.h +++ b/src/qml/jsruntime/qv4internalclass_p.h @@ -352,8 +352,35 @@ struct InternalClass : Base { Q_REQUIRED_RESULT InternalClass *changeMember(PropertyKey identifier, PropertyAttributes data, uint *index = nullptr); static void changeMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, uint *index = nullptr); static void removeMember(QV4::Object *object, PropertyKey identifier); + PropertyHash::Entry *findEntry(const PropertyKey id) + { + Q_ASSERT(id.isStringOrSymbol()); + + PropertyHash::Entry *e = propertyTable.lookup(id); + if (e && e->index < size) + return e; + + return nullptr; + } + + struct IndexAndAttribute { + uint index; + PropertyAttributes attrs; + bool isValid() const { return index != UINT_MAX; } + }; + + IndexAndAttribute find(const PropertyKey id) + { + Q_ASSERT(id.isStringOrSymbol()); - uint find(const PropertyKey id) + PropertyHash::Entry *e = propertyTable.lookup(id); + if (e && e->index < size) + return { e->index, propertyData.at(e->index) }; + + return { UINT_MAX, Attr_Invalid }; + } + + uint indexOfValueOrGetter(const PropertyKey id) { Q_ASSERT(id.isStringOrSymbol()); @@ -364,6 +391,17 @@ struct InternalClass : Base { return UINT_MAX; } + bool verifyIndex(const PropertyKey id, uint index) + { + Q_ASSERT(id.isStringOrSymbol()); + + PropertyHash::Entry *e = propertyTable.lookup(id); + if (e && e->index < size) + return e->index == index; + + return false; + } + Q_REQUIRED_RESULT InternalClass *sealed(); Q_REQUIRED_RESULT InternalClass *frozen(); Q_REQUIRED_RESULT InternalClass *propertiesFrozen() const; |