Commit 18d2e414 authored by haraken@chromium.org's avatar haraken@chromium.org

Rename [Optional=CallWithDefaultValue] and [Optional=CallWithNullValue]

https://bugs.webkit.org/show_bug.cgi?id=78200

Reviewed by Adam Barth.

[Optional=CallWithDefaultValue] and [Optional=CallWithNullValue] are confusing.

- [Optional=CallWithDefaultValue] indicates that a missing value should be treated
as if the JavaScript undefined is passed.
- [Optional=CallWithNullValue] indicates that a missing value should be treated as
the WebKit null value (i.e. JSValue() or v8::Local<v8::Value>()).
- Actually, the difference between [Optional=CallWithDefaultValue] and
[Optional=CallWithNullValue] will appear only when the type of the missing value
is DOMString. In case of [Optional=CallWithDefaultValue], the missing value is
converted to the string "undefined". On the other hand, in case of
[Optional=CallWithNullValue], the missing value is converted to the WebKit null string.

With these observations, this patch renames as follows:

- Rename [Optional=CallWithDefaultValue] to [Optional=DefaultIsUndefined].
- Rename [Optional=CallWithNullValue] to [Optional=DefaultIsNullString].

Test: bindings/scripts/test/TestObj.idl

* bindings/js/JSDOMBinding.h: Renamed MissingIsEmpty to DefaultIsNullString,
renamed MissingIsUndefined to DefaultIsUndefined.
* bindings/v8/V8Binding.h: Ditto.
* bindings/v8/custom/V8BindingMacros.h: Ditto.

* bindings/scripts/CodeGeneratorJS.pm: Modified to support the renaming.
(GenerateParametersCheck):
* bindings/scripts/CodeGeneratorV8.pm: Ditto.
(GenerateParametersCheck):
(RequiresCustomSignature):

* bindings/scripts/test/TestObj.idl: Renamed [Optional=...] as described above.
* bindings/scripts/test/TestInterface.idl: Ditto.
* bindings/scripts/test/TestNamedConstructor.idl: Ditto.

* bindings/scripts/test/CPP/WebDOMTestObj.cpp: Updated run-bindings-tests results.
(WebDOMTestObj::methodWithOptionalString):
(WebDOMTestObj::methodWithOptionalStringIsUndefinedString):
(WebDOMTestObj::methodWithOptionalStringIsNullString):
* bindings/scripts/test/CPP/WebDOMTestObj.h:
* bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
(webkit_dom_test_obj_method_with_optional_string):
(webkit_dom_test_obj_method_with_optional_string_is_undefined_string):
(webkit_dom_test_obj_method_with_optional_string_is_null_string):
* bindings/scripts/test/GObject/WebKitDOMTestObj.h:
* bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
(WebCore::JSTestNamedConstructorNamedConstructor::constructJSTestNamedConstructor):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalString):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalStringIsUndefinedString):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalStringIsNullString):
* bindings/scripts/test/JS/JSTestObj.h:
(WebCore):
* bindings/scripts/test/ObjC/DOMTestObj.h:
* bindings/scripts/test/ObjC/DOMTestObj.mm:
(-[DOMTestObj methodWithOptionalString:]):
(-[DOMTestObj methodWithOptionalStringIsUndefinedString:]):
(-[DOMTestObj methodWithOptionalStringIsNullString:]):
* bindings/scripts/test/V8/V8TestNamedConstructor.cpp:
(WebCore::V8TestNamedConstructorConstructorCallback):
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore::TestObjInternal::methodWithOptionalStringCallback):
(TestObjInternal):
(WebCore::TestObjInternal::methodWithOptionalStringIsUndefinedStringCallback):
(WebCore::TestObjInternal::methodWithOptionalStringIsNullStringCallback):
(WebCore):

