diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-19 13:28:26 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-06-25 07:36:48 +0000 |
commit | 1596112e146b28541bcee412ed159cdea7e692d0 (patch) | |
tree | 29e858041496256c9c9c700fca4fb7220d78d46e /src/qml/jsruntime/qv4object_p.h | |
parent | 3823e9b94f849f8344b81250fac708ac2eaccd16 (diff) |
Add Proxy support for prototype handling
Cleanup get/setPrototypeOf and fix some smaller incompatibilities
in the default implementation for Object.
Add the methods to the vtable and reimplement them according to
spec for ProxyObjects.
Clean up the Object.prototype.get/setPrototypeOf/__proto__ methods
and fix a smaller bug in the Reflect API for those methods.
Change-Id: I6e438753332ec4db963d6cdcf86f340ff212777a
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.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index b55e8f25e2..6ec7452ca6 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -179,6 +179,8 @@ struct ObjectVTable PropertyAttributes (*getOwnProperty)(Managed *m, Identifier id, Property *p); bool (*isExtensible)(const Managed *); bool (*preventExtensions)(Managed *); + Heap::Object *(*getPrototypeOf)(const Managed *); + bool (*setPrototypeOf)(Managed *, const Object *); qint64 (*getLength)(const Managed *m); void (*advanceIterator)(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); ReturnedValue (*instanceOf)(const Object *typeObject, const Value &var); @@ -200,6 +202,8 @@ const QV4::ObjectVTable classname::static_vtbl = \ getOwnProperty, \ isExtensible, \ preventExtensions, \ + getPrototypeOf, \ + setPrototypeOf, \ getLength, \ advanceIterator, \ instanceOf \ @@ -244,8 +248,6 @@ struct Q_QML_EXPORT Object: Managed { void setProperty(ExecutionEngine *engine, uint index, Heap::Base *b) const { d()->setProperty(engine, index, b); } const ObjectVTable *vtable() const { return reinterpret_cast<const ObjectVTable *>(d()->vtable()); } - Heap::Object *prototype() const { return d()->prototype(); } - bool setPrototype(Object *proto); PropertyAttributes getOwnProperty(Identifier id, Property *p = nullptr) { return vtable()->getOwnProperty(this, id, p); @@ -307,6 +309,9 @@ struct Q_QML_EXPORT Object: Managed { bool isExtensible() const { return vtable()->isExtensible(this); } bool preventExtensions() { return vtable()->preventExtensions(this); } + Heap::Object *getPrototypeOf() const { return vtable()->getPrototypeOf(this); } + bool setPrototypeOf(const Object *p) { return vtable()->setPrototypeOf(this, p); } + void setPrototypeUnchecked(const Object *p); // Array handling @@ -366,7 +371,7 @@ public: Scope scope(engine()); ScopedObject p(scope, this); - while ((p = p->prototype())) + while ((p = p->getPrototypeOf())) if (p->arrayData()) return true; @@ -445,6 +450,8 @@ protected: static PropertyAttributes getOwnProperty(Managed *m, Identifier id, Property *p); static bool isExtensible(const Managed *m); static bool preventExtensions(Managed *); + static Heap::Object *getPrototypeOf(const Managed *); + static bool setPrototypeOf(Managed *, const Object *); static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); static qint64 getLength(const Managed *m); static ReturnedValue instanceOf(const Object *typeObject, const Value &var); |