Binding generator should allow using JSC::Value for "any" parameter in lieu of Script...
authoryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Jun 2015 19:04:36 +0000 (19:04 +0000)
committeryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Jun 2015 19:04:36 +0000 (19:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=146403

Reviewed by Darin Adler.

Source/JavaScriptCore:

* 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:

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bindings/ScriptValue.h
Source/WebCore/ChangeLog
Source/WebCore/Modules/streams/ReadableStreamController.h
Source/WebCore/Modules/streams/ReadableStreamController.idl
Source/WebCore/bindings/js/JSReadableStreamControllerCustom.cpp
Source/WebCore/bindings/js/ReadableJSStream.cpp
Source/WebCore/bindings/js/ReadableJSStream.h
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

index 0d13db5..223c0cd 100644 (file)
@@ -1,3 +1,12 @@
+2015-06-29  Youenn Fablet  <youenn.fablet@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   <gskachkov@gmail.com>
 
         [ES6] Implement ES6 arrow function syntax. No Line terminator between function parameters and =>
index c4d0086..b7b521e 100644 (file)
@@ -51,6 +51,7 @@ public:
     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;
index d38c6d0..ee79778 100644 (file)
@@ -1,3 +1,28 @@
+2015-06-29  Youenn Fablet  <youenn.fablet@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  <andersca@apple.com>
 
         Use DISPATCH_SOURCE_TYPE_MEMORYPRESSURE instead of DISPATCH_SOURCE_TYPE_MEMORYSTATUS
index 103bbe4..6f21f29 100644 (file)
@@ -48,6 +48,9 @@ public:
 
     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(); }
 
index ffae99c..57f5666 100644 (file)
@@ -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;
 };
index 46b86e4..14cc166 100644 (file)
@@ -51,15 +51,6 @@ JSValue JSReadableStreamController::enqueue(ExecState* exec)
     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")));
index 7281705..ff18a2f 100644 (file)
@@ -298,6 +298,15 @@ void ReadableJSStream::close(ExceptionCode& ec)
     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();
index 3dc166e..15fde32 100644 (file)
@@ -63,6 +63,7 @@ public:
     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; }
 
index 3d3c83a..e8cb245 100644 (file)
@@ -3868,6 +3868,7 @@ sub JSValueToNative
     }
 
     if ($type eq "any") {
+        AddToImplIncludes("<bindings/ScriptValue.h>");
         return "{ exec->vm(), $value }";
     }
 
index 4a72235..a94619c 100644 (file)
@@ -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>