* Modules/gamepad/GamepadList.idl: Renamed [Optional=...] as described above.
* Modules/intents/Intent.idl:
* css/CSSMediaRule.idl:
* css/CSSPrimitiveValue.idl:
* css/CSSRuleList.idl:
* css/CSSStyleDeclaration.idl:
* css/CSSStyleSheet.idl:
* css/CSSValueList.idl:
* css/MediaList.idl:
* css/MediaQueryList.idl:
* css/MediaQueryListListener.idl:
* css/StyleMedia.idl:
* css/StyleSheetList.idl:
* css/WebKitCSSKeyframesRule.idl:
* css/WebKitCSSMatrix.idl:
* dom/CharacterData.idl:
* dom/ClientRectList.idl:
* dom/CompositionEvent.idl:
* dom/CustomEvent.idl:
* dom/DOMImplementation.idl:
* dom/DOMStringList.idl:
* dom/DataTransferItem.idl:
* dom/DataTransferItemList.idl:
* dom/DeviceMotionEvent.idl:
* dom/DeviceOrientationEvent.idl:
* dom/Document.idl:
* dom/Element.idl:
* dom/Event.idl:
* dom/HashChangeEvent.idl:
* dom/KeyboardEvent.idl:
* dom/MessageEvent.idl:
* dom/MouseEvent.idl:
* dom/MutationEvent.idl:
* dom/NamedNodeMap.idl:
* dom/Node.idl:
* dom/NodeFilter.idl:
* dom/NodeList.idl:
* dom/OverflowEvent.idl:
* dom/Range.idl:
* dom/ShadowRoot.idl:
* dom/Text.idl:
* dom/TextEvent.idl:
* dom/TouchEvent.idl:
* dom/UIEvent.idl:
* dom/WheelEvent.idl:
* html/DOMFormData.idl:
* html/HTMLAllCollection.idl:
* html/HTMLAudioElement.idl:
* html/HTMLCanvasElement.idl:
* html/HTMLCollection.idl:
* html/HTMLDocument.idl:
* html/HTMLElement.idl:
* html/HTMLInputElement.idl:
* html/HTMLMediaElement.idl:
* html/HTMLOptionElement.idl:
* html/HTMLOptionsCollection.idl:
* html/HTMLSelectElement.idl:
* html/HTMLTableElement.idl:
* html/HTMLTableRowElement.idl:
* html/HTMLTableSectionElement.idl:
* html/HTMLTextAreaElement.idl:
* html/TextTrackCue.idl:
* html/canvas/CanvasGradient.idl:
* html/canvas/CanvasRenderingContext2D.idl:
* html/canvas/Float32Array.idl:
* html/canvas/Float64Array.idl:
* html/canvas/Int16Array.idl:
* html/canvas/Int32Array.idl:
* html/canvas/Int8Array.idl:
* html/canvas/OESVertexArrayObject.idl:
* html/canvas/Uint16Array.idl:
* html/canvas/Uint32Array.idl:
* html/canvas/Uint8Array.idl:
* html/canvas/Uint8ClampedArray.idl:
* page/Console.idl:
* page/DOMSelection.idl:
* page/DOMWindow.idl:
* page/History.idl:
* page/Location.idl:
* plugins/DOMMimeTypeArray.idl:
* plugins/DOMPlugin.idl:
* plugins/DOMPluginArray.idl:
* storage/IDBDatabase.idl:
* storage/StorageEvent.idl:
* svg/ElementTimeControl.idl:
* svg/SVGDocument.idl:
* svg/SVGElementInstanceList.idl:
* svg/SVGFEDropShadowElement.idl:
* svg/SVGFEGaussianBlurElement.idl:
* svg/SVGFEMorphologyElement.idl:
* svg/SVGFilterElement.idl:
* svg/SVGLocatable.idl:
* svg/SVGMarkerElement.idl:
* svg/SVGPathElement.idl:
* svg/SVGSVGElement.idl:
* svg/SVGStylable.idl:
* svg/SVGTests.idl:
* svg/SVGTextContentElement.idl:
* webaudio/AudioNode.idl:
* workers/SharedWorker.idl:
* workers/WorkerContext.idl:
* xml/DOMParser.idl:
* xml/XMLSerializer.idl:
* xml/XPathEvaluator.idl:
* xml/XPathExpression.idl:
* xml/XPathNSResolver.idl:
* xml/XPathResult.idl:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@107304 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ea6c3e32
2012-02-09 Kentaro Hara <haraken@chromium.org>
Rename [Optional=CallWithDefaultValue] and [Optional=CallWithNullValue]
https://bugs.webkit.org/show_bug.cgi?id=78200
Reviewed by Adam Barth.
[Optional=CallWithDefaultValue] and [Optional=CallWithNullValue] are confusing.
- [Optional=CallWithDefaultValue] indicates that a missing value should be treated
as if the JavaScript undefined is passed.
- [Optional=CallWithNullValue] indicates that a missing value should be treated as
the WebKit null value (i.e. JSValue() or v8::Local<v8::Value>()).
- Actually, the difference between [Optional=CallWithDefaultValue] and
[Optional=CallWithNullValue] will appear only when the type of the missing value
is DOMString. In case of [Optional=CallWithDefaultValue], the missing value is
converted to the string "undefined". On the other hand, in case of
[Optional=CallWithNullValue], the missing value is converted to the WebKit null string.
With these observations, this patch renames as follows:
- Rename [Optional=CallWithDefaultValue] to [Optional=DefaultIsUndefined].
- Rename [Optional=CallWithNullValue] to [Optional=DefaultIsNullString].
Test: bindings/scripts/test/TestObj.idl
* bindings/js/JSDOMBinding.h: Renamed MissingIsEmpty to DefaultIsNullString,
renamed MissingIsUndefined to DefaultIsUndefined.
* bindings/v8/V8Binding.h: Ditto.
* bindings/v8/custom/V8BindingMacros.h: Ditto.
* bindings/scripts/CodeGeneratorJS.pm: Modified to support the renaming.
(GenerateParametersCheck):
* bindings/scripts/CodeGeneratorV8.pm: Ditto.
(GenerateParametersCheck):
(RequiresCustomSignature):
* bindings/scripts/test/TestObj.idl: Renamed [Optional=...] as described above.
* bindings/scripts/test/TestInterface.idl: Ditto.
* bindings/scripts/test/TestNamedConstructor.idl: Ditto.
* bindings/scripts/test/CPP/WebDOMTestObj.cpp: Updated run-bindings-tests results.
(WebDOMTestObj::methodWithOptionalString):
(WebDOMTestObj::methodWithOptionalStringIsUndefinedString):
(WebDOMTestObj::methodWithOptionalStringIsNullString):
* bindings/scripts/test/CPP/WebDOMTestObj.h:
* bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
(webkit_dom_test_obj_method_with_optional_string):
(webkit_dom_test_obj_method_with_optional_string_is_undefined_string):
(webkit_dom_test_obj_method_with_optional_string_is_null_string):
* bindings/scripts/test/GObject/WebKitDOMTestObj.h:
* bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
(WebCore::JSTestNamedConstructorNamedConstructor::constructJSTestNamedConstructor):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalString):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalStringIsUndefinedString):
(WebCore::jsTestObjPrototypeFunctionMethodWithOptionalStringIsNullString):
* bindings/scripts/test/JS/JSTestObj.h:
(WebCore):
* bindings/scripts/test/ObjC/DOMTestObj.h:
* bindings/scripts/test/ObjC/DOMTestObj.mm:
(-[DOMTestObj methodWithOptionalString:]):
(-[DOMTestObj methodWithOptionalStringIsUndefinedString:]):
(-[DOMTestObj methodWithOptionalStringIsNullString:]):
* bindings/scripts/test/V8/V8TestNamedConstructor.cpp:
(WebCore::V8TestNamedConstructorConstructorCallback):
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore::TestObjInternal::methodWithOptionalStringCallback):
(TestObjInternal):
(WebCore::TestObjInternal::methodWithOptionalStringIsUndefinedStringCallback):
(WebCore::TestObjInternal::methodWithOptionalStringIsNullStringCallback):
(WebCore):
* Modules/gamepad/GamepadList.idl: Renamed [Optional=...] as described above.
* Modules/intents/Intent.idl:
* css/CSSMediaRule.idl:
* css/CSSPrimitiveValue.idl:
* css/CSSRuleList.idl:
* css/CSSStyleDeclaration.idl:
* css/CSSStyleSheet.idl:
* css/CSSValueList.idl:
* css/MediaList.idl:
* css/MediaQueryList.idl:
* css/MediaQueryListListener.idl:
* css/StyleMedia.idl:
* css/StyleSheetList.idl:
* css/WebKitCSSKeyframesRule.idl:
* css/WebKitCSSMatrix.idl:
* dom/CharacterData.idl:
* dom/ClientRectList.idl:
* dom/CompositionEvent.idl:
* dom/CustomEvent.idl:
* dom/DOMImplementation.idl:
* dom/DOMStringList.idl:
* dom/DataTransferItem.idl:
* dom/DataTransferItemList.idl:
* dom/DeviceMotionEvent.idl:
* dom/DeviceOrientationEvent.idl:
* dom/Document.idl:
* dom/Element.idl:
* dom/Event.idl:
* dom/HashChangeEvent.idl:
* dom/KeyboardEvent.idl:
* dom/MessageEvent.idl:
* dom/MouseEvent.idl:
* dom/MutationEvent.idl:
* dom/NamedNodeMap.idl:
* dom/Node.idl:
* dom/NodeFilter.idl:
* dom/NodeList.idl:
* dom/OverflowEvent.idl:
* dom/Range.idl:
* dom/ShadowRoot.idl:
* dom/Text.idl:
* dom/TextEvent.idl:
* dom/TouchEvent.idl:
* dom/UIEvent.idl:
* dom/WheelEvent.idl:
* html/DOMFormData.idl:
* html/HTMLAllCollection.idl:
* html/HTMLAudioElement.idl:
* html/HTMLCanvasElement.idl:
* html/HTMLCollection.idl:
* html/HTMLDocument.idl:
* html/HTMLElement.idl:
* html/HTMLInputElement.idl:
* html/HTMLMediaElement.idl:
* html/HTMLOptionElement.idl:
* html/HTMLOptionsCollection.idl:
* html/HTMLSelectElement.idl:
* html/HTMLTableElement.idl:
* html/HTMLTableRowElement.idl:
* html/HTMLTableSectionElement.idl:
* html/HTMLTextAreaElement.idl:
* html/TextTrackCue.idl:
* html/canvas/CanvasGradient.idl:
* html/canvas/CanvasRenderingContext2D.idl:
* html/canvas/Float32Array.idl:
* html/canvas/Float64Array.idl:
* html/canvas/Int16Array.idl:
* html/canvas/Int32Array.idl:
* html/canvas/Int8Array.idl:
* html/canvas/OESVertexArrayObject.idl:
* html/canvas/Uint16Array.idl:
* html/canvas/Uint32Array.idl:
* html/canvas/Uint8Array.idl:
* html/canvas/Uint8ClampedArray.idl:
* page/Console.idl:
* page/DOMSelection.idl:
* page/DOMWindow.idl:
* page/History.idl:
* page/Location.idl:
* plugins/DOMMimeTypeArray.idl:
* plugins/DOMPlugin.idl:
* plugins/DOMPluginArray.idl:
* storage/IDBDatabase.idl:
* storage/StorageEvent.idl:
* svg/ElementTimeControl.idl:
* svg/SVGDocument.idl:
* svg/SVGElementInstanceList.idl:
* svg/SVGFEDropShadowElement.idl:
* svg/SVGFEGaussianBlurElement.idl:
* svg/SVGFEMorphologyElement.idl:
* svg/SVGFilterElement.idl:
* svg/SVGLocatable.idl:
* svg/SVGMarkerElement.idl:
* svg/SVGPathElement.idl:
* svg/SVGSVGElement.idl:
* svg/SVGStylable.idl:
* svg/SVGTests.idl:
* svg/SVGTextContentElement.idl:
* webaudio/AudioNode.idl:
* workers/SharedWorker.idl:
* workers/WorkerContext.idl:
* xml/DOMParser.idl:
* xml/XMLSerializer.idl:
* xml/XPathEvaluator.idl:
* xml/XPathExpression.idl:
* xml/XPathNSResolver.idl:
* xml/XPathResult.idl:
2012-02-09 Matthew Delaney <mdelaney@apple.com>
getComputedStyle() returns different values for different zoom levels
......@@ -30,7 +30,7 @@ module dom {
IndexedGetter
] GamepadList {
readonly attribute unsigned long length;
Gamepad item(in [Optional=CallWithDefaultValue] unsigned long index);
Gamepad item(in [Optional=DefaultIsUndefined] unsigned long index);
};
}
......@@ -26,7 +26,7 @@
module window {
interface [
Conditional=WEB_INTENTS,
Constructor(in DOMString action, in DOMString type, in [Optional=CallWithNullValue] SerializedScriptValue data),
Constructor(in DOMString action, in DOMString type, in [Optional=DefaultIsNullString] SerializedScriptValue data),
ConstructorRaisesException
] Intent {
readonly attribute DOMString action;
......
......@@ -41,12 +41,12 @@
namespace WebCore {
enum ParameterMissingPolicy {
MissingIsUndefined,
MissingIsEmpty
enum ParameterDefaultPolicy {
DefaultIsUndefined,
DefaultIsNullString
};
#define MAYBE_MISSING_PARAMETER(exec, index, policy) (((policy) == MissingIsEmpty && (index) >= (exec)->argumentCount()) ? (JSValue()) : ((exec)->argument(index)))
#define MAYBE_MISSING_PARAMETER(exec, index, policy) (((policy) == DefaultIsNullString && (index) >= (exec)->argumentCount()) ? (JSValue()) : ((exec)->argument(index)))
class Frame;
class KURL;
......
......@@ -2427,12 +2427,10 @@ sub GenerateParametersCheck
$implIncludes{"JSDOMBinding.h"} = 1;
foreach my $parameter (@{$function->parameters}) {
# Optional callbacks should be treated differently, because they always have a default value (0),
# and we can reduce the number of overloaded functions that take a different number of parameters.
# Optional arguments with [Optional=CallWithDefaultValue] or [Optional=CallWithNullValue]
# should not generate an early call.
# Optional arguments with [Optional] should generate an early call with fewer arguments.
# Optional arguments with [Optional=...] should not generate the early call.
my $optional = $parameter->extendedAttributes->{"Optional"};
if ($optional && $optional ne "CallWithDefaultValue" && $optional ne "CallWithNullValue" && !$parameter->extendedAttributes->{"Callback"}) {
if ($optional && $optional ne "DefaultIsUndefined" && $optional ne "DefaultIsNullString" && !$parameter->extendedAttributes->{"Callback"}) {
# Generate early call if there are enough parameters.
if (!$hasOptionalArguments) {
push(@$outputArray, "\n size_t argsCount = exec->argumentCount();\n");
......@@ -2467,7 +2465,7 @@ sub GenerateParametersCheck
} elsif ($parameter->extendedAttributes->{"Callback"}) {
my $callbackClassName = GetCallbackClassName($argType);
$implIncludes{"$callbackClassName.h"} = 1;
if ($parameter->extendedAttributes->{"Optional"}) {
if ($optional) {
push(@$outputArray, " RefPtr<$argType> $name;\n");
push(@$outputArray, " if (exec->argumentCount() > $argsIndex && !exec->argument($argsIndex).isUndefinedOrNull()) {\n");
push(@$outputArray, " if (!exec->argument($argsIndex).isObject()) {\n");
......@@ -2499,13 +2497,12 @@ sub GenerateParametersCheck
}
}
my $optional = $parameter->extendedAttributes->{"Optional"};
my $parameterMissingPolicy = "MissingIsUndefined";
if ($optional && $optional eq "CallWithNullValue") {
$parameterMissingPolicy = "MissingIsEmpty";
my $parameterDefaultPolicy = "DefaultIsUndefined";
if ($optional and $optional eq "DefaultIsNullString") {
$parameterDefaultPolicy = "DefaultIsNullString";
}
push(@$outputArray, " " . GetNativeTypeFromSignature($parameter) . " $name(" . JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(exec, $argsIndex, $parameterMissingPolicy)") . ");\n");
push(@$outputArray, " " . GetNativeTypeFromSignature($parameter) . " $name(" . JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(exec, $argsIndex, $parameterDefaultPolicy)") . ");\n");
# If a parameter is "an index" and it's negative it should throw an INDEX_SIZE_ERR exception.
# But this needs to be done in the bindings, because the type is unsigned and the fact that it
......
......@@ -1526,21 +1526,19 @@ sub GenerateParametersCheck
my $parameterName = $parameter->name;
# Optional callbacks should be treated differently, because they always have a default value (0),
# and we can reduce the number of overloaded functions that take a different number of parameters.
# Optional arguments with default values [Optional=CallWithDefaultValue] or [Optional=CallWithNullValue] should not generate an early call.
my $optional = $parameter->extendedAttributes->{"Optional"};
if ($optional && $optional ne "CallWithDefaultValue" && $optional ne "CallWithNullValue" && !$parameter->extendedAttributes->{"Callback"}) {
# Generate early call if there are not enough parameters.
# Optional arguments with [Optional] should generate an early call with fewer arguments.
# Optional arguments with [Optional=...] should not generate the early call.
my $optional = $parameter->extendedAttributes->{"Optional"};
if ($optional && $optional ne "DefaultIsUndefined" && $optional ne "DefaultIsNullString" && !$parameter->extendedAttributes->{"Callback"}) {
$parameterCheckString .= " if (args.Length() <= $paramIndex) {\n";
my $functionCall = GenerateFunctionCallString($function, $paramIndex, " " x 2, $implClassName);
$parameterCheckString .= $functionCall;
$parameterCheckString .= " }\n";
}
my $parameterMissingPolicy = "MissingIsUndefined";
if ($optional && $optional eq "CallWithNullValue") {
$parameterMissingPolicy = "MissingIsEmpty";
my $parameterDefaultPolicy = "DefaultIsUndefined";
if ($optional and $optional eq "DefaultIsNullString") {
$parameterDefaultPolicy = "DefaultIsNullString";
}
AddToImplIncludes("ExceptionCode.h");
......@@ -1548,7 +1546,7 @@ sub GenerateParametersCheck
if ($parameter->extendedAttributes->{"Callback"}) {
my $className = GetCallbackClassName($parameter->type);
AddToImplIncludes("$className.h");
if ($parameter->extendedAttributes->{"Optional"}) {
if ($optional) {
$parameterCheckString .= " RefPtr<" . $parameter->type . "> $parameterName;\n";
$parameterCheckString .= " if (args.Length() > $paramIndex && !args[$paramIndex]->IsNull() && !args[$paramIndex]->IsUndefined()) {\n";
$parameterCheckString .= " if (!args[$paramIndex]->IsObject())\n";
......@@ -1574,7 +1572,7 @@ sub GenerateParametersCheck
$parameterCheckString .= " goto fail;\n";
$parameterCheckString .= " }\n";
} elsif ($nativeType =~ /^V8Parameter/) {
my $value = JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(args, $paramIndex, $parameterMissingPolicy)");
my $value = JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(args, $paramIndex, $parameterDefaultPolicy)");
$parameterCheckString .= " " . ConvertToV8Parameter($parameter, $nativeType, $parameterName, $value) . "\n";
} else {
AddToImplIncludes("V8BindingMacros.h");
......@@ -1595,7 +1593,7 @@ sub GenerateParametersCheck
}
}
$parameterCheckString .= " EXCEPTION_BLOCK($nativeType, $parameterName, " .
JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(args, $paramIndex, $parameterMissingPolicy)") . ");\n";
JSValueToNative($parameter, "MAYBE_MISSING_PARAMETER(args, $paramIndex, $parameterDefaultPolicy)") . ");\n";
if ($nativeType eq 'OptionsObject') {
$parameterCheckString .= " if (args.Length() > $paramIndex && !$parameterName.isUndefinedOrNull() && !$parameterName.isObject()) {\n";
$parameterCheckString .= " ec = TYPE_MISMATCH_ERR;\n";
......@@ -3599,7 +3597,7 @@ sub RequiresCustomSignature
}
foreach my $parameter (@{$function->parameters}) {
my $optional = $parameter->extendedAttributes->{"Optional"};
if (($optional && $optional ne "CallWithDefaultValue" && $optional ne "CallWithNullValue") || $parameter->extendedAttributes->{"Callback"}) {
if (($optional && $optional ne "DefaultIsUndefined" && $optional ne "DefaultIsNullString") || $parameter->extendedAttributes->{"Callback"}) {
return 0;
}
}
......
......@@ -943,6 +943,30 @@ void WebDOMTestObj::methodWithNonOptionalArgAndTwoOptionalArgs(int nonOpt, int o
impl()->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2);
}
void WebDOMTestObj::methodWithOptionalString(const WebDOMString& str)
{
if (!impl())
return;
impl()->methodWithOptionalString(str);
}
void WebDOMTestObj::methodWithOptionalStringIsUndefined(const WebDOMString& str)
{
if (!impl())
return;
impl()->methodWithOptionalStringIsUndefined(str);
}
void WebDOMTestObj::methodWithOptionalStringIsNullString(const WebDOMString& str)
{
if (!impl())
return;
impl()->methodWithOptionalStringIsNullString(str);
}
#if ENABLE(Condition1)
WebDOMString WebDOMTestObj::conditionalMethod1()
......
......@@ -186,6 +186,9 @@ public:
void methodWithOptionalArg(int opt);
void methodWithNonOptionalArgAndOptionalArg(int nonOpt, int opt);
void methodWithNonOptionalArgAndTwoOptionalArgs(int nonOpt, int opt1, int opt2);
void methodWithOptionalString(const WebDOMString& str);
void methodWithOptionalStringIsUndefined(const WebDOMString& str);
void methodWithOptionalStringIsNullString(const WebDOMString& str);
WebDOMString conditionalMethod1();
void conditionalMethod2();
void conditionalMethod3();
......
......@@ -334,6 +334,39 @@ webkit_dom_test_obj_method_with_non_optional_arg_and_two_optional_args(WebKitDOM
item->methodWithNonOptionalArgAndTwoOptionalArgs(non_opt, opt1, opt2);
}
void
webkit_dom_test_obj_method_with_optional_string(WebKitDOMTestObj* self, const gchar* str)
{
g_return_if_fail(self);
WebCore::JSMainThreadNullState state;
WebCore::TestObj * item = WebKit::core(self);
g_return_if_fail(str);
WTF::String converted_str = WTF::String::fromUTF8(str);
item->methodWithOptionalString(converted_str);
}
void
webkit_dom_test_obj_method_with_optional_string_is_undefined(WebKitDOMTestObj* self, const gchar* str)
{
g_return_if_fail(self);
WebCore::JSMainThreadNullState state;
WebCore::TestObj * item = WebKit::core(self);
g_return_if_fail(str);
WTF::String converted_str = WTF::String::fromUTF8(str);
item->methodWithOptionalStringIsUndefined(converted_str);
}
void
webkit_dom_test_obj_method_with_optional_string_is_null_string(WebKitDOMTestObj* self, const gchar* str)
{
g_return_if_fail(self);
WebCore::JSMainThreadNullState state;
WebCore::TestObj * item = WebKit::core(self);
g_return_if_fail(str);
WTF::String converted_str = WTF::String::fromUTF8(str);
item->methodWithOptionalStringIsNullString(converted_str);
}
gchar*
webkit_dom_test_obj_conditional_method1(WebKitDOMTestObj* self)
{
......
......@@ -261,6 +261,39 @@ webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg(WebKitDOMTestO
WEBKIT_API void
webkit_dom_test_obj_method_with_non_optional_arg_and_two_optional_args(WebKitDOMTestObj* self, glong non_opt, glong opt1, glong opt2);
/**
* webkit_dom_test_obj_method_with_optional_string:
* @self: A #WebKitDOMTestObj
* @str: A #gchar
*
* Returns:
*
**/
WEBKIT_API void
webkit_dom_test_obj_method_with_optional_string(WebKitDOMTestObj* self, const gchar* str);
/**
* webkit_dom_test_obj_method_with_optional_string_is_undefined:
* @self: A #WebKitDOMTestObj
* @str: A #gchar
*
* Returns:
*
**/
WEBKIT_API void
webkit_dom_test_obj_method_with_optional_string_is_undefined(WebKitDOMTestObj* self, const gchar* str);
/**
* webkit_dom_test_obj_method_with_optional_string_is_null_string:
* @self: A #WebKitDOMTestObj
* @str: A #gchar
*
* Returns:
*
**/
WEBKIT_API void
webkit_dom_test_obj_method_with_optional_string_is_null_string(WebKitDOMTestObj* self, const gchar* str);
/**
* webkit_dom_test_obj_conditional_method1:
* @self: A #WebKitDOMTestObj
......
......@@ -235,7 +235,7 @@ EncodedJSValue JSC_HOST_CALL jsFloat64ArrayPrototypeFunctionFoo(ExecState* exec)
Float64Array* impl = static_cast<Float64Array*>(castedThis->impl());
if (exec->argumentCount() < 1)
return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
Float32Array* array(toFloat32Array(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
Float32Array* array(toFloat32Array(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
......
......@@ -186,7 +186,7 @@ EncodedJSValue JSC_HOST_CALL jsTestActiveDOMObjectPrototypeFunctionExcitingFunct
TestActiveDOMObject* impl = static_cast<TestActiveDOMObject*>(castedThis->impl());
if (exec->argumentCount() < 1)
return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
Node* nextChild(toNode(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
Node* nextChild(toNode(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
impl->excitingFunction(nextChild);
......@@ -203,7 +203,7 @@ EncodedJSValue JSC_HOST_CALL jsTestActiveDOMObjectPrototypeFunctionPostMessage(E
TestActiveDOMObject* impl = static_cast<TestActiveDOMObject*>(castedThis->impl());
if (exec->argumentCount() < 1)
return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
const String& message(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)->value(exec)));
const String& message(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
impl->postMessage(message);
......
......@@ -176,7 +176,7 @@ EncodedJSValue JSC_HOST_CALL jsTestCustomNamedGetterPrototypeFunctionAnotherFunc
TestCustomNamedGetter* impl = static_cast<TestCustomNamedGetter*>(castedThis->impl());
if (exec->argumentCount() < 1)
return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
const String& str(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)->value(exec)));
const String& str(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
impl->anotherFunction(str);
......
......@@ -231,7 +231,7 @@ EncodedJSValue JSC_HOST_CALL jsTestEventTargetPrototypeFunctionItem(ExecState* e
TestEventTarget* impl = static_cast<TestEventTarget*>(castedThis->impl());
if (exec->argumentCount() < 1)
return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
int index(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toUInt32(exec));
int index(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toUInt32(exec));
if (index < 0) {
setDOMException(exec, INDEX_SIZE_ERR);
return JSValue::encode(jsUndefined());
......@@ -288,7 +288,7 @@ EncodedJSValue JSC_HOST_CALL jsTestEventTargetPrototypeFunctionDispatchEvent(Exe
if (exec->argumentCount() < 1)
return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
ExceptionCode ec = 0;
Event* evt(toEvent(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined)));
Event* evt(toEvent(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
......
......@@ -118,10 +118,10 @@ EncodedJSValue JSC_HOST_CALL JSTestInterfaceConstructor::constructJSTestInterfac
if (exec->argumentCount() < 1)
return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
ExceptionCode ec = 0;
const String& str1(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)->value(exec)));
const String& str1(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
const String& str2(ustringToString(MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined).toString(exec)->value(exec)));
const String& str2(ustringToString(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined).toString(exec)->value(exec)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
ScriptExecutionContext* context = jsConstructor->scriptExecutionContext();
......@@ -323,10 +323,10 @@ EncodedJSValue JSC_HOST_CALL jsTestInterfacePrototypeFunctionSupplementalMethod2
ScriptExecutionContext* scriptContext = static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->scriptExecutionContext();
if (!scriptContext)
return JSValue::encode(jsUndefined());
const String& strArg(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)->value(exec)));
const String& strArg(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
TestObj* objArg(toTestObj(MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined)));
TestObj* objArg(toTestObj(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
......
......@@ -166,7 +166,7 @@ EncodedJSValue JSC_HOST_CALL jsTestMediaQueryListListenerPrototypeFunctionMethod
TestMediaQueryListListener* impl = static_cast<TestMediaQueryListListener*>(castedThis->impl());
if (exec->argumentCount() < 1)
return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
RefPtr<MediaQueryListListener> listener(MediaQueryListListener::create(ScriptValue(exec->globalData(), MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined))));
RefPtr<MediaQueryListListener> listener(MediaQueryListListener::create(ScriptValue(exec->globalData(), MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))));
if (exec->hadException())
return JSValue::encode(jsUndefined());
impl->method(listener);
......
......@@ -97,13 +97,13 @@ EncodedJSValue JSC_HOST_CALL JSTestNamedConstructorNamedConstructor::constructJS