Changeset 267865 in webkit


Ignore:
Timestamp:
Oct 1, 2020 6:42:14 PM (4 years ago)
Author:
weinig@apple.com
Message:

[WebIDL] Add support for non-nullable optional wrapper type arguments to operations
https://bugs.webkit.org/show_bug.cgi?id=217162

Reviewed by Chris Dumez.
Source/WebCore:

The bindings currently treat both nullable and optional wrapper types as
having type WrapperType* (or RefPtr<WrapperType> for callbacks), whereas
non-nullable, non-optional wrapper types are treated as having type WrapperType&
(or Ref<WrapperType> for callbacks). This parallels non wrapper types
which use Optional<Type> for both nullable and optional vs Type for the
non-nullable non-optional variant. In both these cases, there is possibility
for ambiguity, should we ever need to disambiguate between nullable and
optional, but thus far it hasn't come up.

This change adds a missing case where we weren't supporting non-nullable
optional wrapper type arguments to operations. We solve this by expecting
the wrapped implementation to take the optional wrapper type argument the
same way it would take an optional wrapper type argument, with a WrapperType*,
(or RefPtr<WrapperType> for callbacks) that gets passed a nullptr if the
parameter was ommited.

Adopt this in Geolocation.idl, which has had a FIXME for this for a long
time.

  • Modules/geolocation/Geolocation.idl:
  • bindings/scripts/CodeGeneratorJS.pm:
  • bindings/scripts/test/JS/JSTestObj.cpp:
  • bindings/scripts/test/TestObj.idl:

LayoutTests:

  • fast/dom/Geolocation/argument-types.html:
  • fast/dom/Geolocation/argument-types-expected.txt:

