summaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4object_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-06-22 22:59:43 +0200
committerLars Knoll <lars.knoll@qt.io>2018-07-02 19:29:29 +0000
commitdb695c5b1d07275f208446dad178b1131b20bb0a (patch)
treec2175a065f4918d31249ca1ce46a2811733b8093 /src/qml/jsruntime/qv4object_p.h
parent98263a01373f5b225d64da216537165ae27d7ff1 (diff)
Unify the get and getIndexed vtable functions of QV4::Object
This finalizes the refactoring of Object's vtable API. Also added the receiver argument to the method as required by the ES7 spec. Change-Id: I36f9989211c47458788fe9f7e929862bcfe7b845 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4object_p.h')
-rw-r--r--src/qml/jsruntime/qv4object_p.h23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h
index 88d07ef3f1..00ec790692 100644
--- a/src/qml/jsruntime/qv4object_p.h
+++ b/src/qml/jsruntime/qv4object_p.h
@@ -169,8 +169,7 @@ struct ObjectVTable
VTable vTable;
ReturnedValue (*call)(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
ReturnedValue (*callAsConstructor)(const FunctionObject *, const Value *argv, int argc);
- ReturnedValue (*get)(const Managed *, StringOrSymbol *name, bool *hasProperty);
- ReturnedValue (*getIndexed)(const Managed *, uint index, bool *hasProperty);
+ ReturnedValue (*get)(const Managed *, Identifier id, const Value *receiver, bool *hasProperty);
bool (*put)(Managed *, Identifier id, const Value &value, Value *receiver);
bool (*deleteProperty)(Managed *m, Identifier id);
bool (*hasProperty)(const Managed *m, Identifier id);
@@ -192,7 +191,6 @@ const QV4::ObjectVTable classname::static_vtbl = \
call, \
callAsConstructor, \
get, \
- getIndexed, \
put, \
deleteProperty, \
hasProperty, \
@@ -373,10 +371,14 @@ public:
return false;
}
- inline ReturnedValue get(StringOrSymbol *name, bool *hasProperty = nullptr) const
- { return vtable()->get(this, name, hasProperty); }
- inline ReturnedValue getIndexed(uint idx, bool *hasProperty = nullptr) const
- { return vtable()->getIndexed(this, idx, hasProperty); }
+ inline ReturnedValue get(StringOrSymbol *name, bool *hasProperty = nullptr, const Value *receiver = nullptr) const
+ { if (!receiver) receiver = this; return vtable()->get(this, name->toPropertyKey(), receiver, hasProperty); }
+ inline ReturnedValue get(uint idx, bool *hasProperty = nullptr, const Value *receiver = nullptr) const
+ { if (!receiver) receiver = this; return vtable()->get(this, Identifier::fromArrayIndex(idx), receiver, hasProperty); }
+ QT_DEPRECATED inline ReturnedValue getIndexed(uint idx, bool *hasProperty = nullptr) const
+ { return get(idx, hasProperty); }
+ inline ReturnedValue get(Identifier id, const Value *receiver = nullptr, bool *hasProperty = nullptr) const
+ { if (!receiver) receiver = this; return vtable()->get(this, id, receiver, hasProperty); }
// use the set variants instead, to customize throw behavior
inline bool put(StringOrSymbol *name, const Value &v, Value *receiver = nullptr)
@@ -437,8 +439,7 @@ public:
protected:
static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc);
static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc);
- static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty);
- static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty);
+ static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver,bool *hasProperty);
static bool put(Managed *m, Identifier id, const Value &value, Value *receiver);
static bool deleteProperty(Managed *m, Identifier id);
static bool hasProperty(const Managed *m, Identifier id);
@@ -454,8 +455,8 @@ protected:
private:
bool internalDefineOwnProperty(ExecutionEngine *engine, uint index, StringOrSymbol *member, const Property *p, PropertyAttributes attrs);
- ReturnedValue internalGet(StringOrSymbol *name, bool *hasProperty) const;
- ReturnedValue internalGetIndexed(uint index, bool *hasProperty) const;
+ ReturnedValue internalGet(StringOrSymbol *name, const Value *receiver, bool *hasProperty) const;
+ ReturnedValue internalGetIndexed(uint index, const Value *receiver, bool *hasProperty) const;
bool internalPut(Identifier id, const Value &value, Value *receiver);
bool internalDeleteProperty(Identifier id);