diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-08-26 15:07:50 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-08-28 21:45:45 +0000 |
commit | 464b878b973710077b2b92b1682d6f38c83554dd (patch) | |
tree | 2577a70c9809bebc3776a0e11422badfdd310c90 /src/qml/jsruntime/qv4mapobject_p.h | |
parent | bead103138c0d9dff3c9f927c9c4e2f44ee7db4c (diff) |
Implement support for WeakMap
Change-Id: Id23e80fe5918ba7dc897568123bf3db4d35e9092
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4mapobject_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4mapobject_p.h | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4mapobject_p.h b/src/qml/jsruntime/qv4mapobject_p.h index 6793612bcb..a0fae2a14a 100644 --- a/src/qml/jsruntime/qv4mapobject_p.h +++ b/src/qml/jsruntime/qv4mapobject_p.h @@ -64,7 +64,11 @@ class ESTable; namespace Heap { -struct MapCtor : FunctionObject { +struct WeakMapCtor : FunctionObject { + void init(QV4::ExecutionContext *scope); +}; + +struct MapCtor : WeakMapCtor { void init(QV4::ExecutionContext *scope); }; @@ -72,19 +76,32 @@ struct MapObject : Object { static void markObjects(Heap::Base *that, MarkStack *markStack); void init(); void destroy(); + void removeUnmarkedKeys(); + + MapObject *nextWeakMap; ESTable *esTable; + bool isWeakMap; }; } -struct MapCtor: FunctionObject +struct WeakMapCtor: FunctionObject { - V4_OBJECT2(MapCtor, FunctionObject) + V4_OBJECT2(WeakMapCtor, FunctionObject) + + static ReturnedValue construct(const FunctionObject *f, const Value *argv, int argc, const Value *, bool weakMap); static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); }; +struct MapCtor : WeakMapCtor +{ + V4_OBJECT2(MapCtor, WeakMapCtor) + + static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); +}; + struct MapObject : Object { V4_OBJECT2(MapObject, Object) @@ -92,7 +109,17 @@ struct MapObject : Object V4_NEEDS_DESTROY }; -struct MapPrototype : Object +struct WeakMapPrototype : Object +{ + void init(ExecutionEngine *engine, Object *ctor); + + static ReturnedValue method_delete(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_get(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_has(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); + static ReturnedValue method_set(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); +}; + +struct MapPrototype : WeakMapPrototype { void init(ExecutionEngine *engine, Object *ctor); |