Update tests now that the second argument to Geolocation.getCurrentPosition
and Geolocation.watchPosition are non-nullable.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r267864 r267865  
     12020-10-01  Sam Weinig  <weinig@apple.com>
     2
     3        [WebIDL] Add support for non-nullable optional wrapper type arguments to operations
     4        https://bugs.webkit.org/show_bug.cgi?id=217162
     5
     6        Reviewed by Chris Dumez.
     7
     8        * fast/dom/Geolocation/argument-types.html:
     9        * fast/dom/Geolocation/argument-types-expected.txt:
     10        Update tests now that the second argument to Geolocation.getCurrentPosition
     11        and Geolocation.watchPosition are non-nullable.
     12
    1132020-10-01  Myles C. Maxfield  <mmaxfield@apple.com>
    214
  • trunk/LayoutTests/fast/dom/Geolocation/argument-types-expected.txt

    r209669 r267865  
    1818PASS navigator.geolocation.getCurrentPosition("string") threw exception TypeError: Argument 1 ('successCallback') to Geolocation.getCurrentPosition must be a function.
    1919PASS navigator.geolocation.getCurrentPosition(emptyFunction, undefined) did not throw exception.
    20 PASS navigator.geolocation.getCurrentPosition(emptyFunction, null) did not throw exception.
     20PASS navigator.geolocation.getCurrentPosition(emptyFunction, null) threw exception TypeError: Argument 2 ('errorCallback') to Geolocation.getCurrentPosition must be a function.
    2121PASS navigator.geolocation.getCurrentPosition(emptyFunction, {}) threw exception TypeError: Argument 2 ('errorCallback') to Geolocation.getCurrentPosition must be a function.
    2222PASS navigator.geolocation.getCurrentPosition(emptyFunction, objectThrowingException) threw exception TypeError: Argument 2 ('errorCallback') to Geolocation.getCurrentPosition must be a function.
  • trunk/LayoutTests/fast/dom/Geolocation/argument-types.html

    r217390 r267865  
    5757
    5858test('navigator.geolocation.getCurrentPosition(emptyFunction, undefined)', false);
    59 test('navigator.geolocation.getCurrentPosition(emptyFunction, null)', false);
     59test('navigator.geolocation.getCurrentPosition(emptyFunction, null)', true, "TypeError: Argument 2 ('errorCallback') to Geolocation.getCurrentPosition must be a function");
    6060test('navigator.geolocation.getCurrentPosition(emptyFunction, {})', true, "TypeError: Argument 2 ('errorCallback') to Geolocation.getCurrentPosition must be a function");
    6161test('navigator.geolocation.getCurrentPosition(emptyFunction, objectThrowingException)', true, "TypeError: Argument 2 ('errorCallback') to Geolocation.getCurrentPosition must be a function");
  • trunk/Source/WebCore/ChangeLog

    r267864 r267865  
     12020-10-01  Sam Weinig  <weinig@apple.com>
     2
     3        [WebIDL] Add support for non-nullable optional wrapper type arguments to operations
     4        https://bugs.webkit.org/show_bug.cgi?id=217162
     5
     6        Reviewed by Chris Dumez.
     7       
     8        The bindings currently treat both nullable and optional wrapper types as
     9        having type WrapperType* (or RefPtr<WrapperType> for callbacks), whereas
     10        non-nullable, non-optional wrapper types are treated as having type WrapperType&
     11        (or Ref<WrapperType> for callbacks). This parallels non wrapper types
     12        which use Optional<Type> for both nullable and optional vs Type for the
     13        non-nullable non-optional variant. In both these cases, there is possibility
     14        for ambiguity, should we ever need to disambiguate between nullable and
     15        optional, but thus far it hasn't come up.
     16       
     17        This change adds a missing case where we weren't supporting non-nullable
     18        optional wrapper type arguments to operations. We solve this by expecting
     19        the wrapped implementation to take the optional wrapper type argument the
     20        same way it would take an optional wrapper type argument, with a WrapperType*,
     21        (or RefPtr<WrapperType> for callbacks) that gets passed a nullptr if the
     22        parameter was ommited.
     23
     24        Adopt this in Geolocation.idl, which has had a FIXME for this for a long
     25        time.
     26
     27        * Modules/geolocation/Geolocation.idl:
     28        * bindings/scripts/CodeGeneratorJS.pm:
     29        * bindings/scripts/test/JS/JSTestObj.cpp:
     30        * bindings/scripts/test/TestObj.idl:
     31
    1322020-10-01  Myles C. Maxfield  <mmaxfield@apple.com>
    233
  • trunk/Source/WebCore/Modules/geolocation/Geolocation.idl

    r267813 r267865  
    3131    Exposed=Window
    3232] interface Geolocation {
    33     // FIXME: PositionErrorCallback should not be nullable
    3433    undefined getCurrentPosition(PositionCallback successCallback,
    35                             optional PositionErrorCallback? errorCallback,
     34                            optional PositionErrorCallback errorCallback,
    3635                            optional PositionOptions options);
    3736
    38     // FIXME: PositionErrorCallback should not be nullable
    3937    long watchPosition(PositionCallback successCallback,
    40                        optional PositionErrorCallback? errorCallback,
     38                       optional PositionErrorCallback errorCallback,
    4139                       optional PositionOptions options);
    4240
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r267859 r267865  
    18251825    }
    18261826
    1827     return "${name}.releaseNonNull()" if $codeGenerator->IsCallbackInterface($type) || $codeGenerator->IsCallbackFunction($type) || ($codeGenerator->IsPromiseType($type) && (ref($context) ne "IDLArgument" || !$context->isOptional));
    1828     return "*${name}" if $codeGenerator->IsWrapperType($type);
     1827    if ($codeGenerator->IsPromiseType($type)) {
     1828        return "WTFMove(${name})" if ref($context) eq "IDLArgument" && $context->isOptional;
     1829        return "${name}.releaseNonNull()";
     1830    }
     1831
     1832    if ($codeGenerator->IsCallbackInterface($type) || $codeGenerator->IsCallbackFunction($type)) {
     1833        return "WTFMove(${name})" if ref($context) eq "IDLArgument" && $context->isOptional;
     1834        return "${name}.releaseNonNull()";
     1835    }
     1836
     1837    if ($codeGenerator->IsWrapperType($type)) {
     1838        return "${name}" if ref($context) eq "IDLArgument" && $context->isOptional;
     1839        return "*${name}";
     1840    }
     1841
    18291842    return "WTFMove(${name})";
    18301843}
     
    61926205        my $type = $argument->type;
    61936206
    6194         assert "Optional arguments of non-nullable wrapper types are not supported (" . $operation->name . ")" if $argument->isOptional && !$type->isNullable && $codeGenerator->IsWrapperType($type);
    6195 
    61966207        if ($argument->isOptional && !defined($argument->default)) {
    61976208            # As per Web IDL, optional dictionary arguments are always considered to have a default value of an empty dictionary, unless otherwise specified.
     
    62106221            # default value for nullable arguments unless otherwise specified.
    62116222            $argument->default("null") if $type->isNullable;
    6212 
    6213             # For callback arguments, the generated bindings treat undefined as null, so use null as implicit default value.
    6214             $argument->default("null") if $codeGenerator->IsCallbackInterface($type) || $codeGenerator->IsCallbackFunction($type);
    62156223        }
    62166224
     
    62476255
    62486256                    my $defaultValue;
    6249                     if ($codeGenerator->IsPromiseType($argument->type)) {
     6257                    if ($codeGenerator->IsCallbackInterface($type) || $codeGenerator->IsCallbackFunction($type)) {
     6258                        $defaultValue = "Converter<$argumentIDLType>::ReturnType()";
     6259                    } elsif ($codeGenerator->IsPromiseType($argument->type) || $codeGenerator->IsWrapperType($type)) {
    62506260                        $defaultValue = "nullptr";
    62516261                    } else {
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r267727 r267865  
    15111511JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalAny);
    15121512JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalObject);
     1513JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalWrapper);
    15131514JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapper);
    15141515JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapperIsNull);
     
    15161517JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalRecord);
    15171518JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalPromise);
    1518 JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithCallbackArg);
    1519 JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg);
    1520 JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithCallbackAndOptionalArg);
     1519JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithCallbackInterfaceArg);
     1520JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithNullableCallbackInterfaceArg);
     1521JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithNonCallbackInterfaceArgAndCallbackInterfaceArg);
     1522JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalCallbackInterfaceArg);
     1523JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalNullableCallbackInterfaceArg);
    15211524JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithCallbackFunctionArg);
     1525JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithNullableCallbackFunctionArg);
    15221526JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackFunctionArg);
    1523 JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithCallbackFunctionAndOptionalArg);
     1527JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalCallbackFunctionArg);
     1528JSC_DECLARE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalNullableCallbackFunctionArg);
    15241529JSC_DECLARE_HOST_FUNCTION(jsTestObjConstructorFunctionStaticMethodWithCallbackAndOptionalArg);
    15251530JSC_DECLARE_HOST_FUNCTION(jsTestObjConstructorFunctionStaticMethodWithCallbackArg);
     
    22212226    { "methodWithOptionalAny", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalAny), (intptr_t) (0) } },
    22222227    { "methodWithOptionalObject", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalObject), (intptr_t) (0) } },
     2228    { "methodWithOptionalWrapper", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalWrapper), (intptr_t) (0) } },
    22232229    { "methodWithOptionalNullableWrapper", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapper), (intptr_t) (0) } },
    22242230    { "methodWithOptionalNullableWrapperIsNull", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapperIsNull), (intptr_t) (0) } },
     
    22262232    { "methodWithOptionalRecord", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalRecord), (intptr_t) (0) } },
    22272233    { "methodWithOptionalPromise", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalPromise), (intptr_t) (0) } },
    2228     { "methodWithCallbackArg", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithCallbackArg), (intptr_t) (1) } },
    2229     { "methodWithNonCallbackArgAndCallbackArg", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg), (intptr_t) (2) } },
    2230     { "methodWithCallbackAndOptionalArg", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithCallbackAndOptionalArg), (intptr_t) (0) } },
     2234    { "methodWithCallbackInterfaceArg", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithCallbackInterfaceArg), (intptr_t) (1) } },
     2235    { "methodWithNullableCallbackInterfaceArg", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithNullableCallbackInterfaceArg), (intptr_t) (1) } },
     2236    { "methodWithNonCallbackInterfaceArgAndCallbackInterfaceArg", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithNonCallbackInterfaceArgAndCallbackInterfaceArg), (intptr_t) (2) } },
     2237    { "methodWithOptionalCallbackInterfaceArg", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalCallbackInterfaceArg), (intptr_t) (0) } },
     2238    { "methodWithOptionalNullableCallbackInterfaceArg", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalNullableCallbackInterfaceArg), (intptr_t) (0) } },
    22312239    { "methodWithCallbackFunctionArg", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithCallbackFunctionArg), (intptr_t) (1) } },
     2240    { "methodWithNullableCallbackFunctionArg", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithNullableCallbackFunctionArg), (intptr_t) (1) } },
    22322241    { "methodWithNonCallbackArgAndCallbackFunctionArg", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackFunctionArg), (intptr_t) (2) } },
    2233     { "methodWithCallbackFunctionAndOptionalArg", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithCallbackFunctionAndOptionalArg), (intptr_t) (0) } },
     2242    { "methodWithOptionalCallbackFunctionArg", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalCallbackFunctionArg), (intptr_t) (0) } },
     2243    { "methodWithOptionalNullableCallbackFunctionArg", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalNullableCallbackFunctionArg), (intptr_t) (0) } },
    22342244#if ENABLE(Condition1)
    22352245    { "conditionalMethod1", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestObjPrototypeFunctionConditionalMethod1), (intptr_t) (0) } },
     
    70277037}
    70287038
     7039static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithOptionalWrapperBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
     7040{
     7041    auto& vm = JSC::getVM(lexicalGlobalObject);
     7042    auto throwScope = DECLARE_THROW_SCOPE(vm);
     7043    UNUSED_PARAM(throwScope);
     7044    UNUSED_PARAM(callFrame);
     7045    auto& impl = castedThis->wrapped();
     7046    EnsureStillAliveScope argument0 = callFrame->argument(0);
     7047    auto obj = argument0.value().isUndefined() ? nullptr : convert<IDLInterface<TestObj>>(*lexicalGlobalObject, argument0.value(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentTypeError(lexicalGlobalObject, scope, 0, "obj", "TestObject", "methodWithOptionalWrapper", "TestObj"); });
     7048    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     7049    throwScope.release();
     7050    impl.methodWithOptionalWrapper(obj);
     7051    return JSValue::encode(jsUndefined());
     7052}
     7053
     7054JSC_DEFINE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalWrapper, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame))
     7055{
     7056    return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunctionMethodWithOptionalWrapperBody>(*lexicalGlobalObject, *callFrame, "methodWithOptionalWrapper");
     7057}
     7058
    70297059static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithOptionalNullableWrapperBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
    70307060{
     
    71277157}
    71287158
    7129 static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithCallbackArgBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
     7159static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithCallbackInterfaceArgBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
    71307160{
    71317161    auto& vm = JSC::getVM(lexicalGlobalObject);
     
    71377167        return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
    71387168    EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
    7139     auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithCallbackArg"); });
    7140     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    7141     throwScope.release();
    7142     impl.methodWithCallbackArg(callback.releaseNonNull());
    7143     return JSValue::encode(jsUndefined());
    7144 }
    7145 
    7146 JSC_DEFINE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithCallbackArg, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame))
    7147 {
    7148     return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunctionMethodWithCallbackArgBody>(*lexicalGlobalObject, *callFrame, "methodWithCallbackArg");
    7149 }
    7150 
    7151 static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArgBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
     7169    auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithCallbackInterfaceArg"); });
     7170    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     7171    throwScope.release();
     7172    impl.methodWithCallbackInterfaceArg(callback.releaseNonNull());
     7173    return JSValue::encode(jsUndefined());
     7174}
     7175
     7176JSC_DEFINE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithCallbackInterfaceArg, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame))
     7177{
     7178    return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunctionMethodWithCallbackInterfaceArgBody>(*lexicalGlobalObject, *callFrame, "methodWithCallbackInterfaceArg");
     7179}
     7180
     7181static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithNullableCallbackInterfaceArgBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
     7182{
     7183    auto& vm = JSC::getVM(lexicalGlobalObject);
     7184    auto throwScope = DECLARE_THROW_SCOPE(vm);
     7185    UNUSED_PARAM(throwScope);
     7186    UNUSED_PARAM(callFrame);
     7187    auto& impl = castedThis->wrapped();
     7188    if (UNLIKELY(callFrame->argumentCount() < 1))
     7189        return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
     7190    EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
     7191    auto callback = convert<IDLNullable<IDLCallbackInterface<JSTestCallbackInterface>>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithNullableCallbackInterfaceArg"); });
     7192    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     7193    throwScope.release();
     7194    impl.methodWithNullableCallbackInterfaceArg(WTFMove(callback));
     7195    return JSValue::encode(jsUndefined());
     7196}
     7197
     7198JSC_DEFINE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithNullableCallbackInterfaceArg, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame))
     7199{
     7200    return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunctionMethodWithNullableCallbackInterfaceArgBody>(*lexicalGlobalObject, *callFrame, "methodWithNullableCallbackInterfaceArg");
     7201}
     7202
     7203static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithNonCallbackInterfaceArgAndCallbackInterfaceArgBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
    71527204{
    71537205    auto& vm = JSC::getVM(lexicalGlobalObject);
     
    71627214    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    71637215    EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1);
    7164     auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument1.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 1, "callback", "TestObject", "methodWithNonCallbackArgAndCallbackArg"); });
    7165     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    7166     throwScope.release();
    7167     impl.methodWithNonCallbackArgAndCallbackArg(WTFMove(nonCallback), callback.releaseNonNull());
    7168     return JSValue::encode(jsUndefined());
    7169 }
    7170 
    7171 JSC_DEFINE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArg, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame))
    7172 {
    7173     return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackArgBody>(*lexicalGlobalObject, *callFrame, "methodWithNonCallbackArgAndCallbackArg");
    7174 }
    7175 
    7176 static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithCallbackAndOptionalArgBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
     7216    auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument1.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 1, "callback", "TestObject", "methodWithNonCallbackInterfaceArgAndCallbackInterfaceArg"); });
     7217    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     7218    throwScope.release();
     7219    impl.methodWithNonCallbackInterfaceArgAndCallbackInterfaceArg(WTFMove(nonCallback), callback.releaseNonNull());
     7220    return JSValue::encode(jsUndefined());
     7221}
     7222
     7223JSC_DEFINE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithNonCallbackInterfaceArgAndCallbackInterfaceArg, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame))
     7224{
     7225    return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunctionMethodWithNonCallbackInterfaceArgAndCallbackInterfaceArgBody>(*lexicalGlobalObject, *callFrame, "methodWithNonCallbackInterfaceArgAndCallbackInterfaceArg");
     7226}
     7227
     7228static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithOptionalCallbackInterfaceArgBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
    71777229{
    71787230    auto& vm = JSC::getVM(lexicalGlobalObject);
     
    71827234    auto& impl = castedThis->wrapped();
    71837235    EnsureStillAliveScope argument0 = callFrame->argument(0);
    7184     auto callback = convert<IDLNullable<IDLCallbackInterface<JSTestCallbackInterface>>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithCallbackAndOptionalArg"); });
    7185     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    7186     throwScope.release();
    7187     impl.methodWithCallbackAndOptionalArg(WTFMove(callback));
    7188     return JSValue::encode(jsUndefined());
    7189 }
    7190 
    7191 JSC_DEFINE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithCallbackAndOptionalArg, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame))
    7192 {
    7193     return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunctionMethodWithCallbackAndOptionalArgBody>(*lexicalGlobalObject, *callFrame, "methodWithCallbackAndOptionalArg");
     7236    auto callback = argument0.value().isUndefined() ? Converter<IDLCallbackInterface<JSTestCallbackInterface>>::ReturnType() : convert<IDLCallbackInterface<JSTestCallbackInterface>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithOptionalCallbackInterfaceArg"); });
     7237    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     7238    throwScope.release();
     7239    impl.methodWithOptionalCallbackInterfaceArg(WTFMove(callback));
     7240    return JSValue::encode(jsUndefined());
     7241}
     7242
     7243JSC_DEFINE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalCallbackInterfaceArg, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame))
     7244{
     7245    return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunctionMethodWithOptionalCallbackInterfaceArgBody>(*lexicalGlobalObject, *callFrame, "methodWithOptionalCallbackInterfaceArg");
     7246}
     7247
     7248static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithOptionalNullableCallbackInterfaceArgBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
     7249{
     7250    auto& vm = JSC::getVM(lexicalGlobalObject);
     7251    auto throwScope = DECLARE_THROW_SCOPE(vm);
     7252    UNUSED_PARAM(throwScope);
     7253    UNUSED_PARAM(callFrame);
     7254    auto& impl = castedThis->wrapped();
     7255    EnsureStillAliveScope argument0 = callFrame->argument(0);
     7256    auto callback = convert<IDLNullable<IDLCallbackInterface<JSTestCallbackInterface>>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeObjectError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithOptionalNullableCallbackInterfaceArg"); });
     7257    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     7258    throwScope.release();
     7259    impl.methodWithOptionalNullableCallbackInterfaceArg(WTFMove(callback));
     7260    return JSValue::encode(jsUndefined());
     7261}
     7262
     7263JSC_DEFINE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalNullableCallbackInterfaceArg, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame))
     7264{
     7265    return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunctionMethodWithOptionalNullableCallbackInterfaceArgBody>(*lexicalGlobalObject, *callFrame, "methodWithOptionalNullableCallbackInterfaceArg");
    71947266}
    71957267
     
    72167288}
    72177289
     7290static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithNullableCallbackFunctionArgBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
     7291{
     7292    auto& vm = JSC::getVM(lexicalGlobalObject);
     7293    auto throwScope = DECLARE_THROW_SCOPE(vm);
     7294    UNUSED_PARAM(throwScope);
     7295    UNUSED_PARAM(callFrame);
     7296    auto& impl = castedThis->wrapped();
     7297    if (UNLIKELY(callFrame->argumentCount() < 1))
     7298        return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
     7299    EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
     7300    auto callback = convert<IDLNullable<IDLCallbackFunction<JSTestCallbackFunction>>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithNullableCallbackFunctionArg"); });
     7301    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     7302    throwScope.release();
     7303    impl.methodWithNullableCallbackFunctionArg(WTFMove(callback));
     7304    return JSValue::encode(jsUndefined());
     7305}
     7306
     7307JSC_DEFINE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithNullableCallbackFunctionArg, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame))
     7308{
     7309    return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunctionMethodWithNullableCallbackFunctionArgBody>(*lexicalGlobalObject, *callFrame, "methodWithNullableCallbackFunctionArg");
     7310}
     7311
    72187312static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithNonCallbackArgAndCallbackFunctionArgBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
    72197313{
     
    72417335}
    72427336
    7243 static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithCallbackFunctionAndOptionalArgBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
     7337static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithOptionalCallbackFunctionArgBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
    72447338{
    72457339    auto& vm = JSC::getVM(lexicalGlobalObject);
     
    72497343    auto& impl = castedThis->wrapped();
    72507344    EnsureStillAliveScope argument0 = callFrame->argument(0);
    7251     auto callback = convert<IDLNullable<IDLCallbackFunction<JSTestCallbackFunction>>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithCallbackFunctionAndOptionalArg"); });
    7252     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    7253     throwScope.release();
    7254     impl.methodWithCallbackFunctionAndOptionalArg(WTFMove(callback));
    7255     return JSValue::encode(jsUndefined());
    7256 }
    7257 
    7258 JSC_DEFINE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithCallbackFunctionAndOptionalArg, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame))
    7259 {
    7260     return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunctionMethodWithCallbackFunctionAndOptionalArgBody>(*lexicalGlobalObject, *callFrame, "methodWithCallbackFunctionAndOptionalArg");
     7345    auto callback = argument0.value().isUndefined() ? Converter<IDLCallbackFunction<JSTestCallbackFunction>>::ReturnType() : convert<IDLCallbackFunction<JSTestCallbackFunction>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithOptionalCallbackFunctionArg"); });
     7346    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     7347    throwScope.release();
     7348    impl.methodWithOptionalCallbackFunctionArg(WTFMove(callback));
     7349    return JSValue::encode(jsUndefined());
     7350}
     7351
     7352JSC_DEFINE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalCallbackFunctionArg, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame))
     7353{
     7354    return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunctionMethodWithOptionalCallbackFunctionArgBody>(*lexicalGlobalObject, *callFrame, "methodWithOptionalCallbackFunctionArg");
     7355}
     7356
     7357static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionMethodWithOptionalNullableCallbackFunctionArgBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestObj>::ClassParameter castedThis)
     7358{
     7359    auto& vm = JSC::getVM(lexicalGlobalObject);
     7360    auto throwScope = DECLARE_THROW_SCOPE(vm);
     7361    UNUSED_PARAM(throwScope);
     7362    UNUSED_PARAM(callFrame);
     7363    auto& impl = castedThis->wrapped();
     7364    EnsureStillAliveScope argument0 = callFrame->argument(0);
     7365    auto callback = convert<IDLNullable<IDLCallbackFunction<JSTestCallbackFunction>>>(*lexicalGlobalObject, argument0.value(), *castedThis->globalObject(), [](JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(lexicalGlobalObject, scope, 0, "callback", "TestObject", "methodWithOptionalNullableCallbackFunctionArg"); });
     7366    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     7367    throwScope.release();
     7368    impl.methodWithOptionalNullableCallbackFunctionArg(WTFMove(callback));
     7369    return JSValue::encode(jsUndefined());
     7370}
     7371
     7372JSC_DEFINE_HOST_FUNCTION(jsTestObjPrototypeFunctionMethodWithOptionalNullableCallbackFunctionArg, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame))
     7373{
     7374    return IDLOperation<JSTestObj>::call<jsTestObjPrototypeFunctionMethodWithOptionalNullableCallbackFunctionArgBody>(*lexicalGlobalObject, *callFrame, "methodWithOptionalNullableCallbackFunctionArg");
    72617375}
    72627376
  • trunk/Source/WebCore/bindings/scripts/test/TestObj.idl

    r267449 r267865  
    242242    undefined    methodWithOptionalAny(optional any a);
    243243    undefined    methodWithOptionalObject(optional object a);
     244    undefined    methodWithOptionalWrapper(optional TestObj obj);
    244245    undefined    methodWithOptionalNullableWrapper(optional TestObj? obj);
    245246    undefined    methodWithOptionalNullableWrapperIsNull(optional TestObj? obj = null);
     
    249250
    250251    // Callback interface parameters.
    251     undefined    methodWithCallbackArg(TestCallbackInterface callback);
    252     undefined    methodWithNonCallbackArgAndCallbackArg(long nonCallback, TestCallbackInterface callback);
    253     undefined    methodWithCallbackAndOptionalArg(optional TestCallbackInterface? callback);
     252    undefined    methodWithCallbackInterfaceArg(TestCallbackInterface callback);
     253    undefined    methodWithNullableCallbackInterfaceArg(TestCallbackInterface? callback);
     254    undefined    methodWithNonCallbackInterfaceArgAndCallbackInterfaceArg(long nonCallback, TestCallbackInterface callback);
     255    undefined    methodWithOptionalCallbackInterfaceArg(optional TestCallbackInterface callback);
     256    undefined    methodWithOptionalNullableCallbackInterfaceArg(optional TestCallbackInterface? callback);
    254257
    255258    // Callback function parameters.
    256259    undefined    methodWithCallbackFunctionArg(TestCallbackFunction callback);
     260    undefined    methodWithNullableCallbackFunctionArg(TestCallbackFunction? callback);
    257261    undefined    methodWithNonCallbackArgAndCallbackFunctionArg(long nonCallback, TestCallbackFunction callback);
    258     undefined    methodWithCallbackFunctionAndOptionalArg(optional TestCallbackFunction? callback);
     262    undefined    methodWithOptionalCallbackFunctionArg(optional TestCallbackFunction callback);
     263    undefined    methodWithOptionalNullableCallbackFunctionArg(optional TestCallbackFunction? callback);
    259264
    260265    // static methods with 'Callback' extended attribute
Note: See TracChangeset for help on using the changeset viewer.