[WebIDL] Add support for default parameter values
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Sep 2015 01:48:17 +0000 (01:48 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Sep 2015 01:48:17 +0000 (01:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=149263
<rdar://problem/22545600>

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Rebaseline several W3C tests now that more NodeIterator / TreeWalker
checks are passing.

* web-platform-tests/dom/traversal/NodeIterator-expected.txt:
* web-platform-tests/dom/traversal/TreeWalker-basic-expected.txt:

Source/WebCore:

Add support for default parameter values to our Web IDL parser and JS
bindings generator. This allows the bindings to convert undefined to
the parameter's default value for optional parameters:
https://heycam.github.io/webidl/#dfn-optional-argument-default-value

Previously, our bindings generator would just convert undefined to
0 / false / "undefined" for optional parameters, depending on the
parameter type.

This patch uses the new default parameter support to fix a bug in
document.createNodeIterator() / document.createTreeWalker()'s handling
of the whatToShow parameter:
https://dom.spec.whatwg.org/#document

WebKit currently was undefined to 0 in this case, even though it should
use the parameter's default value: OxFFFFFFFF.

I am planning to go through other optional parameters in a follow-up
patch and add default values where needed.

No new tests, already covered by existing layout tests and
added bindings tests coverage.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateParametersCheck):
* bindings/scripts/IDLParser.pm:
(parseOptionalOrRequiredArgument):
* bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
(webkit_dom_test_obj_method_with_optional_arg_and_default_value):
(webkit_dom_test_obj_method_with_optional_string_and_default_value):
* bindings/scripts/test/GObject/WebKitDOMTestObj.h:
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalArgAndDefaultValue):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalStringAndDefaultValue):
* bindings/scripts/test/ObjC/DOMTestObj.h:
* bindings/scripts/test/ObjC/DOMTestObj.mm:
(-[DOMTestObj methodWithOptionalArgAndDefaultValue:]):
(-[DOMTestObj methodWithOptionalStringAndDefaultValue:]):
* bindings/scripts/test/TestObj.idl:
* dom/Document.idl:

LayoutTests:

Rebaseline several NodeIterator / TreeWalker tests now that more checks
are passing.

* fast/dom/createNodeIterator-parameters-expected.txt:
* fast/dom/createTreeWalker-parameters-expected.txt:

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

16 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/createNodeIterator-parameters-expected.txt
LayoutTests/fast/dom/createTreeWalker-parameters-expected.txt
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/NodeIterator-expected.txt
LayoutTests/imported/w3c/web-platform-tests/dom/traversal/TreeWalker-basic-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLParser.pm
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h
Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm
Source/WebCore/bindings/scripts/test/TestObj.idl
Source/WebCore/dom/Document.idl

index 4baf65c..5b4f9b1 100644 (file)
@@ -1,3 +1,17 @@
+2015-09-17  Chris Dumez  <cdumez@apple.com>
+
+        [WebIDL] Add support for default parameter values
+        https://bugs.webkit.org/show_bug.cgi?id=149263
+        <rdar://problem/22545600>
+
+        Reviewed by Ryosuke Niwa.
+
+        Rebaseline several NodeIterator / TreeWalker tests now that more checks
+        are passing.
+
+        * fast/dom/createNodeIterator-parameters-expected.txt:
+        * fast/dom/createTreeWalker-parameters-expected.txt:
+
 2015-09-17  Saam barati  <sbarati@apple.com>
 
         add a regress test for richards with try/catch.
index a949343..648aef0 100644 (file)
@@ -29,7 +29,7 @@ Passing undefined for optional parameters
 iterator = document.createNodeIterator(document, undefined, undefined)
 PASS iterator.root is document
 PASS iterator.referenceNode is document
-FAIL iterator.whatToShow should be 4294967295. Was 0.
+PASS iterator.whatToShow is 0xFFFFFFFF
 PASS iterator.filter is null
 PASS iterator.pointerBeforeReferenceNode is true
 PASS successfullyParsed is true
index af6448a..c6427b8 100644 (file)
@@ -27,7 +27,7 @@ Passing undefined for optional parameters
 walker = document.createTreeWalker(document, undefined, undefined)
 PASS walker.root is document
 PASS walker.currentNode is document
