[JSC] Add JSPromiseDeferred::reject(ExecState*, Exception*) interface
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Mar 2017 11:16:47 +0000 (11:16 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Mar 2017 11:16:47 +0000 (11:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=169908

Reviewed by Sam Weinig.

To avoid calling reject(ExecState*, JSValue) with Exception* accidentally,
we add a new interface reject(ExecState*, Exception*).
Such an interface is already added in DOMPromise in WebCore.

* runtime/JSInternalPromiseDeferred.cpp:
(JSC::JSInternalPromiseDeferred::reject):
* runtime/JSInternalPromiseDeferred.h:
* runtime/JSPromiseDeferred.cpp:
(JSC::JSPromiseDeferred::reject):
* runtime/JSPromiseDeferred.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214218 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSInternalPromiseDeferred.cpp
Source/JavaScriptCore/runtime/JSInternalPromiseDeferred.h
Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp
Source/JavaScriptCore/runtime/JSPromiseDeferred.h

index f8100dc..78a7995 100644 (file)
@@ -1,3 +1,21 @@
+2017-03-21  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [JSC] Add JSPromiseDeferred::reject(ExecState*, Exception*) interface
+        https://bugs.webkit.org/show_bug.cgi?id=169908
+
+        Reviewed by Sam Weinig.
+
+        To avoid calling reject(ExecState*, JSValue) with Exception* accidentally,
+        we add a new interface reject(ExecState*, Exception*).
+        Such an interface is already added in DOMPromise in WebCore.
+
+        * runtime/JSInternalPromiseDeferred.cpp:
+        (JSC::JSInternalPromiseDeferred::reject):
+        * runtime/JSInternalPromiseDeferred.h:
+        * runtime/JSPromiseDeferred.cpp:
+        (JSC::JSPromiseDeferred::reject):
+        * runtime/JSPromiseDeferred.h:
+
 2017-03-21  Zan Dobersek  <zdobersek@igalia.com>
 
         [jsc] MacroAssemblerMIPS: implement the branchPtr(RelationalCondition, BaseIndex, RegisterID) overload.
index 9803481..863b8cd 100644 (file)
@@ -75,4 +75,9 @@ JSInternalPromise* JSInternalPromiseDeferred::reject(ExecState* exec, JSValue re
     return promise();
 }
 
+JSInternalPromise* JSInternalPromiseDeferred::reject(ExecState* exec, Exception* reason)
+{
+    return reject(exec, reason->value());
+}
+
 } // namespace JSC
index d2c322c..374f85a 100644 (file)
@@ -48,6 +48,7 @@ public:
     JS_EXPORT_PRIVATE JSInternalPromise* promise() const;
     JS_EXPORT_PRIVATE JSInternalPromise* resolve(ExecState*, JSValue);
     JS_EXPORT_PRIVATE JSInternalPromise* reject(ExecState*, JSValue);
+    JS_EXPORT_PRIVATE JSInternalPromise* reject(ExecState*, Exception*);
 
 private:
     JSInternalPromiseDeferred(VM&);
index 7d3596c..6967e03 100644 (file)
@@ -106,6 +106,11 @@ void JSPromiseDeferred::reject(ExecState* exec, JSValue reason)
     callFunction(exec, m_reject.get(), reason);
 }
 
+void JSPromiseDeferred::reject(ExecState* exec, Exception* reason)
+{
+    reject(exec, reason->value());
+}
+
 void JSPromiseDeferred::finishCreation(VM& vm, JSObject* promise, JSValue resolve, JSValue reject)
 {
     Base::finishCreation(vm);
index cf7693a..26f4a82 100644 (file)
@@ -30,6 +30,7 @@
 
 namespace JSC {
 
+class Exception;
 class JSPromiseConstructor;
 
 class JSPromiseDeferred : public JSCell {
@@ -53,6 +54,7 @@ public:
 
     JS_EXPORT_PRIVATE void resolve(ExecState*, JSValue);
     JS_EXPORT_PRIVATE void reject(ExecState*, JSValue);
+    JS_EXPORT_PRIVATE void reject(ExecState*, Exception*);
 
 protected:
     JSPromiseDeferred(VM&, Structure*);