Changeset 209153 in webkit


Ignore:
Timestamp:
Nov 30, 2016 2:10:49 PM (7 years ago)
Author:
weinig@apple.com
Message:

[WebIDL] Add support for more missing / exotic IDLTypes
https://bugs.webkit.org/show_bug.cgi?id=165156

Reviewed by Alex Christensen.

  • Adds JSDOMConvert support for WebIDL's 'callback interface' and 'callback function'.
  • Adds JSDOMConvert support for WebIDL extensions for SerializedScriptValue, Dictionary, EventListener and XPathNSResolver (moving much of their special casing out of perl and into JSDOMConvert).
  • DerivedSources.make:

Adds $(WebCore)/testing to the list of available IDL directories to keep internals
compiling.

  • Modules/webaudio/WaveShaperNode.cpp:
  • Modules/webaudio/WaveShaperNode.h:

Update to take curve by reference.

  • bindings/generic/IDLTypes.h:

(WebCore::IDLWrapper):
Add helper type, IDLWrapper, which serves as a base type for all IDLTypes that are
RefCounted.

  • bindings/js/JSDOMConvert.h:

(WebCore::convert):
(WebCore::Converter<IDLNullable<T>>::convert):
(WebCore::Converter<IDLCallbackFunction<T>>::convert):
(WebCore::JSConverter<IDLCallbackFunction<T>>::convert):
(WebCore::JSConverter<IDLCallbackFunction<T>>::convertNewlyCreated):
(WebCore::Converter<IDLCallbackInterface<T>>::convert):
(WebCore::JSConverter<IDLCallbackInterface<T>>::convert):
(WebCore::JSConverter<IDLCallbackInterface<T>>::convertNewlyCreated):
(WebCore::Converter<IDLSerializedScriptValue<T>>::convert):
(WebCore::JSConverter<IDLSerializedScriptValue<T>>::convert):
(WebCore::Converter<IDLLegacyDictionary<T>>::convert):
(WebCore::Converter<IDLEventListener<T>>::convert):
(WebCore::Converter<IDLXPathNSResolver<T>>::convert):
(WebCore::JSConverter<IDLXPathNSResolver<T>>::convert):
(WebCore::JSConverter<IDLXPathNSResolver<T>>::convertNewlyCreated):
Add converters for the new types. IDLSerializedScriptValue, IDLLegacyDictionary, IDLEventListener and IDLXPathNSResolver
have been templatized to avoid including their implementation classes everywhere. We can improve this in the future by
splitting JSDOMConvert up into to separate files.

  • bindings/scripts/CodeGenerator.pm:

(IsBuiltinType):
(IsInterfaceType):
(IsWrapperType):
(ComputeIsCallbackInterface):
(ComputeIsCallbackFunction):
Add new predicates, IsBuiltinType and IsInterfaceType, and re-work IsWrapperType to determine all types that
have a JS wrapper (and consequently a JS{name}.h file).

  • bindings/scripts/CodeGeneratorJS.pm:

(AddToIncludesForIDLType):
Update to add include for EventListener.

(GetArgumentExceptionFunction):
(GetArgumentExceptionThrower):
(GetAttributeExceptionFunction):
(GetAttributeExceptionThrower):
Add support for exceptions for callbacks.

(PassArgumentExpression):
Factor out logic on how to pass arguments to C++.

(GenerateHeader):
Make toWrapped and JSDOMWrapperConverterTraits work with XPathNSResolver.

(GenerateImplementation):
Update to use PassArgumentExpression and pass a global object reference to JSValueToNative.

(GenerateParametersCheck):
Remove special casing for callbacks.

(GenerateCallbackHeaderContent):
(GenerateCallbackImplementationContent):
Simplify toJS functions. State and global object are not necessary.

(GetBaseIDLType):
Add support for new types. Add assertion so that unknown types can't get through.

(ShouldPassArgumentByReference):
Rename from ShouldPassWrapperByReference, and merge in CodeGenerator's ShouldPassWrapperByReference.

(JSValueToNativeDOMConvertNeedsThisObject):
Added. Predicate to determine types that need a this object for conversion.

(JSValueToNativeDOMConvertNeedsGlobalObject):
Added. Predicate to determine types that need a global object for conversion.

(JSValueToNative):
Remove special cases for new types.

(NativeToJSValueDOMConvertNeedsState):
Add SerializedScriptValue and XPathNSResolver.

(NativeToJSValueDOMConvertNeedsGlobalObject):
Add SerializedScriptValue and XPathNSResolver.

(NativeToJSValueUsingReferences):
(NativeToJSValueUsingPointers):
(NativeToJSValue):
Remove unused $statePointer and replace $globalObject with $globalObjectReference. Remove
special cases for new types.

(GenerateConstructorDefinition):
Use PassArgumentExpression.

  • bindings/scripts/test/JS/JSTestCallbackFunction.cpp:
  • bindings/scripts/test/JS/JSTestCallbackFunction.h:
  • bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp:
  • bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.h:
  • bindings/scripts/test/JS/JSTestCallbackInterface.cpp:
  • bindings/scripts/test/JS/JSTestCallbackInterface.h:
  • bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
  • bindings/scripts/test/JS/JSTestObj.cpp:
  • bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
  • bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
  • bindings/scripts/test/JS/JSTestTypedefs.cpp:
  • bindings/scripts/test/TestObj.idl:
  • bindings/scripts/test/TestSerializedScriptValueInterface.idl:

Update tests. Remove test for a readonly attribute returning a Promise, which is not supported
yet (this was caught by the assertion added to GetBaseIDLType). Add tests for passing and returning
SerializedScriptValues from functions.