-FAIL walker.whatToShow should be 4294967295. Was 0.
+PASS walker.whatToShow is 0xFFFFFFFF
 PASS walker.filter is null
 PASS successfullyParsed is true
 
index 3e3c755..17e6fb6 100644 (file)
@@ -1,3 +1,17 @@
+2015-09-17  Chris Dumez  <cdumez@apple.com>
+
+        [WebIDL] Add support for default parameter values
+        https://bugs.webkit.org/show_bug.cgi?id=149263
+        <rdar://problem/22545600>
+
+        Reviewed by Ryosuke Niwa.
+
+        Rebaseline several W3C tests now that more NodeIterator / TreeWalker
+        checks are passing.
+
+        * web-platform-tests/dom/traversal/NodeIterator-expected.txt:
+        * web-platform-tests/dom/traversal/TreeWalker-basic-expected.txt:
+
 2015-09-17  Zalan Bujtas  <zalan@apple.com>
 
         CSS WG multicol-1 tests failures with 1px differences due to baseline difference.
index 8a56d7a..26b7c6a 100644 (file)
@@ -2,7 +2,7 @@
 PASS detach() should be a no-op 
 PASS createNodeIterator() parameter defaults 
 PASS createNodeIterator() with null as arguments 
-FAIL createNodeIterator() with undefined as arguments assert_equals: whatToShow expected 4294967295 but got 0
+PASS createNodeIterator() with undefined as arguments 
 PASS Propagate exception from filter function 
 PASS document.createNodeIterator(paras[0], 0, null) 
 PASS document.createNodeIterator(paras[0], 0, (function(node) { return true })) 
index cb7a767..f9492c9 100644 (file)
@@ -3,7 +3,7 @@ This test checks the basic functionality of TreeWalker.
 
 PASS Construct a TreeWalker by document.createTreeWalker(root). 
 PASS Construct a TreeWalker by document.createTreeWalker(root, null, null). 
-FAIL Construct a TreeWalker by document.createTreeWalker(root, undefined, undefined). assert_equals: whatToShow expected 4294967295 but got 0
+PASS Construct a TreeWalker by document.createTreeWalker(root, undefined, undefined). 
 PASS Give an invalid root node to document.createTreeWalker(). 
 PASS Walk over nodes. 
 PASS Optional arguments to createTreeWalker should be optional (3 passed, null). 
index 3b26314..ddd7a24 100644 (file)
@@ -1,3 +1,52 @@
+2015-09-17  Chris Dumez  <cdumez@apple.com>
+
+        [WebIDL] Add support for default parameter values
+        https://bugs.webkit.org/show_bug.cgi?id=149263
+        <rdar://problem/22545600>
+
+        Reviewed by Ryosuke Niwa.
+
+        Add support for default parameter values to our Web IDL parser and JS
+        bindings generator. This allows the bindings to convert undefined to
+        the parameter's default value for optional parameters:
+        https://heycam.github.io/webidl/#dfn-optional-argument-default-value
+
+        Previously, our bindings generator would just convert undefined to
+        0 / false / "undefined" for optional parameters, depending on the
+        parameter type.
+
+        This patch uses the new default parameter support to fix a bug in
+        document.createNodeIterator() / document.createTreeWalker()'s handling
+        of the whatToShow parameter:
+        https://dom.spec.whatwg.org/#document
+
+        WebKit currently was undefined to 0 in this case, even though it should
+        use the parameter's default value: OxFFFFFFFF.
+
+        I am planning to go through other optional parameters in a follow-up
+        patch and add default values where needed.
+
+        No new tests, already covered by existing layout tests and
+        added bindings tests coverage.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateParametersCheck):
+        * bindings/scripts/IDLParser.pm:
+        (parseOptionalOrRequiredArgument):
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
+        (webkit_dom_test_obj_method_with_optional_arg_and_default_value):
+        (webkit_dom_test_obj_method_with_optional_string_and_default_value):
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.h:
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalArgAndDefaultValue):
+        (WebCore::jsTestObjPrototypeFunctionMethodWithOptionalStringAndDefaultValue):
+        * bindings/scripts/test/ObjC/DOMTestObj.h:
+        * bindings/scripts/test/ObjC/DOMTestObj.mm:
+        (-[DOMTestObj methodWithOptionalArgAndDefaultValue:]):
+        (-[DOMTestObj methodWithOptionalStringAndDefaultValue:]):
+        * bindings/scripts/test/TestObj.idl:
+        * dom/Document.idl:
+
 2015-09-17  Dean Jackson  <dino@apple.com>
 
         Multi-hop reference cycles not detected.
