[V8] Remove custom toV8() calls for TypedArray.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Aug 2012 09:27:36 +0000 (09:27 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Aug 2012 09:27:36 +0000 (09:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=93248

Patch by Vineet Chaudhary <rgf748@motorola.com> on 2012-08-07
Reviewed by Kentaro Hara.

With the support of [TypedArray] we can remove the custom calls toV8().
TypedArray spec : http://www.khronos.org/registry/typedarray/specs/latest/#7

Tests: TestTypedArray.idl
Tests under below folders should pass as this does not cause any behavioral changes.
       fast/canvas/webgl
       compositing/webgl

* bindings/js/JSInt8ArrayCustom.cpp:
* bindings/js/JSUint8ArrayCustom.cpp:
* bindings/js/JSUint8ClampedArrayCustom.cpp:
* bindings/scripts/CodeGeneratorV8.pm:
(GenerateImplementation): Modified Generator code to generate bindings for toV8().
(IsWrapperType):
(GetTypeNameOfExternalTypedArray): Method to get view type of TypedArray.
* bindings/scripts/test/V8/V8Float64Array.cpp: Tests results.
(WebCore::toV8):
* bindings/v8/custom/V8Float32ArrayCustom.cpp: Removed custom call toV8().
* bindings/v8/custom/V8Float64ArrayCustom.cpp: Ditto.
* bindings/v8/custom/V8Int16ArrayCustom.cpp: Ditto.
* bindings/v8/custom/V8Int32ArrayCustom.cpp: Ditto.
* bindings/v8/custom/V8Int8ArrayCustom.cpp: Ditto.
* bindings/v8/custom/V8Uint16ArrayCustom.cpp: Ditto.
* bindings/v8/custom/V8Uint32ArrayCustom.cpp: Ditto.
* bindings/v8/custom/V8Uint8ArrayCustom.cpp: Ditto.
* bindings/v8/custom/V8Uint8ClampedArrayCustom.cpp: Ditto.
* html/canvas/Int8Array.idl: Using TypedArray.
* html/canvas/Uint8Array.idl: Ditto.
* html/canvas/Uint8ClampedArray.idl: Ditto.

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

18 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSInt8ArrayCustom.cpp
Source/WebCore/bindings/js/JSUint8ArrayCustom.cpp
Source/WebCore/bindings/js/JSUint8ClampedArrayCustom.cpp
Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp
Source/WebCore/bindings/v8/custom/V8Float32ArrayCustom.cpp
Source/WebCore/bindings/v8/custom/V8Float64ArrayCustom.cpp
Source/WebCore/bindings/v8/custom/V8Int16ArrayCustom.cpp
Source/WebCore/bindings/v8/custom/V8Int32ArrayCustom.cpp
Source/WebCore/bindings/v8/custom/V8Int8ArrayCustom.cpp
Source/WebCore/bindings/v8/custom/V8Uint16ArrayCustom.cpp
Source/WebCore/bindings/v8/custom/V8Uint32ArrayCustom.cpp
Source/WebCore/bindings/v8/custom/V8Uint8ArrayCustom.cpp
Source/WebCore/bindings/v8/custom/V8Uint8ClampedArrayCustom.cpp
Source/WebCore/html/canvas/Int8Array.idl
Source/WebCore/html/canvas/Uint8Array.idl
Source/WebCore/html/canvas/Uint8ClampedArray.idl

index 2f36c8a..e2af3bb 100644 (file)
@@ -1,3 +1,40 @@
+2012-08-07  Vineet Chaudhary  <rgf748@motorola.com>
+
+        [V8] Remove custom toV8() calls for TypedArray.
+        https://bugs.webkit.org/show_bug.cgi?id=93248
+
+        Reviewed by Kentaro Hara.
+
+        With the support of [TypedArray] we can remove the custom calls toV8().
+        TypedArray spec : http://www.khronos.org/registry/typedarray/specs/latest/#7
+
+        Tests: TestTypedArray.idl
+        Tests under below folders should pass as this does not cause any behavioral changes.
+               fast/canvas/webgl
+               compositing/webgl
+
+        * bindings/js/JSInt8ArrayCustom.cpp:
+        * bindings/js/JSUint8ArrayCustom.cpp:
+        * bindings/js/JSUint8ClampedArrayCustom.cpp:
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateImplementation): Modified Generator code to generate bindings for toV8().
+        (IsWrapperType):
+        (GetTypeNameOfExternalTypedArray): Method to get view type of TypedArray.
+        * bindings/scripts/test/V8/V8Float64Array.cpp: Tests results.
+        (WebCore::toV8):
+        * bindings/v8/custom/V8Float32ArrayCustom.cpp: Removed custom call toV8().
+        * bindings/v8/custom/V8Float64ArrayCustom.cpp: Ditto.
+        * bindings/v8/custom/V8Int16ArrayCustom.cpp: Ditto.
+        * bindings/v8/custom/V8Int32ArrayCustom.cpp: Ditto.
+        * bindings/v8/custom/V8Int8ArrayCustom.cpp: Ditto.
+        * bindings/v8/custom/V8Uint16ArrayCustom.cpp: Ditto.
+        * bindings/v8/custom/V8Uint32ArrayCustom.cpp: Ditto.
+        * bindings/v8/custom/V8Uint8ArrayCustom.cpp: Ditto.
+        * bindings/v8/custom/V8Uint8ClampedArrayCustom.cpp: Ditto.
+        * html/canvas/Int8Array.idl: Using TypedArray.
+        * html/canvas/Uint8Array.idl: Ditto.
+        * html/canvas/Uint8ClampedArray.idl: Ditto.
+
 2012-08-07  Pavel Feldman  <pfeldman@chromium.org>
 
         Web Inspector: [regression r121673] restore link between the command and the result.
index 4f053e0..29606b4 100644 (file)
@@ -49,14 +49,4 @@ JSC::JSValue JSInt8Array::set(JSC::ExecState* exec)
     return setWebGLArrayHelper<Int8Array, signed char>(exec, impl());
 }
 
