Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
* vim: set ts=8 sts=2 et sw=2 tw=80:
3
* This Source Code Form is subject to the terms of the Mozilla Public
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef builtin_WeakMapObject_h
8
#define builtin_WeakMapObject_h
9
10
#include "gc/WeakMap.h"
11
#include "vm/NativeObject.h"
12
13
namespace js {
14
15
class GlobalObject;
16
17
// Abstract base class for WeakMapObject and WeakSetObject.
18
class WeakCollectionObject : public NativeObject {
19
public:
20
ObjectValueWeakMap* getMap() {
21
return static_cast<ObjectValueWeakMap*>(getPrivate());
22
}
23
24
size_t sizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) {
25
ObjectValueWeakMap* map = getMap();
26
return map ? map->sizeOfIncludingThis(aMallocSizeOf) : 0;
27
}
28
29
static MOZ_MUST_USE bool nondeterministicGetKeys(
30
JSContext* cx, Handle<WeakCollectionObject*> obj,
31
MutableHandleObject ret);
32
33
protected:
34
static const JSClassOps classOps_;
35
};
36
37
class WeakMapObject : public WeakCollectionObject {
38
public:
39
static const JSClass class_;
40
static const JSClass protoClass_;
41
42
private:
43
static const ClassSpec classSpec_;
44
45
static const JSPropertySpec properties[];
46
static const JSFunctionSpec methods[];
47
48
static MOZ_MUST_USE bool construct(JSContext* cx, unsigned argc, Value* vp);
49
50
static MOZ_MUST_USE MOZ_ALWAYS_INLINE bool is(HandleValue v);
51
52
static MOZ_MUST_USE MOZ_ALWAYS_INLINE bool has_impl(JSContext* cx,
53
const CallArgs& args);
54
static MOZ_MUST_USE bool has(JSContext* cx, unsigned argc, Value* vp);
55
static MOZ_MUST_USE MOZ_ALWAYS_INLINE bool get_impl(JSContext* cx,
56
const CallArgs& args);
57
static MOZ_MUST_USE bool get(JSContext* cx, unsigned argc, Value* vp);
58
static MOZ_MUST_USE MOZ_ALWAYS_INLINE bool delete_impl(JSContext* cx,
59
const CallArgs& args);
60
static MOZ_MUST_USE bool delete_(JSContext* cx, unsigned argc, Value* vp);
61
static MOZ_MUST_USE MOZ_ALWAYS_INLINE bool set_impl(JSContext* cx,
62
const CallArgs& args);
63
static MOZ_MUST_USE bool set(JSContext* cx, unsigned argc, Value* vp);
64
};
65
66
} // namespace js
67
68
#endif /* builtin_WeakMapObject_h */