Debian Codegraph @

js/src/builtin/WeakRefObject.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_WeakRefObject_h
8 #define builtin_WeakRefObject_h
9
10 #include "vm/NativeObject.h"
11
12 namespace js {
13
14 class WeakRefObject : public NativeObject {
15 public:
16 enum { TargetSlot, SlotCount };
17
18 static const JSClass class_;
19 static const JSClass protoClass_;
20
21 JSObject* target() { return maybePtrFromReservedSlot<JSObject>(TargetSlot); }
22
23 void setTargetUnbarriered(JSObject* target);
24 void clearTarget();
25
26 private:
27 static const JSClassOps classOps_;
28 static const ClassSpec classSpec_;
29 static const JSPropertySpec properties[];
30 static const JSFunctionSpec methods[];
31
32 [[nodiscard]] static bool construct(JSContext* cx, unsigned argc, Value* vp);
33 static void trace(JSTracer* trc, JSObject* obj);
34 static void finalize(JS::GCContext* gcx, JSObject* obj);
35
36 static bool preserveDOMWrapper(JSContext* cx, HandleObject obj);
37
38 static bool deref(JSContext* cx, unsigned argc, Value* vp);
39 static void readBarrier(JSContext* cx, Handle<WeakRefObject*> self);
40 };
41
42 } // namespace js
43 #endif /* builtin_WeakRefObject_h */