Get rid of [ConstructorParameters] extended attributes
authorch.dumez@sisa.samsung.com <ch.dumez@sisa.samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 May 2013 20:05:51 +0000 (20:05 +0000)
committerch.dumez@sisa.samsung.com <ch.dumez@sisa.samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 May 2013 20:05:51 +0000 (20:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=116308

Reviewed by Kentaro Hara.

Get rid of WebKit-specific [ConstructorParameters] IDL extended attribute. Instead,
[CustomConstructor] arguments are now explicitly specified, similarly to [Constructor]
arguments and the constructor object's "length" property is now automatically
computed for custom constructors as well.

This is less error-prone as the value is not hardcoded, more consistent with
[Constructor] extended attribute and gives more information about the custom constructor
in the IDL file. We also get rid of a WebKit-specific IDL attribute which is always
nice.

No new tests, already covered by fast/js/constructor-length.html.

* Modules/mediastream/MediaStream.idl:
* Modules/webaudio/AudioContext.idl:
* Modules/websockets/WebSocket.idl:
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateConstructorHelperMethods):
* bindings/scripts/IDLAttributes.txt:
* bindings/scripts/IDLParser.pm:
(applyTypedefs):
(parseAttributeRest):
(copyExtendedAttributes):
(parseExtendedAttributeRest):
(applyExtendedAttributeList):
* bindings/scripts/test/JS/JSFloat64Array.cpp:
(WebCore::JSFloat64ArrayConstructor::finishCreation):
* bindings/scripts/test/TestTypedArray.idl:
* dom/MutationObserver.idl:
* fileapi/Blob.idl:
* html/DOMFormData.idl:
* html/canvas/ArrayBuffer.idl:
* html/canvas/DataView.idl:
* page/WebKitPoint.idl:
* workers/SharedWorker.idl:
* workers/Worker.idl:

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

17 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/MediaStream.idl
Source/WebCore/Modules/webaudio/AudioContext.idl
Source/WebCore/Modules/websockets/WebSocket.idl
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLAttributes.txt
Source/WebCore/bindings/scripts/IDLParser.pm
Source/WebCore/bindings/scripts/test/JS/JSFloat64Array.cpp
Source/WebCore/bindings/scripts/test/TestTypedArray.idl
Source/WebCore/dom/MutationObserver.idl
Source/WebCore/fileapi/Blob.idl
Source/WebCore/html/DOMFormData.idl
Source/WebCore/html/canvas/ArrayBuffer.idl
Source/WebCore/html/canvas/DataView.idl
Source/WebCore/page/WebKitPoint.idl
Source/WebCore/workers/SharedWorker.idl
Source/WebCore/workers/Worker.idl

index 9ebf7c8..8c89172 100644 (file)
@@ -1,3 +1,46 @@
+2013-05-17  Christophe Dumez  <ch.dumez@sisa.samsung.com>
+
+        Get rid of [ConstructorParameters] extended attributes
+        https://bugs.webkit.org/show_bug.cgi?id=116308
+
+        Reviewed by Kentaro Hara.
+
+        Get rid of WebKit-specific [ConstructorParameters] IDL extended attribute. Instead,
+        [CustomConstructor] arguments are now explicitly specified, similarly to [Constructor]
+        arguments and the constructor object's "length" property is now automatically
+        computed for custom constructors as well.
+
+        This is less error-prone as the value is not hardcoded, more consistent with
+        [Constructor] extended attribute and gives more information about the custom constructor
+        in the IDL file. We also get rid of a WebKit-specific IDL attribute which is always
+        nice.
+
+        No new tests, already covered by fast/js/constructor-length.html.
+
+        * Modules/mediastream/MediaStream.idl:
+        * Modules/webaudio/AudioContext.idl:
+        * Modules/websockets/WebSocket.idl:
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateConstructorHelperMethods):
+        * bindings/scripts/IDLAttributes.txt:
+        * bindings/scripts/IDLParser.pm:
+        (applyTypedefs):
+        (parseAttributeRest):
+        (copyExtendedAttributes):
+        (parseExtendedAttributeRest):
+        (applyExtendedAttributeList):
+        * bindings/scripts/test/JS/JSFloat64Array.cpp:
+        (WebCore::JSFloat64ArrayConstructor::finishCreation):
+        * bindings/scripts/test/TestTypedArray.idl:
+        * dom/MutationObserver.idl:
+        * fileapi/Blob.idl:
+        * html/DOMFormData.idl:
+        * html/canvas/ArrayBuffer.idl:
+        * html/canvas/DataView.idl:
+        * page/WebKitPoint.idl:
+        * workers/SharedWorker.idl:
+        * workers/Worker.idl:
+
 2013-05-17  Alexey Proskuryakov  <ap@apple.com>
 
         Text input is largely broken when there are subframes loading
