summaryrefslogtreecommitdiffstats
path: root/js/src/builtin
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2019-06-09 00:19:45 -0400
committerGaming4JC <g4jc@hyperbola.info>2019-07-18 22:38:27 -0400
commite1e313f3b6905c39a4b78a2e6cc918238540aeb2 (patch)
tree726f7cbde8c28de59abddfcbbf47744a126c0db1 /js/src/builtin
parent31c0c2f9cc71f8ff1d8c183d38449693ec7ca502 (diff)
downloadUXP-e1e313f3b6905c39a4b78a2e6cc918238540aeb2.tar
UXP-e1e313f3b6905c39a4b78a2e6cc918238540aeb2.tar.gz
UXP-e1e313f3b6905c39a4b78a2e6cc918238540aeb2.tar.lz
UXP-e1e313f3b6905c39a4b78a2e6cc918238540aeb2.tar.xz
UXP-e1e313f3b6905c39a4b78a2e6cc918238540aeb2.zip
1320408 - Part 20: Change PromiseObject::resolve and PromiseObject::reject to static method.
Diffstat (limited to 'js/src/builtin')
-rw-r--r--js/src/builtin/Promise.cpp20
-rw-r--r--js/src/builtin/Promise.h6
2 files changed, 14 insertions, 12 deletions
diff --git a/js/src/builtin/Promise.cpp b/js/src/builtin/Promise.cpp
index 346b2ebc2..4210b9cd2 100644
--- a/js/src/builtin/Promise.cpp
+++ b/js/src/builtin/Promise.cpp
@@ -2631,14 +2631,14 @@ PromiseObject::dependentPromises(JSContext* cx, MutableHandle<GCVector<Value>> v
return true;
}
-bool
-PromiseObject::resolve(JSContext* cx, HandleValue resolutionValue)
+/* static */ bool
+PromiseObject::resolve(JSContext* cx, Handle<PromiseObject*> promise, HandleValue resolutionValue)
{
- MOZ_ASSERT(!PromiseHasAnyFlag(*this, PROMISE_FLAG_ASYNC));
- if (state() != JS::PromiseState::Pending)
+ MOZ_ASSERT(!PromiseHasAnyFlag(*promise, PROMISE_FLAG_ASYNC));
+ if (promise->state() != JS::PromiseState::Pending)
return true;
- RootedObject resolveFun(cx, GetResolveFunctionFromPromise(this));
+ RootedObject resolveFun(cx, GetResolveFunctionFromPromise(promise));
RootedValue funVal(cx, ObjectValue(*resolveFun));
// For xray'd Promises, the resolve fun may have been created in another
@@ -2654,14 +2654,14 @@ PromiseObject::resolve(JSContext* cx, HandleValue resolutionValue)
return Call(cx, funVal, UndefinedHandleValue, args, &dummy);
}
-bool
-PromiseObject::reject(JSContext* cx, HandleValue rejectionValue)
+/* static */ bool
+PromiseObject::reject(JSContext* cx, Handle<PromiseObject*> promise, HandleValue rejectionValue)
{
- MOZ_ASSERT(!PromiseHasAnyFlag(*this, PROMISE_FLAG_ASYNC));
- if (state() != JS::PromiseState::Pending)
+ MOZ_ASSERT(!PromiseHasAnyFlag(*promise, PROMISE_FLAG_ASYNC));
+ if (promise->state() != JS::PromiseState::Pending)
return true;
- RootedValue funVal(cx, this->getFixedSlot(PromiseSlot_RejectFunction));
+ RootedValue funVal(cx, promise->getFixedSlot(PromiseSlot_RejectFunction));
MOZ_ASSERT(IsCallable(funVal));
FixedInvokeArgs<1> args(cx);
diff --git a/js/src/builtin/Promise.h b/js/src/builtin/Promise.h
index bb4778631..87d95f154 100644
--- a/js/src/builtin/Promise.h
+++ b/js/src/builtin/Promise.h
@@ -66,8 +66,10 @@ class PromiseObject : public NativeObject
return getFixedSlot(PromiseSlot_ReactionsOrResult);
}
- MOZ_MUST_USE bool resolve(JSContext* cx, HandleValue resolutionValue);
- MOZ_MUST_USE bool reject(JSContext* cx, HandleValue rejectionValue);
+ static MOZ_MUST_USE bool resolve(JSContext* cx, Handle<PromiseObject*> promise,
+ HandleValue resolutionValue);
+ static MOZ_MUST_USE bool reject(JSContext* cx, Handle<PromiseObject*> promise,
+ HandleValue rejectionValue);
void onSettled(JSContext* cx);