mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:37:34 +00:00
LibJS: Make PromiseCapability GC-allocated
A struct with three raw pointers to other GC'd types is a pretty big liability, let's just turn this into a Cell itself. This comes with the additional benefit of being able to capture it in a lambda effortlessly, without having to create handles for individual members.
This commit is contained in:
parent
0585029c30
commit
fc9d587e39
29 changed files with 243 additions and 217 deletions
|
@ -23,23 +23,23 @@ public:
|
|||
Reject,
|
||||
};
|
||||
|
||||
static PromiseReaction* create(VM& vm, Type type, Optional<PromiseCapability> capability, Optional<JobCallback> handler);
|
||||
static PromiseReaction* create(VM& vm, Type type, GCPtr<PromiseCapability> capability, Optional<JobCallback> handler);
|
||||
|
||||
virtual ~PromiseReaction() = default;
|
||||
|
||||
Type type() const { return m_type; }
|
||||
Optional<PromiseCapability> const& capability() const { return m_capability; }
|
||||
GCPtr<PromiseCapability> capability() const { return m_capability; }
|
||||
|
||||
Optional<JobCallback>& handler() { return m_handler; }
|
||||
Optional<JobCallback> const& handler() const { return m_handler; }
|
||||
|
||||
private:
|
||||
PromiseReaction(Type type, Optional<PromiseCapability> capability, Optional<JobCallback> handler);
|
||||
PromiseReaction(Type type, GCPtr<PromiseCapability> capability, Optional<JobCallback> handler);
|
||||
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
Type m_type;
|
||||
Optional<PromiseCapability> m_capability;
|
||||
GCPtr<PromiseCapability> m_capability;
|
||||
Optional<JobCallback> m_handler;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue