Changeset 207737 in webkit


Ignore:
Timestamp:
Oct 23, 2016 10:02:05 PM (7 years ago)
Author:
weinig@apple.com
Message:

[WebIDL] Add IDLType based toJS conversion
https://bugs.webkit.org/show_bug.cgi?id=163861

Reviewed by Darin Adler.

Source/WebCore:

Adds toJS<IDLType>() functions to be the new way of converting
from implementation types to JS types. These are implemented via
a similar mechanism to the convert<IDL>() functions, though specializations
of a JSConverter struct (rather than the Converter structs). This allows
us to support arbitrarily complex aggregate types easily (e.g. sequence<(Node or DOMString?)>).

  • Modules/geolocation/Geoposition.idl:
  • dom/Event.idl:

Add typedef for DOMTimeStamp. Eventually, our IDLParser should do this for us, but
for now it allows us to simplify the type system.

  • bindings/js/JSDOMBinding.h:

(WebCore::JSValueTraits::arrayJSValue): Deleted.
(WebCore::JSValueTraits<String>::arrayJSValue): Deleted.
(WebCore::JSValueTraits<double>::arrayJSValue): Deleted.
(WebCore::JSValueTraits<float>::arrayJSValue): Deleted.
(WebCore::jsArray): Deleted.
(WebCore::jsFrozenArray): Deleted.
(WebCore::NativeValueTraits<String>::nativeValue): Deleted.
(WebCore::NativeValueTraits<unsigned>::nativeValue): Deleted.
(WebCore::NativeValueTraits<float>::nativeValue): Deleted.
(WebCore::NativeValueTraits<double>::nativeValue): Deleted.
(WebCore::toNullableJSNumber): Deleted.
(WebCore::toJSArray): Deleted.
(WebCore::toJSBoolean): Deleted.
(WebCore::toJSNumber): Deleted.
(WebCore::toJSString): Deleted.
Remove many now-unneeded conversion functions.

  • bindings/js/JSDOMConvert.h:

(WebCore::toJS):
Add 5 primary toJS functions which take combinations of the following
arguments: ExecState, JSDOMGlobalObject, ThrowScope. All take the value
to be converted as well, except in the case of the throwScope ones, where
they take the value in an ExceptionOr<>.

To simplify the implementations of the JSConverter specializations, avoiding
the need for each one to implement their conversion up to 3 times (one for just
the value, one for the value and the ExecState, and one for the value, the ExecState
and the global object), each JSConverter instead specifies whether it's converter
needs an ExecState or global object via a static constexpr. We then use the
JSConverterOverloader template, to call the correct function. This can probably be
improved in the future, by inferring the number of arguments needed via SFINAE, but
this seemed like a more straightforward first cut.

(WebCore::JSConverter<IDLNullable<T>>::convert):
(WebCore::JSConverter<IDLBoolean>::convert):
(WebCore::JSConverter<IDLInterface<T>>::convert):
(WebCore::JSConverter<IDLAny>::convert):
(WebCore::JSConverter<IDLByte>::convert):
(WebCore::JSConverter<IDLOctet>::convert):
(WebCore::JSConverter<IDLShort>::convert):
(WebCore::JSConverter<IDLUnsignedShort>::convert):
(WebCore::JSConverter<IDLLong>::convert):
(WebCore::JSConverter<IDLUnsignedLong>::convert):
(WebCore::JSConverter<IDLLongLong>::convert):
(WebCore::JSConverter<IDLUnsignedLongLong>::convert):
(WebCore::JSConverter<IDLFloat>::convert):
(WebCore::JSConverter<IDLUnrestrictedFloat>::convert):
(WebCore::JSConverter<IDLDouble>::convert):
(WebCore::JSConverter<IDLUnrestrictedDouble>::convert):
(WebCore::JSConverter<IDLDOMString>::convert):
(WebCore::JSConverter<IDLUSVString>::convert):
(WebCore::JSConverter<IDLSequence<T>>::convert):
(WebCore::JSConverter<IDLFrozenArray<T>>::convert):
(WebCore::JSConverter<IDLEnumeration<T>>::convert):
(WebCore::JSConverter<IDLUnion<T...>>::convert):
There is slightly more duplication than I would have liked, for instance we have a
specialization for each numeric type, even though they are all the same, but that is
something that can be improved going forward.

(WebCore::Converter<IDLUnion<T...>>::convert)
Fix the normal IDLUnion converter to work with boolean types. This was caught by the
test case I added via TypeConversions.idl.

  • bindings/js/JSDOMStringMapCustom.cpp:

(WebCore::JSDOMStringMap::getOwnPropertySlotDelegate):

  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore::JSDOMWindow::setTimeout):
(WebCore::JSDOMWindow::setInterval):

  • bindings/js/JSDataTransferCustom.cpp:

(WebCore::JSDataTransfer::types):

  • bindings/js/JSMediaStreamTrackCustom.cpp:

(WebCore::JSMediaStreamTrack::getCapabilities):

  • bindings/js/JSMutationCallback.cpp:

(WebCore::JSMutationCallback::call):

  • bindings/js/JSSVGLengthCustom.cpp:

(WebCore::JSSVGLength::value):
Switch to use new toJS<> functions.

  • bindings/scripts/CodeGeneratorJS.pm:

(AddStringifierOperationIfNeeded):
Fix stringifier function signature to contain an idlType.

(GenerateEnumerationsHeaderContent):
Remove now unnecessary JSValueTraits specializations.

(JSValueToNativeIsHandledByDOMConvert):
Renamed from IsHandledByDOMConvert, since that name is now ambiguous.

(JSValueToNative):
Update for new name of IsHandledByDOMConvert.

(NativeToJSValueIsHandledByDOMConvert):
Predicate guarding what types currently work with the new conversion system.

(NativeToJSValueDOMConvertNeedsState):
Predicate for determining if the ExecState is needed in the conversion function.

(NativeToJSValueDOMConvertNeedsGlobalObject):
Predicate for determining if the global object is needed in the conversion function.

(NativeToJSValue):
Move things around a little bit and start converting use the new toJS<> when possible.

  • bindings/scripts/IDLParser.pm:

(parseAttributeOrOperationRest):
Fix a missing place where were not setting the idlType.

  • bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
  • bindings/scripts/test/JS/JSTestCEReactions.cpp:
  • bindings/scripts/test/JS/JSTestCEReactionsStringifier.cpp:
  • bindings/scripts/test/JS/JSTestCallback.cpp:
  • bindings/scripts/test/JS/JSTestCallbackFunction.cpp:
  • bindings/scripts/test/JS/JSTestEventConstructor.cpp:
  • bindings/scripts/test/JS/JSTestException.cpp:
  • bindings/scripts/test/JS/JSTestGlobalObject.cpp:
  • bindings/scripts/test/JS/JSTestInterface.cpp:
  • bindings/scripts/test/JS/JSTestNode.cpp:
  • bindings/scripts/test/JS/JSTestNondeterministic.cpp:
  • bindings/scripts/test/JS/JSTestObj.cpp:
  • bindings/scripts/test/JS/JSTestObj.h:
  • bindings/scripts/test/JS/JSTestSerialization.cpp:
  • bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
  • bindings/scripts/test/JS/JSTestTypedefs.cpp:
  • bindings/scripts/test/JS/JSattribute.cpp:

Update test results.

  • testing/TypeConversions.h:

(WebCore::TypeConversions::testUnion):
(WebCore::TypeConversions::setTestUnion):
(WebCore::TypeConversions::typeConversionsDictionarySequenceValue):
(WebCore::TypeConversions::typeConversionsDictionaryUnionValue):

  • testing/TypeConversions.idl:

Add a testUnion attribute, now that we can return unions to JS.

LayoutTests:

  • js/dom/webidl-type-mapping-expected.txt:
  • js/dom/webidl-type-mapping.html:
Location:
trunk
Files:
36 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r207736 r207737  
     12016-10-22  Sam Weinig  <sam@webkit.org>
     2
     3        [WebIDL] Add IDLType based toJS conversion
     4        https://bugs.webkit.org/show_bug.cgi?id=163861
     5
     6        Reviewed by Darin Adler.
     7
     8        * js/dom/webidl-type-mapping-expected.txt:
     9        * js/dom/webidl-type-mapping.html:
     10
    1112016-10-23  Zalan Bujtas  <zalan@apple.com>
    212
  • trunk/LayoutTests/js/dom/webidl-type-mapping-expected.txt

    r207575 r207737  
    10601060PASS converter.testUSVString is "undefined"
    10611061PASS converter.testString is "undefined"
     1062converter.testUnion = 'hello'
     1063PASS converter.testUnion is 'hello'
     1064PASS typeof converter.testUnion is 'string'
     1065converter.testUnion = 1
     1066PASS converter.testUnion is 1
     1067PASS typeof converter.testUnion is 'number'
     1068converter.testUnion = false
     1069PASS converter.testUnion is false
     1070PASS typeof converter.testUnion is 'boolean'
     1071converter.testUnion = document
     1072PASS converter.testUnion is document
     1073PASS typeof converter.testUnion is 'object'
     1074PASS converter.testUnion is an instance of Document
     1075converter.testUnion = [1, 2]
     1076PASS converter.testUnion is [1, 2]
     1077PASS typeof converter.testUnion is 'object'
     1078PASS converter.testUnion is an instance of Array
     1079converter.testUnion = null
     1080PASS converter.testUnion is 'null'
     1081PASS typeof converter.testUnion is 'string'
     1082converter.testUnion = undefined
     1083PASS converter.testUnion is 'undefined'
     1084PASS typeof converter.testUnion is 'string'
     1085converter.testUnion = window
     1086PASS typeof converter.testUnion is 'string'
     1087PASS converter.testUnion is '[object Window]'
     1088converter.testUnion = { }
     1089PASS typeof converter.testUnion is 'string'
     1090PASS converter.testUnion is '[object Object]'
     1091PASS converter.testUnion = { toString: function() { throw Error(); } } threw exception Error.
    10621092converter.setTypeConversionsDictionary({ longValue: 1 })
    10631093PASS converter.typeConversionsDictionaryLongValue is 1
  • trunk/LayoutTests/js/dom/webidl-type-mapping.html

    r207575 r207737  
    5353    convertThrows(attribute, "undefined");
    5454}
    55 
     55//
    5656type = "testLong";
    5757verifyAttribute(type);
     
    587587});
    588588
     589evalAndLog("converter.testUnion = 'hello'");
     590shouldBe("converter.testUnion", "'hello'");
     591shouldBe("typeof converter.testUnion", "'string'");
     592evalAndLog("converter.testUnion = 1");
     593shouldBe("converter.testUnion", "1");
     594shouldBe("typeof converter.testUnion", "'number'");
     595evalAndLog("converter.testUnion = false");
     596shouldBe("converter.testUnion", "false");
     597shouldBe("typeof converter.testUnion", "'boolean'");
     598evalAndLog("converter.testUnion = document");
     599shouldBe("converter.testUnion", "document");
     600shouldBe("typeof converter.testUnion", "'object'");
     601shouldBeType("converter.testUnion", "Document");
     602evalAndLog("converter.testUnion = [1, 2]");
     603shouldBe("converter.testUnion", "[1, 2]");
     604shouldBe("typeof converter.testUnion", "'object'");
     605shouldBeType("converter.testUnion", "Array");
     606evalAndLog("converter.testUnion = null");
     607shouldBe("converter.testUnion", "'null'");
     608shouldBe("typeof converter.testUnion", "'string'");
     609evalAndLog("converter.testUnion = undefined");
     610shouldBe("converter.testUnion", "'undefined'");
     611shouldBe("typeof converter.testUnion", "'string'");
     612evalAndLog("converter.testUnion = window");
     613shouldBe("typeof converter.testUnion", "'string'");
     614shouldBe("converter.testUnion", "'[object Window]'");
     615evalAndLog("converter.testUnion = { }");
     616shouldBe("typeof converter.testUnion", "'string'");
     617shouldBe("converter.testUnion", "'[object Object]'");
     618shouldThrow("converter.testUnion = { toString: function() { throw Error(); } }");
     619
    589620evalAndLog("converter.setTypeConversionsDictionary({ longValue: 1 })");
    590621shouldBe("converter.typeConversionsDictionaryLongValue", "1");
  • trunk/Source/WebCore/ChangeLog

    r207736 r207737  
     12016-10-22  Sam Weinig  <sam@webkit.org>
     2
     3        [WebIDL] Add IDLType based toJS conversion
     4        https://bugs.webkit.org/show_bug.cgi?id=163861
     5
     6        Reviewed by Darin Adler.
     7
     8        Adds toJS<IDLType>() functions to be the new way of converting
     9        from implementation types to JS types. These are implemented via
     10        a similar mechanism to the convert<IDL>() functions, though specializations
     11        of a JSConverter struct (rather than the Converter structs). This allows
     12        us to support arbitrarily complex aggregate types easily (e.g. sequence<(Node or DOMString?)>).
     13
     14        * Modules/geolocation/Geoposition.idl:
     15        * dom/Event.idl:
     16        Add typedef for DOMTimeStamp. Eventually, our IDLParser should do this for us, but
     17        for now it allows us to simplify the type system.
     18
     19        * bindings/js/JSDOMBinding.h:
     20        (WebCore::JSValueTraits::arrayJSValue): Deleted.
     21        (WebCore::JSValueTraits<String>::arrayJSValue): Deleted.
     22        (WebCore::JSValueTraits<double>::arrayJSValue): Deleted.
     23        (WebCore::JSValueTraits<float>::arrayJSValue): Deleted.
     24        (WebCore::jsArray): Deleted.
     25        (WebCore::jsFrozenArray): Deleted.
     26        (WebCore::NativeValueTraits<String>::nativeValue): Deleted.
     27        (WebCore::NativeValueTraits<unsigned>::nativeValue): Deleted.
     28        (WebCore::NativeValueTraits<float>::nativeValue): Deleted.
     29        (WebCore::NativeValueTraits<double>::nativeValue): Deleted.
     30        (WebCore::toNullableJSNumber): Deleted.
     31        (WebCore::toJSArray): Deleted.
     32        (WebCore::toJSBoolean): Deleted.
     33        (WebCore::toJSNumber): Deleted.
     34        (WebCore::toJSString): Deleted.
     35        Remove many now-unneeded conversion functions.
     36
     37        * bindings/js/JSDOMConvert.h:
     38        (WebCore::toJS):
     39        Add 5 primary toJS functions which take combinations of the following
     40        arguments: ExecState, JSDOMGlobalObject, ThrowScope.  All take the value
     41        to be converted as well, except in the case of the throwScope ones, where
     42        they take the value in an ExceptionOr<>.
     43
     44        To simplify the implementations of the JSConverter specializations, avoiding
     45        the need for each one to implement their conversion up to 3 times (one for just
     46        the value, one for the value and the ExecState, and one for the value, the ExecState
     47        and the global object), each JSConverter instead specifies whether it's converter
     48        needs an ExecState or global object via a static constexpr. We then use the
     49        JSConverterOverloader template, to call the correct function. This can probably be
     50        improved in the future, by inferring the number of arguments needed via SFINAE, but
     51        this seemed like a more straightforward first cut.
     52
     53        (WebCore::JSConverter<IDLNullable<T>>::convert):
     54        (WebCore::JSConverter<IDLBoolean>::convert):
     55        (WebCore::JSConverter<IDLInterface<T>>::convert):
     56        (WebCore::JSConverter<IDLAny>::convert):
     57        (WebCore::JSConverter<IDLByte>::convert):
     58        (WebCore::JSConverter<IDLOctet>::convert):
     59        (WebCore::JSConverter<IDLShort>::convert):
     60        (WebCore::JSConverter<IDLUnsignedShort>::convert):
     61        (WebCore::JSConverter<IDLLong>::convert):
     62        (WebCore::JSConverter<IDLUnsignedLong>::convert):
     63        (WebCore::JSConverter<IDLLongLong>::convert):
     64        (WebCore::JSConverter<IDLUnsignedLongLong>::convert):
     65        (WebCore::JSConverter<IDLFloat>::convert):
     66        (WebCore::JSConverter<IDLUnrestrictedFloat>::convert):
     67        (WebCore::JSConverter<IDLDouble>::convert):
     68        (WebCore::JSConverter<IDLUnrestrictedDouble>::convert):
     69        (WebCore::JSConverter<IDLDOMString>::convert):
     70        (WebCore::JSConverter<IDLUSVString>::convert):
     71        (WebCore::JSConverter<IDLSequence<T>>::convert):
     72        (WebCore::JSConverter<IDLFrozenArray<T>>::convert):
     73        (WebCore::JSConverter<IDLEnumeration<T>>::convert):
     74        (WebCore::JSConverter<IDLUnion<T...>>::convert):
     75        There is slightly more duplication than I would have liked, for instance we have a
     76        specialization for each numeric type, even though they are all the same, but that is
     77        something that can be improved going forward.
     78
     79        (WebCore::Converter<IDLUnion<T...>>::convert)
     80        Fix the normal IDLUnion converter to work with boolean types. This was caught by the
     81        test case I added via TypeConversions.idl.
     82       
     83        * bindings/js/JSDOMStringMapCustom.cpp:
     84        (WebCore::JSDOMStringMap::getOwnPropertySlotDelegate):
     85        * bindings/js/JSDOMWindowCustom.cpp:
     86        (WebCore::JSDOMWindow::setTimeout):
     87        (WebCore::JSDOMWindow::setInterval):
     88        * bindings/js/JSDataTransferCustom.cpp:
     89        (WebCore::JSDataTransfer::types):
     90        * bindings/js/JSMediaStreamTrackCustom.cpp:
     91        (WebCore::JSMediaStreamTrack::getCapabilities):
     92        * bindings/js/JSMutationCallback.cpp:
     93        (WebCore::JSMutationCallback::call):
     94        * bindings/js/JSSVGLengthCustom.cpp:
     95        (WebCore::JSSVGLength::value):
     96        Switch to use new toJS<> functions.
     97
     98        * bindings/scripts/CodeGeneratorJS.pm:
     99        (AddStringifierOperationIfNeeded):
     100        Fix stringifier function signature to contain an idlType.
     101
     102        (GenerateEnumerationsHeaderContent):
     103        Remove now unnecessary JSValueTraits specializations.
     104
     105        (JSValueToNativeIsHandledByDOMConvert):
     106        Renamed from IsHandledByDOMConvert, since that name is now ambiguous.
     107
     108        (JSValueToNative):
     109        Update for new name of IsHandledByDOMConvert.
     110
     111        (NativeToJSValueIsHandledByDOMConvert):
     112        Predicate guarding what types currently work with the new conversion system.
     113
     114        (NativeToJSValueDOMConvertNeedsState):
     115        Predicate for determining if the ExecState is needed in the conversion function.
     116
     117        (NativeToJSValueDOMConvertNeedsGlobalObject):
     118        Predicate for determining if the global object is needed in the conversion function.
     119
     120        (NativeToJSValue):
     121        Move things around a little bit and start converting use the new toJS<> when possible.
     122
     123        * bindings/scripts/IDLParser.pm:
     124        (parseAttributeOrOperationRest):
     125        Fix a missing place where were not setting the idlType.
     126 
     127        * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
     128        * bindings/scripts/test/JS/JSTestCEReactions.cpp:
     129        * bindings/scripts/test/JS/JSTestCEReactionsStringifier.cpp:
     130        * bindings/scripts/test/JS/JSTestCallback.cpp:
     131        * bindings/scripts/test/JS/JSTestCallbackFunction.cpp:
     132        * bindings/scripts/test/JS/JSTestEventConstructor.cpp:
     133        * bindings/scripts/test/JS/JSTestException.cpp:
     134        * bindings/scripts/test/JS/JSTestGlobalObject.cpp:
     135        * bindings/scripts/test/JS/JSTestInterface.cpp:
     136        * bindings/scripts/test/JS/JSTestNode.cpp:
     137        * bindings/scripts/test/JS/JSTestNondeterministic.cpp:
     138        * bindings/scripts/test/JS/JSTestObj.cpp:
     139        * bindings/scripts/test/JS/JSTestObj.h:
     140        * bindings/scripts/test/JS/JSTestSerialization.cpp:
     141        * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
     142        * bindings/scripts/test/JS/JSTestTypedefs.cpp:
     143        * bindings/scripts/test/JS/JSattribute.cpp:
     144        Update test results.
     145
     146        * testing/TypeConversions.h:
     147        (WebCore::TypeConversions::testUnion):
     148        (WebCore::TypeConversions::setTestUnion):
     149        (WebCore::TypeConversions::typeConversionsDictionarySequenceValue):
     150        (WebCore::TypeConversions::typeConversionsDictionaryUnionValue):
     151        * testing/TypeConversions.idl:
     152        Add a testUnion attribute, now that we can return unions to JS.
     153
    11542016-10-23  Zalan Bujtas  <zalan@apple.com>
    2155
  • trunk/Source/WebCore/Modules/geolocation/Geoposition.idl

    r151207 r207737  
    2424 */
    2525
     26// FIXME: This should be an implementation provided typedef
     27// https://heycam.github.io/webidl/#DOMTimeStamp
     28typedef unsigned long long DOMTimeStamp;
     29
    2630[
    2731    NoInterfaceObject,
  • trunk/Source/WebCore/Modules/webdatabase/SQLResultSet.idl

    r207384 r207737  
    3131] interface SQLResultSet {
    3232    readonly attribute SQLResultSetRowList rows;
    33     [GetterMayThrowException] readonly attribute long insertId;
     33    [GetterMayThrowException] readonly attribute long long insertId;
    3434    readonly attribute long rowsAffected;
    3535};
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.h

    r207711 r207737  
    224224String valueToUSVStringWithUndefinedOrNullCheck(JSC::ExecState*, JSC::JSValue);
    225225
    226 template<typename T> JSC::JSValue toNullableJSNumber(Optional<T>); // null if the optional is null
    227 
    228226int32_t finiteInt32Value(JSC::JSValue, JSC::ExecState*, bool& okay);
    229227
     
    284282JSC::JSValue toJSIteratorEnd(JSC::ExecState&);
    285283
    286 template<typename T, size_t inlineCapacity> JSC::JSValue jsArray(JSC::ExecState*, JSDOMGlobalObject*, const Vector<T, inlineCapacity>&);
    287 template<typename T, size_t inlineCapacity> JSC::JSValue jsArray(JSC::ExecState*, JSDOMGlobalObject*, const Vector<T, inlineCapacity>*);
    288 template<typename T, size_t inlineCapacity> JSC::JSValue jsFrozenArray(JSC::ExecState*, JSDOMGlobalObject*, const Vector<T, inlineCapacity>&);
    289 
    290284JSC::JSValue jsPair(JSC::ExecState&, JSDOMGlobalObject*, JSC::JSValue, JSC::JSValue);
    291285template<typename FirstType, typename SecondType> JSC::JSValue jsPair(JSC::ExecState&, JSDOMGlobalObject*, const FirstType&, const SecondType&);
     
    329323
    330324template<JSC::NativeFunction, int length> JSC::EncodedJSValue nonCachingStaticFunctionGetter(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
    331 
    332 template<typename T> struct NativeValueTraits;
    333325
    334326
     
    414406void propagateException(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<void>&&);
    415407template<typename T> JSC::JSValue toJS(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, ExceptionOr<T>&&);
    416 template<typename T> JSC::JSValue toJSArray(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, ExceptionOr<T>&&);
    417 JSC::JSValue toJSBoolean(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<bool>&&);
    418408JSC::JSValue toJSDate(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<double>&&);
    419409JSC::JSValue toJSNullableDate(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<Optional<double>>&&);
    420410JSC::JSValue toJSNullableString(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<String>&&);
    421411template<typename T> JSC::JSValue toJSNewlyCreated(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, ExceptionOr<T>&& value);
    422 template<typename T> JSC::JSValue toJSNumber(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<T>&& value);
    423 template<typename T> JSC::JSValue toJSNullableNumber(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<T>&& value);
    424 JSC::JSValue toJSString(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<String>&&);
    425412
    426413// Inline functions and template definitions.
     
    720707{
    721708    return createIteratorResultObject(&state, JSC::jsUndefined(), true);
    722 }
    723 
    724 template<typename T> struct JSValueTraits {
    725     static JSC::JSValue arrayJSValue(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, const T& value)
    726     {
    727         return toJS(exec, globalObject, WTF::getPtr(value));
    728     }
    729 };
    730 
    731 template<> struct JSValueTraits<String> {
    732     static JSC::JSValue arrayJSValue(JSC::ExecState* exec, JSDOMGlobalObject*, const String& value)
    733     {
    734         return JSC::jsStringWithCache(exec, value);
    735     }
    736 };
    737 
    738 template<> struct JSValueTraits<double> {
    739     static JSC::JSValue arrayJSValue(JSC::ExecState*, JSDOMGlobalObject*, const double& value)
    740     {
    741         return JSC::jsNumber(value);
    742     }
    743 };
    744 
    745 template<> struct JSValueTraits<float> {
    746     static JSC::JSValue arrayJSValue(JSC::ExecState*, JSDOMGlobalObject*, const float& value)
    747     {
    748         return JSC::jsNumber(value);
    749     }
    750 };
    751 
    752 template<> struct JSValueTraits<unsigned long> {
    753     static JSC::JSValue arrayJSValue(JSC::ExecState*, JSDOMGlobalObject*, const unsigned long& value)
    754     {
    755         return JSC::jsNumber(value);
    756     }
    757 };
    758 
    759 template<typename T, size_t inlineCapacity> JSC::JSValue jsArray(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, const Vector<T, inlineCapacity>& vector)
    760 {
    761     JSC::MarkedArgumentBuffer list;
    762     for (auto& element : vector)
    763         list.append(JSValueTraits<T>::arrayJSValue(exec, globalObject, element));
    764     return JSC::constructArray(exec, nullptr, globalObject, list);
    765 }
    766 
    767 template<typename T, size_t inlineCapacity> inline JSC::JSValue jsArray(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, const Vector<T, inlineCapacity>* vector)
    768 {
    769     if (!vector)
    770         return JSC::constructEmptyArray(exec, nullptr, globalObject, 0);
    771     return jsArray(exec, globalObject, *vector);
    772 }
    773 
    774 template<typename T, size_t inlineCapacity> JSC::JSValue jsFrozenArray(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, const Vector<T, inlineCapacity>& vector)
    775 {
    776     JSC::VM& vm = globalObject->vm();
    777     auto scope = DECLARE_THROW_SCOPE(vm);
    778 
    779     JSC::MarkedArgumentBuffer list;
    780     for (auto& element : vector) {
    781         list.append(JSValueTraits<T>::arrayJSValue(exec, globalObject, element));
    782         RETURN_IF_EXCEPTION(scope, JSC::JSValue());
    783     }
    784     auto* array = JSC::constructArray(exec, nullptr, globalObject, list);
    785     RETURN_IF_EXCEPTION(scope, JSC::JSValue());
    786     return JSC::objectConstructorFreeze(exec, array);
    787709}
    788710
     
    818740inline RefPtr<JSC::Float64Array> toFloat64Array(JSC::JSValue value) { return JSC::toNativeTypedView<JSC::Float64Adaptor>(value); }
    819741
    820 template<> struct NativeValueTraits<String> {
    821     static inline bool nativeValue(JSC::ExecState& exec, JSC::JSValue jsValue, String& indexedValue)
    822     {
    823         JSC::VM& vm = exec.vm();
    824         auto scope = DECLARE_THROW_SCOPE(vm);
    825         indexedValue = jsValue.toWTFString(&exec);
    826         return !scope.exception();
    827     }
    828 };
    829 
    830 template<> struct NativeValueTraits<unsigned> {
    831     static inline bool nativeValue(JSC::ExecState& exec, JSC::JSValue jsValue, unsigned& indexedValue)
    832     {
    833         JSC::VM& vm = exec.vm();
    834         auto scope = DECLARE_THROW_SCOPE(vm);
    835         indexedValue = jsValue.toUInt32(&exec);
    836         return !scope.exception();
    837     }
    838 };
    839 
    840 template<> struct NativeValueTraits<float> {
    841     static inline bool nativeValue(JSC::ExecState& exec, JSC::JSValue jsValue, float& indexedValue)
    842     {
    843         JSC::VM& vm = exec.vm();
    844         auto scope = DECLARE_THROW_SCOPE(vm);
    845         indexedValue = jsValue.toFloat(&exec);
    846         return !scope.exception();
    847     }
    848 };
    849 
    850 template<> struct NativeValueTraits<double> {
    851     static inline bool nativeValue(JSC::ExecState& exec, JSC::JSValue jsValue, double& indexedValue)
    852     {
    853         JSC::VM& vm = exec.vm();
    854         auto scope = DECLARE_THROW_SCOPE(vm);
    855         indexedValue = jsValue.toNumber(&exec);
    856         return !scope.exception();
    857     }
    858 };
    859 
    860742template<typename T, typename JST> inline Vector<Ref<T>> toRefNativeArray(JSC::ExecState& state, JSC::JSValue value)
    861743{
     
    898780}
    899781
    900 template<typename T> inline JSC::JSValue toNullableJSNumber(Optional<T> optionalNumber)
    901 {
    902     return optionalNumber ? JSC::jsNumber(optionalNumber.value()) : JSC::jsNull();
    903 }
    904 
    905782ALWAYS_INLINE void propagateException(JSC::ExecState& state, JSC::ThrowScope& throwScope, Exception&& exception)
    906783{
     
    932809}
    933810
    934 template<typename T> inline JSC::JSValue toJSArray(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope& throwScope, ExceptionOr<T>&& value)
     811template<typename T> inline JSC::JSValue toJSNewlyCreated(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope& throwScope, ExceptionOr<T>&& value)
    935812{
    936813    if (UNLIKELY(value.hasException())) {
     
    938815        return { };
    939816    }
    940     return jsArray(&state, &globalObject, value.releaseReturnValue());
    941 }
    942 
    943 inline JSC::JSValue toJSBoolean(JSC::ExecState& state, JSC::ThrowScope& throwScope, ExceptionOr<bool>&& value)
     817    return toJSNewlyCreated(&state, &globalObject, value.releaseReturnValue());
     818}
     819
     820inline JSC::JSValue toJSNullableString(JSC::ExecState& state, JSC::ThrowScope& throwScope, ExceptionOr<String>&& value)
    944821{
    945822    if (UNLIKELY(value.hasException())) {
     
    947824        return { };
    948825    }
    949     return JSC::jsBoolean(value.releaseReturnValue());
    950 }
    951 
    952 template<typename T> inline JSC::JSValue toJSNewlyCreated(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope& throwScope, ExceptionOr<T>&& value)
    953 {
    954     if (UNLIKELY(value.hasException())) {
    955         propagateException(state, throwScope, value.releaseException());
    956         return { };
    957     }
    958     return toJSNewlyCreated(&state, &globalObject, value.releaseReturnValue());
    959 }
    960 
    961 inline JSC::JSValue toJSNullableString(JSC::ExecState& state, JSC::ThrowScope& throwScope, ExceptionOr<String>&& value)
    962 {
    963     if (UNLIKELY(value.hasException())) {
    964         propagateException(state, throwScope, value.releaseException());
    965         return { };
    966     }
    967826    return jsStringOrNull(&state, value.releaseReturnValue());
    968827}
    969828
    970 template<typename T> inline JSC::JSValue toJSNumber(JSC::ExecState& state, JSC::ThrowScope& throwScope, ExceptionOr<T>&& value)
    971 {
    972     if (UNLIKELY(value.hasException())) {
    973         propagateException(state, throwScope, value.releaseException());
    974         return { };
    975     }
    976     return JSC::jsNumber(value.releaseReturnValue());
    977 }
    978 
    979 inline JSC::JSValue toJSString(JSC::ExecState& state, JSC::ThrowScope& throwScope, ExceptionOr<String>&& value)
    980 {
    981     if (UNLIKELY(value.hasException())) {
    982         propagateException(state, throwScope, value.releaseException());
    983         return { };
    984     }
    985     return JSC::jsStringWithCache(&state, value.releaseReturnValue());
    986 }
    987 
    988829} // namespace WebCore
  • trunk/Source/WebCore/bindings/js/JSDOMConvert.h

    r207734 r207737  
    3232namespace WebCore {
    3333
     34// Conversion from JSValue -> Implementation
    3435template<typename T> struct Converter;
    3536
    3637template<typename T, typename U = T> using EnableIfIntegralType = typename std::enable_if<IsIDLInteger<T>::value, typename Converter<U>::ReturnType>::type;
    3738template<typename T, typename U = T> using EnableIfNotIntegralType = typename std::enable_if<!IsIDLInteger<T>::value, typename Converter<U>::ReturnType>::type;
    38 
    3939template<typename T> EnableIfNotIntegralType<T> convert(JSC::ExecState&, JSC::JSValue);
    40 
    41 // Specialization for integer types, allowing passing of a conversion flag.
    4240template<typename T> EnableIfIntegralType<T> convert(JSC::ExecState&, JSC::JSValue, IntegerConversionConfiguration = NormalConversion);
    4341
     
    5048template<typename T> const char* expectedEnumerationValues();
    5149
    52 // This is where the implementation of the things declared above begins:
    53 
    5450template<typename T> inline EnableIfNotIntegralType<T> convert(JSC::ExecState& state, JSC::JSValue value)
    5551{
     
    6258}
    6359
     60
     61// Conversion from Implementation -> JSValue
     62template<typename T> struct JSConverter;
     63
     64template<typename T, typename U> inline JSC::JSValue toJS(U&&);
     65template<typename T, typename U> inline JSC::JSValue toJS(JSC::ExecState&, U&&);
     66template<typename T, typename U> inline JSC::JSValue toJS(JSC::ExecState&, JSDOMGlobalObject&, U&&);
     67template<typename T, typename U> inline JSC::JSValue toJS(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<U>&&);
     68template<typename T, typename U> inline JSC::JSValue toJS(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, ExceptionOr<U>&&);
     69
     70// Specialized by generated code for IDL enumeration conversion.
     71template<typename T> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, T);
     72
     73
     74template<typename T, bool needsState = JSConverter<T>::needsState, bool needsGlobalObject = JSConverter<T>::needsGlobalObject>
     75struct JSConverterOverloader;
     76
     77template<typename T>
     78struct JSConverterOverloader<T, true, true> {
     79    template<typename U> static JSC::JSValue convert(JSC::ExecState& state, JSDOMGlobalObject& globalObject, U&& value)
     80    {
     81        return JSConverter<T>::convert(state, globalObject, std::forward<U>(value));
     82    }
     83};
     84
     85template<typename T>
     86struct JSConverterOverloader<T, true, false> {
     87    template<typename U> static JSC::JSValue convert(JSC::ExecState& state, U&& value)
     88    {
     89        return JSConverter<T>::convert(state, std::forward<U>(value));
     90    }
     91
     92    template<typename U> static JSC::JSValue convert(JSC::ExecState& state, JSDOMGlobalObject&, U&& value)
     93    {
     94        return JSConverter<T>::convert(state, std::forward<U>(value));
     95    }
     96};
     97
     98template<typename T>
     99struct JSConverterOverloader<T, false, false> {
     100    template<typename U> static JSC::JSValue convert(JSC::ExecState&, U&& value)
     101    {
     102        return JSConverter<T>::convert(std::forward<U>(value));
     103    }
     104
     105    template<typename U> static JSC::JSValue convert(JSC::ExecState&, JSDOMGlobalObject&, U&& value)
     106    {
     107        return JSConverter<T>::convert(std::forward<U>(value));
     108    }
     109};
     110
     111template<typename T, typename U> inline JSC::JSValue toJS(U&& value)
     112{
     113    return JSConverter<T>::convert(std::forward<U>(value));
     114}
     115
     116template<typename T, typename U> inline JSC::JSValue toJS(JSC::ExecState& state, U&& value)
     117{
     118    return JSConverterOverloader<T>::convert(state, std::forward<U>(value));
     119}
     120
     121template<typename T, typename U> inline JSC::JSValue toJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, U&& value)
     122{
     123    return JSConverterOverloader<T>::convert(state, globalObject, std::forward<U>(value));
     124}
     125
     126template<typename T, typename U> inline JSC::JSValue toJS(JSC::ExecState& state, JSC::ThrowScope& throwScope, ExceptionOr<U>&& value)
     127{
     128    if (UNLIKELY(value.hasException())) {
     129        propagateException(state, throwScope, value.releaseException());
     130        return { };
     131    }
     132
     133    return toJS<T>(state, value.releaseReturnValue());
     134}
     135
     136template<typename T, typename U> inline JSC::JSValue toJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope& throwScope, ExceptionOr<U>&& value)
     137{
     138    if (UNLIKELY(value.hasException())) {
     139        propagateException(state, throwScope, value.releaseException());
     140        return { };
     141    }
     142
     143    return toJS<T>(state, globalObject, value.releaseReturnValue());
     144}
     145
     146
    64147template<typename T> struct DefaultConverter {
    65148    using ReturnType = typename T::ImplementationType;
    66 };
    67 
    68 template<typename T> struct Converter : DefaultConverter<T> {
    69149};
    70150
     
    95175};
    96176
     177template<typename T> struct JSConverter<IDLNullable<T>> {
     178    using ImplementationType = typename IDLNullable<T>::ImplementationType;
     179
     180    static constexpr bool needsState = JSConverter<T>::needsState;
     181    static constexpr bool needsGlobalObject = JSConverter<T>::needsGlobalObject;
     182
     183    // FIXME: These only work if ImplementationType is an Optional. We should generalize
     184    // this so it can work for types that don't use Optional to represent nullness, like
     185    // String and interface types.
     186    static JSC::JSValue convert(const ImplementationType& value)
     187    {
     188        if (!value)
     189            return JSC::jsNull();
     190        return JSConverter<T>::convert(value.value());
     191    }
     192    static JSC::JSValue convert(JSC::ExecState& state, const ImplementationType& value)
     193    {
     194        if (!value)
     195            return JSC::jsNull();
     196        return JSConverter<T>::convert(state, value.value());
     197    }
     198    static JSC::JSValue convert(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const ImplementationType& value)
     199    {
     200        if (!value)
     201            return JSC::jsNull();
     202        return JSConverter<T>::convert(state, globalObject, value.value());
     203    }
     204};
     205
    97206// MARK: -
    98207// MARK: Boolean type
     
    102211    {
    103212        return value.toBoolean(&state);
     213    }
     214};
     215
     216template<> struct JSConverter<IDLBoolean> {
     217    static constexpr bool needsState = false;
     218    static constexpr bool needsGlobalObject = false;
     219
     220    static JSC::JSValue convert(bool value)
     221    {
     222        return JSC::jsBoolean(value);
    104223    }
    105224};
     
    135254};
    136255
     256template<typename T> struct JSConverter<IDLInterface<T>> {
     257    static constexpr bool needsState = true;
     258    static constexpr bool needsGlobalObject = true;
     259
     260    template<typename U>
     261    static JSC::JSValue convert(JSC::ExecState& exec, JSDOMGlobalObject& globalObject, const U& value)
     262    {
     263        return toJS(&exec, &globalObject, WTF::getPtr(value));
     264    }
     265};
     266
    137267// Typed arrays support.
    138268
     
    161291template<> struct Converter<IDLAny> : DefaultConverter<IDLAny> {
    162292    static JSC::JSValue convert(JSC::ExecState&, JSC::JSValue value)
     293    {
     294        return value;
     295    }
     296};
     297
     298template<> struct JSConverter<IDLAny> {
     299    static constexpr bool needsState = false;
     300    static constexpr bool needsGlobalObject = false;
     301
     302    static JSC::JSValue convert(const JSC::JSValue& value)
    163303    {
    164304        return value;
     
    184324};
    185325
     326template<> struct JSConverter<IDLByte> {
     327    using Type = typename IDLByte::ImplementationType;
     328
     329    static constexpr bool needsState = false;
     330    static constexpr bool needsGlobalObject = false;
     331
     332    static JSC::JSValue convert(Type value)
     333    {
     334        return JSC::jsNumber(value);
     335    }
     336};
     337
    186338template<> struct Converter<IDLOctet> : DefaultConverter<IDLOctet> {
    187339    static uint8_t convert(JSC::ExecState& state, JSC::JSValue value, IntegerConversionConfiguration configuration = NormalConversion)
     
    199351};
    200352
     353template<> struct JSConverter<IDLOctet> {
     354    using Type = typename IDLOctet::ImplementationType;
     355
     356    static constexpr bool needsState = false;
     357    static constexpr bool needsGlobalObject = false;
     358
     359    static JSC::JSValue convert(Type value)
     360    {
     361        return JSC::jsNumber(value);
     362    }
     363};
     364
    201365template<> struct Converter<IDLShort> : DefaultConverter<IDLShort> {
    202366    static int16_t convert(JSC::ExecState& state, JSC::JSValue value, IntegerConversionConfiguration configuration = NormalConversion)
     
    214378};
    215379
     380template<> struct JSConverter<IDLShort> {
     381    using Type = typename IDLShort::ImplementationType;
     382
     383    static constexpr bool needsState = false;
     384    static constexpr bool needsGlobalObject = false;
     385
     386    static JSC::JSValue convert(Type value)
     387    {
     388        return JSC::jsNumber(value);
     389    }
     390};
     391
    216392template<> struct Converter<IDLUnsignedShort> : DefaultConverter<IDLUnsignedShort> {
    217393    static uint16_t convert(JSC::ExecState& state, JSC::JSValue value, IntegerConversionConfiguration configuration = NormalConversion)
     
    229405};
    230406
     407template<> struct JSConverter<IDLUnsignedShort> {
     408    using Type = typename IDLUnsignedShort::ImplementationType;
     409
     410    static constexpr bool needsState = false;
     411    static constexpr bool needsGlobalObject = false;
     412
     413    static JSC::JSValue convert(Type value)
     414    {
     415        return JSC::jsNumber(value);
     416    }
     417};
     418
    231419template<> struct Converter<IDLLong> : DefaultConverter<IDLLong> {
    232420    static int32_t convert(JSC::ExecState& state, JSC::JSValue value, IntegerConversionConfiguration configuration = NormalConversion)
     
    244432};
    245433
     434template<> struct JSConverter<IDLLong> {
     435    using Type = typename IDLLong::ImplementationType;
     436
     437    static constexpr bool needsState = false;
     438    static constexpr bool needsGlobalObject = false;
     439
     440    static JSC::JSValue convert(Type value)
     441    {
     442        return JSC::jsNumber(value);
     443    }
     444};
     445
    246446template<> struct Converter<IDLUnsignedLong> : DefaultConverter<IDLUnsignedLong> {
    247447    static uint32_t convert(JSC::ExecState& state, JSC::JSValue value, IntegerConversionConfiguration configuration = NormalConversion)
     
    259459};
    260460
     461template<> struct JSConverter<IDLUnsignedLong> {
     462    using Type = typename IDLUnsignedLong::ImplementationType;
     463
     464    static constexpr bool needsState = false;
     465    static constexpr bool needsGlobalObject = false;
     466
     467    static JSC::JSValue convert(Type value)
     468    {
     469        return JSC::jsNumber(value);
     470    }
     471};
     472
    261473template<> struct Converter<IDLLongLong> : DefaultConverter<IDLLongLong> {
    262474    static int64_t convert(JSC::ExecState& state, JSC::JSValue value, IntegerConversionConfiguration configuration = NormalConversion)
     
    277489};
    278490
     491template<> struct JSConverter<IDLLongLong> {
     492    using Type = typename IDLLongLong::ImplementationType;
     493
     494    static constexpr bool needsState = false;
     495    static constexpr bool needsGlobalObject = false;
     496
     497    static JSC::JSValue convert(Type value)
     498    {
     499        return JSC::jsNumber(value);
     500    }
     501};
     502
    279503template<> struct Converter<IDLUnsignedLongLong> : DefaultConverter<IDLUnsignedLongLong> {
    280504    static uint64_t convert(JSC::ExecState& state, JSC::JSValue value, IntegerConversionConfiguration configuration = NormalConversion)
     
    295519};
    296520
     521template<> struct JSConverter<IDLUnsignedLongLong> {
     522    using Type = typename IDLUnsignedLongLong::ImplementationType;
     523
     524    static constexpr bool needsState = false;
     525    static constexpr bool needsGlobalObject = false;
     526
     527    static JSC::JSValue convert(Type value)
     528    {
     529        return JSC::jsNumber(value);
     530    }
     531};
     532
    297533// MARK: -
    298534// MARK: Floating point types
     
    310546};
    311547
     548template<> struct JSConverter<IDLFloat> {
     549    using Type = typename IDLFloat::ImplementationType;
     550
     551    static constexpr bool needsState = false;
     552    static constexpr bool needsGlobalObject = false;
     553
     554    static JSC::JSValue convert(Type value)
     555    {
     556        return JSC::jsNumber(value);
     557    }
     558};
     559
    312560template<> struct Converter<IDLUnrestrictedFloat> : DefaultConverter<IDLUnrestrictedFloat> {
    313561    static float convert(JSC::ExecState& state, JSC::JSValue value)
    314562    {
    315563        return static_cast<float>(value.toNumber(&state));
     564    }
     565};
     566
     567template<> struct JSConverter<IDLUnrestrictedFloat> {
     568    using Type = typename IDLUnrestrictedFloat::ImplementationType;
     569
     570    static constexpr bool needsState = false;
     571    static constexpr bool needsGlobalObject = false;
     572
     573    static JSC::JSValue convert(Type value)
     574    {
     575        return JSC::jsNumber(value);
    316576    }
    317577};
     
    329589};
    330590
     591template<> struct JSConverter<IDLDouble> {
     592    using Type = typename IDLDouble::ImplementationType;
     593
     594    static constexpr bool needsState = false;
     595    static constexpr bool needsGlobalObject = false;
     596
     597    static JSC::JSValue convert(Type value)
     598    {
     599        return JSC::jsNumber(value);
     600    }
     601};
     602
    331603template<> struct Converter<IDLUnrestrictedDouble> : DefaultConverter<IDLUnrestrictedDouble> {
    332604    static double convert(JSC::ExecState& state, JSC::JSValue value)
     
    336608};
    337609
     610template<> struct JSConverter<IDLUnrestrictedDouble> {
     611    using Type = typename IDLUnrestrictedDouble::ImplementationType;
     612
     613    static constexpr bool needsState = false;
     614    static constexpr bool needsGlobalObject = false;
     615
     616    static JSC::JSValue convert(Type value)
     617    {
     618        return JSC::jsNumber(value);
     619    }
     620
     621    // Add overload for MediaTime.
     622    static JSC::JSValue convert(MediaTime value)
     623    {
     624        return JSC::jsNumber(value.toDouble());
     625    }
     626};
     627
    338628// MARK: -
    339629// MARK: String types
     
    346636};
    347637
     638template<> struct JSConverter<IDLDOMString> {
     639    static constexpr bool needsState = true;
     640    static constexpr bool needsGlobalObject = false;
     641
     642    static JSC::JSValue convert(JSC::ExecState& state, const String& value)
     643    {
     644        return JSC::jsStringWithCache(&state, value);
     645    }
     646};
     647
    348648template<> struct Converter<IDLUSVString> : DefaultConverter<IDLUSVString> {
    349649    static String convert(JSC::ExecState& state, JSC::JSValue value)
    350650    {
    351651        return valueToUSVString(&state, value);
     652    }
     653};
     654
     655template<> struct JSConverter<IDLUSVString> {
     656    static constexpr bool needsState = true;
     657    static constexpr bool needsGlobalObject = false;
     658
     659    static JSC::JSValue convert(JSC::ExecState& state, const String& value)
     660    {
     661        return JSC::jsStringWithCache(&state, value);
    352662    }
    353663};
     
    407717};
    408718
     719template<typename T> struct JSConverter<IDLSequence<T>> {
     720    static constexpr bool needsState = true;
     721    static constexpr bool needsGlobalObject = true;
     722
     723    template<typename U, size_t inlineCapacity>
     724    static JSC::JSValue convert(JSC::ExecState& exec, JSDOMGlobalObject& globalObject, const Vector<U, inlineCapacity>& vector)
     725    {
     726        JSC::MarkedArgumentBuffer list;
     727        for (auto& element : vector)
     728            list.append(toJS<T>(exec, globalObject, element));
     729        return JSC::constructArray(&exec, nullptr, &globalObject, list);
     730    }
     731};
     732
    409733template<typename T> struct Converter<IDLFrozenArray<T>> : DefaultConverter<IDLFrozenArray<T>> {
    410734    using ReturnType = typename Detail::ArrayConverter<T>::ReturnType;
     
    416740};
    417741
     742template<typename T> struct JSConverter<IDLFrozenArray<T>> {
     743    static constexpr bool needsState = true;
     744    static constexpr bool needsGlobalObject = true;
     745
     746    template<typename U, size_t inlineCapacity>
     747    static JSC::JSValue convert(JSC::ExecState& exec, JSDOMGlobalObject& globalObject, const Vector<U, inlineCapacity>& vector)
     748    {
     749        JSC::MarkedArgumentBuffer list;
     750        for (auto& element : vector)
     751            list.append(toJS<T>(exec, globalObject, element));
     752        auto* array = JSC::constructArray(&exec, nullptr, &globalObject, list);
     753        return JSC::objectConstructorFreeze(&exec, array);
     754    }
     755};
     756
    418757// MARK: -
    419758// MARK: Dictionary type
     
    438777};
    439778
     779template<typename T> struct JSConverter<IDLEnumeration<T>> {
     780    static constexpr bool needsState = true;
     781    static constexpr bool needsGlobalObject = false;
     782
     783    static JSC::JSValue convert(JSC::ExecState& exec, T value)
     784    {
     785        return convertEnumerationToJS(exec, value);
     786    }
     787};
    440788
    441789// MARK: -
     
    481829using ConditionalFront = typename Detail::ConditionalFront<List, condition>::type;
    482830
    483 template<typename... T>
    484 struct Converter<IDLUnion<T...>> : DefaultConverter<IDLUnion<T...>>
    485 {
     831template<typename... T> struct Converter<IDLUnion<T...>> : DefaultConverter<IDLUnion<T...>> {
    486832    using Type = IDLUnion<T...>;
    487833    using TypeList = typename Type::TypeList;
     
    549895                    return;
    550896               
    551                 using ImplementationType = typename WTF::RemoveCVAndReference<decltype(type)>::type::type::RawType;
    552                 using WrapperType = typename JSDOMWrapperConverterTraits<ImplementationType>::WrapperClass;
     897                using Type = typename WTF::RemoveCVAndReference<decltype(type)>::type::type;
     898                using ImplementationType = typename Type::ImplementationType;
     899                using RawType = typename Type::RawType;
     900                using WrapperType = typename JSDOMWrapperConverterTraits<RawType>::WrapperClass;
    553901
    554902                auto castedValue = WrapperType::toWrapped(value);
     
    556904                    return;
    557905               
    558                 returnValue = ReturnType(castedValue);
     906                returnValue = ReturnType(ImplementationType(castedValue));
    559907            });
    560908
     
    649997};
    650998
     999template<typename... T> struct JSConverter<IDLUnion<T...>> {
     1000    using Type = IDLUnion<T...>;
     1001    using TypeList = typename Type::TypeList;
     1002    using ImplementationType = typename Type::ImplementationType;
     1003
     1004    static constexpr bool needsState = true;
     1005    static constexpr bool needsGlobalObject = true;
     1006
     1007    using Sequence = brigand::make_sequence<brigand::ptrdiff_t<0>, WTF::variant_size<ImplementationType>::value>;
     1008
     1009    static JSC::JSValue convert(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const ImplementationType& variant)
     1010    {
     1011        auto index = variant.index();
     1012
     1013        Optional<JSC::JSValue> returnValue;
     1014        brigand::for_each<Sequence>([&](auto&& type) {
     1015            using I = typename WTF::RemoveCVAndReference<decltype(type)>::type::type;
     1016            if (I::value == index) {
     1017                ASSERT(!returnValue);
     1018                returnValue = toJS<brigand::at<TypeList, I>>(state, globalObject, WTF::get<I::value>(variant));
     1019            }
     1020        });
     1021
     1022        ASSERT(returnValue);
     1023        return returnValue.value();
     1024    }
     1025};
     1026
    6511027// MARK: -
    6521028// MARK: Support for variadic tail convertions
  • trunk/Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp

    r207571 r207737  
    2929#include "CustomElementReactionQueue.h"
    3030#include "DOMStringMap.h"
     31#include "JSDOMConvert.h"
    3132#include "JSNode.h"
    3233#include <runtime/IdentifierInlines.h>
     
    4445    const AtomicString& item = wrapped().item(propertyNameToString(propertyName), nameIsValid);
    4546    if (nameIsValid) {
    46         slot.setValue(this, ReadOnly | DontDelete | DontEnum, toJS(exec, globalObject(), item));
     47        slot.setValue(this, ReadOnly | DontDelete | DontEnum, toJS<IDLDOMString>(*exec, item));
    4748        return true;
    4849    }
  • trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r207522 r207737  
    557557
    558558    int delay = state.argument(1).toInt32(&state);
    559     return toJSNumber(state, scope, wrapped().setTimeout(WTFMove(action), delay));
     559    return toJS<IDLLong>(state, scope, wrapped().setTimeout(WTFMove(action), delay));
    560560}
    561561
     
    575575
    576576    int delay = state.argument(1).toInt32(&state);
    577     return toJSNumber(state, scope, wrapped().setInterval(WTFMove(action), delay));
     577    return toJS<IDLLong>(state, scope, wrapped().setInterval(WTFMove(action), delay));
    578578}
    579579
  • trunk/Source/WebCore/bindings/js/JSDataTransferCustom.cpp

    r191887 r207737  
    3030#include "JSDataTransfer.h"
    3131
    32 #include "JSDOMBinding.h"
     32#include "JSDOMConvert.h"
    3333
    3434using namespace JSC;
     
    3939{
    4040    Vector<String> types = wrapped().types();
    41     return types.isEmpty() ? jsNull() : jsArray(&state, globalObject(), types);
     41    return types.isEmpty() ? jsNull() : toJS<IDLSequence<IDLDOMString>>(state, *globalObject(), types);
    4242}
    4343
  • trunk/Source/WebCore/bindings/js/JSMediaStreamTrackCustom.cpp

    r206252 r207737  
    141141        }
    142142
    143         object->putDirect(state.vm(), Identifier::fromString(&state, "facingMode"), jsArray(&state, castedThis->globalObject(), facingModes), DontDelete | ReadOnly);
     143        object->putDirect(state.vm(), Identifier::fromString(&state, "facingMode"), toJS<IDLSequence<IDLDOMString>>(state, *castedThis->globalObject(), facingModes), DontDelete | ReadOnly);
    144144    }
    145145    if (capabilities->supportsVolume())
     
    151151    if (capabilities->supportsEchoCancellation()) {
    152152        Vector<String> cancellation;
    153         cancellation.reserveCapacity(2);
    154 
    155         cancellation.append("true");
    156         cancellation.append(capabilities->echoCancellation() == RealtimeMediaSourceCapabilities::EchoCancellation::ReadWrite ? "true" : "false");
    157 
    158         object->putDirect(state.vm(), Identifier::fromString(&state, "echoCancellation"), jsArray(&state, castedThis->globalObject(), cancellation), DontDelete | ReadOnly);
     153        cancellation.reserveInitialCapacity(2);
     154
     155        cancellation.uncheckedAppend("true");
     156        cancellation.uncheckedAppend(capabilities->echoCancellation() == RealtimeMediaSourceCapabilities::EchoCancellation::ReadWrite ? "true" : "false");
     157
     158        object->putDirect(state.vm(), Identifier::fromString(&state, "echoCancellation"), toJS<IDLSequence<IDLDOMString>>(state, *castedThis->globalObject(), cancellation), DontDelete | ReadOnly);
    159159    }
    160160    if (capabilities->supportsDeviceId())
  • trunk/Source/WebCore/bindings/js/JSMutationCallback.cpp

    r206960 r207737  
    8383
    8484    MarkedArgumentBuffer args;
    85     args.append(jsArray(exec, globalObject, mutations));
     85    args.append(toJS<IDLSequence<IDLInterface<MutationRecord>>>(*exec, *globalObject, mutations));
    8686    args.append(jsObserver);
    8787
  • trunk/Source/WebCore/bindings/js/JSSVGLengthCustom.cpp

    r207716 r207737  
    2323
    2424#include "ExceptionCode.h"
    25 #include "JSDOMBinding.h"
     25#include "JSDOMConvert.h"
    2626#include "SVGAnimatedProperty.h"
    2727#include "SVGException.h"
     
    3737    VM& vm = state.vm();
    3838    auto scope = DECLARE_THROW_SCOPE(vm);
    39     return toJSNumber(state, scope, wrapped().propertyReference().valueForBindings(SVGLengthContext { wrapped().contextElement() }));
     39    return toJS<IDLUnrestrictedFloat>(state, scope, wrapped().propertyReference().valueForBindings(SVGLengthContext { wrapped().contextElement() }));
    4040}
    4141
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r207725 r207737  
    172172        $stringifier->signature->name("toString");
    173173        die "stringifier can only be used on attributes of String types" unless $codeGenerator->IsStringType($attribute->signature->type);
    174         $stringifier->signature->type($attribute->signature->type);
     174       
     175        # FIXME: This should use IDLParser's cloneType.
     176        my $type = domType->new();
     177        $type->name($attribute->signature->type);
     178
     179        $stringifier->signature->idlType($type);
     180        $stringifier->signature->type($type->name);
     181
    175182        push(@{$interface->functions}, $stringifier);
    176183        last;
     
    878885        $result .= "#if ${conditionalString}\n\n" if $conditionalString;
    879886
    880         # Take an ExecState* instead of an ExecState& to match the jsStringWithCache from JSString.h.
    881887        # FIXME: Change to take VM& instead of ExecState*.
    882         $result .= "JSString* jsStringWithCache(ExecState* state, $className enumerationValue)\n";
     888        $result .= "template<> JSString* convertEnumerationToJS(ExecState& state, $className enumerationValue)\n";
    883889        $result .= "{\n";
    884890        # FIXME: Might be nice to make this global be "const", but NeverDestroyed does not currently support that.
     
    900906        }
    901907        $result .= "    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));\n";
    902         $result .= "    return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);\n";
     908        $result .= "    return jsStringWithCache(&state, values[static_cast<size_t>(enumerationValue)]);\n";
    903909        $result .= "}\n\n";
    904910
     
    967973        $result .= "#if ${conditionalString}\n\n" if $conditionalString;
    968974
    969         $result .= "JSC::JSString* jsStringWithCache(JSC::ExecState*, $className);\n\n";
    970 
    971         $result .= "template<> struct JSValueTraits<$className> {\n";
    972         $result .= "    static JSC::JSString* arrayJSValue(JSC::ExecState* state, JSDOMGlobalObject*, $className value) { return jsStringWithCache(state, value); }\n";
    973         $result .= "};\n\n";
     975        $result .= "template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, $className);\n\n";
    974976
    975977        $result .= "template<> Optional<$className> parseEnumeration<$className>(JSC::ExecState&, JSC::JSValue);\n";
     
    49334935    "DOMString" => "String",
    49344936    "USVString" => "String",
    4935     "DOMTimeStamp" => "DOMTimeStamp",
    49364937    "Date" => "double",
    49374938    "Dictionary" => "Dictionary",
     
    51635164}
    51645165
    5165 sub IsHandledByDOMConvert
     5166sub JSValueToNativeIsHandledByDOMConvert
    51665167{
    51675168    my $idlType = shift;
     
    51925193    $thisObjectReference = "*castedThis" unless $thisObjectReference;
    51935194
    5194     if (IsHandledByDOMConvert($idlType)) {
     5195    if (JSValueToNativeIsHandledByDOMConvert($idlType)) {
    51955196        AddToImplIncludes("JSDOMConvert.h");
    51965197        AddToImplIncludesForIDLType($idlType, $conditional);
     
    52465247}
    52475248
     5249sub NativeToJSValueIsHandledByDOMConvert
     5250{
     5251    my ($idlType) = @_;
     5252
     5253    return 0 if $idlType->isNullable && ($codeGenerator->IsStringType($idlType->name) || $codeGenerator->IsEnumType($idlType->name));
     5254   
     5255    return 1 if $idlType->name eq "any";
     5256    return 1 if $idlType->name eq "boolean";
     5257    return 1 if $codeGenerator->IsIntegerType($idlType->name);
     5258    return 1 if $codeGenerator->IsFloatingPointType($idlType->name);
     5259    return 1 if $codeGenerator->IsStringType($idlType->name);
     5260    return 1 if $codeGenerator->IsEnumType($idlType->name);
     5261    return 1 if $idlType->isUnion;
     5262    return 1 if $codeGenerator->IsSequenceOrFrozenArrayType($idlType->name);
     5263
     5264    return 0;
     5265}
     5266
     5267sub NativeToJSValueDOMConvertNeedsState
     5268{
     5269    my ($idlType) = @_;
     5270   
     5271    # FIXME: This should actually check if all the sub-objects of the union need the state.
     5272    return 1 if $idlType->isUnion;
     5273    return 1 if $codeGenerator->IsSequenceOrFrozenArrayType($idlType->name);
     5274    return 1 if $codeGenerator->IsStringType($idlType->name);
     5275    return 1 if $codeGenerator->IsEnumType($idlType->name);
     5276
     5277    return 0;
     5278}
     5279
     5280sub NativeToJSValueDOMConvertNeedsGlobalObject
     5281{
     5282    my ($idlType) = @_;
     5283   
     5284    # FIXME: This should actually check if all the sub-objects of the union need the global object.
     5285    return 1 if $idlType->isUnion;
     5286    return 1 if $codeGenerator->IsSequenceOrFrozenArrayType($idlType->name);
     5287
     5288    return 0;
     5289}
     5290
    52485291sub NativeToJSValueUsingReferences
    52495292{
     
    52755318    my $conditional = $signature->extendedAttributes->{Conditional};
    52765319    my $type = $signature->type;
     5320    my $idlType = $signature->idlType;
    52775321    my $isNullable = $signature->isNullable;
    52785322    my $mayThrowException = $signature->extendedAttributes->{GetterMayThrowException} || $signature->extendedAttributes->{MayThrowException};
    52795323
    5280     return "toJSBoolean($stateReference, throwScope, $value)" if $type eq "boolean" && $mayThrowException;
    5281     return "jsBoolean($value)" if $type eq "boolean";
    5282     return "toJSNullableDate($stateReference, throwScope, $value)" if $type eq "Date" && $isNullable && $mayThrowException;
    5283     return "jsDateOrNull($statePointer, $value)" if $type eq "Date" && $isNullable;
    5284     return "toJSDate($stateReference, throwScope, $value)" if $type eq "Date" && $mayThrowException;
    5285     return "jsDate($statePointer, $value)" if $type eq "Date";
    5286 
    5287     if ($codeGenerator->IsNumericType($type) or $type eq "DOMTimeStamp") {
    5288         # We could instead overload a function to work with optional as well as non-optional numbers, but this
    5289         # is slightly better because it guarantees we will fail to compile if the IDL file doesn't match the C++.
    5290         if ($signature->extendedAttributes->{Reflect} and ($type eq "unsigned long" or $type eq "unsigned short")) {
    5291             $value =~ s/getUnsignedIntegralAttribute/getIntegralAttribute/g;
    5292             $value = "std::max(0, $value)";
    5293         }
    5294         return "toJSNullableNumber($stateReference, throwScope, $value)" if $isNullable && $mayThrowException;
    5295         return "toNullableJSNumber($value)" if $isNullable;
    5296         return "toJSNumber($stateReference, throwScope, $value)" if $mayThrowException;
    5297         return "jsNumber($value)";
    5298     }
    5299 
    5300     if ($codeGenerator->IsEnumType($type)) {
    5301         AddToImplIncludes("<runtime/JSString.h>", $conditional);
    5302         return "jsStringWithCache($statePointer, $value)";
    5303     }
    5304 
    5305     if ($codeGenerator->IsStringType($type)) {
    5306         AddToImplIncludes("URL.h", $conditional);
    5307         return "toJSNullableString($stateReference, throwScope, $value)" if $isNullable && $mayThrowException;
    5308         return "jsStringOrNull($statePointer, $value)" if $isNullable;
    5309         return "toJSString($stateReference, throwScope, $value)" if $mayThrowException;
    5310         AddToImplIncludes("<runtime/JSString.h>", $conditional);
    5311         return "jsStringWithCache($statePointer, $value)";
    5312     }
    5313 
    5314     if ($codeGenerator->IsSequenceOrFrozenArrayType($type)) {
    5315         my $innerType = $codeGenerator->GetSequenceOrFrozenArrayInnerType($type);
    5316         AddToImplIncludes("JS${innerType}.h", $conditional) if $codeGenerator->IsRefPtrType($innerType);
    5317         my $isSequence = $codeGenerator->IsSequenceType($type);
    5318         return "toJSArray($stateReference, *$globalObject, throwScope, $value)" if $isSequence && $mayThrowException;
    5319         return "jsArray($statePointer, $globalObject, $value)" if $isSequence;
    5320         return "jsFrozenArray($statePointer, $globalObject, $value)";;
     5324    # We could instead overload a function to work with optional as well as non-optional numbers, but this
     5325    # is slightly better because it guarantees we will fail to compile if the IDL file doesn't match the C++.
     5326    if ($signature->extendedAttributes->{Reflect} and ($type eq "unsigned long" or $type eq "unsigned short")) {
     5327        $value =~ s/getUnsignedIntegralAttribute/getIntegralAttribute/g;
     5328        $value = "std::max(0, $value)";
    53215329    }
    53225330
     
    53275335            return "toJS($stateReference, *$globalObject, $value)";
    53285336        }
    5329         return $value;
     5337    }
     5338
     5339    if (NativeToJSValueIsHandledByDOMConvert($idlType)) {
     5340        AddToImplIncludes("JSDOMConvert.h");
     5341        AddToImplIncludesForIDLType($idlType, $conditional);
     5342
     5343        my $IDLType = GetIDLType($interface, $idlType);
     5344
     5345        my @conversionArguments = ();
     5346        push(@conversionArguments, "$stateReference") if NativeToJSValueDOMConvertNeedsState($idlType) || $mayThrowException;
     5347        push(@conversionArguments, "*$globalObject") if NativeToJSValueDOMConvertNeedsGlobalObject($idlType);
     5348        push(@conversionArguments, "throwScope") if $mayThrowException;
     5349        push(@conversionArguments, "$value");
     5350
     5351        return "toJS<$IDLType>(" . join(", ", @conversionArguments) . ")";
     5352    }
     5353
     5354    return "toJSNullableDate($stateReference, throwScope, $value)" if $type eq "Date" && $isNullable && $mayThrowException;
     5355    return "jsDateOrNull($statePointer, $value)" if $type eq "Date" && $isNullable;
     5356    return "toJSDate($stateReference, throwScope, $value)" if $type eq "Date" && $mayThrowException;
     5357    return "jsDate($statePointer, $value)" if $type eq "Date";
     5358
     5359    if ($codeGenerator->IsStringType($type)) {
     5360        AddToImplIncludes("URL.h", $conditional);
     5361        return "toJSNullableString($stateReference, throwScope, $value)" if $isNullable && $mayThrowException;
     5362        return "jsStringOrNull($statePointer, $value)" if $isNullable;
     5363        assert("Unhandled string type");
    53305364    }
    53315365
  • trunk/Source/WebCore/bindings/scripts/IDLParser.pm

    r207381 r207737  
    12841284        my $interface = $self->parseOperationRest($extendedAttributeList);
    12851285        if (defined ($interface)) {
     1286            $interface->signature->idlType($returnType);
    12861287            $interface->signature->type($returnType->name);
    12871288            $interface->signature->isNullable($returnType->isNullable);
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp

    r207192 r207737  
    2525#include "JSDOMBinding.h"
    2626#include "JSDOMConstructor.h"
     27#include "JSDOMConvert.h"
    2728#include "JSNode.h"
    2829#include <runtime/Error.h>
     
    165166        return jsUndefined();
    166167    auto& impl = thisObject.wrapped();
    167     JSValue result = jsNumber(impl.excitingAttr());
     168    JSValue result = toJS<IDLLong>(impl.excitingAttr());
    168169    return result;
    169170}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCEReactions.cpp

    r207193 r207737  
    2727#include "JSDOMBinding.h"
    2828#include "JSDOMConstructor.h"
     29#include "JSDOMConvert.h"
    2930#include "JSTestCEReactionsStringifier.h"
    30 #include "URL.h"
    3131#include <runtime/Error.h>
    3232#include <runtime/FunctionPrototype.h>
    33 #include <runtime/JSString.h>
    3433#include <wtf/GetPtr.h>
    3534
     
    159158    UNUSED_PARAM(state);
    160159    auto& impl = thisObject.wrapped();
    161     JSValue result = jsStringWithCache(&state, impl.attributeWithCEReactions());
     160    JSValue result = toJS<IDLDOMString>(state, impl.attributeWithCEReactions());
    162161    return result;
    163162}
     
    175174    UNUSED_PARAM(state);
    176175    auto& impl = thisObject.wrapped();
    177     JSValue result = jsStringWithCache(&state, impl.attributeWithoutSynchronization(WebCore::HTMLNames::reflectattributewithcereactionsAttr));
     176    JSValue result = toJS<IDLDOMString>(state, impl.attributeWithoutSynchronization(WebCore::HTMLNames::reflectattributewithcereactionsAttr));
    178177    return result;
    179178}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCEReactionsStringifier.cpp

    r207193 r207737  
    2626#include "JSDOMBinding.h"
    2727#include "JSDOMConstructor.h"
    28 #include "URL.h"
     28#include "JSDOMConvert.h"
    2929#include <runtime/Error.h>
    3030#include <runtime/FunctionPrototype.h>
    31 #include <runtime/JSString.h>
    3231#include <wtf/GetPtr.h>
    3332
     
    151150    UNUSED_PARAM(state);
    152151    auto& impl = thisObject.wrapped();
    153     JSValue result = jsStringWithCache(&state, impl.value());
     152    JSValue result = toJS<IDLDOMString>(state, impl.value());
    154153    return result;
    155154}
     
    218217    UNUSED_PARAM(throwScope);
    219218    auto& impl = castedThis->wrapped();
    220     JSValue result = jsStringWithCache(state, impl.value());
     219    JSValue result = toJS<IDLDOMString>(*state, impl.value());
    221220    return JSValue::encode(result);
    222221}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp

    r207516 r207737  
    2626
    2727#include "JSDOMConstructor.h"
     28#include "JSDOMConvert.h"
    2829#include "JSDOMStringList.h"
    2930#include "JSTestNode.h"
    3031#include "ScriptExecutionContext.h"
    3132#include "SerializedScriptValue.h"
    32 #include "URL.h"
    3333#include <runtime/JSLock.h>
    34 #include <runtime/JSString.h>
    3534#include <runtime/ObjectPrototype.h>
    3635
     
    148147    MarkedArgumentBuffer args;
    149148    args.append(srzParam ? srzParam->deserialize(*state, m_data->globalObject()) : jsNull());
    150     args.append(jsStringWithCache(state, strArg));
     149    args.append(toJS<IDLDOMString>(*state, strArg));
    151150
    152151    NakedPtr<JSC::Exception> returnedException;
     
    188187    ExecState* state = m_data->globalObject()->globalExec();
    189188    MarkedArgumentBuffer args;
    190     args.append(jsBoolean(boolParam));
     189    args.append(toJS<IDLBoolean>(boolParam));
    191190
    192191    NakedPtr<JSC::Exception> returnedException;
     
    208207    ExecState* state = m_data->globalObject()->globalExec();
    209208    MarkedArgumentBuffer args;
    210     args.append(jsNumber(longParam));
     209    args.append(toJS<IDLLong>(longParam));
    211210    args.append(toJS(state, m_data->globalObject(), testNodeParam));
    212211
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.cpp

    r207516 r207737  
    2525#include "JSTestCallbackFunction.h"
    2626
     27#include "JSDOMConvert.h"
    2728#include "JSDOMStringList.h"
    2829#include "JSTestNode.h"
    2930#include "ScriptExecutionContext.h"
    3031#include "SerializedScriptValue.h"
    31 #include "URL.h"
    3232#include <runtime/JSLock.h>
    33 #include <runtime/JSString.h>
    3433
    3534using namespace JSC;
     
    114113    MarkedArgumentBuffer args;
    115114    args.append(srzParam ? srzParam->deserialize(*state, m_data->globalObject()) : jsNull());
    116     args.append(jsStringWithCache(state, strArg));
     115    args.append(toJS<IDLDOMString>(*state, strArg));
    117116
    118117    NakedPtr<JSC::Exception> returnedException;
     
    156155    ExecState* state = m_data->globalObject()->globalExec();
    157156    MarkedArgumentBuffer args;
    158     args.append(jsBoolean(boolParam));
     157    args.append(toJS<IDLBoolean>(boolParam));
    159158
    160159    NakedPtr<JSC::Exception> returnedException;
     
    177176    ExecState* state = m_data->globalObject()->globalExec();
    178177    MarkedArgumentBuffer args;
    179     args.append(jsNumber(longParam));
     178    args.append(toJS<IDLLong>(longParam));
    180179    args.append(toJS(state, m_data->globalObject(), testNodeParam));
    181180
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp

    r207575 r207737  
    2525#include "JSDOMBinding.h"
    2626#include "JSDOMConstructor.h"
    27 #include "URL.h"
    2827#include <runtime/Error.h>
    29 #include <runtime/JSString.h>
    3028#include <wtf/GetPtr.h>
    3129
     
    206204    UNUSED_PARAM(state);
    207205    auto& impl = thisObject.wrapped();
    208     JSValue result = jsStringWithCache(&state, impl.attr1());
     206    JSValue result = toJS<IDLDOMString>(state, impl.attr1());
    209207    return result;
    210208}
     
    222220    UNUSED_PARAM(state);
    223221    auto& impl = thisObject.wrapped();
    224     JSValue result = jsStringWithCache(&state, impl.attr2());
     222    JSValue result = toJS<IDLDOMString>(state, impl.attr2());
    225223    return result;
    226224}
     
    239237    UNUSED_PARAM(state);
    240238    auto& impl = thisObject.wrapped();
    241     JSValue result = jsStringWithCache(&state, impl.attr3());
     239    JSValue result = toJS<IDLDOMString>(state, impl.attr3());
    242240    return result;
    243241}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp

    r207192 r207737  
    2424#include "JSDOMBinding.h"
    2525#include "JSDOMConstructor.h"
    26 #include "URL.h"
     26#include "JSDOMConvert.h"
    2727#include <runtime/FunctionPrototype.h>
    28 #include <runtime/JSString.h>
    2928#include <wtf/GetPtr.h>
    3029
     
    150149    UNUSED_PARAM(state);
    151150    auto& impl = thisObject.wrapped();
    152     JSValue result = jsStringWithCache(&state, impl.name());
     151    JSValue result = toJS<IDLDOMString>(state, impl.name());
    153152    return result;
    154153}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp

    r207328 r207737  
    2727#include "JSDOMConvert.h"
    2828#include "RuntimeEnabledFeatures.h"
    29 #include "URL.h"
    3029#include "WebCoreJSClientData.h"
    3130#include <runtime/Error.h>
    3231#include <runtime/FunctionPrototype.h>
    33 #include <runtime/JSString.h>
    3432#include <wtf/GetPtr.h>
    3533
     
    200198    UNUSED_PARAM(state);
    201199    auto& impl = thisObject.wrapped();
    202     JSValue result = jsStringWithCache(&state, impl.regularAttribute());
     200    JSValue result = toJS<IDLDOMString>(state, impl.regularAttribute());
    203201    return result;
    204202}
     
    216214    UNUSED_PARAM(state);
    217215    auto& impl = thisObject.wrapped();
    218     JSValue result = jsStringWithCache(&state, impl.publicAndPrivateAttribute());
     216    JSValue result = toJS<IDLDOMString>(state, impl.publicAndPrivateAttribute());
    219217    return result;
    220218}
     
    233231    UNUSED_PARAM(state);
    234232    auto& impl = thisObject.wrapped();
    235     JSValue result = jsStringWithCache(&state, impl.publicAndPrivateConditionalAttribute());
     233    JSValue result = toJS<IDLDOMString>(state, impl.publicAndPrivateConditionalAttribute());
    236234    return result;
    237235}
     
    252250    UNUSED_PARAM(state);
    253251    auto& impl = thisObject.wrapped();
    254     JSValue result = jsStringWithCache(&state, impl.enabledAtRuntimeAttribute());
     252    JSValue result = toJS<IDLDOMString>(state, impl.enabledAtRuntimeAttribute());
    255253    return result;
    256254}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp

    r207519 r207737  
    2828#include "JSDOMBinding.h"
    2929#include "JSDOMConstructor.h"
     30#include "JSDOMConvert.h"
    3031#include "TestObj.h"
    3132#include "TestSupplemental.h"
     
    4142#include "JSNode.h"
    4243#include "JSTestObj.h"
    43 #include "URL.h"
    44 #include <runtime/JSString.h>
    4544#endif
    4645
     
    422421{
    423422    UNUSED_PARAM(state);
    424     JSValue result = jsNumber(TestInterface::implementsStaticReadOnlyAttr());
     423    JSValue result = toJS<IDLLong>(TestInterface::implementsStaticReadOnlyAttr());
    425424    return result;
    426425}
     
    440439{
    441440    UNUSED_PARAM(state);
    442     JSValue result = jsStringWithCache(&state, TestInterface::implementsStaticAttr());
     441    JSValue result = toJS<IDLDOMString>(state, TestInterface::implementsStaticAttr());
    443442    return result;
    444443}
     
    459458    UNUSED_PARAM(state);
    460459    auto& impl = thisObject.wrapped();
    461     JSValue result = jsStringWithCache(&state, impl.implementsStr1());
     460    JSValue result = toJS<IDLDOMString>(state, impl.implementsStr1());
    462461    return result;
    463462}
     
    478477    UNUSED_PARAM(state);
    479478    auto& impl = thisObject.wrapped();
    480     JSValue result = jsStringWithCache(&state, impl.implementsStr2());
     479    JSValue result = toJS<IDLDOMString>(state, impl.implementsStr2());
    481480    return result;
    482481}
     
    532531{
    533532    UNUSED_PARAM(state);
    534     JSValue result = jsNumber(WebCore::TestSupplemental::supplementalStaticReadOnlyAttr());
     533    JSValue result = toJS<IDLLong>(WebCore::TestSupplemental::supplementalStaticReadOnlyAttr());
    535534    return result;
    536535}
     
    550549{
    551550    UNUSED_PARAM(state);
    552     JSValue result = jsStringWithCache(&state, WebCore::TestSupplemental::supplementalStaticAttr());
     551    JSValue result = toJS<IDLDOMString>(state, WebCore::TestSupplemental::supplementalStaticAttr());
    553552    return result;
    554553}
     
    569568    UNUSED_PARAM(state);
    570569    auto& impl = thisObject.wrapped();
    571     JSValue result = jsStringWithCache(&state, WebCore::TestSupplemental::supplementalStr1(impl));
     570    JSValue result = toJS<IDLDOMString>(state, WebCore::TestSupplemental::supplementalStr1(impl));
    572571    return result;
    573572}
     
    588587    UNUSED_PARAM(state);
    589588    auto& impl = thisObject.wrapped();
    590     JSValue result = jsStringWithCache(&state, WebCore::TestSupplemental::supplementalStr2(impl));
     589    JSValue result = toJS<IDLDOMString>(state, WebCore::TestSupplemental::supplementalStr2(impl));
    591590    return result;
    592591}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp

    r207378 r207737  
    2525#include "JSDOMBinding.h"
    2626#include "JSDOMConstructor.h"
     27#include "JSDOMConvert.h"
    2728#include "JSDOMIterator.h"
    2829#include "JSDOMPromise.h"
    2930#include "RuntimeEnabledFeatures.h"
    30 #include "URL.h"
    3131#include <runtime/Error.h>
    32 #include <runtime/JSString.h>
    3332#include <runtime/ObjectConstructor.h>
    3433#include <wtf/GetPtr.h>
     
    190189    UNUSED_PARAM(state);
    191190    auto& impl = thisObject.wrapped();
    192     JSValue result = jsStringWithCache(&state, impl.name());
     191    JSValue result = toJS<IDLDOMString>(state, impl.name());
    193192    return result;
    194193}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNondeterministic.cpp

    r207193 r207737  
    2525#include "JSDOMBinding.h"
    2626#include "JSDOMConstructor.h"
    27 #include "URL.h"
     27#include "JSDOMConvert.h"
    2828#include <runtime/Error.h>
    2929#include <runtime/FunctionPrototype.h>
    30 #include <runtime/JSString.h>
    3130#include <wtf/GetPtr.h>
    3231
     
    172171        int32_t memoizedResult = thisObject.wrapped().nondeterministicReadonlyAttr();
    173172        cursor.appendInput<MemoizedDOMResult<int32_t>>(bindingName.get().string(), memoizedResult, 0);
    174         JSValue result = jsNumber(memoizedResult);
     173        JSValue result = toJS<IDLLong>(memoizedResult);
    175174        return result;
    176175    }
     
    180179        MemoizedDOMResultBase* input = cursor.fetchInput<MemoizedDOMResultBase>();
    181180        if (input && input->convertTo<int32_t>(memoizedResult)) {
    182             JSValue result = jsNumber(memoizedResult);
     181            JSValue result = toJS<IDLLong>(memoizedResult);
    183182            return result;
    184183        }
     
    186185#endif
    187186    auto& impl = thisObject.wrapped();
    188     JSValue result = jsNumber(impl.nondeterministicReadonlyAttr());
     187    JSValue result = toJS<IDLLong>(impl.nondeterministicReadonlyAttr());
    189188    return result;
    190189}
     
    208207        String memoizedResult = thisObject.wrapped().nondeterministicWriteableAttr();
    209208        cursor.appendInput<MemoizedDOMResult<String>>(bindingName.get().string(), memoizedResult, 0);
    210         JSValue result = jsStringWithCache(&state, memoizedResult);
     209        JSValue result = toJS<IDLDOMString>(state, memoizedResult);
    211210        return result;
    212211    }
     
    216215        MemoizedDOMResultBase* input = cursor.fetchInput<MemoizedDOMResultBase>();
    217216        if (input && input->convertTo<String>(memoizedResult)) {
    218             JSValue result = jsStringWithCache(&state, memoizedResult);
     217            JSValue result = toJS<IDLDOMString>(state, memoizedResult);
    219218            return result;
    220219        }
     
    222221#endif
    223222    auto& impl = thisObject.wrapped();
    224     JSValue result = jsStringWithCache(&state, impl.nondeterministicWriteableAttr());
     223    JSValue result = toJS<IDLDOMString>(state, impl.nondeterministicWriteableAttr());
    225224    return result;
    226225}
     
    244243        String memoizedResult = thisObject.wrapped().nondeterministicExceptionAttr();
    245244        cursor.appendInput<MemoizedDOMResult<String>>(bindingName.get().string(), memoizedResult, 0);
    246         JSValue result = jsStringWithCache(&state, memoizedResult);
     245        JSValue result = toJS<IDLDOMString>(state, memoizedResult);
    247246        return result;
    248247    }
     
    252251        MemoizedDOMResultBase* input = cursor.fetchInput<MemoizedDOMResultBase>();
    253252        if (input && input->convertTo<String>(memoizedResult)) {
    254             JSValue result = jsStringWithCache(&state, memoizedResult);
     253            JSValue result = toJS<IDLDOMString>(state, memoizedResult);
    255254            return result;
    256255        }
     
    258257#endif
    259258    auto& impl = thisObject.wrapped();
    260     JSValue result = jsStringWithCache(&state, impl.nondeterministicExceptionAttr());
     259    JSValue result = toJS<IDLDOMString>(state, impl.nondeterministicExceptionAttr());
    261260    return result;
    262261}
     
    281280        String memoizedResult = thisObject.wrapped().nondeterministicGetterExceptionAttr(ec);
    282281        cursor.appendInput<MemoizedDOMResult<String>>(bindingName.get().string(), memoizedResult, ec);
    283         JSValue result = jsStringWithCache(&state, memoizedResult);
     282        JSValue result = toJS<IDLDOMString>(state, memoizedResult);
    284283        setDOMException(&state, throwScope, ec);
    285284        return result;
     
    290289        MemoizedDOMResultBase* input = cursor.fetchInput<MemoizedDOMResultBase>();
    291290        if (input && input->convertTo<String>(memoizedResult)) {
    292             JSValue result = jsStringWithCache(&state, memoizedResult);
     291            JSValue result = toJS<IDLDOMString>(state, memoizedResult);
    293292            setDOMException(&state, throwScope, input->exceptionCode());
    294293            return result;
     
    297296#endif
    298297    auto& impl = thisObject.wrapped();
    299     JSValue result = jsStringWithCache(&state, impl.nondeterministicGetterExceptionAttr(ec));
     298    JSValue result = toJS<IDLDOMString>(state, impl.nondeterministicGetterExceptionAttr(ec));
    300299    setDOMException(&state, throwScope, ec);
    301300    return result;
     
    320319        String memoizedResult = thisObject.wrapped().nondeterministicSetterExceptionAttr();
    321320        cursor.appendInput<MemoizedDOMResult<String>>(bindingName.get().string(), memoizedResult, 0);
    322         JSValue result = jsStringWithCache(&state, memoizedResult);
     321        JSValue result = toJS<IDLDOMString>(state, memoizedResult);
    323322        return result;
    324323    }
     
    328327        MemoizedDOMResultBase* input = cursor.fetchInput<MemoizedDOMResultBase>();
    329328        if (input && input->convertTo<String>(memoizedResult)) {
    330             JSValue result = jsStringWithCache(&state, memoizedResult);
     329            JSValue result = toJS<IDLDOMString>(state, memoizedResult);
    331330            return result;
    332331        }
     
    334333#endif
    335334    auto& impl = thisObject.wrapped();
    336     JSValue result = jsStringWithCache(&state, impl.nondeterministicSetterExceptionAttr());
     335    JSValue result = toJS<IDLDOMString>(state, impl.nondeterministicSetterExceptionAttr());
    337336    return result;
    338337}
     
    464463        bool memoizedResult = impl.nondeterministicZeroArgFunction();
    465464        cursor.appendInput<MemoizedDOMResult<bool>>(bindingName.get().string(), memoizedResult, 0);
    466         result = jsBoolean(memoizedResult);
     465        result = toJS<IDLBoolean>(memoizedResult);
    467466    } else if (cursor.isReplaying()) {
    468467        MemoizedDOMResultBase* input = cursor.fetchInput<MemoizedDOMResultBase>();
    469468        bool memoizedResult;
    470469        if (input && input->convertTo<bool>(memoizedResult)) {
    471             result = jsBoolean(memoizedResult);
     470            result = toJS<IDLBoolean>(memoizedResult);
    472471        } else
    473             result = jsBoolean(impl.nondeterministicZeroArgFunction());
     472            result = toJS<IDLBoolean>(impl.nondeterministicZeroArgFunction());
    474473    } else
    475         result = jsBoolean(impl.nondeterministicZeroArgFunction());
     474        result = toJS<IDLBoolean>(impl.nondeterministicZeroArgFunction());
    476475#else
    477     result = jsBoolean(impl.nondeterministicZeroArgFunction());
     476    result = toJS<IDLBoolean>(impl.nondeterministicZeroArgFunction());
    478477#endif
    479478    return JSValue::encode(result);
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r207725 r207737  
    9494namespace WebCore {
    9595
    96 JSString* jsStringWithCache(ExecState* state, TestObj::EnumType enumerationValue)
     96template<> JSString* convertEnumerationToJS(ExecState& state, TestObj::EnumType enumerationValue)
    9797{
    9898    static NeverDestroyed<const String> values[] = {
     
    107107    static_assert(static_cast<size_t>(TestObj::EnumType::EnumValue3) == 3, "TestObj::EnumType::EnumValue3 is not 3 as expected");
    108108    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
    109     return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);
     109    return jsStringWithCache(&state, values[static_cast<size_t>(enumerationValue)]);
    110110}
    111111
     
    141141}
    142142
    143 JSString* jsStringWithCache(ExecState* state, TestObj::Optional enumerationValue)
     143template<> JSString* convertEnumerationToJS(ExecState& state, TestObj::Optional enumerationValue)
    144144{
    145145    static NeverDestroyed<const String> values[] = {
     
    154154    static_assert(static_cast<size_t>(TestObj::Optional::OptionalValue3) == 3, "TestObj::Optional::OptionalValue3 is not 3 as expected");
    155155    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
    156     return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);
     156    return jsStringWithCache(&state, values[static_cast<size_t>(enumerationValue)]);
    157157}
    158158
     
    188188}
    189189
    190 JSString* jsStringWithCache(ExecState* state, AlternateEnumName enumerationValue)
     190template<> JSString* convertEnumerationToJS(ExecState& state, AlternateEnumName enumerationValue)
    191191{
    192192    static NeverDestroyed<const String> values[] = {
     
    197197    static_assert(static_cast<size_t>(AlternateEnumName::EnumValue2) == 1, "AlternateEnumName::EnumValue2 is not 1 as expected");
    198198    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
    199     return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);
     199    return jsStringWithCache(&state, values[static_cast<size_t>(enumerationValue)]);
    200200}
    201201
     
    229229#if ENABLE(Condition1)
    230230
    231 JSString* jsStringWithCache(ExecState* state, TestObj::EnumA enumerationValue)
     231template<> JSString* convertEnumerationToJS(ExecState& state, TestObj::EnumA enumerationValue)
    232232{
    233233    static NeverDestroyed<const String> values[] = {
     
    236236    static_assert(static_cast<size_t>(TestObj::EnumA::A) == 0, "TestObj::EnumA::A is not 0 as expected");
    237237    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
    238     return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);
     238    return jsStringWithCache(&state, values[static_cast<size_t>(enumerationValue)]);
    239239}
    240240
     
    268268#if ENABLE(Condition1) && ENABLE(Condition2)
    269269
    270 JSString* jsStringWithCache(ExecState* state, TestObj::EnumB enumerationValue)
     270template<> JSString* convertEnumerationToJS(ExecState& state, TestObj::EnumB enumerationValue)
    271271{
    272272    static NeverDestroyed<const String> values[] = {
     
    275275    static_assert(static_cast<size_t>(TestObj::EnumB::B) == 0, "TestObj::EnumB::B is not 0 as expected");
    276276    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
    277     return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);
     277    return jsStringWithCache(&state, values[static_cast<size_t>(enumerationValue)]);
    278278}
    279279
     
    307307#if ENABLE(Condition1) || ENABLE(Condition2)
    308308
    309 JSString* jsStringWithCache(ExecState* state, TestObj::EnumC enumerationValue)
     309template<> JSString* convertEnumerationToJS(ExecState& state, TestObj::EnumC enumerationValue)
    310310{
    311311    static NeverDestroyed<const String> values[] = {
     
    314314    static_assert(static_cast<size_t>(TestObj::EnumC::C) == 0, "TestObj::EnumC::C is not 0 as expected");
    315315    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
    316     return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);
     316    return jsStringWithCache(&state, values[static_cast<size_t>(enumerationValue)]);
    317317}
    318318
     
    344344#endif
    345345
    346 JSString* jsStringWithCache(ExecState* state, TestObj::Kind enumerationValue)
     346template<> JSString* convertEnumerationToJS(ExecState& state, TestObj::Kind enumerationValue)
    347347{
    348348    static NeverDestroyed<const String> values[] = {
     
    353353    static_assert(static_cast<size_t>(TestObj::Kind::Dead) == 1, "TestObj::Kind::Dead is not 1 as expected");
    354354    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
    355     return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);
     355    return jsStringWithCache(&state, values[static_cast<size_t>(enumerationValue)]);
    356356}
    357357
     
    383383}
    384384
    385 JSString* jsStringWithCache(ExecState* state, TestObj::Size enumerationValue)
     385template<> JSString* convertEnumerationToJS(ExecState& state, TestObj::Size enumerationValue)
    386386{
    387387    static NeverDestroyed<const String> values[] = {
     
    392392    static_assert(static_cast<size_t>(TestObj::Size::MuchMuchLarger) == 1, "TestObj::Size::MuchMuchLarger is not 1 as expected");
    393393    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
    394     return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);
     394    return jsStringWithCache(&state, values[static_cast<size_t>(enumerationValue)]);
    395395}
    396396
     
    422422}
    423423
    424 JSString* jsStringWithCache(ExecState* state, TestObj::Confidence enumerationValue)
     424template<> JSString* convertEnumerationToJS(ExecState& state, TestObj::Confidence enumerationValue)
    425425{
    426426    static NeverDestroyed<const String> values[] = {
     
    431431    static_assert(static_cast<size_t>(TestObj::Confidence::KindaLow) == 1, "TestObj::Confidence::KindaLow is not 1 as expected");
    432432    ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values));
    433     return jsStringWithCache(state, values[static_cast<size_t>(enumerationValue)]);
     433    return jsStringWithCache(&state, values[static_cast<size_t>(enumerationValue)]);
    434434}
    435435
     
    17481748    UNUSED_PARAM(state);
    17491749    auto& impl = thisObject.wrapped();
    1750     JSValue result = jsNumber(impl.readOnlyLongAttr());
     1750    JSValue result = toJS<IDLLong>(impl.readOnlyLongAttr());
    17511751    return result;
    17521752}
     
    17641764    UNUSED_PARAM(state);
    17651765    auto& impl = thisObject.wrapped();
    1766     JSValue result = jsStringWithCache(&state, impl.readOnlyStringAttr());
     1766    JSValue result = toJS<IDLDOMString>(state, impl.readOnlyStringAttr());
    17671767    return result;
    17681768}
     
    17951795{
    17961796    UNUSED_PARAM(state);
    1797     JSValue result = jsNumber(TestObj::staticReadOnlyLongAttr());
     1797    JSValue result = toJS<IDLLong>(TestObj::staticReadOnlyLongAttr());
    17981798    return result;
    17991799}
     
    18101810{
    18111811    UNUSED_PARAM(state);
    1812     JSValue result = jsStringWithCache(&state, TestObj::staticStringAttr());
     1812    JSValue result = toJS<IDLDOMString>(state, TestObj::staticStringAttr());
    18131813    return result;
    18141814}
     
    18591859    UNUSED_PARAM(state);
    18601860    auto& impl = thisObject.wrapped();
    1861     JSValue result = jsStringWithCache(&state, impl.enumAttr());
     1861    JSValue result = toJS<IDLEnumeration<TestObj::EnumType>>(state, impl.enumAttr());
    18621862    return result;
    18631863}
     
    18751875    UNUSED_PARAM(state);
    18761876    auto& impl = thisObject.wrapped();
    1877     JSValue result = jsNumber(impl.byteAttr());
     1877    JSValue result = toJS<IDLByte>(impl.byteAttr());
    18781878    return result;
    18791879}
     
    18911891    UNUSED_PARAM(state);
    18921892    auto& impl = thisObject.wrapped();
    1893     JSValue result = jsNumber(impl.octetAttr());
     1893    JSValue result = toJS<IDLOctet>(impl.octetAttr());
    18941894    return result;
    18951895}
     
    19071907    UNUSED_PARAM(state);
    19081908    auto& impl = thisObject.wrapped();
    1909     JSValue result = jsNumber(impl.shortAttr());
     1909    JSValue result = toJS<IDLShort>(impl.shortAttr());
    19101910    return result;
    19111911}
     
    19231923    UNUSED_PARAM(state);
    19241924    auto& impl = thisObject.wrapped();
    1925     JSValue result = jsNumber(impl.clampedShortAttr());
     1925    JSValue result = toJS<IDLShort>(impl.clampedShortAttr());
    19261926    return result;
    19271927}
     
    19391939    UNUSED_PARAM(state);
    19401940    auto& impl = thisObject.wrapped();
    1941     JSValue result = jsNumber(impl.enforceRangeShortAttr());
     1941    JSValue result = toJS<IDLShort>(impl.enforceRangeShortAttr());
    19421942    return result;
    19431943}
     
    19551955    UNUSED_PARAM(state);
    19561956    auto& impl = thisObject.wrapped();
    1957     JSValue result = jsNumber(impl.unsignedShortAttr());
     1957    JSValue result = toJS<IDLUnsignedShort>(impl.unsignedShortAttr());
    19581958    return result;
    19591959}
     
    19711971    UNUSED_PARAM(state);
    19721972    auto& impl = thisObject.wrapped();
    1973     JSValue result = jsNumber(impl.longAttr());
     1973    JSValue result = toJS<IDLLong>(impl.longAttr());
    19741974    return result;
    19751975}
     
    19871987    UNUSED_PARAM(state);
    19881988    auto& impl = thisObject.wrapped();
    1989     JSValue result = jsNumber(impl.longLongAttr());
     1989    JSValue result = toJS<IDLLongLong>(impl.longLongAttr());
    19901990    return result;
    19911991}
     
    20032003    UNUSED_PARAM(state);
    20042004    auto& impl = thisObject.wrapped();
    2005     JSValue result = jsNumber(impl.unsignedLongLongAttr());
     2005    JSValue result = toJS<IDLUnsignedLongLong>(impl.unsignedLongLongAttr());
    20062006    return result;
    20072007}
     
    20192019    UNUSED_PARAM(state);
    20202020    auto& impl = thisObject.wrapped();
    2021     JSValue result = jsStringWithCache(&state, impl.stringAttr());
     2021    JSValue result = toJS<IDLDOMString>(state, impl.stringAttr());
    20222022    return result;
    20232023}
     
    20352035    UNUSED_PARAM(state);
    20362036    auto& impl = thisObject.wrapped();
    2037     JSValue result = jsStringWithCache(&state, impl.usvstringAttr());
     2037    JSValue result = toJS<IDLUSVString>(state, impl.usvstringAttr());
    20382038    return result;
    20392039}
     
    20992099    UNUSED_PARAM(state);
    21002100    auto& impl = thisObject.wrapped();
    2101     JSValue result = jsStringWithCache(&state, impl.unforgeableAttr());
     2101    JSValue result = toJS<IDLDOMString>(state, impl.unforgeableAttr());
    21022102    return result;
    21032103}
     
    21152115    UNUSED_PARAM(state);
    21162116    auto& impl = thisObject.wrapped();
    2117     JSValue result = jsStringWithCache(&state, impl.stringAttrTreatingNullAsEmptyString());
     2117    JSValue result = toJS<IDLDOMString>(state, impl.stringAttrTreatingNullAsEmptyString());
    21182118    return result;
    21192119}
     
    21312131    UNUSED_PARAM(state);
    21322132    auto& impl = thisObject.wrapped();
    2133     JSValue result = jsStringWithCache(&state, impl.usvstringAttrTreatingNullAsEmptyString());
     2133    JSValue result = toJS<IDLUSVString>(state, impl.usvstringAttrTreatingNullAsEmptyString());
    21342134    return result;
    21352135}
     
    21472147    UNUSED_PARAM(state);
    21482148    auto& impl = thisObject.wrapped();
    2149     JSValue result = jsStringWithCache(&state, impl.implementationEnumAttr());
     2149    JSValue result = toJS<IDLEnumeration<AlternateEnumName>>(state, impl.implementationEnumAttr());
    21502150    return result;
    21512151}
     
    21792179    UNUSED_PARAM(state);
    21802180    auto& impl = thisObject.wrapped();
    2181     JSValue result = jsBoolean(impl.isCreate());
     2181    JSValue result = toJS<IDLBoolean>(impl.isCreate());
    21822182    return result;
    21832183}
     
    21952195    UNUSED_PARAM(state);
    21962196    auto& impl = thisObject.wrapped();
    2197     JSValue result = jsStringWithCache(&state, impl.attributeWithoutSynchronization(WebCore::HTMLNames::reflectedstringattrAttr));
     2197    JSValue result = toJS<IDLDOMString>(state, impl.attributeWithoutSynchronization(WebCore::HTMLNames::reflectedstringattrAttr));
    21982198    return result;
    21992199}
     
    22112211    UNUSED_PARAM(state);
    22122212    auto& impl = thisObject.wrapped();
    2213     JSValue result = jsStringWithCache(&state, impl.attributeWithoutSynchronization(WebCore::HTMLNames::reflectedusvstringattrAttr));
     2213    JSValue result = toJS<IDLUSVString>(state, impl.attributeWithoutSynchronization(WebCore::HTMLNames::reflectedusvstringattrAttr));
    22142214    return result;
    22152215}
     
    22272227    UNUSED_PARAM(state);
    22282228    auto& impl = thisObject.wrapped();
    2229     JSValue result = jsNumber(impl.getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr));
     2229    JSValue result = toJS<IDLLong>(impl.getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr));
    22302230    return result;
    22312231}
     
    22432243    UNUSED_PARAM(state);
    22442244    auto& impl = thisObject.wrapped();
    2245     JSValue result = jsNumber(std::max(0, impl.getIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr)));
     2245    JSValue result = toJS<IDLUnsignedLong>(std::max(0, impl.getIntegralAttribute(WebCore::HTMLNames::reflectedunsignedintegralattrAttr)));
    22462246    return result;
    22472247}
     
    22592259    UNUSED_PARAM(state);
    22602260    auto& impl = thisObject.wrapped();
    2261     JSValue result = jsBoolean(impl.hasAttributeWithoutSynchronization(WebCore::HTMLNames::reflectedbooleanattrAttr));
     2261    JSValue result = toJS<IDLBoolean>(impl.hasAttributeWithoutSynchronization(WebCore::HTMLNames::reflectedbooleanattrAttr));
    22622262    return result;
    22632263}
     
    22752275    UNUSED_PARAM(state);
    22762276    auto& impl = thisObject.wrapped();
    2277     JSValue result = jsStringWithCache(&state, impl.getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr));
     2277    JSValue result = toJS<IDLDOMString>(state, impl.getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr));
    22782278    return result;
    22792279}
     
    22912291    UNUSED_PARAM(state);
    22922292    auto& impl = thisObject.wrapped();
    2293     JSValue result = jsStringWithCache(&state, impl.getURLAttribute(WebCore::HTMLNames::reflectedusvurlattrAttr));
     2293    JSValue result = toJS<IDLUSVString>(state, impl.getURLAttribute(WebCore::HTMLNames::reflectedusvurlattrAttr));
    22942294    return result;
    22952295}
     
    23072307    UNUSED_PARAM(state);
    23082308    auto& impl = thisObject.wrapped();
    2309     JSValue result = jsStringWithCache(&state, impl.attributeWithoutSynchronization(WebCore::HTMLNames::customContentStringAttrAttr));
     2309    JSValue result = toJS<IDLDOMString>(state, impl.attributeWithoutSynchronization(WebCore::HTMLNames::customContentStringAttrAttr));
    23102310    return result;
    23112311}
     
    23232323    UNUSED_PARAM(state);
    23242324    auto& impl = thisObject.wrapped();
    2325     JSValue result = jsNumber(impl.getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr));
     2325    JSValue result = toJS<IDLLong>(impl.getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr));
    23262326    return result;
    23272327}
     
    23392339    UNUSED_PARAM(state);
    23402340    auto& impl = thisObject.wrapped();
    2341     JSValue result = jsBoolean(impl.hasAttributeWithoutSynchronization(WebCore::HTMLNames::customContentBooleanAttrAttr));
     2341    JSValue result = toJS<IDLBoolean>(impl.hasAttributeWithoutSynchronization(WebCore::HTMLNames::customContentBooleanAttrAttr));
    23422342    return result;
    23432343}
     
    23552355    UNUSED_PARAM(state);
    23562356    auto& impl = thisObject.wrapped();
    2357     JSValue result = jsStringWithCache(&state, impl.getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr));
     2357    JSValue result = toJS<IDLDOMString>(state, impl.getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr));
    23582358    return result;
    23592359}
     
    23722372    UNUSED_PARAM(state);
    23732373    auto& impl = thisObject.wrapped();
    2374     JSValue result = jsStringWithCache(&state, impl.enabledAtRuntimeAttribute());
     2374    JSValue result = toJS<IDLDOMString>(state, impl.enabledAtRuntimeAttribute());
    23752375    return result;
    23762376}
     
    24062406    UNUSED_PARAM(state);
    24072407    auto& impl = thisObject.wrapped();
    2408     JSValue result = toJSNumber(state, throwScope, impl.attributeWithGetterException());
     2408    JSValue result = toJS<IDLLong>(state, throwScope, impl.attributeWithGetterException());
    24092409    return result;
    24102410}
     
    24232423    ExceptionCode ec = 0;
    24242424    auto& impl = thisObject.wrapped();
    2425     JSValue result = jsNumber(impl.attributeWithGetterLegacyException(ec));
     2425    JSValue result = toJS<IDLLong>(impl.attributeWithGetterLegacyException(ec));
    24262426    setDOMException(&state, throwScope, ec);
    24272427    return result;
     
    24402440    UNUSED_PARAM(state);
    24412441    auto& impl = thisObject.wrapped();
    2442     JSValue result = jsNumber(impl.attributeWithSetterException());
     2442    JSValue result = toJS<IDLLong>(impl.attributeWithSetterException());
    24432443    return result;
    24442444}
     
    24562456    UNUSED_PARAM(state);
    24572457    auto& impl = thisObject.wrapped();
    2458     JSValue result = jsNumber(impl.attributeWithSetterLegacyException());
     2458    JSValue result = toJS<IDLLong>(impl.attributeWithSetterLegacyException());
    24592459    return result;
    24602460}
     
    24732473    ExceptionCode ec = 0;
    24742474    auto& impl = thisObject.wrapped();
    2475     JSValue result = jsStringWithCache(&state, impl.stringAttrWithGetterException(ec));
     2475    JSValue result = toJS<IDLDOMString>(state, impl.stringAttrWithGetterException(ec));
    24762476    setDOMException(&state, throwScope, ec);
    24772477    return result;
     
    24902490    UNUSED_PARAM(state);
    24912491    auto& impl = thisObject.wrapped();
    2492     JSValue result = jsStringWithCache(&state, impl.stringAttrWithSetterException());
     2492    JSValue result = toJS<IDLDOMString>(state, impl.stringAttrWithSetterException());
    24932493    return result;
    24942494}
     
    25482548    UNUSED_PARAM(state);
    25492549    auto& impl = thisObject.wrapped();
    2550     JSValue result = jsNumber(impl.withScriptStateAttribute(state));
     2550    JSValue result = toJS<IDLLong>(impl.withScriptStateAttribute(state));
    25512551    return result;
    25522552}
     
    25642564    UNUSED_PARAM(state);
    25652565    auto& impl = thisObject.wrapped();
    2566     JSValue result = jsNumber(impl.withCallWithAndSetterCallWithAttribute(state));
     2566    JSValue result = toJS<IDLLong>(impl.withCallWithAndSetterCallWithAttribute(state));
    25672567    return result;
    25682568}
     
    27142714    UNUSED_PARAM(state);
    27152715    auto& impl = thisObject.wrapped();
    2716     JSValue result = jsNumber(impl.conditionalAttr1());
     2716    JSValue result = toJS<IDLLong>(impl.conditionalAttr1());
    27172717    return result;
    27182718}
     
    27332733    UNUSED_PARAM(state);
    27342734    auto& impl = thisObject.wrapped();
    2735     JSValue result = jsNumber(impl.conditionalAttr2());
     2735    JSValue result = toJS<IDLLong>(impl.conditionalAttr2());
    27362736    return result;
    27372737}
     
    27522752    UNUSED_PARAM(state);
    27532753    auto& impl = thisObject.wrapped();
    2754     JSValue result = jsNumber(impl.conditionalAttr3());
     2754    JSValue result = toJS<IDLLong>(impl.conditionalAttr3());
    27552755    return result;
    27562756}
     
    28232823        return cachedValue;
    28242824    auto& impl = thisObject.wrapped();
    2825     JSValue result = impl.cachedAttribute1();
     2825    JSValue result = toJS<IDLAny>(impl.cachedAttribute1());
    28262826    thisObject.m_cachedAttribute1.set(state.vm(), &thisObject, result);
    28272827    return result;
     
    28422842        return cachedValue;
    28432843    auto& impl = thisObject.wrapped();
    2844     JSValue result = impl.cachedAttribute2();
     2844    JSValue result = toJS<IDLAny>(impl.cachedAttribute2());
    28452845    thisObject.m_cachedAttribute2.set(state.vm(), &thisObject, result);
    28462846    return result;
     
    28592859    UNUSED_PARAM(state);
    28602860    auto& impl = thisObject.wrapped();
    2861     JSValue result = impl.anyAttribute();
     2861    JSValue result = toJS<IDLAny>(impl.anyAttribute());
    28622862    return result;
    28632863}
     
    29222922    UNUSED_PARAM(state);
    29232923    auto& impl = thisObject.wrapped();
    2924     JSValue result = jsNumber(impl.blueberry());
     2924    JSValue result = toJS<IDLLong>(impl.blueberry());
    29252925    return result;
    29262926}
     
    29382938    UNUSED_PARAM(state);
    29392939    auto& impl = thisObject.wrapped();
    2940     JSValue result = jsNumber(impl.description());
     2940    JSValue result = toJS<IDLLong>(impl.description());
    29412941    return result;
    29422942}
     
    29542954    UNUSED_PARAM(state);
    29552955    auto& impl = thisObject.wrapped();
    2956     JSValue result = jsNumber(impl.id());
     2956    JSValue result = toJS<IDLLong>(impl.id());
    29572957    return result;
    29582958}
     
    29702970    UNUSED_PARAM(state);
    29712971    auto& impl = thisObject.wrapped();
    2972     JSValue result = jsStringWithCache(&state, impl.hash());
     2972    JSValue result = toJS<IDLDOMString>(state, impl.hash());
    29732973    return result;
    29742974}
     
    29862986    UNUSED_PARAM(state);
    29872987    auto& impl = thisObject.wrapped();
    2988     JSValue result = jsNumber(impl.replaceableAttribute());
     2988    JSValue result = toJS<IDLLong>(impl.replaceableAttribute());
    29892989    return result;
    29902990}
     
    30023002    UNUSED_PARAM(state);
    30033003    auto& impl = thisObject.wrapped();
    3004     JSValue result = toNullableJSNumber(impl.nullableDoubleAttribute());
     3004    JSValue result = toJS<IDLNullable<IDLUnrestrictedDouble>>(impl.nullableDoubleAttribute());
    30053005    return result;
    30063006}
     
    30183018    UNUSED_PARAM(state);
    30193019    auto& impl = thisObject.wrapped();
    3020     JSValue result = toNullableJSNumber(impl.nullableLongAttribute());
     3020    JSValue result = toJS<IDLNullable<IDLLong>>(impl.nullableLongAttribute());
    30213021    return result;
    30223022}
     
    30343034    UNUSED_PARAM(state);
    30353035    auto& impl = thisObject.wrapped();
    3036     JSValue result = jsBoolean(impl.nullableBooleanAttribute());
     3036    JSValue result = toJS<IDLNullable<IDLBoolean>>(impl.nullableBooleanAttribute());
    30373037    return result;
    30383038}
     
    30663066    UNUSED_PARAM(state);
    30673067    auto& impl = thisObject.wrapped();
    3068     JSValue result = toNullableJSNumber(impl.nullableLongSettableAttribute());
     3068    JSValue result = toJS<IDLNullable<IDLLong>>(impl.nullableLongSettableAttribute());
    30693069    return result;
    30703070}
     
    31153115    ExceptionCode ec = 0;
    31163116    auto& impl = thisObject.wrapped();
    3117     JSValue result = toNullableJSNumber(impl.nullableStringValue(ec));
     3117    JSValue result = toJS<IDLNullable<IDLLong>>(impl.nullableStringValue(ec));
    31183118    setDOMException(&state, throwScope, ec);
    31193119    return result;
     
    31323132    UNUSED_PARAM(state);
    31333133    auto& impl = thisObject.wrapped();
    3134     JSValue result = jsStringWithCache(&state, impl.attribute());
     3134    JSValue result = toJS<IDLDOMString>(state, impl.attribute());
    31353135    return result;
    31363136}
     
    31483148    UNUSED_PARAM(state);
    31493149    auto& impl = thisObject.wrapped();
    3150     JSValue result = jsStringWithCache(&state, impl.attributeWithReservedEnumType());
     3150    JSValue result = toJS<IDLEnumeration<TestObj::Optional>>(state, impl.attributeWithReservedEnumType());
    31513151    return result;
    31523152}
     
    32123212    UNUSED_PARAM(state);
    32133213    auto& impl = thisObject.wrapped();
    3214     JSValue result = jsStringWithCache(&state, impl.stringifierAttribute());
     3214    JSValue result = toJS<IDLUSVString>(state, impl.stringifierAttribute());
    32153215    return result;
    32163216}
     
    48264826    UNUSED_PARAM(throwScope);
    48274827    auto& impl = castedThis->wrapped();
    4828     JSValue result = jsNumber(impl.byteMethod());
     4828    JSValue result = toJS<IDLByte>(impl.byteMethod());
    48294829    return JSValue::encode(result);
    48304830}
     
    48514851    if (UNLIKELY(!objArg))
    48524852        return throwArgumentTypeError(*state, throwScope, 2, "objArg", "TestObject", "byteMethodWithArgs", "TestObj");
    4853     JSValue result = jsNumber(impl.byteMethodWithArgs(WTFMove(byteArg), WTFMove(strArg), *objArg));
     4853    JSValue result = toJS<IDLByte>(impl.byteMethodWithArgs(WTFMove(byteArg), WTFMove(strArg), *objArg));
    48544854    return JSValue::encode(result);
    48554855}
     
    48674867    UNUSED_PARAM(throwScope);
    48684868    auto& impl = castedThis->wrapped();
    4869     JSValue result = jsNumber(impl.octetMethod());
     4869    JSValue result = toJS<IDLOctet>(impl.octetMethod());
    48704870    return JSValue::encode(result);
    48714871}
     
    48924892    if (UNLIKELY(!objArg))
    48934893        return throwArgumentTypeError(*state, throwScope, 2, "objArg", "TestObject", "octetMethodWithArgs", "TestObj");
    4894     JSValue result = jsNumber(impl.octetMethodWithArgs(WTFMove(octetArg), WTFMove(strArg), *objArg));
     4894    JSValue result = toJS<IDLOctet>(impl.octetMethodWithArgs(WTFMove(octetArg), WTFMove(strArg), *objArg));
    48954895    return JSValue::encode(result);
    48964896}
     
    49084908    UNUSED_PARAM(throwScope);
    49094909    auto& impl = castedThis->wrapped();
    4910     JSValue result = jsNumber(impl.longMethod());
     4910    JSValue result = toJS<IDLLong>(impl.longMethod());
    49114911    return JSValue::encode(result);
    49124912}
     
    49334933    if (UNLIKELY(!objArg))
    49344934        return throwArgumentTypeError(*state, throwScope, 2, "objArg", "TestObject", "longMethodWithArgs", "TestObj");
    4935     JSValue result = jsNumber(impl.longMethodWithArgs(WTFMove(longArg), WTFMove(strArg), *objArg));
     4935    JSValue result = toJS<IDLLong>(impl.longMethodWithArgs(WTFMove(longArg), WTFMove(strArg), *objArg));
    49364936    return JSValue::encode(result);
    49374937}
     
    49904990    UNUSED_PARAM(throwScope);
    49914991    auto& impl = castedThis->wrapped();
    4992     JSValue result = jsNumber(impl.unforgeableMethod());
     4992    JSValue result = toJS<IDLLong>(impl.unforgeableMethod());
    49934993    return JSValue::encode(result);
    49944994}
     
    53115311    UNUSED_PARAM(throwScope);
    53125312    auto& impl = castedThis->wrapped();
    5313     JSValue result = toJSNumber(*state, throwScope, impl.methodWithExceptionReturningLong());
     5313    JSValue result = toJS<IDLLong>(*state, throwScope, impl.methodWithExceptionReturningLong());
    53145314    return JSValue::encode(result);
    53155315}
     
    53935393    auto argument = state->uncheckedArgument(0).toWTFString(state);
    53945394    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    5395     JSValue result = jsStringWithCache(state, impl.privateMethod(WTFMove(argument)));
     5395    JSValue result = toJS<IDLDOMString>(*state, impl.privateMethod(WTFMove(argument)));
    53965396    return JSValue::encode(result);
    53975397}
     
    54135413    auto argument = state->uncheckedArgument(0).toWTFString(state);
    54145414    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    5415     JSValue result = jsStringWithCache(state, impl.publicAndPrivateMethod(WTFMove(argument)));
     5415    JSValue result = toJS<IDLDOMString>(*state, impl.publicAndPrivateMethod(WTFMove(argument)));
    54165416    return JSValue::encode(result);
    54175417}
     
    64116411    UNUSED_PARAM(throwScope);
    64126412    auto& impl = castedThis->wrapped();
    6413     JSValue result = jsStringWithCache(state, impl.conditionalMethod1());
     6413    JSValue result = toJS<IDLDOMString>(*state, impl.conditionalMethod1());
    64146414    return JSValue::encode(result);
    64156415}
     
    72447244    auto arg = state->argument(0).isUndefined() ? Optional<int32_t>() : convert<IDLLong>(*state, state->uncheckedArgument(0), NormalConversion);
    72457245    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    7246     JSValue result = jsNumber(TestObj::classMethodWithOptional(WTFMove(arg)));
     7246    JSValue result = toJS<IDLLong>(TestObj::classMethodWithOptional(WTFMove(arg)));
    72477247    return JSValue::encode(result);
    72487248}
     
    73897389    auto values = convert<IDLSequence<IDLDOMString>>(*state, state->uncheckedArgument(0));
    73907390    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    7391     JSValue result = jsArray(state, castedThis->globalObject(), impl.stringArrayFunction(WTFMove(values), ec));
     7391    JSValue result = toJS<IDLSequence<IDLDOMString>>(*state, *castedThis->globalObject(), impl.stringArrayFunction(WTFMove(values), ec));
    73927392
    73937393    setDOMException(state, throwScope, ec);
     
    81538153    UNUSED_PARAM(throwScope);
    81548154    auto& impl = castedThis->wrapped();
    8155     JSValue result = jsStringWithCache(state, impl.stringifierAttribute());
     8155    JSValue result = toJS<IDLUSVString>(*state, impl.stringifierAttribute());
    81568156    return JSValue::encode(result);
    81578157}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h

    r207715 r207737  
    107107    using ToWrappedReturnType = TestObj*;
    108108};
    109 JSC::JSString* jsStringWithCache(JSC::ExecState*, TestObj::EnumType);
    110 
    111 template<> struct JSValueTraits<TestObj::EnumType> {
    112     static JSC::JSString* arrayJSValue(JSC::ExecState* state, JSDOMGlobalObject*, TestObj::EnumType value) { return jsStringWithCache(state, value); }
    113 };
     109template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, TestObj::EnumType);
    114110
    115111template<> Optional<TestObj::EnumType> parseEnumeration<TestObj::EnumType>(JSC::ExecState&, JSC::JSValue);
     
    117113template<> const char* expectedEnumerationValues<TestObj::EnumType>();
    118114
    119 JSC::JSString* jsStringWithCache(JSC::ExecState*, TestObj::Optional);
    120 
    121 template<> struct JSValueTraits<TestObj::Optional> {
    122     static JSC::JSString* arrayJSValue(JSC::ExecState* state, JSDOMGlobalObject*, TestObj::Optional value) { return jsStringWithCache(state, value); }
    123 };
     115template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, TestObj::Optional);
    124116
    125117template<> Optional<TestObj::Optional> parseEnumeration<TestObj::Optional>(JSC::ExecState&, JSC::JSValue);
     
    127119template<> const char* expectedEnumerationValues<TestObj::Optional>();
    128120
    129 JSC::JSString* jsStringWithCache(JSC::ExecState*, AlternateEnumName);
    130 
    131 template<> struct JSValueTraits<AlternateEnumName> {
    132     static JSC::JSString* arrayJSValue(JSC::ExecState* state, JSDOMGlobalObject*, AlternateEnumName value) { return jsStringWithCache(state, value); }
    133 };
     121template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, AlternateEnumName);
    134122
    135123template<> Optional<AlternateEnumName> parseEnumeration<AlternateEnumName>(JSC::ExecState&, JSC::JSValue);
     
    139127#if ENABLE(Condition1)
    140128
    141 JSC::JSString* jsStringWithCache(JSC::ExecState*, TestObj::EnumA);
    142 
    143 template<> struct JSValueTraits<TestObj::EnumA> {
    144     static JSC::JSString* arrayJSValue(JSC::ExecState* state, JSDOMGlobalObject*, TestObj::EnumA value) { return jsStringWithCache(state, value); }
    145 };
     129template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, TestObj::EnumA);
    146130
    147131template<> Optional<TestObj::EnumA> parseEnumeration<TestObj::EnumA>(JSC::ExecState&, JSC::JSValue);
     
    153137#if ENABLE(Condition1) && ENABLE(Condition2)
    154138
    155 JSC::JSString* jsStringWithCache(JSC::ExecState*, TestObj::EnumB);
    156 
    157 template<> struct JSValueTraits<TestObj::EnumB> {
    158     static JSC::JSString* arrayJSValue(JSC::ExecState* state, JSDOMGlobalObject*, TestObj::EnumB value) { return jsStringWithCache(state, value); }
    159 };
     139template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, TestObj::EnumB);
    160140
    161141template<> Optional<TestObj::EnumB> parseEnumeration<TestObj::EnumB>(JSC::ExecState&, JSC::JSValue);
     
    167147#if ENABLE(Condition1) || ENABLE(Condition2)
    168148
    169 JSC::JSString* jsStringWithCache(JSC::ExecState*, TestObj::EnumC);
    170 
    171 template<> struct JSValueTraits<TestObj::EnumC> {
    172     static JSC::JSString* arrayJSValue(JSC::ExecState* state, JSDOMGlobalObject*, TestObj::EnumC value) { return jsStringWithCache(state, value); }
    173 };
     149template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, TestObj::EnumC);
    174150
    175151template<> Optional<TestObj::EnumC> parseEnumeration<TestObj::EnumC>(JSC::ExecState&, JSC::JSValue);
     
    179155#endif
    180156
    181 JSC::JSString* jsStringWithCache(JSC::ExecState*, TestObj::Kind);
    182 
    183 template<> struct JSValueTraits<TestObj::Kind> {
    184     static JSC::JSString* arrayJSValue(JSC::ExecState* state, JSDOMGlobalObject*, TestObj::Kind value) { return jsStringWithCache(state, value); }
    185 };
     157template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, TestObj::Kind);
    186158
    187159template<> Optional<TestObj::Kind> parseEnumeration<TestObj::Kind>(JSC::ExecState&, JSC::JSValue);
     
    189161template<> const char* expectedEnumerationValues<TestObj::Kind>();
    190162
    191 JSC::JSString* jsStringWithCache(JSC::ExecState*, TestObj::Size);
    192 
    193 template<> struct JSValueTraits<TestObj::Size> {
    194     static JSC::JSString* arrayJSValue(JSC::ExecState* state, JSDOMGlobalObject*, TestObj::Size value) { return jsStringWithCache(state, value); }
    195 };
     163template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, TestObj::Size);
    196164
    197165template<> Optional<TestObj::Size> parseEnumeration<TestObj::Size>(JSC::ExecState&, JSC::JSValue);
     
    199167template<> const char* expectedEnumerationValues<TestObj::Size>();
    200168
    201 JSC::JSString* jsStringWithCache(JSC::ExecState*, TestObj::Confidence);
    202 
    203 template<> struct JSValueTraits<TestObj::Confidence> {
    204     static JSC::JSString* arrayJSValue(JSC::ExecState* state, JSDOMGlobalObject*, TestObj::Confidence value) { return jsStringWithCache(state, value); }
    205 };
     169template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, TestObj::Confidence);
    206170
    207171template<> Optional<TestObj::Confidence> parseEnumeration<TestObj::Confidence>(JSC::ExecState&, JSC::JSValue);
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerialization.cpp

    r207378 r207737  
    2626#include "JSDOMConvert.h"
    2727#include "JSTestNode.h"
    28 #include "URL.h"
    2928#include <runtime/FunctionPrototype.h>
    30 #include <runtime/JSString.h>
    3129#include <runtime/ObjectConstructor.h>
    3230#include <wtf/GetPtr.h>
     
    163161    UNUSED_PARAM(state);
    164162    auto& impl = thisObject.wrapped();
    165     JSValue result = jsStringWithCache(&state, impl.firstStringAttribute());
     163    JSValue result = toJS<IDLDOMString>(state, impl.firstStringAttribute());
    166164    return result;
    167165}
     
    179177    UNUSED_PARAM(state);
    180178    auto& impl = thisObject.wrapped();
    181     JSValue result = jsNumber(impl.secondLongAttribute());
     179    JSValue result = toJS<IDLLong>(impl.secondLongAttribute());
    182180    return result;
    183181}
     
    211209    UNUSED_PARAM(state);
    212210    auto& impl = thisObject.wrapped();
    213     JSValue result = jsNumber(impl.fourthUnrestrictedDoubleAttribute());
     211    JSValue result = toJS<IDLUnrestrictedDouble>(impl.fourthUnrestrictedDoubleAttribute());
    214212    return result;
    215213}
     
    227225    UNUSED_PARAM(state);
    228226    auto& impl = thisObject.wrapped();
    229     JSValue result = jsNumber(impl.fifthLongAttribute());
     227    JSValue result = toJS<IDLLong>(impl.fifthLongAttribute());
    230228    return result;
    231229}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp

    r207516 r207737  
    2727#include "JSDOMBinding.h"
    2828#include "JSDOMConstructor.h"
     29#include "JSDOMConvert.h"
    2930#include "JSMessagePort.h"
    3031#include "SerializedScriptValue.h"
     
    201202    UNUSED_PARAM(state);
    202203    auto& impl = thisObject.wrapped();
    203     JSValue result = jsArray(&state, thisObject.globalObject(), impl.ports());
     204    JSValue result = toJS<IDLSequence<IDLInterface<MessagePort>>>(state, *thisObject.globalObject(), impl.ports());
    204205    return result;
    205206}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp

    r207519 r207737  
    3232#include "SVGPoint.h"
    3333#include "SerializedScriptValue.h"
    34 #include "URL.h"
    3534#include <runtime/Error.h>
    3635#include <runtime/FunctionPrototype.h>
    3736#include <runtime/JSArray.h>
    38 #include <runtime/JSString.h>
    3937#include <wtf/GetPtr.h>
    4038#include <wtf/Variant.h>
     
    239237    UNUSED_PARAM(state);
    240238    auto& impl = thisObject.wrapped();
    241     JSValue result = jsNumber(impl.unsignedLongLongAttr());
     239    JSValue result = toJS<IDLUnsignedLongLong>(impl.unsignedLongLongAttr());
    242240    return result;
    243241}
     
    286284    ExceptionCode ec = 0;
    287285    auto& impl = thisObject.wrapped();
    288     JSValue result = jsNumber(impl.attrWithGetterException(ec));
     286    JSValue result = toJS<IDLLong>(impl.attrWithGetterException(ec));
    289287    setDOMException(&state, throwScope, ec);
    290288    return result;
     
    303301    UNUSED_PARAM(state);
    304302    auto& impl = thisObject.wrapped();
    305     JSValue result = jsNumber(impl.attrWithSetterException());
     303    JSValue result = toJS<IDLLong>(impl.attrWithSetterException());
    306304    return result;
    307305}
     
    320318    ExceptionCode ec = 0;
    321319    auto& impl = thisObject.wrapped();
    322     JSValue result = jsStringWithCache(&state, impl.stringAttrWithGetterException(ec));
     320    JSValue result = toJS<IDLDOMString>(state, impl.stringAttrWithGetterException(ec));
    323321    setDOMException(&state, throwScope, ec);
    324322    return result;
     
    337335    UNUSED_PARAM(state);
    338336    auto& impl = thisObject.wrapped();
    339     JSValue result = jsStringWithCache(&state, impl.stringAttrWithSetterException());
     337    JSValue result = toJS<IDLDOMString>(state, impl.stringAttrWithSetterException());
    340338    return result;
    341339}
     
    550548    auto sequenceArg = convert<IDLSequence<IDLInterface<SerializedScriptValue>>>(*state, state->uncheckedArgument(0));
    551549    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    552     JSValue result = jsNumber(impl.methodWithSequenceArg(WTFMove(sequenceArg)));
     550    JSValue result = toJS<IDLUnsignedLongLong>(impl.methodWithSequenceArg(WTFMove(sequenceArg)));
    553551    return JSValue::encode(result);
    554552}
     
    689687    auto values = convert<IDLSequence<IDLDOMString>>(*state, state->uncheckedArgument(0));
    690688    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    691     JSValue result = jsArray(state, castedThis->globalObject(), impl.stringSequenceFunction(WTFMove(values), ec));
     689    JSValue result = toJS<IDLSequence<IDLDOMString>>(*state, *castedThis->globalObject(), impl.stringSequenceFunction(WTFMove(values), ec));
    692690
    693691    setDOMException(state, throwScope, ec);
     
    712710    auto values = convert<IDLSequence<IDLDOMString>>(*state, state->uncheckedArgument(0));
    713711    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    714     JSValue result = jsArray(state, castedThis->globalObject(), impl.stringSequenceFunction2(WTFMove(values), ec));
     712    JSValue result = toJS<IDLSequence<IDLDOMString>>(*state, *castedThis->globalObject(), impl.stringSequenceFunction2(WTFMove(values), ec));
    715713
    716714    setDOMException(state, throwScope, ec);
     
    734732    auto sequenceArg = convert<IDLSequence<IDLInterface<TestEventTarget>>>(*state, state->uncheckedArgument(0));
    735733    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    736     JSValue result = jsBoolean(impl.callWithSequenceThatRequiresInclude(WTFMove(sequenceArg)));
     734    JSValue result = toJS<IDLBoolean>(impl.callWithSequenceThatRequiresInclude(WTFMove(sequenceArg)));
    737735    return JSValue::encode(result);
    738736}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSattribute.cpp

    r207192 r207737  
    2424#include "JSDOMBinding.h"
    2525#include "JSDOMConstructor.h"
    26 #include "URL.h"
     26#include "JSDOMConvert.h"
    2727#include <runtime/FunctionPrototype.h>
    28 #include <runtime/JSString.h>
    2928#include <wtf/GetPtr.h>
    3029
     
    150149    UNUSED_PARAM(state);
    151150    auto& impl = thisObject.wrapped();
    152     JSValue result = jsStringWithCache(&state, impl.readonly());
     151    JSValue result = toJS<IDLDOMString>(state, impl.readonly());
    153152    return result;
    154153}
  • trunk/Source/WebCore/dom/Event.idl

    r207515 r207737  
    1818 * Boston, MA 02110-1301, USA.
    1919 */
     20
     21// FIXME: This should be an implementation provided typedef
     22// https://heycam.github.io/webidl/#DOMTimeStamp
     23typedef unsigned long long DOMTimeStamp;
    2024
    2125[
  • trunk/Source/WebCore/testing/TypeConversions.h

    r207627 r207737  
    5151    };
    5252
     53    using DictionaryUnion = Variant<RefPtr<Node>, Vector<String>, OtherDictionary>;
     54
    5355    struct Dictionary {
    5456        int longValue;
    5557        String stringValue;
    5658        Vector<String> sequenceValue;
    57         Variant<RefPtr<Node>, Vector<String>, OtherDictionary> unionValue;
     59        DictionaryUnion unionValue;
    5860    };
    5961
     
    99101    void setTestUSVString(const String& usvstring) { m_usvstring = usvstring; }
    100102
     103    using TestUnion = Variant<String, int, bool, RefPtr<Node>, Vector<int>>;
     104    const TestUnion& testUnion() const { return m_union; }
     105    void setTestUnion(const TestUnion& value) { m_union = value; }
     106
    101107    void setTypeConversionsDictionary(Dictionary& dictionary)
    102108    {
     
    109115    int typeConversionsDictionaryLongValue() { return m_typeConversionsDictionaryLongValue; }
    110116    String typeConversionsDictionaryStringValue() { return m_typeConversionsDictionaryStringValue; }
    111     Vector<String> typeConversionsDictionarySequenceValue() { return m_typeConversionsDictionarySequenceValue; }
     117    const Vector<String>& typeConversionsDictionarySequenceValue() { return m_typeConversionsDictionarySequenceValue; }
     118    const DictionaryUnion& typeConversionsDictionaryUnionValue() { return m_typeConversionsDictionaryUnionValue; }
    112119    UnionType typeConversionsDictionaryUnionType()
    113120    {
     
    134141    String m_string;
    135142    String m_usvstring;
     143    TestUnion m_union;
    136144   
    137145    int m_typeConversionsDictionaryLongValue { 0 };
    138146    String m_typeConversionsDictionaryStringValue;
    139147    Vector<String> m_typeConversionsDictionarySequenceValue;
    140     Variant<RefPtr<Node>, Vector<String>, OtherDictionary> m_typeConversionsDictionaryUnionValue;
     148    DictionaryUnion m_typeConversionsDictionaryUnionValue;
    141149};
    142150
  • trunk/Source/WebCore/testing/TypeConversions.idl

    r207575 r207737  
    5353    attribute DOMString testString;
    5454    attribute USVString testUSVString;
     55
     56    attribute (DOMString or long or boolean or Node or sequence<long>) testUnion;
    5557   
    5658    void setTypeConversionsDictionary(TypeConversionsDictionary d);
     
    5860    readonly attribute DOMString typeConversionsDictionaryStringValue;
    5961    readonly attribute sequence<DOMString> typeConversionsDictionarySequenceValue;
    60     readonly attribute UnionType typeConversionsDictionaryUnionType; 
     62    readonly attribute UnionType typeConversionsDictionaryUnionType;
    6163};
    6264
Note: See TracChangeset for help on using the changeset viewer.