-EncodedJSValue JSC_HOST_CALL JSInt8ArrayConstructor::constructJSInt8Array(ExecState* exec)
-{
-    JSInt8ArrayConstructor* jsConstructor = jsCast<JSInt8ArrayConstructor*>(exec->callee());
-    RefPtr<Int8Array> array = constructArrayBufferView<Int8Array, signed char>(exec);
-    if (!array.get())
-        // Exception has already been thrown.
-        return JSValue::encode(JSValue());
-    return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get())));
-}
-
 } // namespace WebCore
index db7a43a..a869ba9 100644 (file)
@@ -48,14 +48,4 @@ JSC::JSValue JSUint8Array::set(JSC::ExecState* exec)
     return setWebGLArrayHelper<Uint8Array, unsigned char>(exec, impl());
 }
 
-EncodedJSValue JSC_HOST_CALL JSUint8ArrayConstructor::constructJSUint8Array(ExecState* exec)
-{
-    JSUint8ArrayConstructor* jsConstructor = jsCast<JSUint8ArrayConstructor*>(exec->callee());
-    RefPtr<Uint8Array> array = constructArrayBufferView<Uint8Array, unsigned char>(exec);
-    if (!array.get())
-        // Exception has already been thrown.
-        return JSValue::encode(JSValue());
-    return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get())));
-}
-
 } // namespace WebCore
index c79bac0..19f32a7 100644 (file)
@@ -48,14 +48,4 @@ JSC::JSValue JSUint8ClampedArray::set(JSC::ExecState* exec)
     return setWebGLArrayHelper<Uint8ClampedArray, unsigned char>(exec, impl());
 }
 
-EncodedJSValue JSC_HOST_CALL JSUint8ClampedArrayConstructor::constructJSUint8ClampedArray(ExecState* exec)
-{
-    JSUint8ClampedArrayConstructor* jsConstructor = jsCast<JSUint8ClampedArrayConstructor*>(exec->callee());
-    RefPtr<Uint8ClampedArray> array = constructArrayBufferView<Uint8ClampedArray, unsigned char>(exec);
-    if (!array.get())
-        // Exception has already been thrown.
-        return JSValue::encode(JSValue());
-    return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get())));
-}
-
 } // namespace WebCore
index 1f14601..cdfbe4d 100644 (file)
@@ -2594,6 +2594,22 @@ sub GenerateImplementation
         GenerateVisitDOMWrapper($dataNode, $implClassName);
     }
 
+    if ($dataNode->extendedAttributes->{"TypedArray"}) {
+        my $viewType = GetTypeNameOfExternalTypedArray($dataNode);
+        push(@implContent, <<END);
+v8::Handle<v8::Value> toV8($implClassName* impl, v8::Isolate* isolate)
+{
+    if (!impl)
+        return v8NullWithCheck(isolate);
+    v8::Handle<v8::Object> wrapper = V8${implClassName}::wrap(impl, isolate);
+    if (!wrapper.IsEmpty())
+        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), $viewType, impl->length());
+    return wrapper;
+}
+
+END
+    }
+
     my $indexer;
     my $namedPropertyGetter;
     my @enabledPerContextFunctions;
@@ -3906,6 +3922,24 @@ sub IsWrapperType
     return !($non_wrapper_types{$type});
 }
 
