From 040a70ea209eb8dcd980c077b625dc0b353db89a Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Wed, 18 Jan 2017 14:12:51 +0100 Subject: jsruntime: Add a vtable hook on Object for instanceof This will hopefully allow us to customize the behavior of QmlTypeWrapper to allow comparison QMetaObject comparison against a QObjectWrapper lhs (i.e. foo instanceof Item will hopefully be possible) Task-number: QTBUG-24799 Change-Id: I780c8b424ec14d6ed6f93eeac46390e2fc920000 Reviewed-by: Lars Knoll --- src/qml/jsruntime/qv4object_p.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/qml/jsruntime/qv4object_p.h') diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index 4a78690f47..6a543ae1a8 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -140,6 +140,7 @@ struct ObjectVTable void (*setLookup)(Managed *m, Lookup *l, const Value &v); uint (*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); }; #define DEFINE_OBJECT_VTABLE_BASE(classname) \ @@ -159,7 +160,8 @@ const QV4::ObjectVTable classname::static_vtbl = \ getLookup, \ setLookup, \ getLength, \ - advanceIterator \ + advanceIterator, \ + instanceOf \ } #define DEFINE_OBJECT_VTABLE(classname) \ @@ -351,6 +353,8 @@ public: void advanceIterator(ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes) { vtable()->advanceIterator(this, it, name, index, p, attributes); } uint getLength() const { return vtable()->getLength(this); } + ReturnedValue instanceOf(const Value &var) const + { return vtable()->instanceOf(this, var); } inline void construct(Scope &scope, CallData *d) const { return vtable()->construct(this, scope, d); } @@ -372,6 +376,7 @@ protected: static void setLookup(Managed *m, Lookup *l, const Value &v); static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); static uint getLength(const Managed *m); + static ReturnedValue instanceOf(const Object *typeObject, const Value &var); private: ReturnedValue internalGet(String *name, bool *hasProperty) const; -- cgit v1.2.3