Title: [132698] trunk/Source/WebCore
Revision
132698
Author
jsb...@chromium.org
Date
2012-10-26 14:55:18 -0700 (Fri, 26 Oct 2012)

Log Message

[WebKitIDL] Optional dictionary types should have default values of empty dictionary
https://bugs.webkit.org/show_bug.cgi?id=100547

Reviewed by Adam Barth.

Per WebIDL, "Optional dictionary type arguments are always considered to have a default
value of an empty dictionary." WebKitIDL already supported this via the extended attribute
[Optional=DefaultIsUndefined] but make this the default for Dictionary.

Binding test expectations updated.

* Modules/filesystem/DirectoryEntry.h: Remove default parameters.
(DirectoryEntry):
* Modules/indexeddb/IDBDatabase.h: Remove overloads.
(IDBDatabase):
* Modules/indexeddb/IDBObjectStore.h: Remove overloads.
(IDBObjectStore):
* Modules/mediastream/RTCPeerConnection.idl: Remove DefaultIsUndefined annotations.
* bindings/scripts/CodeGeneratorJS.pm: Special case for Optional Dictionary.
(GenerateParametersCheck):
* bindings/scripts/CodeGeneratorV8.pm: Ditto.
(GenerateParametersCheck):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjPrototypeFunctionOptionsObject): Updated expectation - no early call.
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore::TestObjV8Internal::optionsObjectCallback): Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (132697 => 132698)


--- trunk/Source/WebCore/ChangeLog	2012-10-26 21:41:33 UTC (rev 132697)
+++ trunk/Source/WebCore/ChangeLog	2012-10-26 21:55:18 UTC (rev 132698)
@@ -1,3 +1,32 @@
+2012-10-26  Joshua Bell  <jsb...@chromium.org>
+
+        [WebKitIDL] Optional dictionary types should have default values of empty dictionary
+        https://bugs.webkit.org/show_bug.cgi?id=100547
+
+        Reviewed by Adam Barth.
+
+        Per WebIDL, "Optional dictionary type arguments are always considered to have a default
+        value of an empty dictionary." WebKitIDL already supported this via the extended attribute
+        [Optional=DefaultIsUndefined] but make this the default for Dictionary.
+
+        Binding test expectations updated.
+
+        * Modules/filesystem/DirectoryEntry.h: Remove default parameters.
+        (DirectoryEntry):
+        * Modules/indexeddb/IDBDatabase.h: Remove overloads.
+        (IDBDatabase):
+        * Modules/indexeddb/IDBObjectStore.h: Remove overloads.
+        (IDBObjectStore):
+        * Modules/mediastream/RTCPeerConnection.idl: Remove DefaultIsUndefined annotations.
+        * bindings/scripts/CodeGeneratorJS.pm: Special case for Optional Dictionary.
+        (GenerateParametersCheck):
+        * bindings/scripts/CodeGeneratorV8.pm: Ditto.
+        (GenerateParametersCheck):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::jsTestObjPrototypeFunctionOptionsObject): Updated expectation - no early call.
+        * bindings/scripts/test/V8/V8TestObj.cpp:
+        (WebCore::TestObjV8Internal::optionsObjectCallback): Ditto.
+
 2012-10-26  Vincent Scheib  <sch...@chromium.org>
 
         Generated should not be supported for things with a shadow

Modified: trunk/Source/WebCore/Modules/filesystem/DirectoryEntry.h (132697 => 132698)


--- trunk/Source/WebCore/Modules/filesystem/DirectoryEntry.h	2012-10-26 21:41:33 UTC (rev 132697)
+++ trunk/Source/WebCore/Modules/filesystem/DirectoryEntry.h	2012-10-26 21:55:18 UTC (rev 132698)
@@ -56,8 +56,8 @@
     virtual bool isDirectory() const { return true; }
 
     PassRefPtr<DirectoryReader> createReader();
