4#ifndef QV4PROMISEOBJECT_H
5#define QV4PROMISEOBJECT_H
40 void addReaction(ExecutionEngine *e,
const Value *reaction,
const Value *value);
41 void addResolveThenable(ExecutionEngine *e,
const PromiseObject *promise,
const Object *thenable,
const FunctionObject *then);
54 void init(ExecutionEngine *engine);
57#define PromiseObjectMembers(class, Member)
58 Member(class, HeapValue, HeapValue, resolution)
59 Member(class, HeapValue, HeapValue, fulfillReactions)
60 Member(class, HeapValue, HeapValue, rejectReactions)
63 DECLARE_MARKOBJECTS(PromiseObject)
64 void init(ExecutionEngine *e);
73 bool isSettled()
const;
74 bool isPending()
const;
75 bool isFulfilled()
const;
76 bool isRejected()
const;
80 void triggerFullfillReactions(ExecutionEngine *e);
81 void triggerRejectReactions(ExecutionEngine *e);
84#define PromiseCapabilityMembers(class, Member)
85 Member(class, HeapValue, HeapValue, promise)
86 Member(class, HeapValue, HeapValue, resolve)
87 Member(class, HeapValue, HeapValue, reject)
90 DECLARE_MARKOBJECTS(PromiseCapability)
93#define PromiseReactionMembers(class, Member)
94 Member(class, HeapValue, HeapValue, handler)
95 Member(class, Pointer, PromiseCapability*, capability)
98 DECLARE_MARKOBJECTS(PromiseReaction)
100 static Heap::PromiseReaction *createFulfillReaction(ExecutionEngine* e,
const QV4::PromiseCapability *capability,
const QV4::FunctionObject *onFulfilled);
101 static Heap::PromiseReaction *createRejectReaction(ExecutionEngine* e,
const QV4::
PromiseCapability *capability,
const QV4::FunctionObject *onRejected);
103 void triggerWithValue(ExecutionEngine *e,
const Value *value);
113 friend class ReactionHandler;
116#define CapabilitiesExecutorWrapperMembers(class, Member)
117 Member(class, Pointer, PromiseCapability*, capabilities)
120 DECLARE_MARKOBJECTS(CapabilitiesExecutorWrapper)
125#define PromiseExecutionStateMembers(class, Member)
126 Member(class, HeapValue, HeapValue, values)
127 Member(class, HeapValue, HeapValue, capability)
130 DECLARE_MARKOBJECTS(PromiseExecutionState)
134 uint remainingElementCount;
137#define ResolveElementWrapperMembers(class, Member)
138 Member(class, HeapValue, HeapValue, state)
141 DECLARE_MARKOBJECTS(ResolveElementWrapper)
145 bool alreadyResolved;
148#define ResolveWrapperMembers(class, Member)
149 Member(class, Pointer, PromiseObject*, promise)
152 DECLARE_MARKOBJECTS(ResolveWrapper)
155 bool alreadyResolved;
158#define RejectWrapperMembers(class, Member)
159 Member(class, Pointer, PromiseObject*, promise)
162 DECLARE_MARKOBJECTS(RejectWrapper)
165 bool alreadyResolved;
202 static ReturnedValue method_all(
const FunctionObject *f,
const Value *thisObject,
const Value *argv,
int argc);
208 void init(ExecutionEngine *engine, Object *ctor);
void addResolveThenable(ExecutionEngine *e, const PromiseObject *promise, const Object *thenable, const FunctionObject *then)
void customEvent(QEvent *event) override
This event handler can be reimplemented in a subclass to receive custom events.
~ReactionHandler() override
void addReaction(ExecutionEngine *e, const Value *reaction, const Value *value)
void executeResolveThenable(ResolveThenableEvent *event)
void executeReaction(ReactionEvent *event)
DECLARE_HEAP_OBJECT(StrictArgumentsObject, Object)
DECLARE_HEAP_OBJECT(DynamicFunctionObject, FunctionObject)
DECLARE_HEAP_OBJECT(PromiseCapability, Object)
DECLARE_HEAP_OBJECT(PromiseObject, Object)
void init(ExecutionEngine *engine)
static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_all(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_race(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_reject(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_resolve(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_catch(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_then(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
void init(ExecutionEngine *engine, Object *ctor)