Bug 1885489 - Part 5: Add SnapshotIterator::readInt32(). r=iain
[gecko.git] / js / src / builtin / WeakMapObject.h
blobe487b750cbb9f88c5ec37ceefe6405444745a76c
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/. */
7 #ifndef builtin_WeakMapObject_h
8 #define builtin_WeakMapObject_h
10 #include "gc/WeakMap.h"
11 #include "vm/NativeObject.h"
13 namespace js {
15 // Abstract base class for WeakMapObject and WeakSetObject.
16 class WeakCollectionObject : public NativeObject {
17 public:
18 enum { DataSlot, SlotCount };
20 ValueValueWeakMap* getMap() {
21 return maybePtrFromReservedSlot<ValueValueWeakMap>(DataSlot);
24 size_t sizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf);
26 [[nodiscard]] static bool nondeterministicGetKeys(
27 JSContext* cx, Handle<WeakCollectionObject*> obj,
28 MutableHandleObject ret);
30 protected:
31 static const JSClassOps classOps_;
34 class WeakMapObject : public WeakCollectionObject {
35 public:
36 static const JSClass class_;
37 static const JSClass protoClass_;
39 private:
40 static const ClassSpec classSpec_;
42 static const JSPropertySpec properties[];
43 static const JSFunctionSpec methods[];
45 [[nodiscard]] static bool construct(JSContext* cx, unsigned argc, Value* vp);
47 [[nodiscard]] static MOZ_ALWAYS_INLINE bool is(HandleValue v);
49 [[nodiscard]] static MOZ_ALWAYS_INLINE bool has_impl(JSContext* cx,
50 const CallArgs& args);
51 [[nodiscard]] static bool has(JSContext* cx, unsigned argc, Value* vp);
52 [[nodiscard]] static MOZ_ALWAYS_INLINE bool get_impl(JSContext* cx,
53 const CallArgs& args);
54 [[nodiscard]] static bool get(JSContext* cx, unsigned argc, Value* vp);
55 [[nodiscard]] static MOZ_ALWAYS_INLINE bool delete_impl(JSContext* cx,
56 const CallArgs& args);
57 [[nodiscard]] static bool delete_(JSContext* cx, unsigned argc, Value* vp);
58 [[nodiscard]] static MOZ_ALWAYS_INLINE bool set_impl(JSContext* cx,
59 const CallArgs& args);
60 [[nodiscard]] static bool set(JSContext* cx, unsigned argc, Value* vp);
63 } // namespace js
65 #endif /* builtin_WeakMapObject_h */