Location:
trunk/Source/WebCore
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r209150 r209153  
     12016-11-29  Sam Weinig  <sam@webkit.org>
     2
     3        [WebIDL] Add support for more missing / exotic IDLTypes
     4        https://bugs.webkit.org/show_bug.cgi?id=165156
     5
     6        Reviewed by Alex Christensen.
     7
     8        - Adds JSDOMConvert support for WebIDL's 'callback interface' and 'callback function'.
     9        - Adds JSDOMConvert support for WebIDL extensions for SerializedScriptValue, Dictionary,
     10          EventListener and XPathNSResolver (moving much of their special casing out of perl and
     11          into JSDOMConvert).
     12
     13        * DerivedSources.make:
     14        Adds $(WebCore)/testing to the list of available IDL directories to keep internals
     15        compiling.
     16
     17        * Modules/webaudio/WaveShaperNode.cpp:
     18        * Modules/webaudio/WaveShaperNode.h:
     19        Update to take curve by reference.
     20
     21        * bindings/generic/IDLTypes.h:
     22        (WebCore::IDLWrapper):
     23        Add helper type, IDLWrapper, which serves as a base type for all IDLTypes that are
     24        RefCounted.
     25
     26        * bindings/js/JSDOMConvert.h:
     27        (WebCore::convert):
     28        (WebCore::Converter<IDLNullable<T>>::convert):
     29        (WebCore::Converter<IDLCallbackFunction<T>>::convert):
     30        (WebCore::JSConverter<IDLCallbackFunction<T>>::convert):
     31        (WebCore::JSConverter<IDLCallbackFunction<T>>::convertNewlyCreated):
     32        (WebCore::Converter<IDLCallbackInterface<T>>::convert):
     33        (WebCore::JSConverter<IDLCallbackInterface<T>>::convert):
     34        (WebCore::JSConverter<IDLCallbackInterface<T>>::convertNewlyCreated):
     35        (WebCore::Converter<IDLSerializedScriptValue<T>>::convert):
     36        (WebCore::JSConverter<IDLSerializedScriptValue<T>>::convert):
     37        (WebCore::Converter<IDLLegacyDictionary<T>>::convert):
     38        (WebCore::Converter<IDLEventListener<T>>::convert):
     39        (WebCore::Converter<IDLXPathNSResolver<T>>::convert):
     40        (WebCore::JSConverter<IDLXPathNSResolver<T>>::convert):
     41        (WebCore::JSConverter<IDLXPathNSResolver<T>>::convertNewlyCreated):
     42        Add converters for the new types. IDLSerializedScriptValue, IDLLegacyDictionary, IDLEventListener and IDLXPathNSResolver
     43        have been templatized to avoid including their implementation classes everywhere. We can improve this in the future by
     44        splitting JSDOMConvert up into to separate files.
     45
     46        * bindings/scripts/CodeGenerator.pm:
     47        (IsBuiltinType):
     48        (IsInterfaceType):
     49        (IsWrapperType):
     50        (ComputeIsCallbackInterface):
     51        (ComputeIsCallbackFunction):
     52        Add new predicates, IsBuiltinType and IsInterfaceType, and re-work IsWrapperType to determine all types that
     53        have a JS wrapper (and consequently a JS{name}.h file).
     54
     55        * bindings/scripts/CodeGeneratorJS.pm:
     56        (AddToIncludesForIDLType):
     57        Update to add include for EventListener.
     58
     59        (GetArgumentExceptionFunction):
     60        (GetArgumentExceptionThrower):
     61        (GetAttributeExceptionFunction):
     62        (GetAttributeExceptionThrower):
     63        Add support for exceptions for callbacks.
     64
     65        (PassArgumentExpression):
     66        Factor out logic on how to pass arguments to C++.
     67
     68        (GenerateHeader):
     69        Make toWrapped and JSDOMWrapperConverterTraits work with XPathNSResolver.
     70
     71        (GenerateImplementation):
     72        Update to use PassArgumentExpression and pass a global object reference to JSValueToNative.
     73
     74        (GenerateParametersCheck):
     75        Remove special casing for callbacks.
     76
     77        (GenerateCallbackHeaderContent):
     78        (GenerateCallbackImplementationContent):
     79        Simplify toJS functions. State and global object are not necessary.
     80
     81        (GetBaseIDLType):
     82        Add support for new types. Add assertion so that unknown types can't get through.
     83
     84        (ShouldPassArgumentByReference):
     85        Rename from ShouldPassWrapperByReference, and merge in CodeGenerator's ShouldPassWrapperByReference.
     86
     87        (JSValueToNativeDOMConvertNeedsThisObject):
     88        Added. Predicate to determine types that need a this object for conversion.
     89
     90        (JSValueToNativeDOMConvertNeedsGlobalObject):
     91        Added. Predicate to determine types that need a global object for conversion.
     92
     93        (JSValueToNative):
     94        Remove special cases for new types.
     95
     96        (NativeToJSValueDOMConvertNeedsState):
     97        Add SerializedScriptValue and XPathNSResolver.
     98
     99        (NativeToJSValueDOMConvertNeedsGlobalObject):
     100        Add SerializedScriptValue and XPathNSResolver.
     101
     102        (NativeToJSValueUsingReferences):
     103        (NativeToJSValueUsingPointers):
     104        (NativeToJSValue):
     105        Remove unused $statePointer and replace $globalObject with $globalObjectReference. Remove
     106        special cases for new types.
     107
     108        (GenerateConstructorDefinition):
     109        Use PassArgumentExpression.
     110
     111        * bindings/scripts/test/JS/JSTestCallbackFunction.cpp:
     112        * bindings/scripts/test/JS/JSTestCallbackFunction.h:
     113        * bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp:
     114        * bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.h:
     115        * bindings/scripts/test/JS/JSTestCallbackInterface.cpp:
     116        * bindings/scripts/test/JS/JSTestCallbackInterface.h:
     117        * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
     118        * bindings/scripts/test/JS/JSTestObj.cpp:
     119        * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
     120        * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
     121        * bindings/scripts/test/JS/JSTestTypedefs.cpp:
     122        * bindings/scripts/test/TestObj.idl:
     123        * bindings/scripts/test/TestSerializedScriptValueInterface.idl:
     124        Update tests. Remove test for a readonly attribute returning a Promise, which is not supported
     125        yet (this was caught by the assertion added to GetBaseIDLType). Add tests for passing and returning
     126        SerializedScriptValues from functions.
     127
    11282016-11-30  Jiewen Tan  <jiewen_tan@apple.com>
    2129
  • trunk/Source/WebCore/DerivedSources.make

    r209001 r209153  
    12911291    $(WebCore)/storage \
    12921292    $(WebCore)/svg \
     1293    $(WebCore)/testing \
    12931294    $(WebCore)/workers \
    12941295    $(WebCore)/xml
  • trunk/Source/WebCore/Modules/webaudio/WaveShaperNode.cpp

    r208688 r209153  
    4242}
    4343
    44 void WaveShaperNode::setCurve(Float32Array* curve)
     44void WaveShaperNode::setCurve(Float32Array& curve)
    4545{
    4646    ASSERT(isMainThread());
    47     waveShaperProcessor()->setCurve(curve);
     47    waveShaperProcessor()->setCurve(&curve);
    4848}
    4949
  • trunk/Source/WebCore/Modules/webaudio/WaveShaperNode.h

    r200361 r209153  
    3939
    4040    // setCurve() is called on the main thread.
    41     void setCurve(Float32Array*);
     41    void setCurve(Float32Array&);
    4242    Float32Array* curve();
    4343
  • trunk/Source/WebCore/bindings/generic/IDLTypes.h

    r208985 r209153  
    3838
    3939namespace WebCore {
     40
     41class Dictionary;
     42class EventListener;
     43class XPathNSResolver;
    4044
    4145template <typename Value> class DOMPromise;
     
    9397struct IDLObject : IDLUnsupportedType { };
    9498
    95 template<typename T> struct IDLInterface : IDLType<RefPtr<T>> {
     99template<typename T> struct IDLWrapper : IDLType<RefPtr<T>> {
    96100    using RawType = T;
     101    using NullableType = RefPtr<T>;
    97102
    98     using NullableType = RefPtr<T>;
    99     static std::nullptr_t nullValue() { return nullptr; }
    100     static bool isNullValue(const RefPtr<T>& value) { return !value; }
    101     template <typename U> static U&& extractValueFromNullable(U&& value) { return std::forward<U>(value); }
     103    static inline std::nullptr_t nullValue() { return nullptr; }
     104    template<typename U> static inline bool isNullValue(U&& value) { return !value; }
     105    template<typename U> static inline U&& extractValueFromNullable(U&& value) { return std::forward<U>(value); }
    102106};
     107
     108template<typename T> struct IDLInterface : IDLWrapper<T> { };
     109template<typename T> struct IDLCallbackInterface : IDLWrapper<T> { };
     110template<typename T> struct IDLCallbackFunction : IDLWrapper<T> { };
    103111
    104112template<typename T> struct IDLDictionary : IDLType<T> { };
    105113template<typename T> struct IDLEnumeration : IDLType<T> { };
    106 template<typename T> struct IDLCallbackFunction : IDLUnsupportedType { };
    107114
    108115template<typename T> struct IDLNullable : IDLType<typename T::NullableType> {
     
    144151};
    145152
     153template<typename T> struct IDLSerializedScriptValue : IDLWrapper<T> { };
     154template<typename T> struct IDLLegacyDictionary : IDLType<T> { };
     155template<typename T> struct IDLEventListener : IDLWrapper<T> { };
     156template<typename T> struct IDLXPathNSResolver : IDLWrapper<T> { };
     157
     158
     159// Non-WebIDL convenience type aliases
     160
    146161using IDLBufferSource = IDLUnion<IDLInterface<JSC::ArrayBufferView>, IDLInterface<JSC::ArrayBuffer>>;
     162
    147163
    148164// Helper predicates
  • trunk/Source/WebCore/bindings/js/JSDOMConvert.h

    r208985 r209153  
    4646
    4747template<typename T> typename Converter<T>::ReturnType convert(JSC::ExecState&, JSC::JSValue);
     48template<typename T> typename Converter<T>::ReturnType convert(JSC::ExecState&, JSC::JSValue, JSC::JSObject&);
     49template<typename T> typename Converter<T>::ReturnType convert(JSC::ExecState&, JSC::JSValue, JSDOMGlobalObject&);
    4850template<typename T> typename Converter<T>::ReturnType convert(JSC::ExecState&, JSC::JSValue, IntegerConversionConfiguration);
    4951template<typename T> typename Converter<T>::ReturnType convert(JSC::ExecState&, JSC::JSValue, StringConversionConfiguration);
    5052template<typename T, typename ExceptionThrower> typename Converter<T>::ReturnType convert(JSC::ExecState&, JSC::JSValue, ExceptionThrower&&);
     53template<typename T, typename ExceptionThrower> typename Converter<T>::ReturnType convert(JSC::ExecState&, JSC::JSValue, JSC::JSObject&, ExceptionThrower&&);
     54template<typename T, typename ExceptionThrower> typename Converter<T>::ReturnType convert(JSC::ExecState&, JSC::JSValue, JSDOMGlobalObject&, ExceptionThrower&&);
    5155
    5256// Specialized by generated code for IDL dictionary conversion.
     
    6367}
    6468
     69template<typename T> inline typename Converter<T>::ReturnType convert(JSC::ExecState& state, JSC::JSValue value, JSC::JSObject& thisObject)
     70{
     71    return Converter<T>::convert(state, value, thisObject);
     72}
     73
     74template<typename T> inline typename Converter<T>::ReturnType convert(JSC::ExecState& state, JSC::JSValue value, JSDOMGlobalObject& globalObject)
     75{
     76    return Converter<T>::convert(state, value, globalObject);
     77}
     78
    6579template<typename T> inline typename Converter<T>::ReturnType convert(JSC::ExecState& state, JSC::JSValue value, IntegerConversionConfiguration configuration)
    6680{
     
    7690{
    7791    return Converter<T>::convert(state, value, std::forward<ExceptionThrower>(exceptionThrower));
     92}
     93
     94template<typename T, typename ExceptionThrower> inline typename Converter<T>::ReturnType convert(JSC::ExecState& state, JSC::JSValue value, JSC::JSObject& thisObject, ExceptionThrower&& exceptionThrower)
     95{
     96    return Converter<T>::convert(state, value, thisObject, std::forward<ExceptionThrower>(exceptionThrower));
     97}
     98
     99template<typename T, typename ExceptionThrower> inline typename Converter<T>::ReturnType convert(JSC::ExecState& state, JSC::JSValue value, JSDOMGlobalObject& globalObject, ExceptionThrower&& exceptionThrower)
     100{
     101    return Converter<T>::convert(state, value, globalObject, std::forward<ExceptionThrower>(exceptionThrower));
    78102}
    79103
     
    222246        return Converter<T>::convert(state, value);
    223247    }
     248    static ReturnType convert(JSC::ExecState& state, JSC::JSValue value, JSC::JSObject& thisObject)
     249    {
     250        if (value.isUndefinedOrNull())
     251            return T::nullValue();
     252        return Converter<T>::convert(state, value, thisObject);
     253    }
     254    static ReturnType convert(JSC::ExecState& state, JSC::JSValue value, JSDOMGlobalObject& globalObject)
     255    {
     256        if (value.isUndefinedOrNull())
     257            return T::nullValue();
     258        return Converter<T>::convert(state, value, globalObject);
     259    }
    224260    static ReturnType convert(JSC::ExecState& state, JSC::JSValue value, IntegerConversionConfiguration configuration)
    225261    {
     
    234270        return Converter<T>::convert(state, value, configuration);
    235271    }
    236 
    237272    template<typename ExceptionThrower = DefaultExceptionThrower>
    238273    static ReturnType convert(JSC::ExecState& state, JSC::JSValue value, ExceptionThrower&& exceptionThrower)
     
    241276            return T::nullValue();
    242277        return Converter<T>::convert(state, value, std::forward<ExceptionThrower>(exceptionThrower));
     278    }
     279    template<typename ExceptionThrower = DefaultExceptionThrower>
     280    static ReturnType convert(JSC::ExecState& state, JSC::JSValue value, JSC::JSObject& thisObject, ExceptionThrower&& exceptionThrower)
     281    {
     282        if (value.isUndefinedOrNull())
     283            return T::nullValue();
     284        return Converter<T>::convert(state, value, thisObject, std::forward<ExceptionThrower>(exceptionThrower));
     285    }
     286    template<typename ExceptionThrower = DefaultExceptionThrower>
     287    static ReturnType convert(JSC::ExecState& state, JSC::JSValue value, JSDOMGlobalObject& globalObject, ExceptionThrower&& exceptionThrower)
     288    {
     289        if (value.isUndefinedOrNull())
     290            return T::nullValue();
     291        return Converter<T>::convert(state, value, globalObject, std::forward<ExceptionThrower>(exceptionThrower));
    243292    }
    244293};
     
    10161065    {
    10171066        return convertEnumerationToJS(exec, value);
     1067    }
     1068};
     1069
     1070// MARK: -
     1071// MARK: Callback function type
     1072
     1073template<typename T> struct Converter<IDLCallbackFunction<T>> : DefaultConverter<IDLCallbackFunction<T>> {
     1074    template<typename ExceptionThrower = DefaultExceptionThrower>
     1075    static RefPtr<T> convert(JSC::ExecState& state, JSC::JSValue value, JSDOMGlobalObject& globalObject, ExceptionThrower&& exceptionThrower = ExceptionThrower())
     1076    {
     1077        JSC::VM& vm = state.vm();
     1078        auto scope = DECLARE_THROW_SCOPE(vm);
     1079
     1080        if (!value.isFunction()) {
     1081            exceptionThrower(state, scope);
     1082            return nullptr;
     1083        }
     1084       
     1085        return T::create(JSC::asObject(value), &globalObject);
     1086    }
     1087};
     1088
     1089template<typename T> struct JSConverter<IDLCallbackFunction<T>> {
     1090    static constexpr bool needsState = false;
     1091    static constexpr bool needsGlobalObject = false;
     1092
     1093    template <typename U>
     1094    static JSC::JSValue convert(const U& value)
     1095    {
     1096        return toJS(Detail::getPtrOrRef(value));
     1097    }
     1098
     1099    template<typename U>
     1100    static JSC::JSValue convertNewlyCreated(U&& value)
     1101    {
     1102        return toJSNewlyCreated(std::forward<U>(value));
     1103    }
     1104};
     1105
     1106// MARK: -
     1107// MARK: Callback interface type
     1108
     1109template<typename T> struct Converter<IDLCallbackInterface<T>> : DefaultConverter<IDLCallbackInterface<T>> {
     1110    template<typename ExceptionThrower = DefaultExceptionThrower>
     1111    static RefPtr<T> convert(JSC::ExecState& state, JSC::JSValue value, JSDOMGlobalObject& globalObject, ExceptionThrower&& exceptionThrower = ExceptionThrower())
     1112    {
     1113        JSC::VM& vm = state.vm();
     1114        auto scope = DECLARE_THROW_SCOPE(vm);
     1115
     1116        if (!value.isObject()) {
     1117            exceptionThrower(state, scope);
     1118            return nullptr;
     1119        }
     1120
     1121        return T::create(JSC::asObject(value), &globalObject);
     1122    }
     1123};
     1124
     1125template<typename T> struct JSConverter<IDLCallbackInterface<T>> {
     1126    static constexpr bool needsState = false;
     1127    static constexpr bool needsGlobalObject = false;
     1128
     1129    template <typename U>
     1130    static JSC::JSValue convert(const U& value)
     1131    {
     1132        return toJS(Detail::getPtrOrRef(value));
     1133    }
     1134
     1135    template<typename U>
     1136    static JSC::JSValue convertNewlyCreated(U&& value)
     1137    {
     1138        return toJSNewlyCreated(std::forward<U>(value));
    10181139    }
    10191140};
     
    12931414
    12941415// MARK: -
     1416// MARK: SerializedScriptValue type
     1417
     1418template<typename T> struct Converter<IDLSerializedScriptValue<T>> : DefaultConverter<IDLSerializedScriptValue<T>> {
     1419    static RefPtr<T> convert(JSC::ExecState& state, JSC::JSValue value)
     1420    {
     1421        return T::create(state, value);
     1422    }
     1423};
     1424
     1425template<typename T> struct JSConverter<IDLSerializedScriptValue<T>> {
     1426    static constexpr bool needsState = true;
     1427    static constexpr bool needsGlobalObject = true;
     1428
     1429    static JSC::JSValue convert(JSC::ExecState& state, JSDOMGlobalObject& globalObject, RefPtr<T> value)
     1430    {
     1431        return value ? value->deserialize(state, &globalObject) : JSC::jsNull();
     1432    }
     1433};
     1434
     1435// MARK: -
     1436// MARK: Legacy dictionary type
     1437
     1438template<typename T> struct Converter<IDLLegacyDictionary<T>> : DefaultConverter<IDLLegacyDictionary<T>> {
     1439    using ReturnType = T;
     1440
     1441    static ReturnType convert(JSC::ExecState& state, JSC::JSValue value)
     1442    {
     1443        return T(&state, value);
     1444    }
     1445};
     1446
     1447// MARK: -
     1448// MARK: Event Listener type
     1449
     1450template<typename T> struct Converter<IDLEventListener<T>> : DefaultConverter<IDLEventListener<T>> {
     1451    using ReturnType = RefPtr<T>;
     1452
     1453    static ReturnType convert(JSC::ExecState& state, JSC::JSValue value, JSC::JSObject& thisObject)
     1454    {
     1455        auto scope = DECLARE_THROW_SCOPE(state.vm());
     1456
     1457        auto listener = T::create(value, thisObject, false, currentWorld(&state));
     1458        if (!listener)
     1459            throwTypeError(&state, scope);
     1460   
     1461        return listener;
     1462    }
     1463};
     1464
     1465// MARK: -
     1466// MARK: XPathNSResolver type
     1467
     1468template<typename T> struct Converter<IDLXPathNSResolver<T>> : DefaultConverter<IDLXPathNSResolver<T>> {
     1469    using ReturnType = RefPtr<T>;
     1470    using WrapperType = typename JSDOMWrapperConverterTraits<T>::WrapperClass;
     1471
     1472    template<typename ExceptionThrower = DefaultExceptionThrower>
     1473    static ReturnType convert(JSC::ExecState& state, JSC::JSValue value, ExceptionThrower&& exceptionThrower = ExceptionThrower())
     1474    {
     1475        JSC::VM& vm = state.vm();
     1476        auto scope = DECLARE_THROW_SCOPE(vm);
     1477        ReturnType object = WrapperType::toWrapped(state, value);
     1478        if (UNLIKELY(!object))
     1479            exceptionThrower(state, scope);
     1480        return object;
     1481    }
     1482};
     1483
     1484template<typename T> struct JSConverter<IDLXPathNSResolver<T>> {
     1485    static constexpr bool needsState = true;
     1486    static constexpr bool needsGlobalObject = true;
     1487
     1488    template <typename U>
     1489    static JSC::JSValue convert(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const U& value)
     1490    {
     1491        return toJS(&state, &globalObject, Detail::getPtrOrRef(value));
     1492    }
     1493
     1494    template<typename U>
     1495    static JSC::JSValue convertNewlyCreated(JSC::ExecState& state, JSDOMGlobalObject& globalObject, U&& value)
     1496    {
     1497        return toJSNewlyCreated(&state, &globalObject, std::forward<U>(value));
     1498    }
     1499};
     1500
     1501// MARK: -
    12951502// MARK: Support for variadic tail convertions
    12961503
  • trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm

    r208893 r209153  
    9292);
    9393
    94 # WebCore types used directly in IDL files.
    95 my %webCoreTypeHash = (
    96     "Dictionary" => 1,
    97     "SerializedScriptValue" => 1,
    98 );
    99 
    10094my %dictionaryTypeImplementationNameOverrides = ();
    10195my %enumTypeImplementationNameOverrides = ();
     
    856850}
    857851
     852sub IsBuiltinType
     853{
     854    my ($object, $type) = @_;
     855
     856    assert("Not a type") if ref($type) ne "IDLType";
     857
     858    return 1 if $object->IsPrimitiveType($type);
     859    return 1 if $object->IsSequenceOrFrozenArrayType($type);
     860    return 1 if $object->IsRecordType($type);
     861    return 1 if $object->IsStringType($type);
     862    return 1 if $object->IsTypedArrayType($type);
     863    return 1 if $type->isUnion;
     864    return 1 if $type->name eq "any";
     865    return 1 if $type->name eq "BufferSource";
     866    return 1 if $type->name eq "Promise";
     867    return 1 if $type->name eq "XPathNSResolver";   
     868    return 1 if $type->name eq "EventListener";   
     869    return 1 if $type->name eq "Dictionary";   
     870    return 1 if $type->name eq "SerializedScriptValue";   
     871
     872    return 0;
     873}
     874
     875sub IsInterfaceType
     876{
     877    my ($object, $type) = @_;
     878
     879    assert("Not a type") if ref($type) ne "IDLType";
     880
     881    return 0 if $object->IsBuiltinType($type);
     882    return 0 if $object->IsDictionaryType($type);
     883    return 0 if $object->IsEnumType($type);
     884
     885    return 1;
     886}
     887
    858888sub IsWrapperType
    859889{
     
    862892    assert("Not a type") if ref($type) ne "IDLType";
    863893
    864     return 0 if !$object->IsRefPtrType($type);
    865     return 0 if $object->IsTypedArrayType($type);
    866     return 0 if $type->name eq "BufferSource";
    867     return 0 if $webCoreTypeHash{$type->name};
    868 
    869     return 1;
     894    return 1 if $object->IsInterfaceType($type);
     895    return 1 if $type->name eq "XPathNSResolver";
     896
     897    return 0;
    870898}
    871899
     
    908936    assert("Not a type") if ref($type) ne "IDLType";
    909937
    910     return 0 unless $object->IsWrapperType($type);
     938    return 0 unless $object->IsInterfaceType($type);
    911939
    912940    my $typeName = $type->name;
     
    945973    assert("Not a type") if ref($type) ne "IDLType";
    946974
    947     return 0 unless $object->IsWrapperType($type);
     975    return 0 unless $object->IsInterfaceType($type);
    948976
    949977    my $typeName = $type->name;
     
    10931121}
    10941122
    1095 sub ShouldPassWrapperByReference
    1096 {
    1097     my ($object, $argument) = @_;
    1098 
    1099     return 0 if $argument->type->isNullable;
    1100     return 0 if !$object->IsWrapperType($argument->type) && !$object->IsTypedArrayType($argument->type);
    1101 
    1102     return 1;
    1103 }
    11041123
    110511241;
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r208985 r209153  
    279279    return if $codeGenerator->IsStringType($type);
    280280    return if $codeGenerator->IsTypedArrayType($type);
    281     return if $type->name eq "BufferSource";
    282281    return if $type->name eq "any";
    283282
     
    305304    }
    306305
    307     if ($codeGenerator->IsWrapperType($type) || $codeGenerator->IsExternalDictionaryType($type) || $codeGenerator->IsExternalEnumType($type)) {
     306    if ($codeGenerator->IsWrapperType($type) || $codeGenerator->IsExternalDictionaryType($type) || $codeGenerator->IsExternalEnumType($type) || $type->name eq "EventListener") {
    308307        AddToIncludes("JS" . $type->name . ".h", $includesRef, $conditional);
    309308        return;
     
    565564}
    566565
    567 sub GetArgumentExceptionThrower
     566sub GetArgumentExceptionFunction
    568567{
    569568    my ($interface, $argument, $argumentIndex, $quotedFunctionName) = @_;
    570 
    571     return undef if !$codeGenerator->IsWrapperType($argument->type) && !$codeGenerator->IsTypedArrayType($argument->type);
    572569
    573570    my $name = $argument->name;
    574571    my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interface);
    575572    my $typeName = $argument->type->name;
    576    
    577     return "[](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, ${argumentIndex}, \"${name}\", \"${visibleInterfaceName}\", ${quotedFunctionName}, \"${typeName}\"); }"
    578 }
    579 
    580 sub GetAttributeExceptionThrower
     573
     574    if ($codeGenerator->IsCallbackInterface($argument->type) || $codeGenerator->IsCallbackFunction($argument->type)) {
     575        # FIXME: We should have specialized messages for callback interfaces vs. callback functions.
     576        return "throwArgumentMustBeFunctionError(state, scope, ${argumentIndex}, \"${name}\", \"${visibleInterfaceName}\", ${quotedFunctionName});";
     577    }
     578
     579    if ($codeGenerator->IsWrapperType($argument->type) || $codeGenerator->IsTypedArrayType($argument->type)) {
     580        return "throwArgumentTypeError(state, scope, ${argumentIndex}, \"${name}\", \"${visibleInterfaceName}\", ${quotedFunctionName}, \"${typeName}\");";
     581    }
     582
     583    return undef;
     584}
     585
     586sub GetArgumentExceptionThrower
     587{
     588    my ($interface, $argument, $argumentIndex, $quotedFunctionName) = @_;
     589
     590    my $functionCall = GetArgumentExceptionFunction($interface, $argument, $argumentIndex, $quotedFunctionName);
     591    return "[](JSC::ExecState& state, JSC::ThrowScope& scope) { " . $functionCall . " }" if $functionCall;
     592}
     593
     594sub GetAttributeExceptionFunction
    581595{
    582596    my ($interface, $attribute) = @_;
    583 
    584     return undef if !$codeGenerator->IsWrapperType($attribute->type) && !$codeGenerator->IsTypedArrayType($attribute->type);
    585597   
    586598    my $name = $attribute->name;
    587599    my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interface);
    588600    my $typeName = $attribute->type->name;
     601
     602    if ($codeGenerator->IsWrapperType($attribute->type) || $codeGenerator->IsTypedArrayType($attribute->type)) {
     603        return "throwAttributeTypeError(state, scope, \"${visibleInterfaceName}\", \"${name}\", \"${typeName}\");";
     604    }
     605}
     606
     607sub GetAttributeExceptionThrower
     608{
     609    my ($interface, $attribute) = @_;
     610
     611    my $functionCall = GetAttributeExceptionFunction($interface, $attribute);
     612    return "[](JSC::ExecState& state, JSC::ThrowScope& scope) { " . $functionCall . " }" if $functionCall;
     613
     614}
     615
     616sub PassArgumentExpression
     617{
     618    my ($name, $context) = @_;
     619
     620    my $type = $context->type;
     621
     622    return "${name}.value()" if $codeGenerator->IsEnumType($type);
     623    return "WTFMove(${name})" if $type->isNullable;
    589624   
    590     return "[](JSC::ExecState& state, JSC::ThrowScope& scope) { throwAttributeTypeError(state, scope, \"${visibleInterfaceName}\", \"${name}\", \"${typeName}\"); }"
     625    if ($codeGenerator->IsTypedArrayType($type)) {
     626        return "*${name}" if $type->name eq "ArrayBuffer";
     627        return "${name}.releaseNonNull()";
     628    }
     629
     630    return "${name}.releaseNonNull()" if $codeGenerator->IsCallbackInterface($type) || $codeGenerator->IsCallbackFunction($type);
     631    return "*${name}" if $codeGenerator->IsWrapperType($type);
     632    return "WTFMove(${name})";
    591633}
    592634
     
    14301472    if (ShouldGenerateToWrapped($hasParent, $interface)) {
    14311473        my $nativeType = GetNativeType($interface, $interface->type);
    1432         if ($interface->type->name eq "XPathNSResolver") {
    1433             push(@headerContent, "    static $nativeType toWrapped(JSC::ExecState&, JSC::JSValue);\n");
    1434         } else {
    1435             my $export = "";
    1436             $export = "WEBCORE_EXPORT " if $interface->extendedAttributes->{ExportToWrappedFunction};
    1437             push(@headerContent, "    static $export$nativeType toWrapped(JSC::JSValue);\n");
    1438         }
     1474
     1475        # FIXME: Add extended attribute for this.
     1476        my @toWrappedArguments = ();
     1477        push(@toWrappedArguments, "JSC::ExecState&") if $interface->type->name eq "XPathNSResolver";
     1478        push(@toWrappedArguments, "JSC::JSValue");
     1479
     1480        my $export = "";
     1481        $export = "WEBCORE_EXPORT " if $interface->extendedAttributes->{ExportToWrappedFunction};
     1482        push(@headerContent, "    static $export$nativeType toWrapped(" . join(", ", @toWrappedArguments) . ");\n");
    14391483    }
    14401484
     
    18171861        push(@headerContent, "template<> struct JSDOMWrapperConverterTraits<${implType}> {\n");
    18181862        push(@headerContent, "    using WrapperClass = ${className};\n");
    1819         push(@headerContent, "    using ToWrappedReturnType = ${implType}*;\n");
     1863        push(@headerContent, "    using ToWrappedReturnType = " . GetNativeType($interface, $interface->type) . ";\n");
    18201864        push(@headerContent, "};\n");
    18211865    }
     
    35813625                }
    35823626
     3627                my $globalObjectReference = $attribute->isStatic ? "*jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())" : "*thisObject.globalObject()";
    35833628                my $exceptionThrower = GetAttributeExceptionThrower($interface, $attribute);
    35843629
    3585                 my ($nativeValue, $mayThrowException) = JSValueToNative($interface, $attribute, "value", $attribute->extendedAttributes->{Conditional}, "&state", "state", "thisObject", $exceptionThrower);
     3630                my ($nativeValue, $mayThrowException) = JSValueToNative($interface, $attribute, "value", $attribute->extendedAttributes->{Conditional}, "&state", "state", "thisObject", $globalObjectReference, $exceptionThrower);
    35863631
    35873632                push(@implContent, "    auto nativeValue = $nativeValue;\n");
     
    35953640                my ($functionName, @arguments) = $codeGenerator->SetterExpression(\%implIncludes, $interfaceName, $attribute);
    35963641
    3597                 if ($codeGenerator->IsTypedArrayType($type) and not $type->name eq "ArrayBuffer") {
    3598                     push(@arguments, "nativeValue.get()");
    3599                 } elsif ($codeGenerator->IsEnumType($type)) {
    3600                     push(@arguments, "nativeValue.value()");
    3601                 } else {
    3602                     push(@arguments, ShouldPassWrapperByReference($attribute, $interface) ? "*nativeValue" : "WTFMove(nativeValue)");
    3603                 }
     3642                push(@arguments, PassArgumentExpression("nativeValue", $attribute));
     3643
    36043644                my $implementedBy = $attribute->extendedAttributes->{ImplementedBy};
    36053645                if ($implementedBy) {
     
    38413881                    my $encodedName = "encoded" . $codeGenerator->WK_ucfirst($name);
    38423882                    my $nativeType = GetNativeType($interface, $argument->type);
    3843                     my $shouldPassByReference = ShouldPassWrapperByReference($argument, $interface);
     3883                    my $shouldPassByReference = ShouldPassArgumentByReference($argument);
    38443884
    38453885                    if (!$shouldPassByReference && ($codeGenerator->IsWrapperType($type) || $codeGenerator->IsTypedArrayType($type))) {
     
    43094349    my $implementedBy = $function->extendedAttributes->{ImplementedBy};
    43104350    my $numArguments = @{$function->arguments};
     4351    my $conditional = $function->extendedAttributes->{Conditional};
    43114352
    43124353    if ($implementedBy) {
    4313         AddToImplIncludes("${implementedBy}.h", $function->extendedAttributes->{Conditional});
     4354        AddToImplIncludes("${implementedBy}.h", $conditional);
    43144355        unshift(@arguments, "impl") if !$function->isStatic;
    43154356        $functionName = "WebCore::${implementedBy}::${functionImplementationName}";
     
    43294370    }
    43304371
    4331     $implIncludes{"JSDOMBinding.h"} = 1;
     4372    AddToImplIncludes("JSDOMBinding.h", $conditional);
    43324373
    43334374    my $argumentIndex = 0;
     
    43594400        my $value = $name;
    43604401
    4361         if ($codeGenerator->IsCallbackInterface($type) || $codeGenerator->IsCallbackFunction($type)) {
    4362             my $callbackClassName = GetCallbackClassName($type->name);
    4363             my $typeName = $type->name;
    4364             $implIncludes{"$callbackClassName.h"} = 1;
    4365             if ($argument->isOptional) {
    4366                 push(@$outputArray, "    RefPtr<$typeName> $name;\n");
    4367                 push(@$outputArray, "    if (!state->argument($argumentIndex).isUndefinedOrNull()) {\n");
    4368                 if ($codeGenerator->IsCallbackFunction($type)) {
    4369                     push(@$outputArray, "        if (!state->uncheckedArgument($argumentIndex).isFunction())\n");
    4370                 } else {
    4371                     push(@$outputArray, "        if (!state->uncheckedArgument($argumentIndex).isObject())\n");
    4372                 }
    4373                 push(@$outputArray, "            return throwArgumentMustBeFunctionError(*state, throwScope, $argumentIndex, \"$name\", \"$visibleInterfaceName\", $quotedFunctionName);\n");
    4374                 if ($function->isStatic) {
    4375                     AddToImplIncludes("CallbackFunction.h");
    4376                     push(@$outputArray, "        $name = createFunctionOnlyCallback<${callbackClassName}>(state, jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), state->uncheckedArgument($argumentIndex));\n");
    4377                 } else {
    4378                     push(@$outputArray, "        $name = ${callbackClassName}::create(asObject(state->uncheckedArgument($argumentIndex)), castedThis->globalObject());\n");
    4379                 }
    4380                 push(@$outputArray, "    }\n");
    4381             } else {
    4382                 die "CallbackInterface does not support Variadic arguments" if $argument->isVariadic;
    4383                 if ($codeGenerator->IsCallbackFunction($type)) {
    4384                     push(@$outputArray, "    if (UNLIKELY(!state->uncheckedArgument($argumentIndex).isFunction()))\n");
    4385                 } else {
    4386                     push(@$outputArray, "    if (UNLIKELY(!state->uncheckedArgument($argumentIndex).isObject()))\n");
    4387                 }
    4388                 push(@$outputArray, "        return throwArgumentMustBeFunctionError(*state, throwScope, $argumentIndex, \"$name\", \"$visibleInterfaceName\", $quotedFunctionName);\n");
    4389                 if ($function->isStatic) {
    4390                     AddToImplIncludes("CallbackFunction.h");
    4391                     push(@$outputArray, "    auto $name = createFunctionOnlyCallback<${callbackClassName}>(state, jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), state->uncheckedArgument($argumentIndex));\n");
    4392                 } else {
    4393                     push(@$outputArray, "    auto $name = ${callbackClassName}::create(asObject(state->uncheckedArgument($argumentIndex)), castedThis->globalObject());\n");
    4394                 }
    4395             }
    4396             $value = "WTFMove($name)";
    4397         } elsif ($argument->isVariadic) {
    4398             $implIncludes{"JSDOMConvert.h"} = 1;
    4399             AddToImplIncludesForIDLType($type, $function->extendedAttributes->{Conditional});
     4402        if ($argument->isVariadic) {
     4403            AddToImplIncludes("JSDOMConvert.h", $conditional);
     4404            AddToImplIncludesForIDLType($type, $conditional);
    44004405       
    4401             my $metaType = GetIDLType($interface, $type);
    4402             push(@$outputArray, "    auto $name = convertVariadicArguments<$metaType>(*state, $argumentIndex);\n");
     4406            my $IDLType = GetIDLType($interface, $type);
     4407
     4408            push(@$outputArray, "    auto ${name} = convertVariadicArguments<${IDLType}>(*state, ${argumentIndex});\n");
    44034409            push(@$outputArray, "    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n");
    44044410
    4405             $value = "WTFMove($name.arguments.value())";
     4411            $value = "WTFMove(${name}.arguments.value())";
    44064412
    44074413        } elsif ($codeGenerator->IsEnumType($type)) {
     4414            AddToImplIncludes("<runtime/Error.h>", $conditional);
     4415
    44084416            my $className = GetEnumerationClassName($type, $interface);
    4409 
    4410             $implIncludes{"<runtime/Error.h>"} = 1;
    4411 
    44124417            my $nativeType = $className;
    44134418            my $optionalValue = "optionalValue";
     
    44774482                $outer = "state->$argumentLookupMethod($argumentIndex).isUndefined() ? std::optional<$nativeType>() : ";
    44784483                $inner = "state->uncheckedArgument($argumentIndex)";
    4479             } elsif (($argument->type->name eq "EventListener" || $argument->type->name eq "XPathNSResolver") && ($argument->isOptional || $type->isNullable)) {
    4480                 $outer = "";
    4481                 $inner = "state->uncheckedArgument($argumentIndex)";
    44824484            } else {
    44834485                $outer = "";
     
    44854487            }
    44864488
     4489            my $globalObjectReference = $function->isStatic ? "*jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())" : "*castedThis->globalObject()";
    44874490            my $argumentExceptionThrower = GetArgumentExceptionThrower($interface, $argument, $argumentIndex, $quotedFunctionName);
    4488             my ($nativeValue, $mayThrowException) = JSValueToNative($interface, $argument, $inner, $function->extendedAttributes->{Conditional}, "state", "*state", "", $argumentExceptionThrower);
    4489 
    4490             if ($argument->type->name eq "EventListener" || $argument->type->name eq "XPathNSResolver") {
    4491                 if ($argument->isOptional || $type->isNullable) {
    4492                     push(@$outputArray, "    $nativeType $name = nullptr;\n");
    4493                     push(@$outputArray, "    if (!state->$argumentLookupMethod($argumentIndex).isUndefinedOrNull()) {\n");
    4494                     push(@$outputArray, "        $name = $nativeValue;\n");
    4495                     push(@$outputArray, "        RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n") if $mayThrowException;
    4496                     push(@$outputArray, "        if (UNLIKELY(!$name))\n");
    4497                     push(@$outputArray, "            return throwArgumentTypeError(*state, throwScope, $argumentIndex, \"$name\", \"$visibleInterfaceName\", $quotedFunctionName, \"" . $type->name . "\");\n");
    4498                     push(@$outputArray, "    }\n");
    4499                 } else {
    4500                     push(@$outputArray, "    auto $name = $nativeValue;\n");
    4501                     push(@$outputArray, "    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n") if $mayThrowException;
    4502                     push(@$outputArray, "    if (UNLIKELY(!$name))\n");
    4503                     push(@$outputArray, "        return throwArgumentTypeError(*state, throwScope, $argumentIndex, \"$name\", \"$visibleInterfaceName\", $quotedFunctionName, \"" . $type->name . "\");\n");
    4504                 }
    4505             } else {
    4506                 push(@$outputArray, "    auto $name = ${outer}${nativeValue};\n");
    4507                 push(@$outputArray, "    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n") if $mayThrowException;
    4508             }
    4509 
    4510             if (ShouldPassWrapperByReference($argument, $interface)) {
    4511                 if ($codeGenerator->IsTypedArrayType($type) and $type->name ne "ArrayBuffer") {
    4512                     $value = "$name.releaseNonNull()";
    4513                 } else {
    4514                     $value = "*$name";
    4515                 }
    4516             } else {
    4517                 $value = "WTFMove($name)";
    4518             }
     4491
     4492            my ($nativeValue, $mayThrowException) = JSValueToNative($interface, $argument, $inner, $conditional, "state", "*state", "*castedThis", $globalObjectReference, $argumentExceptionThrower);
     4493
     4494            push(@$outputArray, "    auto $name = ${outer}${nativeValue};\n");
     4495            push(@$outputArray, "    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());\n") if $mayThrowException;
     4496
     4497            $value = PassArgumentExpression($name, $argument);
    45194498        }
    45204499
     
    47224701
    47234702    # Constructor
    4724     push(@$contentRef, "    $className(JSC::JSObject* callback, JSDOMGlobalObject*);\n\n");
     4703    push(@$contentRef, "    ${className}(JSC::JSObject*, JSDOMGlobalObject*);\n\n");
    47254704
    47264705    # Private members
     
    47294708
    47304709    # toJS().
    4731     push(@$contentRef, "JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, ${name}&);\n");
    4732     push(@$contentRef, "inline JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, ${name}* impl) { return impl ? toJS(state, globalObject, *impl) : JSC::jsNull(); }\n\n");
     4710    push(@$contentRef, "JSC::JSValue toJS(${name}&);\n");
     4711    push(@$contentRef, "inline JSC::JSValue toJS(${name}* impl) { return impl ? toJS(*impl) : JSC::jsNull(); }\n\n");
    47334712}
    47344713
     
    48714850
    48724851    # toJS() implementation.
    4873     push(@$contentRef, "JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, ${name}& impl)\n");
     4852    push(@$contentRef, "JSC::JSValue toJS(${name}& impl)\n");
    48744853    push(@$contentRef, "{\n");
    48754854    push(@$contentRef, "    if (!static_cast<${className}&>(impl).callbackData())\n");
     
    51425121        # Non-WebIDL extensions
    51435122        "Date" => "IDLDate",
     5123        "SerializedScriptValue" => "IDLSerializedScriptValue<SerializedScriptValue>",
     5124        "Dictionary" => "IDLLegacyDictionary<Dictionary>",
     5125        "EventListener" => "IDLEventListener<JSEventListener>",
     5126        "XPathNSResolver" => "IDLXPathNSResolver<XPathNSResolver>",
     5127
     5128        # Convenience type aliases
    51445129        "BufferSource" => "IDLBufferSource",
    51455130    );
     
    51525137    return "IDLRecord<" . GetIDLType($interface, @{$type->subtypes}[0]) . ", " . GetIDLType($interface, @{$type->subtypes}[1]) . ">" if $codeGenerator->IsRecordType($type);
    51535138    return "IDLUnion<" . join(", ", GetIDLUnionMemberTypes($interface, $type)) . ">" if $type->isUnion;
     5139    return "IDLCallbackFunction<" . GetCallbackClassName($type->name) . ">" if $codeGenerator->IsCallbackFunction($type);
     5140    return "IDLCallbackInterface<" . GetCallbackClassName($type->name) . ">" if $codeGenerator->IsCallbackInterface($type);
     5141
     5142    assert("Unknown type '" . $type->name . "'.\n") unless $codeGenerator->IsInterfaceType($type) || $codeGenerator->IsTypedArrayType($type);
    51545143    return "IDLInterface<" . $type->name . ">";
    51555144}
     
    52145203}
    52155204
    5216 sub ShouldPassWrapperByReference
    5217 {
    5218     my ($parameter, $interface) = @_;
    5219 
    5220     return 0 if $codeGenerator->IsCallbackInterface($parameter->type) || $codeGenerator->IsCallbackFunction($parameter->type);
    5221 
    5222     my $nativeType = GetNativeType($interface, $parameter->type);
    5223     return $codeGenerator->ShouldPassWrapperByReference($parameter) && (substr($nativeType, -1) eq '*' || $nativeType =~ /^RefPtr/);
     5205sub ShouldPassArgumentByReference
     5206{
     5207    my ($argument) = @_;
     5208
     5209    my $type = $argument->type;
     5210
     5211    return 0 if $type->isNullable;
     5212    return 0 if $codeGenerator->IsCallbackInterface($type);
     5213    return 0 if $codeGenerator->IsCallbackFunction($type);
     5214    return 0 if !$codeGenerator->IsWrapperType($type) && !$codeGenerator->IsTypedArrayType($type);
     5215
     5216    return 1;
    52245217}
    52255218
     
    52415234}
    52425235
     5236sub JSValueToNativeDOMConvertNeedsThisObject
     5237{
     5238    my $type = shift;
     5239
     5240    return 1 if $type->name eq "EventListener";
     5241    return 0;
     5242}
     5243
     5244sub JSValueToNativeDOMConvertNeedsGlobalObject
     5245{
     5246    my $type = shift;
     5247
     5248    return 1 if $codeGenerator->IsCallbackInterface($type);
     5249    return 1 if $codeGenerator->IsCallbackFunction($type);
     5250    return 0;
     5251}
     5252
    52435253sub IsValidContextForJSValueToNative
    52445254{
     
    52525262sub JSValueToNative
    52535263{
    5254     my ($interface, $context, $value, $conditional, $statePointer, $stateReference, $thisObjectReference, $exceptionThrower) = @_;
     5264    my ($interface, $context, $value, $conditional, $statePointer, $stateReference, $thisObjectReference, $globalObjectReference, $exceptionThrower) = @_;
    52555265
    52565266    assert("Invalid context type") if !IsValidContextForJSValueToNative($context);
     
    52705280    }
    52715281
    5272     if ($type->name eq "SerializedScriptValue") {
    5273         return ("SerializedScriptValue::create($stateReference, $value)", 1);
    5274     }
    5275 
    5276     if ($type->name eq "Dictionary") {
    5277         return ("Dictionary($statePointer, $value)", 0);
    5278     }
    5279 
    52805282    if ($codeGenerator->IsEnumType($type)) {
    52815283        return ("parseEnumeration<" . GetEnumerationClassName($type, $interface) . ">($stateReference, $value)", 1);
    52825284    }
    52835285
    5284     # FIXME: EventListener should be a callback interface.
    5285     if ($type->name eq "EventListener") {
    5286         return ("JSEventListener::create($value, $thisObjectReference, false, currentWorld($statePointer))", 0);
    5287     }
    5288 
    5289     # FIXME: XPathNSResolver should be a callback interface.
    5290     if ($type->name eq "XPathNSResolver") {
    5291         return ("JSXPathNSResolver::toWrapped($stateReference, $value)", 1);
    5292     }
    5293 
    52945286    AddToImplIncludes("JSDOMConvert.h");
    52955287
     
    52975289
    52985290    my @conversionArguments = ();
    5299     push(@conversionArguments, "$stateReference");
    5300     push(@conversionArguments, "$value");
     5291    push(@conversionArguments, $stateReference);
     5292    push(@conversionArguments, $value);
     5293    push(@conversionArguments, $thisObjectReference) if JSValueToNativeDOMConvertNeedsThisObject($type);
     5294    push(@conversionArguments, $globalObjectReference) if JSValueToNativeDOMConvertNeedsGlobalObject($type);
    53015295    push(@conversionArguments, GetIntegerConversionConfiguration($context)) if $codeGenerator->IsIntegerType($type);
    53025296    push(@conversionArguments, GetStringConversionConfiguration($context)) if $codeGenerator->IsStringType($type);
     
    53565350    return 1 if $codeGenerator->IsStringType($type);
    53575351    return 1 if $codeGenerator->IsEnumType($type);
    5358     return 1 if $codeGenerator->IsWrapperType($type);
     5352    return 1 if $codeGenerator->IsInterfaceType($type);
    53595353    return 1 if $codeGenerator->IsTypedArrayType($type);
    53605354    return 1 if $type->name eq "Date";
     5355    return 1 if $type->name eq "SerializedScriptValue";
     5356    return 1 if $type->name eq "XPathNSResolver";
    53615357
    53625358    return 0;
     
    53715367    return 1 if $codeGenerator->IsSequenceOrFrozenArrayType($type);
    53725368    return 1 if $codeGenerator->IsRecordType($type);
    5373     return 1 if $codeGenerator->IsWrapperType($type);
     5369    return 1 if $codeGenerator->IsInterfaceType($type);
    53745370    return 1 if $codeGenerator->IsTypedArrayType($type);
     5371    return 1 if $type->name eq "SerializedScriptValue";
     5372    return 1 if $type->name eq "XPathNSResolver";
    53755373
    53765374    return 0;
     
    53805378{
    53815379    my ($context, $inFunctionCall, $interface, $value, $thisValue) = @_;
    5382     my $statePointer = "&state";
    53835380    my $stateReference = "state";
    53845381    my $wrapped = "$thisValue.wrapped()";
    5385     my $globalObject = $thisValue ? "$thisValue.globalObject()" : "jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject())";
    5386 
    5387     return NativeToJSValue($context, $inFunctionCall, $interface, $value, $statePointer, $stateReference, $wrapped, $globalObject);
     5382    my $globalObjectReference = $thisValue ? "*$thisValue.globalObject()" : "*jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject())";
     5383
     5384    return NativeToJSValue($context, $inFunctionCall, $interface, $value, $stateReference, $wrapped, $globalObjectReference);
    53885385}
    53895386
     
    53925389{
    53935390    my ($context, $inFunctionCall, $interface, $value, $thisValue) = @_;
    5394     my $statePointer = "state";
    53955391    my $stateReference = "*state";
    53965392    my $wrapped = "$thisValue->wrapped()";
    5397     my $globalObject = $thisValue ? "$thisValue->globalObject()" : "jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())";
    5398 
    5399     return NativeToJSValue($context, $inFunctionCall, $interface, $value, $statePointer, $stateReference, $wrapped, $globalObject);
     5393    my $globalObjectReference = $thisValue ? "*$thisValue->globalObject()" : "*jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())";
     5394
     5395    return NativeToJSValue($context, $inFunctionCall, $interface, $value, $stateReference, $wrapped, $globalObjectReference);
    54005396}
    54015397
     
    54095405sub NativeToJSValue
    54105406{
    5411     my ($context, $inFunctionCall, $interface, $value, $statePointer, $stateReference, $wrapped, $globalObject) = @_;
     5407    my ($context, $inFunctionCall, $interface, $value, $stateReference, $wrapped, $globalObjectReference) = @_;
    54125408
    54135409    assert("Invalid context type") if !IsValidContextForNativeToJSValue($context);
     
    54285424        if (defined $returnType and ($returnType eq "IDBKeyPath" or $returnType eq "IDBKey")) {
    54295425            AddToImplIncludes("IDBBindingUtilities.h", $conditional);
    5430             return "toJS($stateReference, *$globalObject, $value)";
     5426            return "toJS($stateReference, $globalObjectReference, $value)";
    54315427        }
    54325428    }
    54335429
    54345430    AddToImplIncludesForIDLType($type, $conditional);
    5435 
    5436 
    5437     if ($type->name eq "SerializedScriptValue") {
    5438         return "$value ? $value->deserialize($stateReference, $globalObject) : jsNull()";
    5439     }
     5431    AddToImplIncludes("JSDOMConvert.h", $conditional);
    54405432
    54415433    $value = "BindingSecurity::checkSecurityForNode($stateReference, $value)" if $context->extendedAttributes->{CheckSecurityForNode};
    54425434
    5443     AddToImplIncludes("JSDOMConvert.h");
    5444 
    54455435    my $IDLType = GetIDLType($interface, $type);
    54465436
    54475437    my @conversionArguments = ();
    5448     push(@conversionArguments, "$stateReference") if NativeToJSValueDOMConvertNeedsState($type) || $mayThrowException;
    5449     push(@conversionArguments, "*$globalObject") if NativeToJSValueDOMConvertNeedsGlobalObject($type);
     5438    push(@conversionArguments, $stateReference) if NativeToJSValueDOMConvertNeedsState($type) || $mayThrowException;
     5439    push(@conversionArguments, $globalObjectReference) if NativeToJSValueDOMConvertNeedsGlobalObject($type);
    54505440    push(@conversionArguments, "throwScope") if $mayThrowException;
    5451     push(@conversionArguments, "$value");
     5441    push(@conversionArguments, $value);
    54525442
    54535443    my $functionName = $context->extendedAttributes->{NewObject} ? "toJSNewlyCreated" : "toJS";
     
    58935883            foreach my $argument (@{$function->arguments}) {
    58945884                last if $index eq $paramIndex;
    5895                 if (ShouldPassWrapperByReference($argument, $interface)) {
    5896                     push(@constructorArgList, "*" . $argument->name);
    5897                 } else {
    5898                     push(@constructorArgList, "WTFMove(" . $argument->name . ")");
    5899                 }
     5885
     5886                push(@constructorArgList, PassArgumentExpression($argument->name, $argument));
     5887
    59005888                $index++;
    59015889            }
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.cpp

    r208408 r209153  
    6868    MarkedArgumentBuffer args;
    6969    args.append(toJS<IDLInterface<Float32Array>>(*state, *m_data->globalObject(), arrayParam));
    70     args.append(srzParam ? srzParam->deserialize(*state, m_data->globalObject()) : jsNull());
     70    args.append(toJS<IDLSerializedScriptValue<SerializedScriptValue>>(*state, *m_data->globalObject(), srzParam));
    7171    args.append(toJS<IDLDOMString>(*state, strArg));
    7272    args.append(toJS<IDLBoolean>(boolParam));
     
    8181}
    8282
    83 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestCallbackFunction& impl)
     83JSC::JSValue toJS(TestCallbackFunction& impl)
    8484{
    8585    if (!static_cast<JSTestCallbackFunction&>(impl).callbackData())
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.h

    r208408 r209153  
    4646
    4747private:
    48     JSTestCallbackFunction(JSC::JSObject* callback, JSDOMGlobalObject*);
     48    JSTestCallbackFunction(JSC::JSObject*, JSDOMGlobalObject*);
    4949
    5050    JSCallbackDataStrong* m_data;
    5151};
    5252
    53 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestCallbackFunction&);
    54 inline JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestCallbackFunction* impl) { return impl ? toJS(state, globalObject, *impl) : JSC::jsNull(); }
     53JSC::JSValue toJS(TestCallbackFunction&);
     54inline JSC::JSValue toJS(TestCallbackFunction* impl) { return impl ? toJS(*impl) : JSC::jsNull(); }
    5555
    5656} // namespace WebCore
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.cpp

    r208893 r209153  
    7373}
    7474
    75 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestCallbackFunctionWithTypedefs& impl)
     75JSC::JSValue toJS(TestCallbackFunctionWithTypedefs& impl)
    7676{
    7777    if (!static_cast<JSTestCallbackFunctionWithTypedefs&>(impl).callbackData())
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunctionWithTypedefs.h

    r208893 r209153  
    4444
    4545private:
    46     JSTestCallbackFunctionWithTypedefs(JSC::JSObject* callback, JSDOMGlobalObject*);
     46    JSTestCallbackFunctionWithTypedefs(JSC::JSObject*, JSDOMGlobalObject*);
    4747
    4848    JSCallbackDataStrong* m_data;
    4949};
    5050
    51 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestCallbackFunctionWithTypedefs&);
    52 inline JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestCallbackFunctionWithTypedefs* impl) { return impl ? toJS(state, globalObject, *impl) : JSC::jsNull(); }
     51JSC::JSValue toJS(TestCallbackFunctionWithTypedefs&);
     52inline JSC::JSValue toJS(TestCallbackFunctionWithTypedefs* impl) { return impl ? toJS(*impl) : JSC::jsNull(); }
    5353
    5454} // namespace WebCore
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.cpp

    r208408 r209153  
    143143    ExecState* state = m_data->globalObject()->globalExec();
    144144    MarkedArgumentBuffer args;
    145     args.append(srzParam ? srzParam->deserialize(*state, m_data->globalObject()) : jsNull());
     145    args.append(toJS<IDLSerializedScriptValue<SerializedScriptValue>>(*state, *m_data->globalObject(), srzParam));
    146146    args.append(toJS<IDLDOMString>(*state, strParam));
    147147
     
    214214}
    215215
    216 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestCallbackInterface& impl)
     216JSC::JSValue toJS(TestCallbackInterface& impl)
    217217{
    218218    if (!static_cast<JSTestCallbackInterface&>(impl).callbackData())
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackInterface.h

    r208408 r209153  
    5353
    5454private:
    55     JSTestCallbackInterface(JSC::JSObject* callback, JSDOMGlobalObject*);
     55    JSTestCallbackInterface(JSC::JSObject*, JSDOMGlobalObject*);
    5656
    5757    JSCallbackDataStrong* m_data;
    5858};
    5959
    60 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestCallbackInterface&);
    61 inline JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestCallbackInterface* impl) { return impl ? toJS(state, globalObject, *impl) : JSC::jsNull(); }
     60JSC::JSValue toJS(TestCallbackInterface&);
     61inline JSC::JSValue toJS(TestCallbackInterface* impl) { return impl ? toJS(*impl) : JSC::jsNull(); }
    6262
    6363} // namespace WebCore
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp

    r208688 r209153  
    2424#include "JSDOMBinding.h"
    2525#include "JSDOMConstructor.h"
     26#include "JSDOMConvert.h"
    2627#include "JSMediaQueryListListener.h"
    2728#include <runtime/Error.h>
     
    178179    if (UNLIKELY(state->argumentCount() < 1))
    179180        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    180     if (UNLIKELY(!state->uncheckedArgument(0).isFunction()))
    181         return throwArgumentMustBeFunctionError(*state, throwScope, 0, "listener", "TestMediaQueryListListener", "method");
    182     auto listener = JSMediaQueryListListener::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
    183     impl.method(WTFMove(listener));
     181    auto listener = convert<IDLCallbackFunction<JSMediaQueryListListener>>(*state, state->uncheckedArgument(0), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 0, "listener", "TestMediaQueryListListener", "method"); });
     182    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     183    impl.method(listener.releaseNonNull());
    184184    return JSValue::encode(jsUndefined());
    185185}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r208985 r209153  
    2222#include "JSTestObj.h"
    2323
    24 #include "CallbackFunction.h"
    2524#include "Dictionary.h"
    2625#include "Document.h"
     
    4140#include "JSFetchRequest.h"
    4241#include "JSNode.h"
    43 #include "JSPromise.h"
    4442#include "JSSVGDocument.h"
    4543#include "JSSVGPoint.h"
     
    12731271JSC::EncodedJSValue jsTestObjAttributeWithReservedEnumType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
    12741272bool setJSTestObjAttributeWithReservedEnumType(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
    1275 JSC::EncodedJSValue jsTestObjTestReadOnlyPromiseAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
    12761273JSC::EncodedJSValue jsTestObjPutForwardsAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
    12771274bool setJSTestObjPutForwardsAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
     
    14201417    if (UNLIKELY(state->argumentCount() < 2))
    14211418        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    1422     if (UNLIKELY(!state->uncheckedArgument(0).isObject()))
    1423         return throwArgumentMustBeFunctionError(*state, throwScope, 0, "testCallback", "TestObject", nullptr);
    1424     auto testCallback = JSTestCallbackInterface::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
    1425     if (UNLIKELY(!state->uncheckedArgument(1).isFunction()))
    1426         return throwArgumentMustBeFunctionError(*state, throwScope, 1, "testCallbackFunction", "TestObject", nullptr);
    1427     auto testCallbackFunction = JSTestCallbackFunction::create(asObject(state->uncheckedArgument(1)), castedThis->globalObject());
     1419    auto testCallback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*state, state->uncheckedArgument(0), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 0, "testCallback", "TestObject", nullptr); });
     1420    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     1421    auto testCallbackFunction = convert<IDLCallbackFunction<JSTestCallbackFunction>>(*state, state->uncheckedArgument(1), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 1, "testCallbackFunction", "TestObject", nullptr); });
     1422    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    14281423    ScriptExecutionContext* context = castedThis->scriptExecutionContext();
    14291424    if (UNLIKELY(!context))
     
    14311426    ASSERT(context->isDocument());
    14321427    auto& document = downcast<Document>(*context);
    1433     auto object = TestObj::create(document, WTFMove(testCallback), WTFMove(testCallbackFunction));
     1428    auto object = TestObj::create(document, testCallback.releaseNonNull(), testCallbackFunction.releaseNonNull());
    14341429    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
    14351430}
     
    15651560    { "attribute", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
    15661561    { "attributeWithReservedEnumType", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttributeWithReservedEnumType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjAttributeWithReservedEnumType) } },
    1567     { "testReadOnlyPromiseAttribute", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjTestReadOnlyPromiseAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
    15681562    { "putForwardsAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjPutForwardsAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjPutForwardsAttribute) } },
    15691563    { "putForwardsNullableAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjPutForwardsNullableAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestObjPutForwardsNullableAttribute) } },
     
    33363330}
    33373331
    3338 static inline JSValue jsTestObjTestReadOnlyPromiseAttributeGetter(ExecState&, JSTestObj&, ThrowScope& throwScope);
    3339 
    3340 EncodedJSValue jsTestObjTestReadOnlyPromiseAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
    3341 {
    3342     return BindingCaller<JSTestObj>::attribute<jsTestObjTestReadOnlyPromiseAttributeGetter, CastedThisErrorBehavior::RejectPromise>(state, thisValue, "testReadOnlyPromiseAttribute");
    3343 }
    3344 
    3345 static inline JSValue jsTestObjTestReadOnlyPromiseAttributeGetter(ExecState& state, JSTestObj& thisObject, ThrowScope& throwScope)
    3346 {
    3347     UNUSED_PARAM(throwScope);
    3348     UNUSED_PARAM(state);
    3349     auto& impl = thisObject.wrapped();
    3350     JSValue result = toJS<IDLInterface<Promise>>(state, *thisObject.globalObject(), impl.testReadOnlyPromiseAttribute());
    3351     return result;
    3352 }
    3353 
    33543332static inline JSValue jsTestObjPutForwardsAttributeGetter(ExecState&, JSTestObj&, ThrowScope& throwScope);
    33553333
     
    41954173    auto nativeValue = convert<IDLInterface<Float32Array>>(state, value, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwAttributeTypeError(state, scope, "TestObject", "typedArrayAttr", "Float32Array"); });
    41964174    RETURN_IF_EXCEPTION(throwScope, false);
    4197     impl.setTypedArrayAttr(nativeValue.get());
     4175    impl.setTypedArrayAttr(nativeValue.releaseNonNull());
    41984176    return true;
    41994177}
     
    52575235    if (UNLIKELY(state->argumentCount() < 1))
    52585236        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    5259     auto resolver = JSXPathNSResolver::toWrapped(*state, state->uncheckedArgument(0));
    5260     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    5261     if (UNLIKELY(!resolver))
    5262         return throwArgumentTypeError(*state, throwScope, 0, "resolver", "TestObject", "methodWithXPathNSResolverParameter", "XPathNSResolver");
     5237    auto resolver = convert<IDLXPathNSResolver<XPathNSResolver>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "resolver", "TestObject", "methodWithXPathNSResolverParameter", "XPathNSResolver"); });
     5238    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    52635239    impl.methodWithXPathNSResolverParameter(*resolver);
    52645240    return JSValue::encode(jsUndefined());
     
    55635539    if (UNLIKELY(state->argumentCount() < 1))
    55645540        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    5565     auto serializedArg = SerializedScriptValue::create(*state, state->uncheckedArgument(0));
     5541    auto serializedArg = convert<IDLSerializedScriptValue<SerializedScriptValue>>(*state, state->uncheckedArgument(0));
    55665542    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    55675543    impl.serializedValue(WTFMove(serializedArg));
     
    55835559    if (UNLIKELY(state->argumentCount() < 1))
    55845560        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    5585     auto oo = Dictionary(state, state->uncheckedArgument(0));
    5586     auto ooo = Dictionary(state, state->argument(1));
     5561    auto oo = convert<IDLLegacyDictionary<Dictionary>>(*state, state->uncheckedArgument(0));
     5562    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     5563    auto ooo = convert<IDLLegacyDictionary<Dictionary>>(*state, state->argument(1));
     5564    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    55875565    impl.optionsObject(WTFMove(oo), WTFMove(ooo));
    55885566    return JSValue::encode(jsUndefined());
     
    57375715    auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0), StringConversionConfiguration::Normal);
    57385716    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    5739     auto listener = JSEventListener::create(state->uncheckedArgument(1), *castedThis, false, currentWorld(state));
    5740     if (UNLIKELY(!listener))
    5741         return throwArgumentTypeError(*state, throwScope, 1, "listener", "TestObject", "addEventListener", "EventListener");
     5717    auto listener = convert<IDLEventListener<JSEventListener>>(*state, state->uncheckedArgument(1), *castedThis);
     5718    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    57425719    auto useCapture = convert<IDLBoolean>(*state, state->argument(2));
    57435720    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    5744     impl.addEventListener(WTFMove(type), *listener, WTFMove(useCapture));
     5721    impl.addEventListener(WTFMove(type), WTFMove(listener), WTFMove(useCapture));
    57455722    return JSValue::encode(jsUndefined());
    57465723}
     
    57625739    auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0), StringConversionConfiguration::Normal);
    57635740    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    5764     auto listener = JSEventListener::create(state->uncheckedArgument(1), *castedThis, false, currentWorld(state));
    5765     if (UNLIKELY(!listener))
    5766         return throwArgumentTypeError(*state, throwScope, 1, "listener", "TestObject", "removeEventListener", "EventListener");
     5741    auto listener = convert<IDLEventListener<JSEventListener>>(*state, state->uncheckedArgument(1), *castedThis);
     5742    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    57675743    auto useCapture = convert<IDLBoolean>(*state, state->argument(2));
    57685744    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    5769     impl.removeEventListener(WTFMove(type), *listener, WTFMove(useCapture));
     5745    impl.removeEventListener(WTFMove(type), WTFMove(listener), WTFMove(useCapture));
    57705746    return JSValue::encode(jsUndefined());
    57715747}
     
    65066482    UNUSED_PARAM(throwScope);
    65076483    auto& impl = castedThis->wrapped();
    6508     RefPtr<XPathNSResolver> resolver = nullptr;
    6509     if (!state->argument(0).isUndefinedOrNull()) {
    6510         resolver = JSXPathNSResolver::toWrapped(*state, state->uncheckedArgument(0));
    6511         RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    6512         if (UNLIKELY(!resolver))
    6513             return throwArgumentTypeError(*state, throwScope, 0, "resolver", "TestObject", "methodWithOptionalXPathNSResolver", "XPathNSResolver");
    6514     }
     6484    auto resolver = convert<IDLNullable<IDLXPathNSResolver<XPathNSResolver>>>(*state, state->argument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "resolver", "TestObject", "methodWithOptionalXPathNSResolver", "XPathNSResolver"); });
     6485    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    65156486    impl.methodWithOptionalXPathNSResolver(WTFMove(resolver));
    65166487    return JSValue::encode(jsUndefined());
     
    65496520    if (UNLIKELY(state->argumentCount() < 1))
    65506521        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    6551     if (UNLIKELY(!state->uncheckedArgument(0).isObject()))
    6552         return throwArgumentMustBeFunctionError(*state, throwScope, 0, "callback", "TestObject", "methodWithCallbackArg");
    6553     auto callback = JSTestCallbackInterface::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
    6554     impl.methodWithCallbackArg(WTFMove(callback));
     6522    auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*state, state->uncheckedArgument(0), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 0, "callback", "TestObject", "methodWithCallbackArg"); });
     6523    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     6524    impl.methodWithCallbackArg(callback.releaseNonNull());
    65556525    return JSValue::encode(jsUndefined());
    65566526}
     
    65726542    auto nonCallback = convert<IDLLong>(*state, state->uncheckedArgument(0), IntegerConversionConfiguration::Normal);
    65736543    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    6574     if (UNLIKELY(!state->uncheckedArgument(1).isObject()))
    6575         return throwArgumentMustBeFunctionError(*state, throwScope, 1, "callback", "TestObject", "methodWithNonCallbackArgAndCallbackArg");
    6576     auto callback = JSTestCallbackInterface::create(asObject(state->uncheckedArgument(1)), castedThis->globalObject());
    6577     impl.methodWithNonCallbackArgAndCallbackArg(WTFMove(nonCallback), WTFMove(callback));
     6544    auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*state, state->uncheckedArgument(1), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 1, "callback", "TestObject", "methodWithNonCallbackArgAndCallbackArg"); });
     6545    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     6546    impl.methodWithNonCallbackArgAndCallbackArg(WTFMove(nonCallback), callback.releaseNonNull());
    65786547    return JSValue::encode(jsUndefined());
    65796548}
     
    65916560    UNUSED_PARAM(throwScope);
    65926561    auto& impl = castedThis->wrapped();
    6593     RefPtr<TestCallbackInterface> callback;
    6594     if (!state->argument(0).isUndefinedOrNull()) {
    6595         if (!state->uncheckedArgument(0).isObject())
    6596             return throwArgumentMustBeFunctionError(*state, throwScope, 0, "callback", "TestObject", "methodWithCallbackAndOptionalArg");
    6597         callback = JSTestCallbackInterface::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
    6598     }
     6562    auto callback = convert<IDLNullable<IDLCallbackInterface<JSTestCallbackInterface>>>(*state, state->argument(0), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 0, "callback", "TestObject", "methodWithCallbackAndOptionalArg"); });
     6563    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    65996564    impl.methodWithCallbackAndOptionalArg(WTFMove(callback));
    66006565    return JSValue::encode(jsUndefined());
     
    66156580    if (UNLIKELY(state->argumentCount() < 1))
    66166581        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    6617     if (UNLIKELY(!state->uncheckedArgument(0).isFunction()))
    6618         return throwArgumentMustBeFunctionError(*state, throwScope, 0, "callback", "TestObject", "methodWithCallbackFunctionArg");
    6619     auto callback = JSTestCallbackFunction::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
    6620     impl.methodWithCallbackFunctionArg(WTFMove(callback));
     6582    auto callback = convert<IDLCallbackFunction<JSTestCallbackFunction>>(*state, state->uncheckedArgument(0), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 0, "callback", "TestObject", "methodWithCallbackFunctionArg"); });
     6583    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     6584    impl.methodWithCallbackFunctionArg(callback.releaseNonNull());
    66216585    return JSValue::encode(jsUndefined());
    66226586}
     
    66386602    auto nonCallback = convert<IDLLong>(*state, state->uncheckedArgument(0), IntegerConversionConfiguration::Normal);
    66396603    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    6640     if (UNLIKELY(!state->uncheckedArgument(1).isFunction()))
    6641         return throwArgumentMustBeFunctionError(*state, throwScope, 1, "callback", "TestObject", "methodWithNonCallbackArgAndCallbackFunctionArg");
    6642     auto callback = JSTestCallbackFunction::create(asObject(state->uncheckedArgument(1)), castedThis->globalObject());
    6643     impl.methodWithNonCallbackArgAndCallbackFunctionArg(WTFMove(nonCallback), WTFMove(callback));
     6604    auto callback = convert<IDLCallbackFunction<JSTestCallbackFunction>>(*state, state->uncheckedArgument(1), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 1, "callback", "TestObject", "methodWithNonCallbackArgAndCallbackFunctionArg"); });
     6605    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     6606    impl.methodWithNonCallbackArgAndCallbackFunctionArg(WTFMove(nonCallback), callback.releaseNonNull());
    66446607    return JSValue::encode(jsUndefined());
    66456608}
     
    66576620    UNUSED_PARAM(throwScope);
    66586621    auto& impl = castedThis->wrapped();
    6659     RefPtr<TestCallbackFunction> callback;
    6660     if (!state->argument(0).isUndefinedOrNull()) {
    6661         if (!state->uncheckedArgument(0).isFunction())
    6662             return throwArgumentMustBeFunctionError(*state, throwScope, 0, "callback", "TestObject", "methodWithCallbackFunctionAndOptionalArg");
    6663         callback = JSTestCallbackFunction::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
    6664     }
     6622    auto callback = convert<IDLNullable<IDLCallbackFunction<JSTestCallbackFunction>>>(*state, state->argument(0), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 0, "callback", "TestObject", "methodWithCallbackFunctionAndOptionalArg"); });
     6623    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    66656624    impl.methodWithCallbackFunctionAndOptionalArg(WTFMove(callback));
    66666625    return JSValue::encode(jsUndefined());
     
    66726631    auto throwScope = DECLARE_THROW_SCOPE(vm);
    66736632    UNUSED_PARAM(throwScope);
    6674     RefPtr<TestCallbackInterface> callback;
    6675     if (!state->argument(0).isUndefinedOrNull()) {
    6676         if (!state->uncheckedArgument(0).isObject())
    6677             return throwArgumentMustBeFunctionError(*state, throwScope, 0, "callback", "TestObject", "staticMethodWithCallbackAndOptionalArg");
    6678         callback = createFunctionOnlyCallback<JSTestCallbackInterface>(state, jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), state->uncheckedArgument(0));
    6679     }
     6633    auto callback = convert<IDLNullable<IDLCallbackInterface<JSTestCallbackInterface>>>(*state, state->argument(0), *jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 0, "callback", "TestObject", "staticMethodWithCallbackAndOptionalArg"); });
     6634    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    66806635    TestObj::staticMethodWithCallbackAndOptionalArg(WTFMove(callback));
    66816636    return JSValue::encode(jsUndefined());
     
    66896644    if (UNLIKELY(state->argumentCount() < 1))
    66906645        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    6691     if (UNLIKELY(!state->uncheckedArgument(0).isObject()))
    6692         return throwArgumentMustBeFunctionError(*state, throwScope, 0, "callback", "TestObject", "staticMethodWithCallbackArg");
    6693     auto callback = createFunctionOnlyCallback<JSTestCallbackInterface>(state, jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), state->uncheckedArgument(0));
    6694     TestObj::staticMethodWithCallbackArg(WTFMove(callback));
     6646    auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*state, state->uncheckedArgument(0), *jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 0, "callback", "TestObject", "staticMethodWithCallbackArg"); });
     6647    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     6648    TestObj::staticMethodWithCallbackArg(callback.releaseNonNull());
    66956649    return JSValue::encode(jsUndefined());
    66966650}
     
    68506804    if (UNLIKELY(state->argumentCount() < 1))
    68516805        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    6852     if (UNLIKELY(!state->uncheckedArgument(0).isObject()))
    6853         return throwArgumentMustBeFunctionError(*state, throwScope, 0, "callback", "TestObject", "overloadedMethod");
    6854     auto callback = JSTestCallbackInterface::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
    6855     impl.overloadedMethod(WTFMove(callback));
     6806    auto callback = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*state, state->uncheckedArgument(0), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 0, "callback", "TestObject", "overloadedMethod"); });
     6807    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     6808    impl.overloadedMethod(callback.releaseNonNull());
    68566809    return JSValue::encode(jsUndefined());
    68576810}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp

    r208688 r209153  
    9292    auto arrayBufferView = convert<IDLInterface<ArrayBufferView>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "arrayBufferView", "TestOverloadedConstructors", nullptr, "ArrayBufferView"); });
    9393    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    94     auto object = TestOverloadedConstructors::create(*arrayBufferView);
     94    auto object = TestOverloadedConstructors::create(arrayBufferView.releaseNonNull());
    9595    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
    9696}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp

    r208613 r209153  
    3030#include "JSMessagePort.h"
    3131#include "SerializedScriptValue.h"
     32#include <runtime/Error.h>
    3233#include <runtime/FunctionPrototype.h>
    3334#include <runtime/JSArray.h>
     
    3738
    3839namespace WebCore {
     40
     41// Functions
     42
     43JSC::EncodedJSValue JSC_HOST_CALL jsTestSerializedScriptValueInterfacePrototypeFunctionFunction(JSC::ExecState*);
     44JSC::EncodedJSValue JSC_HOST_CALL jsTestSerializedScriptValueInterfacePrototypeFunctionFunctionReturning(JSC::ExecState*);
    3945
    4046// Attributes
     
    102108    { "ports", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfacePorts), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
    103109    { "cachedReadonlyValue", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceCachedReadonlyValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
     110    { "function", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestSerializedScriptValueInterfacePrototypeFunctionFunction), (intptr_t) (1) } },
     111    { "functionReturning", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestSerializedScriptValueInterfacePrototypeFunctionFunctionReturning), (intptr_t) (0) } },
    104112};
    105113
     
    147155}
    148156
     157template<> inline JSTestSerializedScriptValueInterface* BindingCaller<JSTestSerializedScriptValueInterface>::castForOperation(ExecState& state)
     158{
     159    return jsDynamicDowncast<JSTestSerializedScriptValueInterface*>(state.thisValue());
     160}
     161
    149162static inline JSValue jsTestSerializedScriptValueInterfaceValueGetter(ExecState&, JSTestSerializedScriptValueInterface&, ThrowScope& throwScope);
    150163
     
    159172    UNUSED_PARAM(state);
    160173    auto& impl = thisObject.wrapped();
    161     JSValue result = impl.value() ? impl.value()->deserialize(state, thisObject.globalObject()) : jsNull();
     174    JSValue result = toJS<IDLSerializedScriptValue<SerializedScriptValue>>(state, *thisObject.globalObject(), impl.value());
    162175    return result;
    163176}
     
    175188    UNUSED_PARAM(state);
    176189    auto& impl = thisObject.wrapped();
    177     JSValue result = impl.readonlyValue() ? impl.readonlyValue()->deserialize(state, thisObject.globalObject()) : jsNull();
     190    JSValue result = toJS<IDLSerializedScriptValue<SerializedScriptValue>>(state, *thisObject.globalObject(), impl.readonlyValue());
    178191    return result;
    179192}
     
    193206        return cachedValue;
    194207    auto& impl = thisObject.wrapped();
    195     JSValue result = impl.cachedValue() ? impl.cachedValue()->deserialize(state, thisObject.globalObject()) : jsNull();
     208    JSValue result = toJS<IDLSerializedScriptValue<SerializedScriptValue>>(state, *thisObject.globalObject(), impl.cachedValue());
    196209    thisObject.m_cachedValue.set(state.vm(), &thisObject, result);
    197210    return result;
     
    228241        return cachedValue;
    229242    auto& impl = thisObject.wrapped();
    230     JSValue result = impl.cachedReadonlyValue() ? impl.cachedReadonlyValue()->deserialize(state, thisObject.globalObject()) : jsNull();
     243    JSValue result = toJS<IDLSerializedScriptValue<SerializedScriptValue>>(state, *thisObject.globalObject(), impl.cachedReadonlyValue());
    231244    thisObject.m_cachedReadonlyValue.set(state.vm(), &thisObject, result);
    232245    return result;
     
    269282    UNUSED_PARAM(throwScope);
    270283    auto& impl = thisObject.wrapped();
    271     auto nativeValue = SerializedScriptValue::create(state, value);
     284    auto nativeValue = convert<IDLSerializedScriptValue<SerializedScriptValue>>(state, value);
    272285    RETURN_IF_EXCEPTION(throwScope, false);
    273286    impl.setValue(WTFMove(nativeValue));
     
    288301    UNUSED_PARAM(throwScope);
    289302    auto& impl = thisObject.wrapped();
    290     auto nativeValue = SerializedScriptValue::create(state, value);
     303    auto nativeValue = convert<IDLSerializedScriptValue<SerializedScriptValue>>(state, value);
    291304    RETURN_IF_EXCEPTION(throwScope, false);
    292305    impl.setCachedValue(WTFMove(nativeValue));
     
    298311{
    299312    return getDOMConstructor<JSTestSerializedScriptValueInterfaceConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
     313}
     314
     315static inline JSC::EncodedJSValue jsTestSerializedScriptValueInterfacePrototypeFunctionFunctionCaller(JSC::ExecState*, JSTestSerializedScriptValueInterface*, JSC::ThrowScope&);
     316
     317EncodedJSValue JSC_HOST_CALL jsTestSerializedScriptValueInterfacePrototypeFunctionFunction(ExecState* state)
     318{
     319    return BindingCaller<JSTestSerializedScriptValueInterface>::callOperation<jsTestSerializedScriptValueInterfacePrototypeFunctionFunctionCaller>(state, "function");
     320}
     321
     322static inline JSC::EncodedJSValue jsTestSerializedScriptValueInterfacePrototypeFunctionFunctionCaller(JSC::ExecState* state, JSTestSerializedScriptValueInterface* castedThis, JSC::ThrowScope& throwScope)
     323{
     324    UNUSED_PARAM(state);
     325    UNUSED_PARAM(throwScope);
     326    auto& impl = castedThis->wrapped();
     327    if (UNLIKELY(state->argumentCount() < 1))
     328        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
     329    auto value = convert<IDLSerializedScriptValue<SerializedScriptValue>>(*state, state->uncheckedArgument(0));
     330    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     331    impl.function(WTFMove(value));
     332    return JSValue::encode(jsUndefined());
     333}
     334
     335static inline JSC::EncodedJSValue jsTestSerializedScriptValueInterfacePrototypeFunctionFunctionReturningCaller(JSC::ExecState*, JSTestSerializedScriptValueInterface*, JSC::ThrowScope&);
     336
     337EncodedJSValue JSC_HOST_CALL jsTestSerializedScriptValueInterfacePrototypeFunctionFunctionReturning(ExecState* state)
     338{
     339    return BindingCaller<JSTestSerializedScriptValueInterface>::callOperation<jsTestSerializedScriptValueInterfacePrototypeFunctionFunctionReturningCaller>(state, "functionReturning");
     340}
     341
     342static inline JSC::EncodedJSValue jsTestSerializedScriptValueInterfacePrototypeFunctionFunctionReturningCaller(JSC::ExecState* state, JSTestSerializedScriptValueInterface* castedThis, JSC::ThrowScope& throwScope)
     343{
     344    UNUSED_PARAM(state);
     345    UNUSED_PARAM(throwScope);
     346    auto& impl = castedThis->wrapped();
     347    return JSValue::encode(toJS<IDLSerializedScriptValue<SerializedScriptValue>>(*state, *castedThis->globalObject(), impl.functionReturning()));
    300348}
    301349
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp

    r208985 r209153  
    135135    auto hello = convert<IDLDOMString>(*state, state->uncheckedArgument(0), StringConversionConfiguration::Normal);
    136136    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    137     if (UNLIKELY(!state->uncheckedArgument(1).isFunction()))
    138         return throwArgumentMustBeFunctionError(*state, throwScope, 1, "testCallbackFunction", "TestTypedefs", nullptr);
    139     auto testCallbackFunction = JSTestCallbackFunction::create(asObject(state->uncheckedArgument(1)), castedThis->globalObject());
    140     if (UNLIKELY(!state->uncheckedArgument(2).isObject()))
    141         return throwArgumentMustBeFunctionError(*state, throwScope, 2, "testCallbackInterface", "TestTypedefs", nullptr);
    142     auto testCallbackInterface = JSTestCallbackInterface::create(asObject(state->uncheckedArgument(2)), castedThis->globalObject());
    143     auto object = TestTypedefs::create(WTFMove(hello), WTFMove(testCallbackFunction), WTFMove(testCallbackInterface));
     137    auto testCallbackFunction = convert<IDLCallbackFunction<JSTestCallbackFunction>>(*state, state->uncheckedArgument(1), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 1, "testCallbackFunction", "TestTypedefs", nullptr); });
     138    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     139    auto testCallbackInterface = convert<IDLCallbackInterface<JSTestCallbackInterface>>(*state, state->uncheckedArgument(2), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 2, "testCallbackInterface", "TestTypedefs", nullptr); });
     140    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     141    auto object = TestTypedefs::create(WTFMove(hello), testCallbackFunction.releaseNonNull(), testCallbackInterface.releaseNonNull());
    144142    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
    145143}
     
    264262    UNUSED_PARAM(state);
    265263    auto& impl = thisObject.wrapped();
    266     JSValue result = impl.immutableSerializedScriptValue() ? impl.immutableSerializedScriptValue()->deserialize(state, thisObject.globalObject()) : jsNull();
     264    JSValue result = toJS<IDLSerializedScriptValue<SerializedScriptValue>>(state, *thisObject.globalObject(), impl.immutableSerializedScriptValue());
    267265    return result;
    268266}
     
    401399    UNUSED_PARAM(throwScope);
    402400    auto& impl = thisObject.wrapped();
    403     auto nativeValue = SerializedScriptValue::create(state, value);
     401    auto nativeValue = convert<IDLSerializedScriptValue<SerializedScriptValue>>(state, value);
    404402    RETURN_IF_EXCEPTION(throwScope, false);
    405403    impl.setImmutableSerializedScriptValue(WTFMove(nativeValue));
     
    549547    if (UNLIKELY(state->argumentCount() < 1))
    550548        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    551     auto sequenceArg = convert<IDLSequence<IDLInterface<SerializedScriptValue>>>(*state, state->uncheckedArgument(0));
     549    auto sequenceArg = convert<IDLSequence<IDLSerializedScriptValue<SerializedScriptValue>>>(*state, state->uncheckedArgument(0));
    552550    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    553551    return JSValue::encode(toJS<IDLUnsignedLongLong>(impl.methodWithSequenceArg(WTFMove(sequenceArg))));
  • trunk/Source/WebCore/bindings/scripts/test/TestObj.idl

    r208893 r209153  
    392392    void _any(unrestricted float a, long b);
    393393
    394 
    395     readonly attribute Promise<void> testReadOnlyPromiseAttribute;
     394    // FIXME: Add support for Promise attributes.
     395    // readonly attribute Promise<void> testReadOnlyPromiseAttribute;
     396   
    396397    // Promise function
    397398    Promise<void> testPromiseFunction();
  • trunk/Source/WebCore/bindings/scripts/test/TestSerializedScriptValueInterface.idl

    r204336 r209153  
    2525
    2626// This IDL file is for testing the bindings code generator and for tracking
    27 // changes in its ouput.
     27// changes in its output.
    2828[
    2929    Conditional=Condition1|Condition2,
     
    3434    readonly attribute sequence<MessagePort> ports;
    3535    [CachedAttribute] readonly attribute SerializedScriptValue cachedReadonlyValue;
     36    void function(SerializedScriptValue value);
     37    SerializedScriptValue functionReturning();
    3638};
Note: See TracChangeset for help on using the changeset viewer.