+sub GetTypeNameOfExternalTypedArray
+{
+    my $dataNode = shift;
+    my $interfaceName = $dataNode->name;
+    my $viewType = $dataNode->extendedAttributes->{"TypedArray"};
+    return "v8::kExternalByteArray" if $viewType eq "signed char" and $interfaceName eq "Int8Array";
+    return "v8::kExternalPixelArray" if $viewType eq "unsigned char" and $interfaceName eq "Uint8ClampedArray";
+    return "v8::kExternalUnsignedByteArray" if $viewType eq "unsigned char" and $interfaceName eq "Uint8Array";
+    return "v8::kExternalShortArray" if $viewType eq "short" and $interfaceName eq "Int16Array";
+    return "v8::kExternalUnsignedShortArray" if $viewType eq "unsigned short" and $interfaceName eq "Uint16Array";
+    return "v8::kExternalIntArray" if $viewType eq "int" and $interfaceName eq "Int32Array";
+    return "v8::kExternalUnsignedIntArray" if $viewType eq "unsigned int" and $interfaceName eq "Uint32Array";
+    return "v8::kExternalFloatArray" if $viewType eq "float" and $interfaceName eq "Float32Array";
+    return "v8::kExternalDoubleArray" if $viewType eq "double" and $interfaceName eq "Float64Array";
+
+    die "TypedArray of unknown type is found";
+}
+
 sub IsArrayType
 {
     my $type = $codeGenerator->StripModule(shift);
index 5618135..33b4cec 100644 (file)
@@ -61,6 +61,16 @@ static v8::Handle<v8::Value> fooCallback(const v8::Arguments& args)
 
 } // namespace Float64ArrayV8Internal
 
+v8::Handle<v8::Value> toV8(Float64Array* impl, v8::Isolate* isolate)
+{
+    if (!impl)
+        return v8NullWithCheck(isolate);
+    v8::Handle<v8::Object> wrapper = V8Float64Array::wrap(impl, isolate);
+    if (!wrapper.IsEmpty())
+        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalDoubleArray, impl->length());
+    return wrapper;
+}
+
 static v8::Persistent<v8::FunctionTemplate> ConfigureV8Float64ArrayTemplate(v8::Persistent<v8::FunctionTemplate> desc)
 {
     desc->ReadOnlyPrototype();
index 691e1bc..b87a8d7 100644 (file)
@@ -54,14 +54,4 @@ v8::Handle<v8::Value> V8Float32Array::setCallback(const v8::Arguments& args)
     return setWebGLArrayHelper<Float32Array, V8Float32Array>(args);
 }
 
-v8::Handle<v8::Value> toV8(Float32Array* impl, v8::Isolate* isolate)
-{
-    if (!impl)
-        return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8Float32Array::wrap(impl, isolate);
-    if (!wrapper.IsEmpty())
-        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalFloatArray, impl->length());
-    return wrapper;
-}
-
 } // namespace WebCore
index 8df1c4d..42a9e20 100644 (file)
@@ -49,14 +49,4 @@ v8::Handle<v8::Value> V8Float64Array::setCallback(const v8::Arguments& args)
     return setWebGLArrayHelper<Float64Array, V8Float64Array>(args);
 }
 
-v8::Handle<v8::Value> toV8(Float64Array* impl, v8::Isolate* isolate)
-{
-    if (!impl)
-        return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8Float64Array::wrap(impl, isolate);
-    if (!wrapper.IsEmpty())
-        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalDoubleArray, impl->length());
-    return wrapper;
-}
-
 } // namespace WebCore
index 81c78e2..72d68bc 100644 (file)
@@ -53,14 +53,4 @@ v8::Handle<v8::Value> V8Int16Array::setCallback(const v8::Arguments& args)
     return setWebGLArrayHelper<Int16Array, V8Int16Array>(args);
 }
 
-v8::Handle<v8::Value> toV8(Int16Array* impl, v8::Isolate* isolate)
-{
-    if (!impl)
-        return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8Int16Array::wrap(impl, isolate);
-    if (!wrapper.IsEmpty())
-        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalShortArray, impl->length());
-    return wrapper;
-}
-
 } // namespace WebCore
index 9b04960..2372e28 100644 (file)
@@ -53,14 +53,4 @@ v8::Handle<v8::Value> V8Int32Array::setCallback(const v8::Arguments& args)
     return setWebGLArrayHelper<Int32Array, V8Int32Array>(args);
 }
 
-v8::Handle<v8::Value> toV8(Int32Array* impl, v8::Isolate* isolate)
-{
-    if (!impl)
-        return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8Int32Array::wrap(impl, isolate);
-    if (!wrapper.IsEmpty())
-        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalIntArray, impl->length());
-    return wrapper;
-}
-
 } // namespace WebCore
