Title: [186076] trunk/Source
Revision
186076
Author
youenn.fab...@crf.canon.fr
Date
2015-06-29 12:04:36 -0700 (Mon, 29 Jun 2015)

Log Message

Binding generator should allow using JSC::Value for "any" parameter in lieu of ScriptValue
https://bugs.webkit.org/show_bug.cgi?id=146403

Reviewed by Darin Adler.

Source/_javascript_Core:

* bindings/ScriptValue.h: Added implicit conversion to JSC::JSValue.

Source/WebCore:

Covered by existing tests.

Enabling new APIs to use JSC::JSValue by using implicit case from ScriptValue to JSC::JSValue.
Updated binding generator to include ScruptValue header in the needed JSXX.cpp files.
Applied approach to ReadableStreamController.error.

* Modules/streams/ReadableStreamController.h:
(WebCore::ReadableStreamController::error):
* Modules/streams/ReadableStreamController.idl:
* bindings/js/JSReadableStreamControllerCustom.cpp:
(WebCore::constructJSReadableStreamController): Deleted.
* bindings/js/ReadableJSStream.cpp:
(WebCore::ReadableJSStream::error):
* bindings/js/ReadableJSStream.h:
* bindings/scripts/CodeGeneratorJS.pm:
(JSValueToNative):
* bindings/scripts/test/JS/JSTestObj.cpp:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (186075 => 186076)


--- trunk/Source/_javascript_Core/ChangeLog	2015-06-29 18:56:56 UTC (rev 186075)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-06-29 19:04:36 UTC (rev 186076)
@@ -1,3 +1,12 @@
+2015-06-29  Youenn Fablet  <youenn.fab...@crf.canon.fr>
+
+        Binding generator should allow using JSC::Value for "any" parameter in lieu of ScriptValue
+        https://bugs.webkit.org/show_bug.cgi?id=146403
+
+        Reviewed by Darin Adler.
+
+        * bindings/ScriptValue.h: Added implicit conversion to JSC::JSValue.
+
 2015-06-28 Aleksandr Skachkov   <gskach...@gmail.com>
 
         [ES6] Implement ES6 arrow function syntax. No Line terminator between function parameters and =>

Modified: trunk/Source/_javascript_Core/bindings/ScriptValue.h (186075 => 186076)


--- trunk/Source/_javascript_Core/bindings/ScriptValue.h	2015-06-29 18:56:56 UTC (rev 186075)
+++ trunk/Source/_javascript_Core/bindings/ScriptValue.h	2015-06-29 19:04:36 UTC (rev 186076)
@@ -51,6 +51,7 @@
     ScriptValue(JSC::VM& vm, JSC::JSValue value) : m_value(vm, value) { }
     virtual ~ScriptValue();
 
+    operator JSC::JSValue() const { return jsValue(); }
     JSC::JSValue jsValue() const { return m_value.get(); }
     bool getString(JSC::ExecState*, String& result) const;
     String toString(JSC::ExecState*) const;

Modified: trunk/Source/WebCore/ChangeLog (186075 => 186076)


--- trunk/Source/WebCore/ChangeLog	2015-06-29 18:56:56 UTC (rev 186075)
+++ trunk/Source/WebCore/ChangeLog	2015-06-29 19:04:36 UTC (rev 186076)
@@ -1,3 +1,28 @@
+2015-06-29  Youenn Fablet  <youenn.fab...@crf.canon.fr>
+
+        Binding generator should allow using JSC::Value for "any" parameter in lieu of ScriptValue
+        https://bugs.webkit.org/show_bug.cgi?id=146403
+
+        Reviewed by Darin Adler.
+
+        Covered by existing tests.
+
+        Enabling new APIs to use JSC::JSValue by using implicit case from ScriptValue to JSC::JSValue.
+        Updated binding generator to include ScruptValue header in the needed JSXX.cpp files.
+        Applied approach to ReadableStreamController.error.
+
+        * Modules/streams/ReadableStreamController.h:
+        (WebCore::ReadableStreamController::error):
+        * Modules/streams/ReadableStreamController.idl:
+        * bindings/js/JSReadableStreamControllerCustom.cpp:
+        (WebCore::constructJSReadableStreamController): Deleted.
+        * bindings/js/ReadableJSStream.cpp:
+        (WebCore::ReadableJSStream::error):
+        * bindings/js/ReadableJSStream.h:
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (JSValueToNative):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+
 2015-06-29  Anders Carlsson  <ander...@apple.com>
 
         Use DISPATCH_SOURCE_TYPE_MEMORYPRESSURE instead of DISPATCH_SOURCE_TYPE_MEMORYSTATUS

Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamController.h (186075 => 186076)