-    void getFile(const String& path, const Dictionary& = Dictionary(), PassRefPtr<EntryCallback> = 0, PassRefPtr<ErrorCallback> = 0);
-    void getDirectory(const String& path, const Dictionary& = Dictionary(), PassRefPtr<EntryCallback> = 0, PassRefPtr<ErrorCallback> = 0);
+    void getFile(const String& path, const Dictionary&, PassRefPtr<EntryCallback> = 0, PassRefPtr<ErrorCallback> = 0);
+    void getDirectory(const String& path, const Dictionary&, PassRefPtr<EntryCallback> = 0, PassRefPtr<ErrorCallback> = 0);
     void removeRecursively(PassRefPtr<VoidCallback> successCallback = 0, PassRefPtr<ErrorCallback> = 0) const;
 
 private:

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.h (132697 => 132698)


--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.h	2012-10-26 21:41:33 UTC (rev 132697)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.h	2012-10-26 21:55:18 UTC (rev 132698)
@@ -62,8 +62,6 @@
     PassRefPtr<IDBAny> version() const;
     PassRefPtr<DOMStringList> objectStoreNames() const;
 
-    // FIXME: Try to modify the code generator so this is unneeded.
-    PassRefPtr<IDBObjectStore> createObjectStore(const String& name, ExceptionCode& ec) { return createObjectStore(name, Dictionary(), ec); }
     PassRefPtr<IDBObjectStore> createObjectStore(const String& name, const Dictionary&, ExceptionCode&);
     PassRefPtr<IDBTransaction> transaction(ScriptExecutionContext*, PassRefPtr<DOMStringList>, const String& mode, ExceptionCode&);
     PassRefPtr<IDBTransaction> transaction(ScriptExecutionContext*, const String&, const String& mode, ExceptionCode&);

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h (132697 => 132698)


--- trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h	2012-10-26 21:41:33 UTC (rev 132697)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h	2012-10-26 21:55:18 UTC (rev 132698)
@@ -81,11 +81,8 @@
     PassRefPtr<IDBRequest> deleteFunction(ScriptExecutionContext*, PassRefPtr<IDBKey> key, ExceptionCode&);
     PassRefPtr<IDBRequest> clear(ScriptExecutionContext*, ExceptionCode&);
 
-    // FIXME: Try to modify the code generator so this duplication is unneeded.
     PassRefPtr<IDBIndex> createIndex(ScriptExecutionContext*, const String& name, const String& keyPath, const Dictionary&, ExceptionCode&);
-    PassRefPtr<IDBIndex> createIndex(ScriptExecutionContext* context, const String& name, const String& keyPath, ExceptionCode& ec) { return createIndex(context, name, keyPath, Dictionary(), ec); }
     PassRefPtr<IDBIndex> createIndex(ScriptExecutionContext*, const String& name, PassRefPtr<DOMStringList> keyPath, const Dictionary&, ExceptionCode&);
