tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

WeakSetObject.h (2023B)


      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  static bool hasObject(WeakSetObject* weakSet, JSObject* obj);
     24 
     25 private:
     26  static const ClassSpec classSpec_;
     27 
     28  static const JSPropertySpec properties[];
     29  static const JSFunctionSpec methods[];
     30 
     31  static WeakSetObject* create(JSContext* cx, HandleObject proto = nullptr);
     32  [[nodiscard]] static bool construct(JSContext* cx, unsigned argc, Value* vp);
     33 
     34  [[nodiscard]] static bool tryOptimizeCtorWithIterable(
     35      JSContext* cx, Handle<WeakSetObject*> obj, Handle<Value> iterableVal,
     36      bool* optimized);
     37 
     38  [[nodiscard]] static MOZ_ALWAYS_INLINE bool is(HandleValue v);
     39 
     40  [[nodiscard]] static MOZ_ALWAYS_INLINE bool add_impl(JSContext* cx,
     41                                                       const CallArgs& args);
     42  [[nodiscard]] static MOZ_ALWAYS_INLINE bool delete_impl(JSContext* cx,
     43                                                          const CallArgs& args);
     44  [[nodiscard]] static MOZ_ALWAYS_INLINE bool has_impl(JSContext* cx,
     45                                                       const CallArgs& args);
     46 };
     47 
     48 }  // namespace js
     49 
     50 template <>
     51 inline bool JSObject::is<js::WeakCollectionObject>() const {
     52  return is<js::WeakMapObject>() || is<js::WeakSetObject>();
     53 }
     54 
     55 #endif /* builtin_WeakSetObject_h */