index de8e0c9..fc4ed10 100644 (file)
@@ -29,7 +29,6 @@
     Constructor,
     Constructor(MediaStream stream),
     Constructor(MediaStreamTrack[] tracks),
-    ConstructorParameters=0,
     CallWith=ScriptExecutionContext,
     SkipVTableValidation
 ] interface MediaStream {
index a702d2c..111add8 100644 (file)
@@ -28,7 +28,6 @@
     Conditional=WEB_AUDIO,
     ActiveDOMObject,
     CustomConstructor,
-    ConstructorParameters=0,
     EventTarget
 ] interface AudioContext {
     // All rendered audio ultimately connects to destination, which represents the audio hardware.
index e9f0fea..3ee5a2a 100644 (file)
@@ -40,7 +40,6 @@
     CallWith=ScriptExecutionContext,
     EventTarget,
     JSNoStaticTables,
-    ConstructorParameters=1
 ] interface WebSocket {
     readonly attribute DOMString URL; // Lowercased .url is the one in the spec, but leaving .URL for compatibility reasons.
     readonly attribute DOMString url;
index 97fd2d5..4b75a84 100644 (file)
@@ -4202,20 +4202,19 @@ sub GenerateConstructorHelperMethods
     my $generatingNamedConstructor = shift;
 
     my $constructorClassName = $generatingNamedConstructor ? "${className}NamedConstructor" : "${className}Constructor";
-    my $leastConstructorLength = $interface->extendedAttributes->{"ConstructorParameters"};
-    if (!defined $leastConstructorLength) {
-        if ($codeGenerator->IsConstructorTemplate($interface, "Event") || $codeGenerator->IsConstructorTemplate($interface, "TypedArray")) {
-            $leastConstructorLength = 1;
-        } elsif ($interface->extendedAttributes->{"Constructor"}) {
-            my @constructors = @{$interface->constructors};
-            $leastConstructorLength = 255;
-            foreach my $constructor (@constructors) {
-                my $constructorLength = GetFunctionLength($constructor);
-                $leastConstructorLength = $constructorLength if ($constructorLength < $leastConstructorLength);
-            }
-        } else {
-            $leastConstructorLength = 0;
+    my $leastConstructorLength = 0;
+    if ($codeGenerator->IsConstructorTemplate($interface, "Event") || $codeGenerator->IsConstructorTemplate($interface, "TypedArray")) {
+        $leastConstructorLength = 1;
+    } elsif ($interface->extendedAttributes->{"Constructor"} || $interface->extendedAttributes->{"CustomConstructor"}) {
+        my @constructors = @{$interface->constructors};
+        my @customConstructors = @{$interface->customConstructors};
+        $leastConstructorLength = 255;
+        foreach my $constructor (@constructors, @customConstructors) {
+            my $constructorLength = GetFunctionLength($constructor);
+            $leastConstructorLength = $constructorLength if ($constructorLength < $leastConstructorLength);
         }
+    } else {
+        $leastConstructorLength = 0;
     }
 
     if ($generatingNamedConstructor) {
index d99b9e6..edc2735 100644 (file)
@@ -28,7 +28,6 @@ Clamp
 Conditional=*
 Constructor
 ConstructorConditional=*
-ConstructorParameters=*
 ConstructorRaisesException
 ConstructorTemplate=Event|TypedArray
 Custom
index 8236de3..b50068c 100644 (file)
@@ -49,6 +49,7 @@ struct( domInterface => {
     attributes => '@',    # List of 'domAttribute'    
     extendedAttributes => '$', # Extended attributes
     constructors => '@', # Constructors, list of 'domFunction'
+    customConstructors => '@', # Custom constructors, list of 'domFunction'
     isException => '$', # Used for exception interfaces
     isCallback => '$', # Used for callback interfaces
     isPartial => '$', # Used for partial interfaces
@@ -382,7 +383,7 @@ sub applyTypedefs
             foreach my $attribute (@{$definition->attributes}) {
                 $self->applyTypedefsForSignature($attribute->signature);
             }
-            foreach my $function (@{$definition->functions}, @{$definition->constructors}) {
+            foreach my $function (@{$definition->functions}, @{$definition->constructors}, @{$definition->customConstructors}) {
                 $self->applyTypedefsForSignature($function->signature);
                 foreach my $signature (@{$function->parameters}) {
                     $self->applyTypedefsForSignature($signature);
@@ -1166,6 +1167,11 @@ sub parseAttributeRest
             push(@{$newDataNode->setterExceptions}, @{$getRef->{"setraises"}});
         }
         $self->assertTokenValue($self->getToken(), ";", __LINE__);
+        # CustomConstructor may also be used on attributes.
+        if (defined $extendedAttributeList->{"CustomConstructors"}) {
+            delete $extendedAttributeList->{"CustomConstructors"};
+            $extendedAttributeList->{"CustomConstructor"} = "VALUE_IS_MISSING";
+        }
         $newDataNode->signature->extendedAttributes($extendedAttributeList);
         return $newDataNode;
     }
@@ -1537,6 +1543,13 @@ sub copyExtendedAttributes
             foreach my $constructor (@constructors) {
                 push(@{$extendedAttributeList->{"Constructors"}}, $constructor);
             }
+        } elsif ($key eq "CustomConstructor") {
+            push(@{$extendedAttributeList->{"CustomConstructors"}}, $attr->{$key});
+        } elsif ($key eq "CustomConstructors") {
+           my @customConstructors = @{$attr->{$key}};
+            foreach my $customConstructor (@customConstructors) {
+                push(@{$extendedAttributeList->{"CustomConstructors"}}, $customConstructor);
+            }
         } else {
             $extendedAttributeList->{$key} = $attr->{$key};
         }
@@ -1623,7 +1636,7 @@ sub parseExtendedAttributeRest
         return $attrs;
     }
 
-    if ($name eq "Constructor") {
+    if ($name eq "Constructor" || $name eq "CustomConstructor") {
         $attrs->{$name} = [];
     } else {
         $attrs->{$name} = "VALUE_IS_MISSING";
@@ -2607,6 +2620,21 @@ sub applyExtendedAttributeList
         $extendedAttributeList->{"NamedConstructor"} = $constructorName;
         push(@{$interface->constructors}, $newDataNode);
     }
+    if (defined $extendedAttributeList->{"CustomConstructors"}) {
+        my @customConstructorParams = @{$extendedAttributeList->{"CustomConstructors"}};
+        my $index = (@customConstructorParams == 1) ? 0 : 1;
+        foreach my $param (@customConstructorParams) {
+            my $customConstructor = domFunction->new();
+            $customConstructor->signature(domSignature->new());
+            $customConstructor->signature->name("CustomConstructor");
+            $customConstructor->signature->extendedAttributes($extendedAttributeList);
+            $customConstructor->parameters($param);
+            $customConstructor->{overloadedIndex} = $index++;
+            push(@{$interface->customConstructors}, $customConstructor);
+        }
+        delete $extendedAttributeList->{"CustomConstructors"};
+        $extendedAttributeList->{"CustomConstructor"} = "VALUE_IS_MISSING";
+    }
     $interface->extendedAttributes($extendedAttributeList);
 }
 
index 9a472ec..6afd4d3 100644 (file)
@@ -90,7 +90,7 @@ void JSFloat64ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObjec
     Base::finishCreation(exec->vm());
     ASSERT(inherits(&s_info));
     putDirect(exec->vm(), exec->propertyNames().prototype, JSFloat64ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly);
-    putDirect(exec->vm(), exec->propertyNames().length, jsNumber(123), ReadOnly | DontDelete | DontEnum);
+    putDirect(exec->vm(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
 }
 
 bool JSFloat64ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
index 5dd2e03..97ce95e 100644 (file)
@@ -26,7 +26,6 @@
 
 [
     ConstructorTemplate=TypedArray,
-    ConstructorParameters=123,
     NumericIndexedGetter,
     CustomIndexedSetter,
     JSGenerateToNativeObject,
index 0eab25a..fe686c5 100644 (file)
@@ -29,8 +29,7 @@
  */
 
 [
-    CustomConstructor,
-    ConstructorParameters=1,
+    CustomConstructor(MutationCallback callback),
     CustomIsReachable,
     ImplementationLacksVTable
 ] interface MutationObserver {
index 027e5db..1c606c4 100644 (file)
@@ -32,7 +32,8 @@
     GenerateIsReachable=Impl,
     CustomToJSObject,
     JSNoStaticTables,
-    CustomConstructor
+    CustomConstructor,
+    CustomConstructor(sequence<any> blobParts, optional BlobPropertyBag options)
 ] interface Blob {
     readonly attribute unsigned long long size;
     readonly attribute DOMString type;
index 9e9270f..9291845 100644 (file)
@@ -29,8 +29,7 @@
  */
 
 [
-    CustomConstructor,
-    ConstructorParameters=1,
+    CustomConstructor(optional HTMLFormElement form),
     JSGenerateToNativeObject,
     JSGenerateToJSObject,
     InterfaceName=FormData,
index aeb9cb4..1d800cd 100644 (file)
@@ -25,8 +25,7 @@
 
 [
     GenerateIsReachable=Impl,
-    CustomConstructor,
-    ConstructorParameters=1,
+    CustomConstructor(unsigned long length),
     JSNoStaticTables,
     ImplementationNamespace=WTF,
     ImplementationLacksVTable
index c87ac87..470b745 100644 (file)
@@ -24,8 +24,7 @@
  */
 
 [
-    CustomConstructor,
-    ConstructorParameters=1,
+    CustomConstructor(ArrayBuffer buffer, optional unsigned long byteOffset, optional unsigned long byteLength),
     CustomToJSObject,
     JSNoStaticTables
 ] interface DataView : ArrayBufferView {
index 178d564..44e3b10 100644 (file)
@@ -25,6 +25,7 @@
 
 [
     CustomConstructor,
+    CustomConstructor(float x, float y),
     ImplementationLacksVTable
 ] interface WebKitPoint {
     attribute float x;
index f555f5e..07ece45 100644 (file)
@@ -32,8 +32,7 @@
 [
     EnabledAtRuntime,
     Conditional=SHARED_WORKERS,
-    CustomConstructor,
-    Constructor(DOMString scriptURL, [Default=NullString] optional DOMString name),
+    CustomConstructor(DOMString scriptURL, [Default=NullString] optional DOMString name),
     CallWith=ScriptExecutionContext,
     ConstructorRaisesException,
     JSCustomMarkFunction,
index 71789ee..6515dc1 100644 (file)
@@ -27,8 +27,7 @@
 
 [
     Conditional=WORKERS,
-    CustomConstructor,
-    Constructor(DOMString scriptUrl),
+    CustomConstructor(DOMString scriptUrl),
     CallWith=ScriptExecutionContext,
     ConstructorRaisesException,
     JSGenerateToNativeObject,