Title: [222480] trunk/Source/WebCore
Revision
222480
Author
[email protected]
Date
2017-09-25 16:27:02 -0700 (Mon, 25 Sep 2017)

Log Message

[WebIDL] Factor out IsExceptionOr check from toJS/toJSNewlyCreated signature
https://bugs.webkit.org/show_bug.cgi?id=177457

Patch by Sam Weinig <[email protected]> on 2017-09-25
Reviewed by Youenn Fablet.

Add new type, IsExceptionOr, that factors out the previously repeated logic of determining
if a type is an ExceptionOr template type.

* bindings/js/JSDOMConvertBase.h:
(WebCore::toJS):
(WebCore::toJSNewlyCreated):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (222479 => 222480)


--- trunk/Source/WebCore/ChangeLog	2017-09-25 23:24:37 UTC (rev 222479)
+++ trunk/Source/WebCore/ChangeLog	2017-09-25 23:27:02 UTC (rev 222480)
@@ -1,3 +1,17 @@
+2017-09-25  Sam Weinig  <[email protected]>
+
+        [WebIDL] Factor out IsExceptionOr check from toJS/toJSNewlyCreated signature
+        https://bugs.webkit.org/show_bug.cgi?id=177457
+
+        Reviewed by Youenn Fablet.
+
+        Add new type, IsExceptionOr, that factors out the previously repeated logic of determining
+        if a type is an ExceptionOr template type.
+
+        * bindings/js/JSDOMConvertBase.h:
+        (WebCore::toJS):
+        (WebCore::toJSNewlyCreated):
+
 2017-09-25  Basuke Suzuki  <[email protected]>
 
         [Curl] Refactor and improve methods in the CurlHandle

Modified: trunk/Source/WebCore/bindings/js/JSDOMConvertBase.h (222479 => 222480)


--- trunk/Source/WebCore/bindings/js/JSDOMConvertBase.h	2017-09-25 23:24:37 UTC (rev 222479)
+++ trunk/Source/WebCore/bindings/js/JSDOMConvertBase.h	2017-09-25 23:27:02 UTC (rev 222480)
@@ -86,6 +86,11 @@
     return Converter<T>::convert(state, value, globalObject, std::forward<ExceptionThrower>(exceptionThrower));
 }
 
+
+template <typename T>
+struct IsExceptionOr : public std::integral_constant<bool, WTF::IsTemplate<std::decay_t<T>, ExceptionOr>::value> { };
+
+
 // Conversion from Implementation -> JSValue
 template<typename T> struct JSConverter;
 
@@ -93,12 +98,12 @@
 template<typename T, typename U> inline JSC::JSValue toJS(JSC::ExecState&, U&&);
 template<typename T, typename U> inline JSC::JSValue toJS(JSC::ExecState&, JSDOMGlobalObject&, U&&);
 template<typename T, typename U> inline JSC::JSValue toJSNewlyCreated(JSC::ExecState&, JSDOMGlobalObject&, U&&);
-template<typename T, typename U> inline auto toJS(JSC::ExecState&, JSC::ThrowScope&, U&&) -> std::enable_if_t<WTF::IsTemplate<std::decay_t<U>, ExceptionOr>::value, JSC::JSValue>;
-template<typename T, typename U> inline auto toJS(JSC::ExecState&, JSC::ThrowScope&, U&&) -> std::enable_if_t<!WTF::IsTemplate<std::decay_t<U>, ExceptionOr>::value, JSC::JSValue>;
-template<typename T, typename U> inline auto toJS(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, U&&) -> std::enable_if_t<WTF::IsTemplate<std::decay_t<U>, ExceptionOr>::value, JSC::JSValue>;
-template<typename T, typename U> inline auto toJS(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, U&&) -> std::enable_if_t<!WTF::IsTemplate<std::decay_t<U>, ExceptionOr>::value, JSC::JSValue>;
-template<typename T, typename U> inline auto toJSNewlyCreated(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, U&&) -> std::enable_if_t<WTF::IsTemplate<std::decay_t<U>, ExceptionOr>::value, JSC::JSValue>;
-template<typename T, typename U> inline auto toJSNewlyCreated(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, U&&) -> std::enable_if_t<!WTF::IsTemplate<std::decay_t<U>, ExceptionOr>::value, JSC::JSValue>;
+template<typename T, typename U> inline auto toJS(JSC::ExecState&, JSC::ThrowScope&, U&&) -> std::enable_if_t<IsExceptionOr<U>::value, JSC::JSValue>;
+template<typename T, typename U> inline auto toJS(JSC::ExecState&, JSC::ThrowScope&, U&&) -> std::enable_if_t<!IsExceptionOr<U>::value, JSC::JSValue>;
+template<typename T, typename U> inline auto toJS(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, U&&) -> std::enable_if_t<IsExceptionOr<U>::value, JSC::JSValue>;
+template<typename T, typename U> inline auto toJS(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, U&&) -> std::enable_if_t<!IsExceptionOr<U>::value, JSC::JSValue>;
+template<typename T, typename U> inline auto toJSNewlyCreated(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, U&&) -> std::enable_if_t<IsExceptionOr<U>::value, JSC::JSValue>;
+template<typename T, typename U> inline auto toJSNewlyCreated(JSC::ExecState&, JSDOMGlobalObject&, JSC::ThrowScope&, U&&) -> std::enable_if_t<!IsExceptionOr<U>::value, JSC::JSValue>;
 
 template<typename T, bool needsState = JSConverter<T>::needsState, bool needsGlobalObject = JSConverter<T>::needsGlobalObject>
 struct JSConverterOverloader;