index e8eeebb..e301e80 100644 (file)
@@ -3404,6 +3404,9 @@ sub GenerateParametersCheck
                 if ($optional && $defaultAttribute && $defaultAttribute eq "NullString") {
                     $outer = "exec->argument($argsIndex).isUndefined() ? String() : ";
                     $inner = "exec->uncheckedArgument($argsIndex)";
+                } elsif ($optional && $parameter->default) {
+                    $outer = "exec->argument($argsIndex).isUndefined() ? " . $parameter->default  . " : ";
+                    $inner = "exec->uncheckedArgument($argsIndex)";
                 } else {
                     $outer = "";
                     $inner = "exec->argument($argsIndex)";
index 2c11b42..292a3ed 100644 (file)
@@ -82,6 +82,7 @@ struct( domSignature => {
     isNullable => '$', # Is variable type Nullable (T?)
     isVariadic => '$', # Is variable variadic (long... numbers)
     isOptional => '$', # Is variable optional (optional T)
+    default => '$', # Default value for parameters
 });
 
 # Used to represent string constants
@@ -1433,7 +1434,7 @@ sub parseOptionalOrRequiredArgument
         $paramDataNode->type(identifierRemoveNullablePrefix(typeRemoveNullableSuffix($type)));
         $paramDataNode->isOptional(1);
         $paramDataNode->name($self->parseArgumentName());
-        $self->parseDefault();
+        $paramDataNode->default($self->parseDefault());
         return $paramDataNode;
     }
     if ($next->type() == IdentifierToken || $next->value() =~ /$nextExceptionField_1/) {
index e4feb8b..2ef8767 100644 (file)
@@ -1283,6 +1283,14 @@ void webkit_dom_test_obj_method_with_optional_arg(WebKitDOMTestObj* self, glong
     item->methodWithOptionalArg(opt);
 }
 
+void webkit_dom_test_obj_method_with_optional_arg_and_default_value(WebKitDOMTestObj* self, glong opt)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    WebCore::TestObj* item = WebKit::core(self);
+    item->methodWithOptionalArgAndDefaultValue(opt);
+}
+
 void webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg(WebKitDOMTestObj* self, glong nonOpt, glong opt)
 {
     WebCore::JSMainThreadNullState state;
@@ -1309,6 +1317,16 @@ void webkit_dom_test_obj_method_with_optional_string(WebKitDOMTestObj* self, con
     item->methodWithOptionalString(convertedStr);
 }
 
+void webkit_dom_test_obj_method_with_optional_string_and_default_value(WebKitDOMTestObj* self, const gchar* str)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self));
+    g_return_if_fail(str);
+    WebCore::TestObj* item = WebKit::core(self);
+    WTF::String convertedStr = WTF::String::fromUTF8(str);
+    item->methodWithOptionalStringAndDefaultValue(convertedStr);
+}
+
 void webkit_dom_test_obj_method_with_optional_string_is_undefined(WebKitDOMTestObj* self, const gchar* str)
 {
     WebCore::JSMainThreadNullState state;
index a437944..4577d31 100644 (file)
@@ -384,6 +384,16 @@ WEBKIT_API void
 webkit_dom_test_obj_method_with_optional_arg(WebKitDOMTestObj* self, glong opt);
 
 /**
+ * webkit_dom_test_obj_method_with_optional_arg_and_default_value:
+ * @self: A #WebKitDOMTestObj
+ * @opt: A #glong
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_method_with_optional_arg_and_default_value(WebKitDOMTestObj* self, glong opt);
+
+/**
  * webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg:
  * @self: A #WebKitDOMTestObj
  * @nonOpt: A #glong
@@ -417,6 +427,16 @@ WEBKIT_API void
 webkit_dom_test_obj_method_with_optional_string(WebKitDOMTestObj* self, const gchar* str);
 
 /**
+ * webkit_dom_test_obj_method_with_optional_string_and_default_value:
+ * @self: A #WebKitDOMTestObj
+ * @str: A #gchar
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API void
+webkit_dom_test_obj_method_with_optional_string_and_default_value(WebKitDOMTestObj* self, const gchar* str);
+
+/**
  * webkit_dom_test_obj_method_with_optional_string_is_undefined:
  * @self: A #WebKitDOMTestObj
  * @str: A #gchar
index 1d78a16..c4c5767 100644 (file)
@@ -109,9 +109,11 @@ JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptExecutionC
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptExecutionContextAndScriptStateWithSpaces(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptArgumentsAndCallStack(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArgAndDefaultValue(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalString(JSC::ExecState*);
+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringAndDefaultValue(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringIsUndefined(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringIsNullString(JSC::ExecState*);
 JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithCallbackArg(JSC::ExecState*);
@@ -620,9 +622,11 @@ static const HashTableValue JSTestObjPrototypeTableValues[] =
     { "withScriptExecutionContextAndScriptStateWithSpaces", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptExecutionContextAndScriptStateWithSpaces), (intptr_t) (0) } },
     { "withScriptArgumentsAndCallStack", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptArgumentsAndCallStack), (intptr_t) (0) } },
     { "methodWithOptionalArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalArg), (intptr_t) (0) } },
+    { "methodWithOptionalArgAndDefaultValue", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalArgAndDefaultValue), (intptr_t) (0) } },
     { "methodWithNonOptionalArgAndOptionalArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg), (intptr_t) (1) } },
     { "methodWithNonOptionalArgAndTwoOptionalArgs", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs), (intptr_t) (1) } },
     { "methodWithOptionalString", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalString), (intptr_t) (0) } },
+    { "methodWithOptionalStringAndDefaultValue", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalStringAndDefaultValue), (intptr_t) (0) } },
     { "methodWithOptionalStringIsUndefined", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalStringIsUndefined), (intptr_t) (0) } },
     { "methodWithOptionalStringIsNullString", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalStringIsNullString), (intptr_t) (0) } },
     { "methodWithCallbackArg", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithCallbackArg), (intptr_t) (1) } },
@@ -3529,6 +3533,28 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(Exe
     return JSValue::encode(jsUndefined());
 }
 
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArgAndDefaultValue(ExecState* exec)
+{
+    JSValue thisValue = exec->thisValue();
+    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*exec, "TestObj", "methodWithOptionalArgAndDefaultValue");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& impl = castedThis->impl();
+
+    size_t argsCount = exec->argumentCount();
+    if (argsCount <= 0) {
+        impl.methodWithOptionalArgAndDefaultValue();
+        return JSValue::encode(jsUndefined());
+    }
+
+    int opt = exec->argument(0).isUndefined() ? 666 : toInt32(exec, exec->uncheckedArgument(0), NormalConversion);
+    if (UNLIKELY(exec->hadException()))
+        return JSValue::encode(jsUndefined());
+    impl.methodWithOptionalArgAndDefaultValue(opt);
+    return JSValue::encode(jsUndefined());
+}
+
 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg(ExecState* exec)
 {
     JSValue thisValue = exec->thisValue();
@@ -3613,6 +3639,28 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalString(
     return JSValue::encode(jsUndefined());
 }
 
+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringAndDefaultValue(ExecState* exec)
+{
+    JSValue thisValue = exec->thisValue();
+    JSTestObj* castedThis = jsDynamicCast<JSTestObj*>(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*exec, "TestObj", "methodWithOptionalStringAndDefaultValue");
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto& impl = castedThis->impl();
+
+    size_t argsCount = exec->argumentCount();
+    if (argsCount <= 0) {
+        impl.methodWithOptionalStringAndDefaultValue();
+        return JSValue::encode(jsUndefined());
+    }
+
+    String str = exec->argument(0).isUndefined() ? "foo" : exec->uncheckedArgument(0).toString(exec)->value(exec);
+    if (UNLIKELY(exec->hadException()))
+        return JSValue::encode(jsUndefined());
+    impl.methodWithOptionalStringAndDefaultValue(str);
+    return JSValue::encode(jsUndefined());
+}
+
 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalStringIsUndefined(ExecState* exec)
 {
     JSValue thisValue = exec->thisValue();
index 16bac31..85f6eb9 100644 (file)
@@ -151,9 +151,11 @@ WEBCORE_EXPORT @interface DOMTestObj : DOMObject
 - (DOMTestObj *)withScriptExecutionContextAndScriptStateWithSpaces;
 - (void)withScriptArgumentsAndCallStack;
 - (void)methodWithOptionalArg:(int)opt;
+- (void)methodWithOptionalArgAndDefaultValue:(int)opt;
 - (void)methodWithNonOptionalArgAndOptionalArg:(int)nonOpt opt:(int)opt;
 - (void)methodWithNonOptionalArgAndTwoOptionalArgs:(int)nonOpt opt1:(int)opt1 opt2:(int)opt2;
 - (void)methodWithOptionalString:(NSString *)str;
+- (void)methodWithOptionalStringAndDefaultValue:(NSString *)str;
 - (void)methodWithOptionalStringIsUndefined:(NSString *)str;
 - (void)methodWithOptionalStringIsNullString:(NSString *)str;
 - (void)classMethod;
index 2a95535..668dfca 100644 (file)
     IMPL->methodWithOptionalArg(opt);
 }
 
+- (void)methodWithOptionalArgAndDefaultValue:(int)opt
+{
+    WebCore::JSMainThreadNullState state;
+    IMPL->methodWithOptionalArgAndDefaultValue(opt);
+}
+
 - (void)methodWithNonOptionalArgAndOptionalArg:(int)nonOpt opt:(int)opt
 {
     WebCore::JSMainThreadNullState state;
     IMPL->methodWithOptionalString(str);
 }
 
+- (void)methodWithOptionalStringAndDefaultValue:(NSString *)str
+{
+    WebCore::JSMainThreadNullState state;
+    IMPL->methodWithOptionalStringAndDefaultValue(str);
+}
+
 - (void)methodWithOptionalStringIsUndefined:(NSString *)str
 {
     WebCore::JSMainThreadNullState state;
index c1ff8ba..cc9e700 100644 (file)
@@ -140,11 +140,13 @@ enum _optional { "", "OptionalValue1", "OptionalValue2", "OptionalValue3" };
     [CallWith=  ScriptExecutionContext  &  ScriptState  ] attribute TestObj withScriptExecutionContextAndScriptStateWithSpacesAttribute;
     [CallWith=ScriptArguments&CallStack] attribute TestObj withScriptArgumentsAndCallStackAttribute;
 
-    // 'Optional' extended attribute
+    // Optional parameters.
     void    methodWithOptionalArg(optional long opt);
+    void    methodWithOptionalArgAndDefaultValue(optional long opt = 666);
     void    methodWithNonOptionalArgAndOptionalArg(long nonOpt, optional long opt);
     void    methodWithNonOptionalArgAndTwoOptionalArgs(long nonOpt, optional long opt1, optional long opt2);
     void    methodWithOptionalString(optional DOMString str);
+    void    methodWithOptionalStringAndDefaultValue(optional DOMString str = "foo");
     void    methodWithOptionalStringIsUndefined([Default=Undefined] optional DOMString str);
     void    methodWithOptionalStringIsNullString([Default=NullString] optional DOMString str);
 
index dfd7d7a..81b10ae 100644 (file)
     // DOM Level 2 Tranversal and Range (DocumentTraversal interface)
 
     [ObjCLegacyUnnamedParameters, RaisesException, NewObject] NodeIterator createNodeIterator(Node root,
-        optional unsigned long whatToShow,
+        optional unsigned long whatToShow = 0xFFFFFFFF,
         optional NodeFilter? filter,
         optional boolean expandEntityReferences);
     [ObjCLegacyUnnamedParameters, RaisesException, NewObject] TreeWalker createTreeWalker(Node root,
-        optional unsigned long whatToShow,
+        optional unsigned long whatToShow = 0xFFFFFFFF,
         optional NodeFilter? filter,
         optional boolean expandEntityReferences);