-    PassRefPtr<IDBIndex> createIndex(ScriptExecutionContext* context, const String& name, PassRefPtr<DOMStringList> keyPath, ExceptionCode& ec) { return createIndex(context, name, keyPath, Dictionary(), ec); }
     PassRefPtr<IDBIndex> createIndex(ScriptExecutionContext*, const String&, const IDBKeyPath&, const Dictionary&, ExceptionCode&);
 
     PassRefPtr<IDBIndex> index(const String& name, ExceptionCode&);

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl (132697 => 132698)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl	2012-10-26 21:41:33 UTC (rev 132697)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.idl	2012-10-26 21:55:18 UTC (rev 132698)
@@ -31,15 +31,15 @@
 [
     Conditional=MEDIA_STREAM,
     ActiveDOMObject,
-    Constructor(in Dictionary rtcIceServers, in [Optional=DefaultIsUndefined] Dictionary mediaConstraints),
+    Constructor(in Dictionary rtcIceServers, in [Optional] Dictionary mediaConstraints),
     ConstructorRaisesException,
     CallWith=ScriptExecutionContext,
     EventTarget
 ] interface RTCPeerConnection {
-    void createOffer(in [Callback] RTCSessionDescriptionCallback successCallback, in [Callback,Optional=DefaultIsUndefined] RTCErrorCallback failureCallback, in [Optional=DefaultIsUndefined] Dictionary mediaConstraints)
+    void createOffer(in [Callback] RTCSessionDescriptionCallback successCallback, in [Callback,Optional=DefaultIsUndefined] RTCErrorCallback failureCallback, in [Optional] Dictionary mediaConstraints)
         raises(DOMException);
 
-    void createAnswer(in [Callback] RTCSessionDescriptionCallback successCallback, in [Callback, Optional=DefaultIsUndefined] RTCErrorCallback failureCallback, in [Optional=DefaultIsUndefined] Dictionary mediaConstraints)
+    void createAnswer(in [Callback] RTCSessionDescriptionCallback successCallback, in [Callback, Optional=DefaultIsUndefined] RTCErrorCallback failureCallback, in [Optional] Dictionary mediaConstraints)
         raises(DOMException);
 
     void setLocalDescription(in RTCSessionDescription description, in [Callback, Optional=DefaultIsUndefined] VoidCallback successCallback, in [Callback, Optional=DefaultIsUndefined] RTCErrorCallback failureCallback)
@@ -54,7 +54,7 @@
 
     readonly attribute DOMString readyState;
 
-    void updateIce(in [Optional=DefaultIsUndefined] Dictionary configuration, in [Optional=DefaultIsUndefined] Dictionary mediaConstraints)
+    void updateIce(in [Optional] Dictionary configuration, in [Optional] Dictionary mediaConstraints)
         raises(DOMException);
 
     void addIceCandidate(in RTCIceCandidate candidate)
@@ -65,14 +65,14 @@
     readonly attribute MediaStreamList localStreams;
     readonly attribute MediaStreamList remoteStreams;
 
-    [StrictTypeChecking] void addStream(in MediaStream stream, in [Optional=DefaultIsUndefined] Dictionary mediaConstraints)
+    [StrictTypeChecking] void addStream(in MediaStream stream, in [Optional] Dictionary mediaConstraints)
         raises(DOMException);
     [StrictTypeChecking] void removeStream(in MediaStream stream)
         raises(DOMException);
 
     void getStats(in [Callback] RTCStatsCallback successCallback, in [Optional=DefaultIsUndefined] MediaStreamTrack selector);
 
-    RTCDataChannel createDataChannel(in [TreatNullAs=NullString, TreatUndefinedAs=NullString] DOMString label, in [Optional=DefaultIsUndefined] Dictionary options)
+    RTCDataChannel createDataChannel(in [TreatNullAs=NullString, TreatUndefinedAs=NullString] DOMString label, in [Optional] Dictionary options)
          raises(DOMException);
 
     void close()

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (132697 => 132698)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2012-10-26 21:41:33 UTC (rev 132697)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2012-10-26 21:55:18 UTC (rev 132698)
@@ -2652,10 +2652,13 @@
     $implIncludes{"JSDOMBinding.h"} = 1;
 
     foreach my $parameter (@{$function->parameters}) {
+        my $argType = $codeGenerator->StripModule($parameter->type);
+
         # Optional arguments with [Optional] should generate an early call with fewer arguments.
         # Optional arguments with [Optional=...] should not generate the early call.
+        # Optional Dictionary arguments always considered to have default of empty dictionary.
         my $optional = $parameter->extendedAttributes->{"Optional"};
-        if ($optional && $optional ne "DefaultIsUndefined" && $optional ne "DefaultIsNullString" && !$parameter->extendedAttributes->{"Callback"}) {
+        if ($optional && $optional ne "DefaultIsUndefined" && $optional ne "DefaultIsNullString" && $argType ne "Dictionary" && !$parameter->extendedAttributes->{"Callback"}) {
             # Generate early call if there are enough parameters.
             if (!$hasOptionalArguments) {
                 push(@$outputArray, "\n    size_t argsCount = exec->argumentCount();\n");
@@ -2673,7 +2676,6 @@
         }
 
         my $name = $parameter->name;
-        my $argType = $codeGenerator->StripModule($parameter->type);
 
         if ($argType eq "XPathNSResolver") {
             push(@$outputArray, "    RefPtr<XPathNSResolver> customResolver;\n");

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (132697 => 132698)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-10-26 21:41:33 UTC (rev 132697)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-10-26 21:55:18 UTC (rev 132698)
@@ -1715,13 +1715,13 @@
 
     foreach my $parameter (@{$function->parameters}) {
         TranslateParameter($parameter);
+        my $nativeType = GetNativeTypeFromSignature($parameter, $paramIndex);
 
-        my $parameterName = $parameter->name;
-
         # Optional arguments with [Optional] should generate an early call with fewer arguments.
         # Optional arguments with [Optional=...] should not generate the early call.
+        # Optional Dictionary arguments always considered to have default of empty dictionary.
         my $optional = $parameter->extendedAttributes->{"Optional"};
-        if ($optional && $optional ne "DefaultIsUndefined" && $optional ne "DefaultIsNullString" && !$parameter->extendedAttributes->{"Callback"}) {
+        if ($optional && $optional ne "DefaultIsUndefined" && $optional ne "DefaultIsNullString" && $nativeType ne "Dictionary" && !$parameter->extendedAttributes->{"Callback"}) {
             $parameterCheckString .= "    if (args.Length() <= $paramIndex) {\n";
             my $functionCall = GenerateFunctionCallString($function, $paramIndex, "    " x 2, $implClassName, %replacements);
             $parameterCheckString .= $functionCall;
@@ -1733,6 +1733,7 @@
             $parameterDefaultPolicy = "DefaultIsNullString";
         }
 
+        my $parameterName = $parameter->name;
         if (GetIndexOf($parameterName, @paramTransferListNames) != -1) {
             $replacements{$parameterName} = "messagePortArray" . ucfirst($parameterName);
             $paramIndex++;
@@ -1740,7 +1741,6 @@
         }
 
         AddToImplIncludes("ExceptionCode.h");
-        my $nativeType = GetNativeTypeFromSignature($parameter, $paramIndex);
         if ($parameter->extendedAttributes->{"Callback"}) {
             my $className = GetCallbackClassName($parameter->type);
             AddToImplIncludes("$className.h");

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


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2012-10-26 21:41:33 UTC (rev 132697)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2012-10-26 21:55:18 UTC (rev 132698)
@@ -1636,13 +1636,6 @@
     Dictionary oo(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined));
     if (exec->hadException())
         return JSValue::encode(jsUndefined());
-
-    size_t argsCount = exec->argumentCount();
-    if (argsCount <= 1) {
-        impl->optionsObject(oo);
-        return JSValue::encode(jsUndefined());
-    }
-
     Dictionary ooo(exec, MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined));
     if (exec->hadException())
         return JSValue::encode(jsUndefined());

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (132697 => 132698)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-10-26 21:41:33 UTC (rev 132697)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-10-26 21:55:18 UTC (rev 132698)
@@ -1173,10 +1173,6 @@
     EXCEPTION_BLOCK(Dictionary, oo, Dictionary(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined), args.GetIsolate()));
     if (!oo.isUndefinedOrNull() && !oo.isObject())
         return throwTypeError("Not an object.", args.GetIsolate());
-    if (args.Length() <= 1) {
-        imp->optionsObject(oo);
-        return v8Undefined();
-    }
     EXCEPTION_BLOCK(Dictionary, ooo, Dictionary(MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined), args.GetIsolate()));
     if (!ooo.isUndefinedOrNull() && !ooo.isObject())
         return throwTypeError("Not an object.", args.GetIsolate());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to