--- trunk/Source/WebCore/Modules/streams/ReadableStreamController.h	2015-06-29 18:56:56 UTC (rev 186075)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamController.h	2015-06-29 19:04:36 UTC (rev 186076)
@@ -48,6 +48,9 @@
 
     ReadableJSStream& stream() { return m_stream; }
 
+    void error(JSC::ExecState* state, ExceptionCode& ec) { m_stream.error(*state, ec); }
+    void error(JSC::ExecState* state, JSC::JSValue, ExceptionCode& ec) { m_stream.error(*state, ec); }
+
     void ref() { m_stream.ref(); }
     void deref() { m_stream.deref(); }
 

Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamController.idl (186075 => 186076)


--- trunk/Source/WebCore/Modules/streams/ReadableStreamController.idl	2015-06-29 18:56:56 UTC (rev 186075)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamController.idl	2015-06-29 19:04:36 UTC (rev 186076)
@@ -35,7 +35,7 @@
 ] interface ReadableStreamController {
     [Custom, RaisesException] boolean enqueue(any chunk);
     [RaisesException] void close();
-    [Custom, RaisesException] void error(any error);
+    [CallWith=ScriptState, RaisesException] void error(optional any error);
 
     readonly attribute double desiredSize;
 };

Modified: trunk/Source/WebCore/bindings/js/JSReadableStreamControllerCustom.cpp (186075 => 186076)


--- trunk/Source/WebCore/bindings/js/JSReadableStreamControllerCustom.cpp	2015-06-29 18:56:56 UTC (rev 186075)
+++ trunk/Source/WebCore/bindings/js/JSReadableStreamControllerCustom.cpp	2015-06-29 19:04:36 UTC (rev 186076)
@@ -51,15 +51,6 @@
     return jsUndefined();
 }
 
-JSValue JSReadableStreamController::error(ExecState* state)
-{
-    ReadableJSStream& stream = impl().stream();
-    if (!stream.isReadable())
-        return state->vm().throwException(state, createTypeError(state, ASCIILiteral("Calling error on a stream which is not readable")));
-    stream.storeError(*state, state->argument(0));
-    return jsUndefined();
-}
-
 EncodedJSValue JSC_HOST_CALL constructJSReadableStreamController(ExecState* exec)
 {
     return throwVMError(exec, createTypeError(exec, ASCIILiteral("ReadableStreamController constructor should not be called directly")));

Modified: trunk/Source/WebCore/bindings/js/ReadableJSStream.cpp (186075 => 186076)


--- trunk/Source/WebCore/bindings/js/ReadableJSStream.cpp	2015-06-29 18:56:56 UTC (rev 186075)
+++ trunk/Source/WebCore/bindings/js/ReadableJSStream.cpp	2015-06-29 19:04:36 UTC (rev 186076)
@@ -298,6 +298,15 @@
     changeStateToClosed();
 }
 
+void ReadableJSStream::error(JSC::ExecState& state, ExceptionCode& ec)
+{
+    if (!isReadable()) {
+        ec = TypeError;
+        return;
+    }
+    storeError(state, state.argument(0));
+}
+
 void ReadableJSStream::storeException(JSC::ExecState& state)
 {
     JSValue exception = state.exception()->value();

Modified: trunk/Source/WebCore/bindings/js/ReadableJSStream.h (186075 => 186076)


--- trunk/Source/WebCore/bindings/js/ReadableJSStream.h	2015-06-29 18:56:56 UTC (rev 186075)
+++ trunk/Source/WebCore/bindings/js/ReadableJSStream.h	2015-06-29 19:04:36 UTC (rev 186076)
@@ -63,6 +63,7 @@
     JSC::JSValue error() override { return m_error.get(); }
 
     void enqueue(JSC::ExecState&);
+    void error(JSC::ExecState&, ExceptionCode&);
 
     double desiredSize() const { return m_highWaterMark - m_totalQueueSize; }
 

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (186075 => 186076)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2015-06-29 18:56:56 UTC (rev 186075)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2015-06-29 19:04:36 UTC (rev 186076)
@@ -3868,6 +3868,7 @@
     }
 
     if ($type eq "any") {
+        AddToImplIncludes("<bindings/ScriptValue.h>");
         return "{ exec->vm(), $value }";
     }
 

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (186075 => 186076)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2015-06-29 18:56:56 UTC (rev 186075)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2015-06-29 19:04:36 UTC (rev 186076)
@@ -52,6 +52,7 @@
 #include "TestObj.h"
 #include "URL.h"
 #include "bool.h"
+#include <bindings/ScriptValue.h>
 #include <inspector/ScriptArguments.h>
 #include <inspector/ScriptCallStackFactory.h>
 #include <runtime/Error.h>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to