index bd3a34d..516306f 100644 (file)
@@ -53,14 +53,4 @@ v8::Handle<v8::Value> V8Int8Array::setCallback(const v8::Arguments& args)
     return setWebGLArrayHelper<Int8Array, V8Int8Array>(args);
 }
 
-v8::Handle<v8::Value> toV8(Int8Array* impl, v8::Isolate* isolate)
-{
-    if (!impl)
-        return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8Int8Array::wrap(impl, isolate);
-    if (!wrapper.IsEmpty())
-        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalByteArray, impl->length());
-    return wrapper;
-}
-
 } // namespace WebCore
index d40f9b7..c1b0a59 100644 (file)
@@ -53,14 +53,4 @@ v8::Handle<v8::Value> V8Uint16Array::setCallback(const v8::Arguments& args)
     return setWebGLArrayHelper<Uint16Array, V8Uint16Array>(args);
 }
 
-v8::Handle<v8::Value> toV8(Uint16Array* impl, v8::Isolate* isolate)
-{
-    if (!impl)
-        return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8Uint16Array::wrap(impl, isolate);
-    if (!wrapper.IsEmpty())
-        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedShortArray, impl->length());
-    return wrapper;
-}
-
 } // namespace WebCore
index 837ce59..af29593 100644 (file)
@@ -53,14 +53,4 @@ v8::Handle<v8::Value> V8Uint32Array::setCallback(const v8::Arguments& args)
     return setWebGLArrayHelper<Uint32Array, V8Uint32Array>(args);
 }
 
-v8::Handle<v8::Value> toV8(Uint32Array* impl, v8::Isolate* isolate)
-{
-    if (!impl)
-        return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8Uint32Array::wrap(impl, isolate);
-    if (!wrapper.IsEmpty())
-        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedIntArray, impl->length());
-    return wrapper;
-}
-
 } // namespace WebCore
index 7da64af..794a6f6 100644 (file)
@@ -53,14 +53,4 @@ v8::Handle<v8::Value> V8Uint8Array::setCallback(const v8::Arguments& args)
     return setWebGLArrayHelper<Uint8Array, V8Uint8Array>(args);
 }
 
-v8::Handle<v8::Value> toV8(Uint8Array* impl, v8::Isolate* isolate)
-{
-    if (!impl)
-        return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8Uint8Array::wrap(impl, isolate);
-    if (!wrapper.IsEmpty())
-        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedByteArray, impl->length());
-    return wrapper;
-}
-
 } // namespace WebCore
index be18d9b..e8fa8f0 100644 (file)
@@ -50,14 +50,4 @@ v8::Handle<v8::Value> V8Uint8ClampedArray::setCallback(const v8::Arguments& args
     return setWebGLArrayHelper<Uint8ClampedArray, V8Uint8ClampedArray>(args);
 }
 
-v8::Handle<v8::Value> toV8(Uint8ClampedArray* impl, v8::Isolate* isolate)
-{
-    if (!impl)
-        return v8NullWithCheck(isolate);
-    v8::Handle<v8::Object> wrapper = V8Uint8ClampedArray::wrap(impl, isolate);
-    if (!wrapper.IsEmpty())
-        wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalPixelArray, impl->length());
-    return wrapper;
-}
-
 } // namespace WebCore
index 00faa4f..65a90af 100644 (file)
@@ -33,7 +33,8 @@ module html {
         JSGenerateToNativeObject,
         JSNoStaticTables,
         CustomToJSObject,
-        DoNotCheckConstants
+        DoNotCheckConstants,
+        TypedArray=signed char
     ] Int8Array : ArrayBufferView {
         const unsigned long BYTES_PER_ELEMENT = 1;
 
index 260a327..b236fb6 100644 (file)
@@ -33,7 +33,8 @@ module html {
         JSGenerateToNativeObject,
         JSNoStaticTables,
         CustomToJSObject,
-        DoNotCheckConstants
+        DoNotCheckConstants,
+        TypedArray=unsigned char
     ] Uint8Array : ArrayBufferView {
         const unsigned long BYTES_PER_ELEMENT = 1;
 
index cadd663..e2b537a 100644 (file)
@@ -33,7 +33,8 @@ module html {
         JSGenerateToNativeObject,
         JSNoStaticTables,
         CustomToJSObject,
-        DoNotCheckConstants
+        DoNotCheckConstants,
+        TypedArray=unsigned char
     ] Uint8ClampedArray : Uint8Array {
         const unsigned long BYTES_PER_ELEMENT = 1;