@@ -157,7 +162,7 @@
     return JSConverter<T>::convertNewlyCreated(state, globalObject, std::forward<U>(value));
 }
 
-template<typename T, typename U> inline auto toJS(JSC::ExecState& state, JSC::ThrowScope& throwScope, U&& value) -> std::enable_if_t<WTF::IsTemplate<std::decay_t<U>, ExceptionOr>::value, JSC::JSValue>
+template<typename T, typename U> inline auto toJS(JSC::ExecState& state, JSC::ThrowScope& throwScope, U&& value) -> std::enable_if_t<IsExceptionOr<U>::value, JSC::JSValue>
 {
     if (UNLIKELY(value.hasException())) {
         propagateException(state, throwScope, value.releaseException());
@@ -167,12 +172,12 @@
     return toJS<T>(state, value.releaseReturnValue());
 }
 
-template<typename T, typename U> inline auto toJS(JSC::ExecState& state, JSC::ThrowScope&, U&& value) -> std::enable_if_t<!WTF::IsTemplate<std::decay_t<U>, ExceptionOr>::value, JSC::JSValue>
+template<typename T, typename U> inline auto toJS(JSC::ExecState& state, JSC::ThrowScope&, U&& value) -> std::enable_if_t<!IsExceptionOr<U>::value, JSC::JSValue>
 {
     return toJS<T>(state, std::forward<U>(value));
 }
 
-template<typename T, typename U> inline auto toJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope& throwScope, U&& value) -> std::enable_if_t<WTF::IsTemplate<std::decay_t<U>, ExceptionOr>::value, JSC::JSValue>
+template<typename T, typename U> inline auto toJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope& throwScope, U&& value) -> std::enable_if_t<IsExceptionOr<U>::value, JSC::JSValue>
 {
     if (UNLIKELY(value.hasException())) {
         propagateException(state, throwScope, value.releaseException());
@@ -182,12 +187,12 @@
     return toJS<T>(state, globalObject, value.releaseReturnValue());
 }
 
-template<typename T, typename U> inline auto toJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope&, U&& value) -> std::enable_if_t<!WTF::IsTemplate<std::decay_t<U>, ExceptionOr>::value, JSC::JSValue>
+template<typename T, typename U> inline auto toJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope&, U&& value) -> std::enable_if_t<!IsExceptionOr<U>::value, JSC::JSValue>
 {
     return toJS<T>(state, globalObject, std::forward<U>(value));
 }
 
-template<typename T, typename U> inline auto toJSNewlyCreated(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope& throwScope, U&& value) -> std::enable_if_t<WTF::IsTemplate<std::decay_t<U>, ExceptionOr>::value, JSC::JSValue>
+template<typename T, typename U> inline auto toJSNewlyCreated(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope& throwScope, U&& value) -> std::enable_if_t<IsExceptionOr<U>::value, JSC::JSValue>
 {
     if (UNLIKELY(value.hasException())) {
         propagateException(state, throwScope, value.releaseException());
@@ -197,7 +202,7 @@
     return toJSNewlyCreated<T>(state, globalObject, value.releaseReturnValue());
 }
 
-template<typename T, typename U> inline auto toJSNewlyCreated(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope&, U&& value) -> std::enable_if_t<!WTF::IsTemplate<std::decay_t<U>, ExceptionOr>::value, JSC::JSValue>
+template<typename T, typename U> inline auto toJSNewlyCreated(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSC::ThrowScope&, U&& value) -> std::enable_if_t<!IsExceptionOr<U>::value, JSC::JSValue>
 {
     return toJSNewlyCreated<T>(state, globalObject, std::forward<U>(value));
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to