Changeset 243486 in webkit
- Timestamp:
- Mar 25, 2019, 10:53:57 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/wtf/Expected.h (modified) (3 diffs)
-
Source/WTF/wtf/Unexpected.h (modified) (2 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/contentextensions/ContentExtensionParser.cpp (modified) (2 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WTF/Expected.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r243429 r243486 1 2019-03-25 Alex Christensen <achristensen@webkit.org> 2 3 Expected shouldn't assume its contained types are copyable 4 https://bugs.webkit.org/show_bug.cgi?id=195986 5 6 Reviewed by JF Bastien. 7 8 * wtf/Expected.h: 9 (std::experimental::fundamentals_v3::__expected_detail::constexpr_base::constexpr_base): 10 (std::experimental::fundamentals_v3::operator==): 11 (std::experimental::fundamentals_v3::operator!=): 12 * wtf/Unexpected.h: 13 (std::experimental::fundamentals_v3::unexpected::unexpected): 14 1 15 2019-03-24 Keith Miller <keith_miller@apple.com> 2 16 -
trunk/Source/WTF/wtf/Expected.h
r242778 r243486 250 250 constexpr constexpr_storage(value_tag_t) : val() { } 251 251 constexpr constexpr_storage(error_tag_t) : err() { } 252 constexpr constexpr_storage(value_tag_t, const value_type& v) : val(v) { } 253 constexpr constexpr_storage(error_tag_t, const error_type& e) : err(e) { } 252 template<typename U = T> 253 constexpr constexpr_storage(value_tag_t, U&& v) : val(std::forward<U>(v)) { } 254 template<typename U = E> 255 constexpr constexpr_storage(error_tag_t, U&& e) : err(std::forward<U>(e)) { } 254 256 ~constexpr_storage() = default; 255 257 }; … … 312 314 constexpr constexpr_base(value_tag_t tag) : s(tag), has(true) { } 313 315 constexpr constexpr_base(error_tag_t tag) : s(tag), has(false) { } 314 constexpr constexpr_base(value_tag_t tag, const value_type& val) : s(tag, val), has(true) { } 315 constexpr constexpr_base(error_tag_t tag, const error_type& err) : s(tag, err), has(false) { } 316 template<typename U = T> 317 constexpr constexpr_base(value_tag_t tag, U&& val) : s(tag, std::forward<U>(val)), has(true) { } 318 template<typename U = E> 319 constexpr constexpr_base(error_tag_t tag, U&& err) : s(tag, std::forward<U>(err)), has(false) { } 316 320 ~constexpr_base() = default; 317 321 }; … … 559 563 template<class E> constexpr bool operator==(const expected<void, E>& x, const expected<void, E>& y) { return bool(x) == bool(y) && (x ? true : x.error() == y.error()); } 560 564 561 template<class T, class E> constexpr bool operator==(const expected<T, E>& x, const T& y) { return x == expected<T, E>(y); }562 template<class T, class E> constexpr bool operator==(const T& x, const expected<T, E>& y) { return expected<T, E>(x) == y; }563 template<class T, class E> constexpr bool operator!=(const expected<T, E>& x, const T& y) { return x != expected<T, E>(y); }564 template<class T, class E> constexpr bool operator!=(const T& x, const expected<T, E>& y) { return expected<T, E>(x) != y; }565 566 template<class T, class E> constexpr bool operator==(const expected<T, E>& x, const unexpected<E>& y) { return x == expected<T, E>(y); }567 template<class T, class E> constexpr bool operator==(const unexpected<E>& x, const expected<T, E>& y) { return expected<T, E>(x) == y; }568 template<class T, class E> constexpr bool operator!=(const expected<T, E>& x, const unexpected<E>& y) { return x != expected<T, E>(y); }569 template<class T, class E> constexpr bool operator!=(const unexpected<E>& x, const expected<T, E>& y) { return expected<T, E>(x) != y; }565 template<class T, class E> constexpr bool operator==(const expected<T, E>& x, const T& y) { return x ? *x == y : false; } 566 template<class T, class E> constexpr bool operator==(const T& x, const expected<T, E>& y) { return y ? x == *y : false; } 567 template<class T, class E> constexpr bool operator!=(const expected<T, E>& x, const T& y) { return x ? *x != y : true; } 568 template<class T, class E> constexpr bool operator!=(const T& x, const expected<T, E>& y) { return y ? x != *y : true; } 569 570 template<class T, class E> constexpr bool operator==(const expected<T, E>& x, const unexpected<E>& y) { return x ? false : x.error() == y.value(); } 571 template<class T, class E> constexpr bool operator==(const unexpected<E>& x, const expected<T, E>& y) { return y ? false : x.value() == y.error(); } 572 template<class T, class E> constexpr bool operator!=(const expected<T, E>& x, const unexpected<E>& y) { return x ? true : x.error() != y.value(); } 573 template<class T, class E> constexpr bool operator!=(const unexpected<E>& x, const expected<T, E>& y) { return y ? true : x.value() != y.error(); } 570 574 571 575 template<typename T, typename E> void swap(expected<T, E>& x, expected<T, E>& y) { x.swap(y); } -
trunk/Source/WTF/wtf/Unexpected.h
r225728 r243486 50 50 public: 51 51 unexpected() = delete; 52 constexpr explicit unexpected(const E&);53 constexpr explicit unexpected(E&&);52 template <class U = E> 53 constexpr explicit unexpected(E&&); 54 54 constexpr const E& value() const &; 55 55 constexpr E& value() &; … … 76 76 public: 77 77 unexpected() = delete; 78 constexpr explicit unexpected(const E& e) : val(e) { }79 constexpr explicit unexpected( E&& e) : val(std::forward<E>(e)) { }78 template <class U = E> 79 constexpr explicit unexpected(U&& u) : val(std::forward<U>(u)) { } 80 80 constexpr const E& value() const & { return val; } 81 81 constexpr E& value() & { return val; } -
trunk/Source/WebCore/ChangeLog
r243483 r243486 1 2019-03-25 Alex Christensen <achristensen@webkit.org> 2 3 Expected shouldn't assume its contained types are copyable 4 https://bugs.webkit.org/show_bug.cgi?id=195986 5 6 Reviewed by JF Bastien. 7 8 * contentextensions/ContentExtensionParser.cpp: 9 (WebCore::ContentExtensions::loadAction): 10 1 11 2019-03-20 Ryosuke Niwa <rniwa@webkit.org> 2 12 -
trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp
r243319 r243486 257 257 258 258 if (actionType == "block") 259 return { { ActionType::BlockLoad }};259 return { Action(ActionType::BlockLoad) }; 260 260 if (actionType == "ignore-previous-rules") 261 return { { ActionType::IgnorePreviousRules }};261 return { Action(ActionType::IgnorePreviousRules) }; 262 262 if (actionType == "block-cookies") 263 return { { ActionType::BlockCookies }};263 return { Action(ActionType::BlockCookies) }; 264 264 if (actionType == "css-display-none") { 265 265 JSValue selector = actionObject.get(&exec, Identifier::fromString(&exec, "selector")); … … 275 275 } 276 276 if (actionType == "make-https") 277 return { { ActionType::MakeHTTPS }};277 return { Action(ActionType::MakeHTTPS) }; 278 278 if (actionType == "notify") { 279 279 JSValue notification = actionObject.get(&exec, Identifier::fromString(&exec, "notification")); -
trunk/Tools/ChangeLog
r243484 r243486 1 2019-03-25 Alex Christensen <achristensen@webkit.org> 2 3 Expected shouldn't assume its contained types are copyable 4 https://bugs.webkit.org/show_bug.cgi?id=195986 5 6 Reviewed by JF Bastien. 7 8 * TestWebKitAPI/Tests/WTF/Expected.cpp: 9 (TestWebKitAPI::NonCopyable::operator== const): 10 (TestWebKitAPI::NonCopyable::operator!= const): 11 (TestWebKitAPI::TEST): 12 1 13 2019-03-25 Tim Horton <timothy_horton@apple.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WTF/Expected.cpp
r242778 r243486 290 290 } 291 291 292 template<typename T> 293 struct NonCopyable { 294 NonCopyable(NonCopyable&&) = default; 295 NonCopyable(const NonCopyable&) = delete; 296 NonCopyable& operator=(const NonCopyable&) = delete; 297 NonCopyable& operator=(NonCopyable&&) = default; 298 bool operator==(const NonCopyable<T>& other) const { return value == other.value; } 299 bool operator!=(const NonCopyable<T>& other) const { return value != other.value; } 300 T value; 301 }; 302 292 303 TEST(WTF_Expected, comparison) 293 304 { … … 335 346 EXPECT_FALSE(makeUnexpected(oops) == Ex(42)); 336 347 EXPECT_NE(makeUnexpected(oops), Ex(42)); 348 349 NonCopyable<int> a { 5 }; 350 NonCopyable<int> b { 6 }; 351 Unexpected<NonCopyable<double>> c { makeUnexpected(NonCopyable<double> { 5.0 }) }; 352 Expected<NonCopyable<int>, NonCopyable<double>> d { NonCopyable<int> { 5 } }; 353 Expected<NonCopyable<int>, NonCopyable<double>> e { makeUnexpected(NonCopyable<double> { 5.0 }) }; 354 355 EXPECT_TRUE(a != e); 356 EXPECT_TRUE(e != a); 357 EXPECT_FALSE(a == e); 358 EXPECT_FALSE(e == a); 359 360 EXPECT_TRUE(b != e); 361 EXPECT_TRUE(e != b); 362 EXPECT_FALSE(b == e); 363 EXPECT_FALSE(e == b); 364 365 EXPECT_TRUE(c != d); 366 EXPECT_TRUE(d != c); 367 EXPECT_FALSE(c == d); 368 EXPECT_FALSE(d == c); 369 370 EXPECT_TRUE(c == e); 371 EXPECT_TRUE(e == c); 372 EXPECT_FALSE(c != e); 373 EXPECT_FALSE(e != c); 337 374 } 338 375
Note:
See TracChangeset
for help on using the changeset viewer.