Debian Codegraph @

js/src/builtin/WeakSetObject.h

raw
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_WeakSetObject_h
8 #define builtin_WeakSetObject_h
9
10 #include "builtin/WeakMapObject.h"
11
12 namespace js {
13
14 class WeakSetObject : public WeakCollectionObject {
15 public:
16 static const JSClass class_;
17 static const JSClass protoClass_;
18
19 [[nodiscard]] static bool add(JSContext* cx, unsigned argc, Value* vp);
20 [[nodiscard]] static bool delete_(JSContext* cx, unsigned argc, Value* vp);
21 [[nodiscard]] static bool has(JSContext* cx, unsigned argc, Value* vp);
22
23 private:
24 static const ClassSpec classSpec_;
25
26 static const JSPropertySpec properties[];
27 static const JSFunctionSpec methods[];
28
29 static WeakSetObject* create(JSContext* cx, HandleObject proto = nullptr);
30 [[nodiscard]] static bool construct(JSContext* cx, unsigned argc, Value* vp);
31
32 [[nodiscard]] static bool tryOptimizeCtorWithIterable(
33 JSContext* cx, Handle<WeakSetObject*> obj, Handle<Value> iterableVal,
34 bool* optimized);
35
36 [[nodiscard]] static MOZ_ALWAYS_INLINE bool is(HandleValue v);
37
38 [[nodiscard]] static MOZ_ALWAYS_INLINE bool add_impl(JSContext* cx,
39 const CallArgs& args);
40 [[nodiscard]] static MOZ_ALWAYS_INLINE bool delete_impl(JSContext* cx,
41 const CallArgs& args);
42 [[nodiscard]] static MOZ_ALWAYS_INLINE bool has_impl(JSContext* cx,
43 const CallArgs& args);
44 };
45
46 } // namespace js
47
48 template <>
49 inline bool JSObject::is<js::WeakCollectionObject>() const {
50 return is<js::WeakMapObject>() || is<js::WeakSetObject>();
51 }
52
53 #endif /* builtin_WeakSetObject_h */