Changeset 207737 in webkit
- Timestamp:
- Oct 23, 2016 10:02:05 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r207736 r207737 1 2016-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 1 11 2016-10-23 Zalan Bujtas <zalan@apple.com> 2 12 -
trunk/LayoutTests/js/dom/webidl-type-mapping-expected.txt
r207575 r207737 1060 1060 PASS converter.testUSVString is "undefined" 1061 1061 PASS converter.testString is "undefined" 1062 converter.testUnion = 'hello' 1063 PASS converter.testUnion is 'hello' 1064 PASS typeof converter.testUnion is 'string' 1065 converter.testUnion = 1 1066 PASS converter.testUnion is 1 1067 PASS typeof converter.testUnion is 'number' 1068 converter.testUnion = false 1069 PASS converter.testUnion is false 1070 PASS typeof converter.testUnion is 'boolean' 1071 converter.testUnion = document 1072 PASS converter.testUnion is document 1073 PASS typeof converter.testUnion is 'object' 1074 PASS converter.testUnion is an instance of Document 1075 converter.testUnion = [1, 2] 1076 PASS converter.testUnion is [1, 2] 1077 PASS typeof converter.testUnion is 'object' 1078 PASS converter.testUnion is an instance of Array 1079 converter.testUnion = null 1080 PASS converter.testUnion is 'null' 1081 PASS typeof converter.testUnion is 'string' 1082 converter.testUnion = undefined 1083 PASS converter.testUnion is 'undefined' 1084 PASS typeof converter.testUnion is 'string' 1085 converter.testUnion = window 1086 PASS typeof converter.testUnion is 'string' 1087 PASS converter.testUnion is '[object Window]' 1088 converter.testUnion = { } 1089 PASS typeof converter.testUnion is 'string' 1090 PASS converter.testUnion is '[object Object]' 1091 PASS converter.testUnion = { toString: function() { throw Error(); } } threw exception Error. 1062 1092 converter.setTypeConversionsDictionary({ longValue: 1 }) 1063 1093 PASS converter.typeConversionsDictionaryLongValue is 1 -
trunk/LayoutTests/js/dom/webidl-type-mapping.html
r207575 r207737 53 53 convertThrows(attribute, "undefined"); 54 54 } 55 55 // 56 56 type = "testLong"; 57 57 verifyAttribute(type); … … 587 587 }); 588 588 589 evalAndLog("converter.testUnion = 'hello'"); 590 shouldBe("converter.testUnion", "'hello'"); 591 shouldBe("typeof converter.testUnion", "'string'"); 592 evalAndLog("converter.testUnion = 1"); 593 shouldBe("converter.testUnion", "1"); 594 shouldBe("typeof converter.testUnion", "'number'"); 595 evalAndLog("converter.testUnion = false"); 596 shouldBe("converter.testUnion", "false"); 597 shouldBe("typeof converter.testUnion", "'boolean'"); 598 evalAndLog("converter.testUnion = document"); 599 shouldBe("converter.testUnion", "document"); 600 shouldBe("typeof converter.testUnion", "'object'"); 601 shouldBeType("converter.testUnion", "Document"); 602 evalAndLog("converter.testUnion = [1, 2]"); 603 shouldBe("converter.testUnion", "[1, 2]"); 604 shouldBe("typeof converter.testUnion", "'object'"); 605 shouldBeType("converter.testUnion", "Array"); 606 evalAndLog("converter.testUnion = null"); 607 shouldBe("converter.testUnion", "'null'"); 608 shouldBe("typeof converter.testUnion", "'string'"); 609 evalAndLog("converter.testUnion = undefined"); 610 shouldBe("converter.testUnion", "'undefined'"); 611 shouldBe("typeof converter.testUnion", "'string'"); 612 evalAndLog("converter.testUnion = window"); 613 shouldBe("typeof converter.testUnion", "'string'"); 614 shouldBe("converter.testUnion", "'[object Window]'"); 615 evalAndLog("converter.testUnion = { }"); 616 shouldBe("typeof converter.testUnion", "'string'"); 617 shouldBe("converter.testUnion", "'[object Object]'"); 618 shouldThrow("converter.testUnion = { toString: function() { throw Error(); } }"); 619 589 620 evalAndLog("converter.setTypeConversionsDictionary({ longValue: 1 })"); 590 621 shouldBe("converter.typeConversionsDictionaryLongValue", "1"); -
trunk/Source/WebCore/ChangeLog
r207736 r207737 1 2016-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 1 154 2016-10-23 Zalan Bujtas <zalan@apple.com> 2 155 -
trunk/Source/WebCore/Modules/geolocation/Geoposition.idl
r151207 r207737 24 24 */ 25 25 26 // FIXME: This should be an implementation provided typedef 27 // https://heycam.github.io/webidl/#DOMTimeStamp 28 typedef unsigned long long DOMTimeStamp; 29 26 30 [ 27 31 NoInterfaceObject, -
trunk/Source/WebCore/Modules/webdatabase/SQLResultSet.idl
r207384 r207737 31 31 ] interface SQLResultSet { 32 32 readonly attribute SQLResultSetRowList rows; 33 [GetterMayThrowException] readonly attribute long insertId;33 [GetterMayThrowException] readonly attribute long long insertId; 34 34 readonly attribute long rowsAffected; 35 35 }; -
trunk/Source/WebCore/bindings/js/JSDOMBinding.h
r207711 r207737 224 224 String valueToUSVStringWithUndefinedOrNullCheck(JSC::ExecState*, JSC::JSValue); 225 225 226 template<typename T> JSC::JSValue toNullableJSNumber(Optional<T>); // null if the optional is null227 228 226 int32_t finiteInt32Value(JSC::JSValue, JSC::ExecState*, bool& okay); 229 227 … … 284 282 JSC::JSValue toJSIteratorEnd(JSC::ExecState&); 285 283 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 290 284 JSC::JSValue jsPair(JSC::ExecState&, JSDOMGlobalObject*, JSC::JSValue, JSC::JSValue); 291 285 template<typename FirstType, typename SecondType> JSC::JSValue jsPair(JSC::ExecState&, JSDOMGlobalObject*, const FirstType&, const SecondType&); … … 329 323 330 324 template<JSC::NativeFunction, int length> JSC::EncodedJSValue nonCachingStaticFunctionGetter(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); 331 332 template<typename T> struct NativeValueTraits;333 325 334 326 … … 414 406 void propagateException(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<void>&&); 415 407 template<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>&&);418 408 JSC::JSValue toJSDate(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<double>&&); 419 409 JSC::JSValue toJSNullableDate(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<Optional<double>>&&); 420 410 JSC::JSValue toJSNullableString(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<String>&&); 421 411 template<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>&&);425 412 426 413 // Inline functions and template definitions. … … 720 707 { 721 708 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);787 709 } 788 710 … … 818 740 inline RefPtr<JSC::Float64Array> toFloat64Array(JSC::JSValue value) { return JSC::toNativeTypedView<JSC::Float64Adaptor>(value); } 819 741 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 860 742 template<typename T, typename JST> inline Vector<Ref<T>> toRefNativeArray(JSC::ExecState& state, JSC::JSValue value) 861 743 { … … 898 780 } 899 781 900 template<typename T> inline JSC::JSValue toNullableJSNumber(Optional<T> optionalNumber)901 {902 return optionalNumber ? JSC::jsNumber(optionalNumber.value()) : JSC::jsNull();903 }904 905 782 ALWAYS_INLINE void propagateException(JSC::ExecState& state, JSC::ThrowScope& throwScope, Exception&& exception) 906 783 { … … 932 809 } 933 810 934 template<typename T> inline JSC::JSValue toJS Array(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope& throwScope, ExceptionOr<T>&& value)811 template<typename T> inline JSC::JSValue toJSNewlyCreated(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope& throwScope, ExceptionOr<T>&& value) 935 812 { 936 813 if (UNLIKELY(value.hasException())) { … … 938 815 return { }; 939 816 } 940 return jsArray(&state, &globalObject, value.releaseReturnValue());941 } 942 943 inline JSC::JSValue toJS Boolean(JSC::ExecState& state, JSC::ThrowScope& throwScope, ExceptionOr<bool>&& value)817 return toJSNewlyCreated(&state, &globalObject, value.releaseReturnValue()); 818 } 819 820 inline JSC::JSValue toJSNullableString(JSC::ExecState& state, JSC::ThrowScope& throwScope, ExceptionOr<String>&& value) 944 821 { 945 822 if (UNLIKELY(value.hasException())) { … … 947 824 return { }; 948 825 } 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 }967 826 return jsStringOrNull(&state, value.releaseReturnValue()); 968 827 } 969 828 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 988 829 } // namespace WebCore -
trunk/Source/WebCore/bindings/js/JSDOMConvert.h
r207734 r207737 32 32 namespace WebCore { 33 33 34 // Conversion from JSValue -> Implementation 34 35 template<typename T> struct Converter; 35 36 36 37 template<typename T, typename U = T> using EnableIfIntegralType = typename std::enable_if<IsIDLInteger<T>::value, typename Converter<U>::ReturnType>::type; 37 38 template<typename T, typename U = T> using EnableIfNotIntegralType = typename std::enable_if<!IsIDLInteger<T>::value, typename Converter<U>::ReturnType>::type; 38 39 39 template<typename T> EnableIfNotIntegralType<T> convert(JSC::ExecState&, JSC::JSValue); 40 41 // Specialization for integer types, allowing passing of a conversion flag.42 40 template<typename T> EnableIfIntegralType<T> convert(JSC::ExecState&, JSC::JSValue, IntegerConversionConfiguration = NormalConversion); 43 41 … … 50 48 template<typename T> const char* expectedEnumerationValues(); 51 49 52 // This is where the implementation of the things declared above begins:53 54 50 template<typename T> inline EnableIfNotIntegralType<T> convert(JSC::ExecState& state, JSC::JSValue value) 55 51 { … … 62 58 } 63 59 60 61 // Conversion from Implementation -> JSValue 62 template<typename T> struct JSConverter; 63 64 template<typename T, typename U> inline JSC::JSValue toJS(U&&); 65 template<typename T, typename U> inline JSC::JSValue toJS(JSC::ExecState&, U&&); 66 template<typename T, typename U> inline JSC::JSValue toJS(JSC::ExecState&, JSDOMGlobalObject&, U&&); 67 template<typename T, typename U> inline JSC::JSValue toJS(JSC::ExecState&, JSC::ThrowScope&, ExceptionOr<U>&&); 68 template<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. 71 template<typename T> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, T); 72 73 74 template<typename T, bool needsState = JSConverter<T>::needsState, bool needsGlobalObject = JSConverter<T>::needsGlobalObject> 75 struct JSConverterOverloader; 76 77 template<typename T> 78 struct 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 85 template<typename T> 86 struct 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 98 template<typename T> 99 struct 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 111 template<typename T, typename U> inline JSC::JSValue toJS(U&& value) 112 { 113 return JSConverter<T>::convert(std::forward<U>(value)); 114 } 115 116 template<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 121 template<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 126 template<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 136 template<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 64 147 template<typename T> struct DefaultConverter { 65 148 using ReturnType = typename T::ImplementationType; 66 };67 68 template<typename T> struct Converter : DefaultConverter<T> {69 149 }; 70 150 … … 95 175 }; 96 176 177 template<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 97 206 // MARK: - 98 207 // MARK: Boolean type … … 102 211 { 103 212 return value.toBoolean(&state); 213 } 214 }; 215 216 template<> 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); 104 223 } 105 224 }; … … 135 254 }; 136 255 256 template<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 137 267 // Typed arrays support. 138 268 … … 161 291 template<> struct Converter<IDLAny> : DefaultConverter<IDLAny> { 162 292 static JSC::JSValue convert(JSC::ExecState&, JSC::JSValue value) 293 { 294 return value; 295 } 296 }; 297 298 template<> 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) 163 303 { 164 304 return value; … … 184 324 }; 185 325 326 template<> 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 186 338 template<> struct Converter<IDLOctet> : DefaultConverter<IDLOctet> { 187 339 static uint8_t convert(JSC::ExecState& state, JSC::JSValue value, IntegerConversionConfiguration configuration = NormalConversion) … … 199 351 }; 200 352 353 template<> 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 201 365 template<> struct Converter<IDLShort> : DefaultConverter<IDLShort> { 202 366 static int16_t convert(JSC::ExecState& state, JSC::JSValue value, IntegerConversionConfiguration configuration = NormalConversion) … … 214 378 }; 215 379 380 template<> 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 216 392 template<> struct Converter<IDLUnsignedShort> : DefaultConverter<IDLUnsignedShort> { 217 393 static uint16_t convert(JSC::ExecState& state, JSC::JSValue value, IntegerConversionConfiguration configuration = NormalConversion) … … 229 405 }; 230 406 407 template<> 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 231 419 template<> struct Converter<IDLLong> : DefaultConverter<IDLLong> { 232 420 static int32_t convert(JSC::ExecState& state, JSC::JSValue value, IntegerConversionConfiguration configuration = NormalConversion) … … 244 432 }; 245 433 434 template<> 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 246 446 template<> struct Converter<IDLUnsignedLong> : DefaultConverter<IDLUnsignedLong> { 247 447 static uint32_t convert(JSC::ExecState& state, JSC::JSValue value, IntegerConversionConfiguration configuration = NormalConversion) … … 259 459 }; 260 460 461 template<> 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 261 473 template<> struct Converter<IDLLongLong> : DefaultConverter<IDLLongLong> { 262 474 static int64_t convert(JSC::ExecState& state, JSC::JSValue value, IntegerConversionConfiguration configuration = NormalConversion) … … 277 489 }; 278 490 491 template<> 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 279 503 template<> struct Converter<IDLUnsignedLongLong> : DefaultConverter<IDLUnsignedLongLong> { 280 504 static uint64_t convert(JSC::ExecState& state, JSC::JSValue value, IntegerConversionConfiguration configuration = NormalConversion) … … 295 519 }; 296 520 521 template<> 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 297 533 // MARK: - 298 534 // MARK: Floating point types … … 310 546 }; 311 547 548 template<> 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 312 560 template<> struct Converter<IDLUnrestrictedFloat> : DefaultConverter<IDLUnrestrictedFloat> { 313 561 static float convert(JSC::ExecState& state, JSC::JSValue value) 314 562 { 315 563 return static_cast<float>(value.toNumber(&state)); 564 } 565 }; 566 567 template<> 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); 316 576 } 317 577 }; … … 329 589 }; 330 590 591 template<> 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 331 603 template<> struct Converter<IDLUnrestrictedDouble> : DefaultConverter<IDLUnrestrictedDouble> { 332 604 static double convert(JSC::ExecState& state, JSC::JSValue value) … … 336 608 }; 337 609 610 template<> 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 338 628 // MARK: - 339 629 // MARK: String types … … 346 636 }; 347 637 638 template<> 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 348 648 template<> struct Converter<IDLUSVString> : DefaultConverter<IDLUSVString> { 349 649 static String convert(JSC::ExecState& state, JSC::JSValue value) 350 650 { 351 651 return valueToUSVString(&state, value); 652 } 653 }; 654 655 template<> 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); 352 662 } 353 663 }; … … 407 717 }; 408 718 719 template<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 409 733 template<typename T> struct Converter<IDLFrozenArray<T>> : DefaultConverter<IDLFrozenArray<T>> { 410 734 using ReturnType = typename Detail::ArrayConverter<T>::ReturnType; … … 416 740 }; 417 741 742 template<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 418 757 // MARK: - 419 758 // MARK: Dictionary type … … 438 777 }; 439 778 779 template<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 }; 440 788 441 789 // MARK: - … … 481 829 using ConditionalFront = typename Detail::ConditionalFront<List, condition>::type; 482 830 483 template<typename... T> 484 struct Converter<IDLUnion<T...>> : DefaultConverter<IDLUnion<T...>> 485 { 831 template<typename... T> struct Converter<IDLUnion<T...>> : DefaultConverter<IDLUnion<T...>> { 486 832 using Type = IDLUnion<T...>; 487 833 using TypeList = typename Type::TypeList; … … 549 895 return; 550 896 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; 553 901 554 902 auto castedValue = WrapperType::toWrapped(value); … … 556 904 return; 557 905 558 returnValue = ReturnType( castedValue);906 returnValue = ReturnType(ImplementationType(castedValue)); 559 907 }); 560 908 … … 649 997 }; 650 998 999 template<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 651 1027 // MARK: - 652 1028 // MARK: Support for variadic tail convertions -
trunk/Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp
r207571 r207737 29 29 #include "CustomElementReactionQueue.h" 30 30 #include "DOMStringMap.h" 31 #include "JSDOMConvert.h" 31 32 #include "JSNode.h" 32 33 #include <runtime/IdentifierInlines.h> … … 44 45 const AtomicString& item = wrapped().item(propertyNameToString(propertyName), nameIsValid); 45 46 if (nameIsValid) { 46 slot.setValue(this, ReadOnly | DontDelete | DontEnum, toJS (exec, globalObject(), item));47 slot.setValue(this, ReadOnly | DontDelete | DontEnum, toJS<IDLDOMString>(*exec, item)); 47 48 return true; 48 49 } -
trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
r207522 r207737 557 557 558 558 int delay = state.argument(1).toInt32(&state); 559 return toJS Number(state, scope, wrapped().setTimeout(WTFMove(action), delay));559 return toJS<IDLLong>(state, scope, wrapped().setTimeout(WTFMove(action), delay)); 560 560 } 561 561 … … 575 575 576 576 int delay = state.argument(1).toInt32(&state); 577 return toJS Number(state, scope, wrapped().setInterval(WTFMove(action), delay));577 return toJS<IDLLong>(state, scope, wrapped().setInterval(WTFMove(action), delay)); 578 578 } 579 579 -
trunk/Source/WebCore/bindings/js/JSDataTransferCustom.cpp
r191887 r207737 30 30 #include "JSDataTransfer.h" 31 31 32 #include "JSDOM Binding.h"32 #include "JSDOMConvert.h" 33 33 34 34 using namespace JSC; … … 39 39 { 40 40 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); 42 42 } 43 43 -
trunk/Source/WebCore/bindings/js/JSMediaStreamTrackCustom.cpp
r206252 r207737 141 141 } 142 142 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); 144 144 } 145 145 if (capabilities->supportsVolume()) … … 151 151 if (capabilities->supportsEchoCancellation()) { 152 152 Vector<String> cancellation; 153 cancellation.reserve Capacity(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); 159 159 } 160 160 if (capabilities->supportsDeviceId()) -
trunk/Source/WebCore/bindings/js/JSMutationCallback.cpp
r206960 r207737 83 83 84 84 MarkedArgumentBuffer args; 85 args.append( jsArray(exec,globalObject, mutations));85 args.append(toJS<IDLSequence<IDLInterface<MutationRecord>>>(*exec, *globalObject, mutations)); 86 86 args.append(jsObserver); 87 87 -
trunk/Source/WebCore/bindings/js/JSSVGLengthCustom.cpp
r207716 r207737 23 23 24 24 #include "ExceptionCode.h" 25 #include "JSDOM Binding.h"25 #include "JSDOMConvert.h" 26 26 #include "SVGAnimatedProperty.h" 27 27 #include "SVGException.h" … … 37 37 VM& vm = state.vm(); 38 38 auto scope = DECLARE_THROW_SCOPE(vm); 39 return toJS Number(state, scope, wrapped().propertyReference().valueForBindings(SVGLengthContext { wrapped().contextElement() }));39 return toJS<IDLUnrestrictedFloat>(state, scope, wrapped().propertyReference().valueForBindings(SVGLengthContext { wrapped().contextElement() })); 40 40 } 41 41 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r207725 r207737 172 172 $stringifier->signature->name("toString"); 173 173 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 175 182 push(@{$interface->functions}, $stringifier); 176 183 last; … … 878 885 $result .= "#if ${conditionalString}\n\n" if $conditionalString; 879 886 880 # Take an ExecState* instead of an ExecState& to match the jsStringWithCache from JSString.h.881 887 # 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"; 883 889 $result .= "{\n"; 884 890 # FIXME: Might be nice to make this global be "const", but NeverDestroyed does not currently support that. … … 900 906 } 901 907 $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"; 903 909 $result .= "}\n\n"; 904 910 … … 967 973 $result .= "#if ${conditionalString}\n\n" if $conditionalString; 968 974 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"; 974 976 975 977 $result .= "template<> Optional<$className> parseEnumeration<$className>(JSC::ExecState&, JSC::JSValue);\n"; … … 4933 4935 "DOMString" => "String", 4934 4936 "USVString" => "String", 4935 "DOMTimeStamp" => "DOMTimeStamp",4936 4937 "Date" => "double", 4937 4938 "Dictionary" => "Dictionary", … … 5163 5164 } 5164 5165 5165 sub IsHandledByDOMConvert5166 sub JSValueToNativeIsHandledByDOMConvert 5166 5167 { 5167 5168 my $idlType = shift; … … 5192 5193 $thisObjectReference = "*castedThis" unless $thisObjectReference; 5193 5194 5194 if ( IsHandledByDOMConvert($idlType)) {5195 if (JSValueToNativeIsHandledByDOMConvert($idlType)) { 5195 5196 AddToImplIncludes("JSDOMConvert.h"); 5196 5197 AddToImplIncludesForIDLType($idlType, $conditional); … … 5246 5247 } 5247 5248 5249 sub 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 5267 sub 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 5280 sub 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 5248 5291 sub NativeToJSValueUsingReferences 5249 5292 { … … 5275 5318 my $conditional = $signature->extendedAttributes->{Conditional}; 5276 5319 my $type = $signature->type; 5320 my $idlType = $signature->idlType; 5277 5321 my $isNullable = $signature->isNullable; 5278 5322 my $mayThrowException = $signature->extendedAttributes->{GetterMayThrowException} || $signature->extendedAttributes->{MayThrowException}; 5279 5323 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)"; 5321 5329 } 5322 5330 … … 5327 5335 return "toJS($stateReference, *$globalObject, $value)"; 5328 5336 } 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"); 5330 5364 } 5331 5365 -
trunk/Source/WebCore/bindings/scripts/IDLParser.pm
r207381 r207737 1284 1284 my $interface = $self->parseOperationRest($extendedAttributeList); 1285 1285 if (defined ($interface)) { 1286 $interface->signature->idlType($returnType); 1286 1287 $interface->signature->type($returnType->name); 1287 1288 $interface->signature->isNullable($returnType->isNullable); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp
r207192 r207737 25 25 #include "JSDOMBinding.h" 26 26 #include "JSDOMConstructor.h" 27 #include "JSDOMConvert.h" 27 28 #include "JSNode.h" 28 29 #include <runtime/Error.h> … … 165 166 return jsUndefined(); 166 167 auto& impl = thisObject.wrapped(); 167 JSValue result = jsNumber(impl.excitingAttr());168 JSValue result = toJS<IDLLong>(impl.excitingAttr()); 168 169 return result; 169 170 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCEReactions.cpp
r207193 r207737 27 27 #include "JSDOMBinding.h" 28 28 #include "JSDOMConstructor.h" 29 #include "JSDOMConvert.h" 29 30 #include "JSTestCEReactionsStringifier.h" 30 #include "URL.h"31 31 #include <runtime/Error.h> 32 32 #include <runtime/FunctionPrototype.h> 33 #include <runtime/JSString.h>34 33 #include <wtf/GetPtr.h> 35 34 … … 159 158 UNUSED_PARAM(state); 160 159 auto& impl = thisObject.wrapped(); 161 JSValue result = jsStringWithCache(&state, impl.attributeWithCEReactions());160 JSValue result = toJS<IDLDOMString>(state, impl.attributeWithCEReactions()); 162 161 return result; 163 162 } … … 175 174 UNUSED_PARAM(state); 176 175 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)); 178 177 return result; 179 178 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCEReactionsStringifier.cpp
r207193 r207737 26 26 #include "JSDOMBinding.h" 27 27 #include "JSDOMConstructor.h" 28 #include " URL.h"28 #include "JSDOMConvert.h" 29 29 #include <runtime/Error.h> 30 30 #include <runtime/FunctionPrototype.h> 31 #include <runtime/JSString.h>32 31 #include <wtf/GetPtr.h> 33 32 … … 151 150 UNUSED_PARAM(state); 152 151 auto& impl = thisObject.wrapped(); 153 JSValue result = jsStringWithCache(&state, impl.value());152 JSValue result = toJS<IDLDOMString>(state, impl.value()); 154 153 return result; 155 154 } … … 218 217 UNUSED_PARAM(throwScope); 219 218 auto& impl = castedThis->wrapped(); 220 JSValue result = jsStringWithCache(state, impl.value());219 JSValue result = toJS<IDLDOMString>(*state, impl.value()); 221 220 return JSValue::encode(result); 222 221 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp
r207516 r207737 26 26 27 27 #include "JSDOMConstructor.h" 28 #include "JSDOMConvert.h" 28 29 #include "JSDOMStringList.h" 29 30 #include "JSTestNode.h" 30 31 #include "ScriptExecutionContext.h" 31 32 #include "SerializedScriptValue.h" 32 #include "URL.h"33 33 #include <runtime/JSLock.h> 34 #include <runtime/JSString.h>35 34 #include <runtime/ObjectPrototype.h> 36 35 … … 148 147 MarkedArgumentBuffer args; 149 148 args.append(srzParam ? srzParam->deserialize(*state, m_data->globalObject()) : jsNull()); 150 args.append( jsStringWithCache(state, strArg));149 args.append(toJS<IDLDOMString>(*state, strArg)); 151 150 152 151 NakedPtr<JSC::Exception> returnedException; … … 188 187 ExecState* state = m_data->globalObject()->globalExec(); 189 188 MarkedArgumentBuffer args; 190 args.append( jsBoolean(boolParam));189 args.append(toJS<IDLBoolean>(boolParam)); 191 190 192 191 NakedPtr<JSC::Exception> returnedException; … … 208 207 ExecState* state = m_data->globalObject()->globalExec(); 209 208 MarkedArgumentBuffer args; 210 args.append( jsNumber(longParam));209 args.append(toJS<IDLLong>(longParam)); 211 210 args.append(toJS(state, m_data->globalObject(), testNodeParam)); 212 211 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCallbackFunction.cpp
r207516 r207737 25 25 #include "JSTestCallbackFunction.h" 26 26 27 #include "JSDOMConvert.h" 27 28 #include "JSDOMStringList.h" 28 29 #include "JSTestNode.h" 29 30 #include "ScriptExecutionContext.h" 30 31 #include "SerializedScriptValue.h" 31 #include "URL.h"32 32 #include <runtime/JSLock.h> 33 #include <runtime/JSString.h>34 33 35 34 using namespace JSC; … … 114 113 MarkedArgumentBuffer args; 115 114 args.append(srzParam ? srzParam->deserialize(*state, m_data->globalObject()) : jsNull()); 116 args.append( jsStringWithCache(state, strArg));115 args.append(toJS<IDLDOMString>(*state, strArg)); 117 116 118 117 NakedPtr<JSC::Exception> returnedException; … … 156 155 ExecState* state = m_data->globalObject()->globalExec(); 157 156 MarkedArgumentBuffer args; 158 args.append( jsBoolean(boolParam));157 args.append(toJS<IDLBoolean>(boolParam)); 159 158 160 159 NakedPtr<JSC::Exception> returnedException; … … 177 176 ExecState* state = m_data->globalObject()->globalExec(); 178 177 MarkedArgumentBuffer args; 179 args.append( jsNumber(longParam));178 args.append(toJS<IDLLong>(longParam)); 180 179 args.append(toJS(state, m_data->globalObject(), testNodeParam)); 181 180 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp
r207575 r207737 25 25 #include "JSDOMBinding.h" 26 26 #include "JSDOMConstructor.h" 27 #include "URL.h"28 27 #include <runtime/Error.h> 29 #include <runtime/JSString.h>30 28 #include <wtf/GetPtr.h> 31 29 … … 206 204 UNUSED_PARAM(state); 207 205 auto& impl = thisObject.wrapped(); 208 JSValue result = jsStringWithCache(&state, impl.attr1());206 JSValue result = toJS<IDLDOMString>(state, impl.attr1()); 209 207 return result; 210 208 } … … 222 220 UNUSED_PARAM(state); 223 221 auto& impl = thisObject.wrapped(); 224 JSValue result = jsStringWithCache(&state, impl.attr2());222 JSValue result = toJS<IDLDOMString>(state, impl.attr2()); 225 223 return result; 226 224 } … … 239 237 UNUSED_PARAM(state); 240 238 auto& impl = thisObject.wrapped(); 241 JSValue result = jsStringWithCache(&state, impl.attr3());239 JSValue result = toJS<IDLDOMString>(state, impl.attr3()); 242 240 return result; 243 241 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp
r207192 r207737 24 24 #include "JSDOMBinding.h" 25 25 #include "JSDOMConstructor.h" 26 #include " URL.h"26 #include "JSDOMConvert.h" 27 27 #include <runtime/FunctionPrototype.h> 28 #include <runtime/JSString.h>29 28 #include <wtf/GetPtr.h> 30 29 … … 150 149 UNUSED_PARAM(state); 151 150 auto& impl = thisObject.wrapped(); 152 JSValue result = jsStringWithCache(&state, impl.name());151 JSValue result = toJS<IDLDOMString>(state, impl.name()); 153 152 return result; 154 153 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGlobalObject.cpp
r207328 r207737 27 27 #include "JSDOMConvert.h" 28 28 #include "RuntimeEnabledFeatures.h" 29 #include "URL.h"30 29 #include "WebCoreJSClientData.h" 31 30 #include <runtime/Error.h> 32 31 #include <runtime/FunctionPrototype.h> 33 #include <runtime/JSString.h>34 32 #include <wtf/GetPtr.h> 35 33 … … 200 198 UNUSED_PARAM(state); 201 199 auto& impl = thisObject.wrapped(); 202 JSValue result = jsStringWithCache(&state, impl.regularAttribute());200 JSValue result = toJS<IDLDOMString>(state, impl.regularAttribute()); 203 201 return result; 204 202 } … … 216 214 UNUSED_PARAM(state); 217 215 auto& impl = thisObject.wrapped(); 218 JSValue result = jsStringWithCache(&state, impl.publicAndPrivateAttribute());216 JSValue result = toJS<IDLDOMString>(state, impl.publicAndPrivateAttribute()); 219 217 return result; 220 218 } … … 233 231 UNUSED_PARAM(state); 234 232 auto& impl = thisObject.wrapped(); 235 JSValue result = jsStringWithCache(&state, impl.publicAndPrivateConditionalAttribute());233 JSValue result = toJS<IDLDOMString>(state, impl.publicAndPrivateConditionalAttribute()); 236 234 return result; 237 235 } … … 252 250 UNUSED_PARAM(state); 253 251 auto& impl = thisObject.wrapped(); 254 JSValue result = jsStringWithCache(&state, impl.enabledAtRuntimeAttribute());252 JSValue result = toJS<IDLDOMString>(state, impl.enabledAtRuntimeAttribute()); 255 253 return result; 256 254 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
r207519 r207737 28 28 #include "JSDOMBinding.h" 29 29 #include "JSDOMConstructor.h" 30 #include "JSDOMConvert.h" 30 31 #include "TestObj.h" 31 32 #include "TestSupplemental.h" … … 41 42 #include "JSNode.h" 42 43 #include "JSTestObj.h" 43 #include "URL.h"44 #include <runtime/JSString.h>45 44 #endif 46 45 … … 422 421 { 423 422 UNUSED_PARAM(state); 424 JSValue result = jsNumber(TestInterface::implementsStaticReadOnlyAttr());423 JSValue result = toJS<IDLLong>(TestInterface::implementsStaticReadOnlyAttr()); 425 424 return result; 426 425 } … … 440 439 { 441 440 UNUSED_PARAM(state); 442 JSValue result = jsStringWithCache(&state, TestInterface::implementsStaticAttr());441 JSValue result = toJS<IDLDOMString>(state, TestInterface::implementsStaticAttr()); 443 442 return result; 444 443 } … … 459 458 UNUSED_PARAM(state); 460 459 auto& impl = thisObject.wrapped(); 461 JSValue result = jsStringWithCache(&state, impl.implementsStr1());460 JSValue result = toJS<IDLDOMString>(state, impl.implementsStr1()); 462 461 return result; 463 462 } … … 478 477 UNUSED_PARAM(state); 479 478 auto& impl = thisObject.wrapped(); 480 JSValue result = jsStringWithCache(&state, impl.implementsStr2());479 JSValue result = toJS<IDLDOMString>(state, impl.implementsStr2()); 481 480 return result; 482 481 } … … 532 531 { 533 532 UNUSED_PARAM(state); 534 JSValue result = jsNumber(WebCore::TestSupplemental::supplementalStaticReadOnlyAttr());533 JSValue result = toJS<IDLLong>(WebCore::TestSupplemental::supplementalStaticReadOnlyAttr()); 535 534 return result; 536 535 } … … 550 549 { 551 550 UNUSED_PARAM(state); 552 JSValue result = jsStringWithCache(&state, WebCore::TestSupplemental::supplementalStaticAttr());551 JSValue result = toJS<IDLDOMString>(state, WebCore::TestSupplemental::supplementalStaticAttr()); 553 552 return result; 554 553 } … … 569 568 UNUSED_PARAM(state); 570 569 auto& impl = thisObject.wrapped(); 571 JSValue result = jsStringWithCache(&state, WebCore::TestSupplemental::supplementalStr1(impl));570 JSValue result = toJS<IDLDOMString>(state, WebCore::TestSupplemental::supplementalStr1(impl)); 572 571 return result; 573 572 } … … 588 587 UNUSED_PARAM(state); 589 588 auto& impl = thisObject.wrapped(); 590 JSValue result = jsStringWithCache(&state, WebCore::TestSupplemental::supplementalStr2(impl));589 JSValue result = toJS<IDLDOMString>(state, WebCore::TestSupplemental::supplementalStr2(impl)); 591 590 return result; 592 591 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp
r207378 r207737 25 25 #include "JSDOMBinding.h" 26 26 #include "JSDOMConstructor.h" 27 #include "JSDOMConvert.h" 27 28 #include "JSDOMIterator.h" 28 29 #include "JSDOMPromise.h" 29 30 #include "RuntimeEnabledFeatures.h" 30 #include "URL.h"31 31 #include <runtime/Error.h> 32 #include <runtime/JSString.h>33 32 #include <runtime/ObjectConstructor.h> 34 33 #include <wtf/GetPtr.h> … … 190 189 UNUSED_PARAM(state); 191 190 auto& impl = thisObject.wrapped(); 192 JSValue result = jsStringWithCache(&state, impl.name());191 JSValue result = toJS<IDLDOMString>(state, impl.name()); 193 192 return result; 194 193 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNondeterministic.cpp
r207193 r207737 25 25 #include "JSDOMBinding.h" 26 26 #include "JSDOMConstructor.h" 27 #include " URL.h"27 #include "JSDOMConvert.h" 28 28 #include <runtime/Error.h> 29 29 #include <runtime/FunctionPrototype.h> 30 #include <runtime/JSString.h>31 30 #include <wtf/GetPtr.h> 32 31 … … 172 171 int32_t memoizedResult = thisObject.wrapped().nondeterministicReadonlyAttr(); 173 172 cursor.appendInput<MemoizedDOMResult<int32_t>>(bindingName.get().string(), memoizedResult, 0); 174 JSValue result = jsNumber(memoizedResult);173 JSValue result = toJS<IDLLong>(memoizedResult); 175 174 return result; 176 175 } … … 180 179 MemoizedDOMResultBase* input = cursor.fetchInput<MemoizedDOMResultBase>(); 181 180 if (input && input->convertTo<int32_t>(memoizedResult)) { 182 JSValue result = jsNumber(memoizedResult);181 JSValue result = toJS<IDLLong>(memoizedResult); 183 182 return result; 184 183 } … … 186 185 #endif 187 186 auto& impl = thisObject.wrapped(); 188 JSValue result = jsNumber(impl.nondeterministicReadonlyAttr());187 JSValue result = toJS<IDLLong>(impl.nondeterministicReadonlyAttr()); 189 188 return result; 190 189 } … … 208 207 String memoizedResult = thisObject.wrapped().nondeterministicWriteableAttr(); 209 208 cursor.appendInput<MemoizedDOMResult<String>>(bindingName.get().string(), memoizedResult, 0); 210 JSValue result = jsStringWithCache(&state, memoizedResult);209 JSValue result = toJS<IDLDOMString>(state, memoizedResult); 211 210 return result; 212 211 } … … 216 215 MemoizedDOMResultBase* input = cursor.fetchInput<MemoizedDOMResultBase>(); 217 216 if (input && input->convertTo<String>(memoizedResult)) { 218 JSValue result = jsStringWithCache(&state, memoizedResult);217 JSValue result = toJS<IDLDOMString>(state, memoizedResult); 219 218 return result; 220 219 } … … 222 221 #endif 223 222 auto& impl = thisObject.wrapped(); 224 JSValue result = jsStringWithCache(&state, impl.nondeterministicWriteableAttr());223 JSValue result = toJS<IDLDOMString>(state, impl.nondeterministicWriteableAttr()); 225 224 return result; 226 225 } … … 244 243 String memoizedResult = thisObject.wrapped().nondeterministicExceptionAttr(); 245 244 cursor.appendInput<MemoizedDOMResult<String>>(bindingName.get().string(), memoizedResult, 0); 246 JSValue result = jsStringWithCache(&state, memoizedResult);245 JSValue result = toJS<IDLDOMString>(state, memoizedResult); 247 246 return result; 248 247 } … … 252 251 MemoizedDOMResultBase* input = cursor.fetchInput<MemoizedDOMResultBase>(); 253 252 if (input && input->convertTo<String>(memoizedResult)) { 254 JSValue result = jsStringWithCache(&state, memoizedResult);253 JSValue result = toJS<IDLDOMString>(state, memoizedResult); 255 254 return result; 256 255 } … … 258 257 #endif 259 258 auto& impl = thisObject.wrapped(); 260 JSValue result = jsStringWithCache(&state, impl.nondeterministicExceptionAttr());259 JSValue result = toJS<IDLDOMString>(state, impl.nondeterministicExceptionAttr()); 261 260 return result; 262 261 } … … 281 280 String memoizedResult = thisObject.wrapped().nondeterministicGetterExceptionAttr(ec); 282 281 cursor.appendInput<MemoizedDOMResult<String>>(bindingName.get().string(), memoizedResult, ec); 283 JSValue result = jsStringWithCache(&state, memoizedResult);282 JSValue result = toJS<IDLDOMString>(state, memoizedResult); 284 283 setDOMException(&state, throwScope, ec); 285 284 return result; … … 290 289 MemoizedDOMResultBase* input = cursor.fetchInput<MemoizedDOMResultBase>(); 291 290 if (input && input->convertTo<String>(memoizedResult)) { 292 JSValue result = jsStringWithCache(&state, memoizedResult);291 JSValue result = toJS<IDLDOMString>(state, memoizedResult); 293 292 setDOMException(&state, throwScope, input->exceptionCode()); 294 293 return result; … … 297 296 #endif 298 297 auto& impl = thisObject.wrapped(); 299 JSValue result = jsStringWithCache(&state, impl.nondeterministicGetterExceptionAttr(ec));298 JSValue result = toJS<IDLDOMString>(state, impl.nondeterministicGetterExceptionAttr(ec)); 300 299 setDOMException(&state, throwScope, ec); 301 300 return result; … … 320 319 String memoizedResult = thisObject.wrapped().nondeterministicSetterExceptionAttr(); 321 320 cursor.appendInput<MemoizedDOMResult<String>>(bindingName.get().string(), memoizedResult, 0); 322 JSValue result = jsStringWithCache(&state, memoizedResult);321 JSValue result = toJS<IDLDOMString>(state, memoizedResult); 323 322 return result; 324 323 } … … 328 327 MemoizedDOMResultBase* input = cursor.fetchInput<MemoizedDOMResultBase>(); 329 328 if (input && input->convertTo<String>(memoizedResult)) { 330 JSValue result = jsStringWithCache(&state, memoizedResult);329 JSValue result = toJS<IDLDOMString>(state, memoizedResult); 331 330 return result; 332 331 } … … 334 333 #endif 335 334 auto& impl = thisObject.wrapped(); 336 JSValue result = jsStringWithCache(&state, impl.nondeterministicSetterExceptionAttr());335 JSValue result = toJS<IDLDOMString>(state, impl.nondeterministicSetterExceptionAttr()); 337 336 return result; 338 337 } … … 464 463 bool memoizedResult = impl.nondeterministicZeroArgFunction(); 465 464 cursor.appendInput<MemoizedDOMResult<bool>>(bindingName.get().string(), memoizedResult, 0); 466 result = jsBoolean(memoizedResult);465 result = toJS<IDLBoolean>(memoizedResult); 467 466 } else if (cursor.isReplaying()) { 468 467 MemoizedDOMResultBase* input = cursor.fetchInput<MemoizedDOMResultBase>(); 469 468 bool memoizedResult; 470 469 if (input && input->convertTo<bool>(memoizedResult)) { 471 result = jsBoolean(memoizedResult);470 result = toJS<IDLBoolean>(memoizedResult); 472 471 } else 473 result = jsBoolean(impl.nondeterministicZeroArgFunction());472 result = toJS<IDLBoolean>(impl.nondeterministicZeroArgFunction()); 474 473 } else 475 result = jsBoolean(impl.nondeterministicZeroArgFunction());474 result = toJS<IDLBoolean>(impl.nondeterministicZeroArgFunction()); 476 475 #else 477 result = jsBoolean(impl.nondeterministicZeroArgFunction());476 result = toJS<IDLBoolean>(impl.nondeterministicZeroArgFunction()); 478 477 #endif 479 478 return JSValue::encode(result); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r207725 r207737 94 94 namespace WebCore { 95 95 96 JSString* jsStringWithCache(ExecState*state, TestObj::EnumType enumerationValue)96 template<> JSString* convertEnumerationToJS(ExecState& state, TestObj::EnumType enumerationValue) 97 97 { 98 98 static NeverDestroyed<const String> values[] = { … … 107 107 static_assert(static_cast<size_t>(TestObj::EnumType::EnumValue3) == 3, "TestObj::EnumType::EnumValue3 is not 3 as expected"); 108 108 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)]); 110 110 } 111 111 … … 141 141 } 142 142 143 JSString* jsStringWithCache(ExecState*state, TestObj::Optional enumerationValue)143 template<> JSString* convertEnumerationToJS(ExecState& state, TestObj::Optional enumerationValue) 144 144 { 145 145 static NeverDestroyed<const String> values[] = { … … 154 154 static_assert(static_cast<size_t>(TestObj::Optional::OptionalValue3) == 3, "TestObj::Optional::OptionalValue3 is not 3 as expected"); 155 155 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)]); 157 157 } 158 158 … … 188 188 } 189 189 190 JSString* jsStringWithCache(ExecState*state, AlternateEnumName enumerationValue)190 template<> JSString* convertEnumerationToJS(ExecState& state, AlternateEnumName enumerationValue) 191 191 { 192 192 static NeverDestroyed<const String> values[] = { … … 197 197 static_assert(static_cast<size_t>(AlternateEnumName::EnumValue2) == 1, "AlternateEnumName::EnumValue2 is not 1 as expected"); 198 198 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)]); 200 200 } 201 201 … … 229 229 #if ENABLE(Condition1) 230 230 231 JSString* jsStringWithCache(ExecState*state, TestObj::EnumA enumerationValue)231 template<> JSString* convertEnumerationToJS(ExecState& state, TestObj::EnumA enumerationValue) 232 232 { 233 233 static NeverDestroyed<const String> values[] = { … … 236 236 static_assert(static_cast<size_t>(TestObj::EnumA::A) == 0, "TestObj::EnumA::A is not 0 as expected"); 237 237 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)]); 239 239 } 240 240 … … 268 268 #if ENABLE(Condition1) && ENABLE(Condition2) 269 269 270 JSString* jsStringWithCache(ExecState*state, TestObj::EnumB enumerationValue)270 template<> JSString* convertEnumerationToJS(ExecState& state, TestObj::EnumB enumerationValue) 271 271 { 272 272 static NeverDestroyed<const String> values[] = { … … 275 275 static_assert(static_cast<size_t>(TestObj::EnumB::B) == 0, "TestObj::EnumB::B is not 0 as expected"); 276 276 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)]); 278 278 } 279 279 … … 307 307 #if ENABLE(Condition1) || ENABLE(Condition2) 308 308 309 JSString* jsStringWithCache(ExecState*state, TestObj::EnumC enumerationValue)309 template<> JSString* convertEnumerationToJS(ExecState& state, TestObj::EnumC enumerationValue) 310 310 { 311 311 static NeverDestroyed<const String> values[] = { … … 314 314 static_assert(static_cast<size_t>(TestObj::EnumC::C) == 0, "TestObj::EnumC::C is not 0 as expected"); 315 315 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)]); 317 317 } 318 318 … … 344 344 #endif 345 345 346 JSString* jsStringWithCache(ExecState*state, TestObj::Kind enumerationValue)346 template<> JSString* convertEnumerationToJS(ExecState& state, TestObj::Kind enumerationValue) 347 347 { 348 348 static NeverDestroyed<const String> values[] = { … … 353 353 static_assert(static_cast<size_t>(TestObj::Kind::Dead) == 1, "TestObj::Kind::Dead is not 1 as expected"); 354 354 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)]); 356 356 } 357 357 … … 383 383 } 384 384 385 JSString* jsStringWithCache(ExecState*state, TestObj::Size enumerationValue)385 template<> JSString* convertEnumerationToJS(ExecState& state, TestObj::Size enumerationValue) 386 386 { 387 387 static NeverDestroyed<const String> values[] = { … … 392 392 static_assert(static_cast<size_t>(TestObj::Size::MuchMuchLarger) == 1, "TestObj::Size::MuchMuchLarger is not 1 as expected"); 393 393 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)]); 395 395 } 396 396 … … 422 422 } 423 423 424 JSString* jsStringWithCache(ExecState*state, TestObj::Confidence enumerationValue)424 template<> JSString* convertEnumerationToJS(ExecState& state, TestObj::Confidence enumerationValue) 425 425 { 426 426 static NeverDestroyed<const String> values[] = { … … 431 431 static_assert(static_cast<size_t>(TestObj::Confidence::KindaLow) == 1, "TestObj::Confidence::KindaLow is not 1 as expected"); 432 432 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)]); 434 434 } 435 435 … … 1748 1748 UNUSED_PARAM(state); 1749 1749 auto& impl = thisObject.wrapped(); 1750 JSValue result = jsNumber(impl.readOnlyLongAttr());1750 JSValue result = toJS<IDLLong>(impl.readOnlyLongAttr()); 1751 1751 return result; 1752 1752 } … … 1764 1764 UNUSED_PARAM(state); 1765 1765 auto& impl = thisObject.wrapped(); 1766 JSValue result = jsStringWithCache(&state, impl.readOnlyStringAttr());1766 JSValue result = toJS<IDLDOMString>(state, impl.readOnlyStringAttr()); 1767 1767 return result; 1768 1768 } … … 1795 1795 { 1796 1796 UNUSED_PARAM(state); 1797 JSValue result = jsNumber(TestObj::staticReadOnlyLongAttr());1797 JSValue result = toJS<IDLLong>(TestObj::staticReadOnlyLongAttr()); 1798 1798 return result; 1799 1799 } … … 1810 1810 { 1811 1811 UNUSED_PARAM(state); 1812 JSValue result = jsStringWithCache(&state, TestObj::staticStringAttr());1812 JSValue result = toJS<IDLDOMString>(state, TestObj::staticStringAttr()); 1813 1813 return result; 1814 1814 } … … 1859 1859 UNUSED_PARAM(state); 1860 1860 auto& impl = thisObject.wrapped(); 1861 JSValue result = jsStringWithCache(&state, impl.enumAttr());1861 JSValue result = toJS<IDLEnumeration<TestObj::EnumType>>(state, impl.enumAttr()); 1862 1862 return result; 1863 1863 } … … 1875 1875 UNUSED_PARAM(state); 1876 1876 auto& impl = thisObject.wrapped(); 1877 JSValue result = jsNumber(impl.byteAttr());1877 JSValue result = toJS<IDLByte>(impl.byteAttr()); 1878 1878 return result; 1879 1879 } … … 1891 1891 UNUSED_PARAM(state); 1892 1892 auto& impl = thisObject.wrapped(); 1893 JSValue result = jsNumber(impl.octetAttr());1893 JSValue result = toJS<IDLOctet>(impl.octetAttr()); 1894 1894 return result; 1895 1895 } … … 1907 1907 UNUSED_PARAM(state); 1908 1908 auto& impl = thisObject.wrapped(); 1909 JSValue result = jsNumber(impl.shortAttr());1909 JSValue result = toJS<IDLShort>(impl.shortAttr()); 1910 1910 return result; 1911 1911 } … … 1923 1923 UNUSED_PARAM(state); 1924 1924 auto& impl = thisObject.wrapped(); 1925 JSValue result = jsNumber(impl.clampedShortAttr());1925 JSValue result = toJS<IDLShort>(impl.clampedShortAttr()); 1926 1926 return result; 1927 1927 } … … 1939 1939 UNUSED_PARAM(state); 1940 1940 auto& impl = thisObject.wrapped(); 1941 JSValue result = jsNumber(impl.enforceRangeShortAttr());1941 JSValue result = toJS<IDLShort>(impl.enforceRangeShortAttr()); 1942 1942 return result; 1943 1943 } … … 1955 1955 UNUSED_PARAM(state); 1956 1956 auto& impl = thisObject.wrapped(); 1957 JSValue result = jsNumber(impl.unsignedShortAttr());1957 JSValue result = toJS<IDLUnsignedShort>(impl.unsignedShortAttr()); 1958 1958 return result; 1959 1959 } … … 1971 1971 UNUSED_PARAM(state); 1972 1972 auto& impl = thisObject.wrapped(); 1973 JSValue result = jsNumber(impl.longAttr());1973 JSValue result = toJS<IDLLong>(impl.longAttr()); 1974 1974 return result; 1975 1975 } … … 1987 1987 UNUSED_PARAM(state); 1988 1988 auto& impl = thisObject.wrapped(); 1989 JSValue result = jsNumber(impl.longLongAttr());1989 JSValue result = toJS<IDLLongLong>(impl.longLongAttr()); 1990 1990 return result; 1991 1991 } … … 2003 2003 UNUSED_PARAM(state); 2004 2004 auto& impl = thisObject.wrapped(); 2005 JSValue result = jsNumber(impl.unsignedLongLongAttr());2005 JSValue result = toJS<IDLUnsignedLongLong>(impl.unsignedLongLongAttr()); 2006 2006 return result; 2007 2007 } … … 2019 2019 UNUSED_PARAM(state); 2020 2020 auto& impl = thisObject.wrapped(); 2021 JSValue result = jsStringWithCache(&state, impl.stringAttr());2021 JSValue result = toJS<IDLDOMString>(state, impl.stringAttr()); 2022 2022 return result; 2023 2023 } … … 2035 2035 UNUSED_PARAM(state); 2036 2036 auto& impl = thisObject.wrapped(); 2037 JSValue result = jsStringWithCache(&state, impl.usvstringAttr());2037 JSValue result = toJS<IDLUSVString>(state, impl.usvstringAttr()); 2038 2038 return result; 2039 2039 } … … 2099 2099 UNUSED_PARAM(state); 2100 2100 auto& impl = thisObject.wrapped(); 2101 JSValue result = jsStringWithCache(&state, impl.unforgeableAttr());2101 JSValue result = toJS<IDLDOMString>(state, impl.unforgeableAttr()); 2102 2102 return result; 2103 2103 } … … 2115 2115 UNUSED_PARAM(state); 2116 2116 auto& impl = thisObject.wrapped(); 2117 JSValue result = jsStringWithCache(&state, impl.stringAttrTreatingNullAsEmptyString());2117 JSValue result = toJS<IDLDOMString>(state, impl.stringAttrTreatingNullAsEmptyString()); 2118 2118 return result; 2119 2119 } … … 2131 2131 UNUSED_PARAM(state); 2132 2132 auto& impl = thisObject.wrapped(); 2133 JSValue result = jsStringWithCache(&state, impl.usvstringAttrTreatingNullAsEmptyString());2133 JSValue result = toJS<IDLUSVString>(state, impl.usvstringAttrTreatingNullAsEmptyString()); 2134 2134 return result; 2135 2135 } … … 2147 2147 UNUSED_PARAM(state); 2148 2148 auto& impl = thisObject.wrapped(); 2149 JSValue result = jsStringWithCache(&state, impl.implementationEnumAttr());2149 JSValue result = toJS<IDLEnumeration<AlternateEnumName>>(state, impl.implementationEnumAttr()); 2150 2150 return result; 2151 2151 } … … 2179 2179 UNUSED_PARAM(state); 2180 2180 auto& impl = thisObject.wrapped(); 2181 JSValue result = jsBoolean(impl.isCreate());2181 JSValue result = toJS<IDLBoolean>(impl.isCreate()); 2182 2182 return result; 2183 2183 } … … 2195 2195 UNUSED_PARAM(state); 2196 2196 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)); 2198 2198 return result; 2199 2199 } … … 2211 2211 UNUSED_PARAM(state); 2212 2212 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)); 2214 2214 return result; 2215 2215 } … … 2227 2227 UNUSED_PARAM(state); 2228 2228 auto& impl = thisObject.wrapped(); 2229 JSValue result = jsNumber(impl.getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr));2229 JSValue result = toJS<IDLLong>(impl.getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr)); 2230 2230 return result; 2231 2231 } … … 2243 2243 UNUSED_PARAM(state); 2244 2244 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))); 2246 2246 return result; 2247 2247 } … … 2259 2259 UNUSED_PARAM(state); 2260 2260 auto& impl = thisObject.wrapped(); 2261 JSValue result = jsBoolean(impl.hasAttributeWithoutSynchronization(WebCore::HTMLNames::reflectedbooleanattrAttr));2261 JSValue result = toJS<IDLBoolean>(impl.hasAttributeWithoutSynchronization(WebCore::HTMLNames::reflectedbooleanattrAttr)); 2262 2262 return result; 2263 2263 } … … 2275 2275 UNUSED_PARAM(state); 2276 2276 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)); 2278 2278 return result; 2279 2279 } … … 2291 2291 UNUSED_PARAM(state); 2292 2292 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)); 2294 2294 return result; 2295 2295 } … … 2307 2307 UNUSED_PARAM(state); 2308 2308 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)); 2310 2310 return result; 2311 2311 } … … 2323 2323 UNUSED_PARAM(state); 2324 2324 auto& impl = thisObject.wrapped(); 2325 JSValue result = jsNumber(impl.getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr));2325 JSValue result = toJS<IDLLong>(impl.getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr)); 2326 2326 return result; 2327 2327 } … … 2339 2339 UNUSED_PARAM(state); 2340 2340 auto& impl = thisObject.wrapped(); 2341 JSValue result = jsBoolean(impl.hasAttributeWithoutSynchronization(WebCore::HTMLNames::customContentBooleanAttrAttr));2341 JSValue result = toJS<IDLBoolean>(impl.hasAttributeWithoutSynchronization(WebCore::HTMLNames::customContentBooleanAttrAttr)); 2342 2342 return result; 2343 2343 } … … 2355 2355 UNUSED_PARAM(state); 2356 2356 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)); 2358 2358 return result; 2359 2359 } … … 2372 2372 UNUSED_PARAM(state); 2373 2373 auto& impl = thisObject.wrapped(); 2374 JSValue result = jsStringWithCache(&state, impl.enabledAtRuntimeAttribute());2374 JSValue result = toJS<IDLDOMString>(state, impl.enabledAtRuntimeAttribute()); 2375 2375 return result; 2376 2376 } … … 2406 2406 UNUSED_PARAM(state); 2407 2407 auto& impl = thisObject.wrapped(); 2408 JSValue result = toJS Number(state, throwScope, impl.attributeWithGetterException());2408 JSValue result = toJS<IDLLong>(state, throwScope, impl.attributeWithGetterException()); 2409 2409 return result; 2410 2410 } … … 2423 2423 ExceptionCode ec = 0; 2424 2424 auto& impl = thisObject.wrapped(); 2425 JSValue result = jsNumber(impl.attributeWithGetterLegacyException(ec));2425 JSValue result = toJS<IDLLong>(impl.attributeWithGetterLegacyException(ec)); 2426 2426 setDOMException(&state, throwScope, ec); 2427 2427 return result; … … 2440 2440 UNUSED_PARAM(state); 2441 2441 auto& impl = thisObject.wrapped(); 2442 JSValue result = jsNumber(impl.attributeWithSetterException());2442 JSValue result = toJS<IDLLong>(impl.attributeWithSetterException()); 2443 2443 return result; 2444 2444 } … … 2456 2456 UNUSED_PARAM(state); 2457 2457 auto& impl = thisObject.wrapped(); 2458 JSValue result = jsNumber(impl.attributeWithSetterLegacyException());2458 JSValue result = toJS<IDLLong>(impl.attributeWithSetterLegacyException()); 2459 2459 return result; 2460 2460 } … … 2473 2473 ExceptionCode ec = 0; 2474 2474 auto& impl = thisObject.wrapped(); 2475 JSValue result = jsStringWithCache(&state, impl.stringAttrWithGetterException(ec));2475 JSValue result = toJS<IDLDOMString>(state, impl.stringAttrWithGetterException(ec)); 2476 2476 setDOMException(&state, throwScope, ec); 2477 2477 return result; … … 2490 2490 UNUSED_PARAM(state); 2491 2491 auto& impl = thisObject.wrapped(); 2492 JSValue result = jsStringWithCache(&state, impl.stringAttrWithSetterException());2492 JSValue result = toJS<IDLDOMString>(state, impl.stringAttrWithSetterException()); 2493 2493 return result; 2494 2494 } … … 2548 2548 UNUSED_PARAM(state); 2549 2549 auto& impl = thisObject.wrapped(); 2550 JSValue result = jsNumber(impl.withScriptStateAttribute(state));2550 JSValue result = toJS<IDLLong>(impl.withScriptStateAttribute(state)); 2551 2551 return result; 2552 2552 } … … 2564 2564 UNUSED_PARAM(state); 2565 2565 auto& impl = thisObject.wrapped(); 2566 JSValue result = jsNumber(impl.withCallWithAndSetterCallWithAttribute(state));2566 JSValue result = toJS<IDLLong>(impl.withCallWithAndSetterCallWithAttribute(state)); 2567 2567 return result; 2568 2568 } … … 2714 2714 UNUSED_PARAM(state); 2715 2715 auto& impl = thisObject.wrapped(); 2716 JSValue result = jsNumber(impl.conditionalAttr1());2716 JSValue result = toJS<IDLLong>(impl.conditionalAttr1()); 2717 2717 return result; 2718 2718 } … … 2733 2733 UNUSED_PARAM(state); 2734 2734 auto& impl = thisObject.wrapped(); 2735 JSValue result = jsNumber(impl.conditionalAttr2());2735 JSValue result = toJS<IDLLong>(impl.conditionalAttr2()); 2736 2736 return result; 2737 2737 } … … 2752 2752 UNUSED_PARAM(state); 2753 2753 auto& impl = thisObject.wrapped(); 2754 JSValue result = jsNumber(impl.conditionalAttr3());2754 JSValue result = toJS<IDLLong>(impl.conditionalAttr3()); 2755 2755 return result; 2756 2756 } … … 2823 2823 return cachedValue; 2824 2824 auto& impl = thisObject.wrapped(); 2825 JSValue result = impl.cachedAttribute1();2825 JSValue result = toJS<IDLAny>(impl.cachedAttribute1()); 2826 2826 thisObject.m_cachedAttribute1.set(state.vm(), &thisObject, result); 2827 2827 return result; … … 2842 2842 return cachedValue; 2843 2843 auto& impl = thisObject.wrapped(); 2844 JSValue result = impl.cachedAttribute2();2844 JSValue result = toJS<IDLAny>(impl.cachedAttribute2()); 2845 2845 thisObject.m_cachedAttribute2.set(state.vm(), &thisObject, result); 2846 2846 return result; … … 2859 2859 UNUSED_PARAM(state); 2860 2860 auto& impl = thisObject.wrapped(); 2861 JSValue result = impl.anyAttribute();2861 JSValue result = toJS<IDLAny>(impl.anyAttribute()); 2862 2862 return result; 2863 2863 } … … 2922 2922 UNUSED_PARAM(state); 2923 2923 auto& impl = thisObject.wrapped(); 2924 JSValue result = jsNumber(impl.blueberry());2924 JSValue result = toJS<IDLLong>(impl.blueberry()); 2925 2925 return result; 2926 2926 } … … 2938 2938 UNUSED_PARAM(state); 2939 2939 auto& impl = thisObject.wrapped(); 2940 JSValue result = jsNumber(impl.description());2940 JSValue result = toJS<IDLLong>(impl.description()); 2941 2941 return result; 2942 2942 } … … 2954 2954 UNUSED_PARAM(state); 2955 2955 auto& impl = thisObject.wrapped(); 2956 JSValue result = jsNumber(impl.id());2956 JSValue result = toJS<IDLLong>(impl.id()); 2957 2957 return result; 2958 2958 } … … 2970 2970 UNUSED_PARAM(state); 2971 2971 auto& impl = thisObject.wrapped(); 2972 JSValue result = jsStringWithCache(&state, impl.hash());2972 JSValue result = toJS<IDLDOMString>(state, impl.hash()); 2973 2973 return result; 2974 2974 } … … 2986 2986 UNUSED_PARAM(state); 2987 2987 auto& impl = thisObject.wrapped(); 2988 JSValue result = jsNumber(impl.replaceableAttribute());2988 JSValue result = toJS<IDLLong>(impl.replaceableAttribute()); 2989 2989 return result; 2990 2990 } … … 3002 3002 UNUSED_PARAM(state); 3003 3003 auto& impl = thisObject.wrapped(); 3004 JSValue result = to NullableJSNumber(impl.nullableDoubleAttribute());3004 JSValue result = toJS<IDLNullable<IDLUnrestrictedDouble>>(impl.nullableDoubleAttribute()); 3005 3005 return result; 3006 3006 } … … 3018 3018 UNUSED_PARAM(state); 3019 3019 auto& impl = thisObject.wrapped(); 3020 JSValue result = to NullableJSNumber(impl.nullableLongAttribute());3020 JSValue result = toJS<IDLNullable<IDLLong>>(impl.nullableLongAttribute()); 3021 3021 return result; 3022 3022 } … … 3034 3034 UNUSED_PARAM(state); 3035 3035 auto& impl = thisObject.wrapped(); 3036 JSValue result = jsBoolean(impl.nullableBooleanAttribute());3036 JSValue result = toJS<IDLNullable<IDLBoolean>>(impl.nullableBooleanAttribute()); 3037 3037 return result; 3038 3038 } … … 3066 3066 UNUSED_PARAM(state); 3067 3067 auto& impl = thisObject.wrapped(); 3068 JSValue result = to NullableJSNumber(impl.nullableLongSettableAttribute());3068 JSValue result = toJS<IDLNullable<IDLLong>>(impl.nullableLongSettableAttribute()); 3069 3069 return result; 3070 3070 } … … 3115 3115 ExceptionCode ec = 0; 3116 3116 auto& impl = thisObject.wrapped(); 3117 JSValue result = to NullableJSNumber(impl.nullableStringValue(ec));3117 JSValue result = toJS<IDLNullable<IDLLong>>(impl.nullableStringValue(ec)); 3118 3118 setDOMException(&state, throwScope, ec); 3119 3119 return result; … … 3132 3132 UNUSED_PARAM(state); 3133 3133 auto& impl = thisObject.wrapped(); 3134 JSValue result = jsStringWithCache(&state, impl.attribute());3134 JSValue result = toJS<IDLDOMString>(state, impl.attribute()); 3135 3135 return result; 3136 3136 } … … 3148 3148 UNUSED_PARAM(state); 3149 3149 auto& impl = thisObject.wrapped(); 3150 JSValue result = jsStringWithCache(&state, impl.attributeWithReservedEnumType());3150 JSValue result = toJS<IDLEnumeration<TestObj::Optional>>(state, impl.attributeWithReservedEnumType()); 3151 3151 return result; 3152 3152 } … … 3212 3212 UNUSED_PARAM(state); 3213 3213 auto& impl = thisObject.wrapped(); 3214 JSValue result = jsStringWithCache(&state, impl.stringifierAttribute());3214 JSValue result = toJS<IDLUSVString>(state, impl.stringifierAttribute()); 3215 3215 return result; 3216 3216 } … … 4826 4826 UNUSED_PARAM(throwScope); 4827 4827 auto& impl = castedThis->wrapped(); 4828 JSValue result = jsNumber(impl.byteMethod());4828 JSValue result = toJS<IDLByte>(impl.byteMethod()); 4829 4829 return JSValue::encode(result); 4830 4830 } … … 4851 4851 if (UNLIKELY(!objArg)) 4852 4852 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)); 4854 4854 return JSValue::encode(result); 4855 4855 } … … 4867 4867 UNUSED_PARAM(throwScope); 4868 4868 auto& impl = castedThis->wrapped(); 4869 JSValue result = jsNumber(impl.octetMethod());4869 JSValue result = toJS<IDLOctet>(impl.octetMethod()); 4870 4870 return JSValue::encode(result); 4871 4871 } … … 4892 4892 if (UNLIKELY(!objArg)) 4893 4893 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)); 4895 4895 return JSValue::encode(result); 4896 4896 } … … 4908 4908 UNUSED_PARAM(throwScope); 4909 4909 auto& impl = castedThis->wrapped(); 4910 JSValue result = jsNumber(impl.longMethod());4910 JSValue result = toJS<IDLLong>(impl.longMethod()); 4911 4911 return JSValue::encode(result); 4912 4912 } … … 4933 4933 if (UNLIKELY(!objArg)) 4934 4934 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)); 4936 4936 return JSValue::encode(result); 4937 4937 } … … 4990 4990 UNUSED_PARAM(throwScope); 4991 4991 auto& impl = castedThis->wrapped(); 4992 JSValue result = jsNumber(impl.unforgeableMethod());4992 JSValue result = toJS<IDLLong>(impl.unforgeableMethod()); 4993 4993 return JSValue::encode(result); 4994 4994 } … … 5311 5311 UNUSED_PARAM(throwScope); 5312 5312 auto& impl = castedThis->wrapped(); 5313 JSValue result = toJS Number(*state, throwScope, impl.methodWithExceptionReturningLong());5313 JSValue result = toJS<IDLLong>(*state, throwScope, impl.methodWithExceptionReturningLong()); 5314 5314 return JSValue::encode(result); 5315 5315 } … … 5393 5393 auto argument = state->uncheckedArgument(0).toWTFString(state); 5394 5394 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 5395 JSValue result = jsStringWithCache(state, impl.privateMethod(WTFMove(argument)));5395 JSValue result = toJS<IDLDOMString>(*state, impl.privateMethod(WTFMove(argument))); 5396 5396 return JSValue::encode(result); 5397 5397 } … … 5413 5413 auto argument = state->uncheckedArgument(0).toWTFString(state); 5414 5414 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 5415 JSValue result = jsStringWithCache(state, impl.publicAndPrivateMethod(WTFMove(argument)));5415 JSValue result = toJS<IDLDOMString>(*state, impl.publicAndPrivateMethod(WTFMove(argument))); 5416 5416 return JSValue::encode(result); 5417 5417 } … … 6411 6411 UNUSED_PARAM(throwScope); 6412 6412 auto& impl = castedThis->wrapped(); 6413 JSValue result = jsStringWithCache(state, impl.conditionalMethod1());6413 JSValue result = toJS<IDLDOMString>(*state, impl.conditionalMethod1()); 6414 6414 return JSValue::encode(result); 6415 6415 } … … 7244 7244 auto arg = state->argument(0).isUndefined() ? Optional<int32_t>() : convert<IDLLong>(*state, state->uncheckedArgument(0), NormalConversion); 7245 7245 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 7246 JSValue result = jsNumber(TestObj::classMethodWithOptional(WTFMove(arg)));7246 JSValue result = toJS<IDLLong>(TestObj::classMethodWithOptional(WTFMove(arg))); 7247 7247 return JSValue::encode(result); 7248 7248 } … … 7389 7389 auto values = convert<IDLSequence<IDLDOMString>>(*state, state->uncheckedArgument(0)); 7390 7390 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)); 7392 7392 7393 7393 setDOMException(state, throwScope, ec); … … 8153 8153 UNUSED_PARAM(throwScope); 8154 8154 auto& impl = castedThis->wrapped(); 8155 JSValue result = jsStringWithCache(state, impl.stringifierAttribute());8155 JSValue result = toJS<IDLUSVString>(*state, impl.stringifierAttribute()); 8156 8156 return JSValue::encode(result); 8157 8157 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h
r207715 r207737 107 107 using ToWrappedReturnType = TestObj*; 108 108 }; 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 }; 109 template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, TestObj::EnumType); 114 110 115 111 template<> Optional<TestObj::EnumType> parseEnumeration<TestObj::EnumType>(JSC::ExecState&, JSC::JSValue); … … 117 113 template<> const char* expectedEnumerationValues<TestObj::EnumType>(); 118 114 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 }; 115 template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, TestObj::Optional); 124 116 125 117 template<> Optional<TestObj::Optional> parseEnumeration<TestObj::Optional>(JSC::ExecState&, JSC::JSValue); … … 127 119 template<> const char* expectedEnumerationValues<TestObj::Optional>(); 128 120 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 }; 121 template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, AlternateEnumName); 134 122 135 123 template<> Optional<AlternateEnumName> parseEnumeration<AlternateEnumName>(JSC::ExecState&, JSC::JSValue); … … 139 127 #if ENABLE(Condition1) 140 128 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 }; 129 template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, TestObj::EnumA); 146 130 147 131 template<> Optional<TestObj::EnumA> parseEnumeration<TestObj::EnumA>(JSC::ExecState&, JSC::JSValue); … … 153 137 #if ENABLE(Condition1) && ENABLE(Condition2) 154 138 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 }; 139 template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, TestObj::EnumB); 160 140 161 141 template<> Optional<TestObj::EnumB> parseEnumeration<TestObj::EnumB>(JSC::ExecState&, JSC::JSValue); … … 167 147 #if ENABLE(Condition1) || ENABLE(Condition2) 168 148 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 }; 149 template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, TestObj::EnumC); 174 150 175 151 template<> Optional<TestObj::EnumC> parseEnumeration<TestObj::EnumC>(JSC::ExecState&, JSC::JSValue); … … 179 155 #endif 180 156 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 }; 157 template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, TestObj::Kind); 186 158 187 159 template<> Optional<TestObj::Kind> parseEnumeration<TestObj::Kind>(JSC::ExecState&, JSC::JSValue); … … 189 161 template<> const char* expectedEnumerationValues<TestObj::Kind>(); 190 162 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 }; 163 template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, TestObj::Size); 196 164 197 165 template<> Optional<TestObj::Size> parseEnumeration<TestObj::Size>(JSC::ExecState&, JSC::JSValue); … … 199 167 template<> const char* expectedEnumerationValues<TestObj::Size>(); 200 168 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 }; 169 template<> JSC::JSString* convertEnumerationToJS(JSC::ExecState&, TestObj::Confidence); 206 170 207 171 template<> Optional<TestObj::Confidence> parseEnumeration<TestObj::Confidence>(JSC::ExecState&, JSC::JSValue); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerialization.cpp
r207378 r207737 26 26 #include "JSDOMConvert.h" 27 27 #include "JSTestNode.h" 28 #include "URL.h"29 28 #include <runtime/FunctionPrototype.h> 30 #include <runtime/JSString.h>31 29 #include <runtime/ObjectConstructor.h> 32 30 #include <wtf/GetPtr.h> … … 163 161 UNUSED_PARAM(state); 164 162 auto& impl = thisObject.wrapped(); 165 JSValue result = jsStringWithCache(&state, impl.firstStringAttribute());163 JSValue result = toJS<IDLDOMString>(state, impl.firstStringAttribute()); 166 164 return result; 167 165 } … … 179 177 UNUSED_PARAM(state); 180 178 auto& impl = thisObject.wrapped(); 181 JSValue result = jsNumber(impl.secondLongAttribute());179 JSValue result = toJS<IDLLong>(impl.secondLongAttribute()); 182 180 return result; 183 181 } … … 211 209 UNUSED_PARAM(state); 212 210 auto& impl = thisObject.wrapped(); 213 JSValue result = jsNumber(impl.fourthUnrestrictedDoubleAttribute());211 JSValue result = toJS<IDLUnrestrictedDouble>(impl.fourthUnrestrictedDoubleAttribute()); 214 212 return result; 215 213 } … … 227 225 UNUSED_PARAM(state); 228 226 auto& impl = thisObject.wrapped(); 229 JSValue result = jsNumber(impl.fifthLongAttribute());227 JSValue result = toJS<IDLLong>(impl.fifthLongAttribute()); 230 228 return result; 231 229 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp
r207516 r207737 27 27 #include "JSDOMBinding.h" 28 28 #include "JSDOMConstructor.h" 29 #include "JSDOMConvert.h" 29 30 #include "JSMessagePort.h" 30 31 #include "SerializedScriptValue.h" … … 201 202 UNUSED_PARAM(state); 202 203 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()); 204 205 return result; 205 206 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
r207519 r207737 32 32 #include "SVGPoint.h" 33 33 #include "SerializedScriptValue.h" 34 #include "URL.h"35 34 #include <runtime/Error.h> 36 35 #include <runtime/FunctionPrototype.h> 37 36 #include <runtime/JSArray.h> 38 #include <runtime/JSString.h>39 37 #include <wtf/GetPtr.h> 40 38 #include <wtf/Variant.h> … … 239 237 UNUSED_PARAM(state); 240 238 auto& impl = thisObject.wrapped(); 241 JSValue result = jsNumber(impl.unsignedLongLongAttr());239 JSValue result = toJS<IDLUnsignedLongLong>(impl.unsignedLongLongAttr()); 242 240 return result; 243 241 } … … 286 284 ExceptionCode ec = 0; 287 285 auto& impl = thisObject.wrapped(); 288 JSValue result = jsNumber(impl.attrWithGetterException(ec));286 JSValue result = toJS<IDLLong>(impl.attrWithGetterException(ec)); 289 287 setDOMException(&state, throwScope, ec); 290 288 return result; … … 303 301 UNUSED_PARAM(state); 304 302 auto& impl = thisObject.wrapped(); 305 JSValue result = jsNumber(impl.attrWithSetterException());303 JSValue result = toJS<IDLLong>(impl.attrWithSetterException()); 306 304 return result; 307 305 } … … 320 318 ExceptionCode ec = 0; 321 319 auto& impl = thisObject.wrapped(); 322 JSValue result = jsStringWithCache(&state, impl.stringAttrWithGetterException(ec));320 JSValue result = toJS<IDLDOMString>(state, impl.stringAttrWithGetterException(ec)); 323 321 setDOMException(&state, throwScope, ec); 324 322 return result; … … 337 335 UNUSED_PARAM(state); 338 336 auto& impl = thisObject.wrapped(); 339 JSValue result = jsStringWithCache(&state, impl.stringAttrWithSetterException());337 JSValue result = toJS<IDLDOMString>(state, impl.stringAttrWithSetterException()); 340 338 return result; 341 339 } … … 550 548 auto sequenceArg = convert<IDLSequence<IDLInterface<SerializedScriptValue>>>(*state, state->uncheckedArgument(0)); 551 549 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 552 JSValue result = jsNumber(impl.methodWithSequenceArg(WTFMove(sequenceArg)));550 JSValue result = toJS<IDLUnsignedLongLong>(impl.methodWithSequenceArg(WTFMove(sequenceArg))); 553 551 return JSValue::encode(result); 554 552 } … … 689 687 auto values = convert<IDLSequence<IDLDOMString>>(*state, state->uncheckedArgument(0)); 690 688 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)); 692 690 693 691 setDOMException(state, throwScope, ec); … … 712 710 auto values = convert<IDLSequence<IDLDOMString>>(*state, state->uncheckedArgument(0)); 713 711 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)); 715 713 716 714 setDOMException(state, throwScope, ec); … … 734 732 auto sequenceArg = convert<IDLSequence<IDLInterface<TestEventTarget>>>(*state, state->uncheckedArgument(0)); 735 733 RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); 736 JSValue result = jsBoolean(impl.callWithSequenceThatRequiresInclude(WTFMove(sequenceArg)));734 JSValue result = toJS<IDLBoolean>(impl.callWithSequenceThatRequiresInclude(WTFMove(sequenceArg))); 737 735 return JSValue::encode(result); 738 736 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSattribute.cpp
r207192 r207737 24 24 #include "JSDOMBinding.h" 25 25 #include "JSDOMConstructor.h" 26 #include " URL.h"26 #include "JSDOMConvert.h" 27 27 #include <runtime/FunctionPrototype.h> 28 #include <runtime/JSString.h>29 28 #include <wtf/GetPtr.h> 30 29 … … 150 149 UNUSED_PARAM(state); 151 150 auto& impl = thisObject.wrapped(); 152 JSValue result = jsStringWithCache(&state, impl.readonly());151 JSValue result = toJS<IDLDOMString>(state, impl.readonly()); 153 152 return result; 154 153 } -
trunk/Source/WebCore/dom/Event.idl
r207515 r207737 18 18 * Boston, MA 02110-1301, USA. 19 19 */ 20 21 // FIXME: This should be an implementation provided typedef 22 // https://heycam.github.io/webidl/#DOMTimeStamp 23 typedef unsigned long long DOMTimeStamp; 20 24 21 25 [ -
trunk/Source/WebCore/testing/TypeConversions.h
r207627 r207737 51 51 }; 52 52 53 using DictionaryUnion = Variant<RefPtr<Node>, Vector<String>, OtherDictionary>; 54 53 55 struct Dictionary { 54 56 int longValue; 55 57 String stringValue; 56 58 Vector<String> sequenceValue; 57 Variant<RefPtr<Node>, Vector<String>, OtherDictionary>unionValue;59 DictionaryUnion unionValue; 58 60 }; 59 61 … … 99 101 void setTestUSVString(const String& usvstring) { m_usvstring = usvstring; } 100 102 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 101 107 void setTypeConversionsDictionary(Dictionary& dictionary) 102 108 { … … 109 115 int typeConversionsDictionaryLongValue() { return m_typeConversionsDictionaryLongValue; } 110 116 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; } 112 119 UnionType typeConversionsDictionaryUnionType() 113 120 { … … 134 141 String m_string; 135 142 String m_usvstring; 143 TestUnion m_union; 136 144 137 145 int m_typeConversionsDictionaryLongValue { 0 }; 138 146 String m_typeConversionsDictionaryStringValue; 139 147 Vector<String> m_typeConversionsDictionarySequenceValue; 140 Variant<RefPtr<Node>, Vector<String>, OtherDictionary>m_typeConversionsDictionaryUnionValue;148 DictionaryUnion m_typeConversionsDictionaryUnionValue; 141 149 }; 142 150 -
trunk/Source/WebCore/testing/TypeConversions.idl
r207575 r207737 53 53 attribute DOMString testString; 54 54 attribute USVString testUSVString; 55 56 attribute (DOMString or long or boolean or Node or sequence<long>) testUnion; 55 57 56 58 void setTypeConversionsDictionary(TypeConversionsDictionary d); … … 58 60 readonly attribute DOMString typeConversionsDictionaryStringValue; 59 61 readonly attribute sequence<DOMString> typeConversionsDictionarySequenceValue; 60 readonly attribute UnionType typeConversionsDictionaryUnionType; 62 readonly attribute UnionType typeConversionsDictionaryUnionType; 61 63 }; 62 64
Note: See TracChangeset
for help on using the changeset viewer.