Update std::expected to match libc++ coding style
authorjfbastien@apple.com <jfbastien@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Dec 2017 23:34:57 +0000 (23:34 +0000)
committerjfbastien@apple.com <jfbastien@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Dec 2017 23:34:57 +0000 (23:34 +0000)
commit259ffec3f7e442fa396540252d98d8ce12de7b13
treeddc9decdbc4892b3c53500dabfa5b8f4eb0631cf
parent280fc9367522c012cbc28d7ab8b1982a0133048a
Update std::expected to match libc++ coding style
https://bugs.webkit.org/show_bug.cgi?id=180264

Reviewed by Alex Christensen.

Source/JavaScriptCore:

Update various uses of Expected.

* wasm/WasmModule.h:
* wasm/WasmModuleParser.cpp:
(JSC::Wasm::ModuleParser::parseImport):
(JSC::Wasm::ModuleParser::parseTableHelper):
(JSC::Wasm::ModuleParser::parseTable):
(JSC::Wasm::ModuleParser::parseMemoryHelper):
* wasm/WasmParser.h:
* wasm/generateWasmValidateInlinesHeader.py:
(loadMacro):
(storeMacro):
* wasm/js/JSWebAssemblyModule.cpp:
(JSC::JSWebAssemblyModule::createStub):
* wasm/js/JSWebAssemblyModule.h:

Source/WebCore:

Update various uses of Expected, mostly renaming valueOr and
hasValue to the STL naming convention.

* Modules/cache/DOMCache.cpp:
(WebCore::DOMCache::retrieveRecords):
(WebCore::DOMCache::batchDeleteOperation):
(WebCore::DOMCache::batchPutOperation):
* Modules/cache/DOMCacheStorage.cpp:
(WebCore::DOMCacheStorage::retrieveCaches):
(WebCore::DOMCacheStorage::open):
(WebCore::DOMCacheStorage::remove):
* Modules/cache/WorkerCacheStorageConnection.cpp:
(WebCore::WorkerCacheStorageConnection::doRemove):
(WebCore::WorkerCacheStorageConnection::doRetrieveCaches):
(WebCore::recordsDataOrErrorFromRecords):
(WebCore::recordsOrErrorFromRecordsData):
* bindings/js/CachedScriptFetcher.cpp:
(WebCore::CachedScriptFetcher::requestScriptWithCache const):
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
* contentextensions/ContentExtensionParser.cpp:
(WebCore::ContentExtensions::getDomainList):
(WebCore::ContentExtensions::loadTrigger):
(WebCore::ContentExtensions::loadRule):
(WebCore::ContentExtensions::loadEncodedRules):
(WebCore::ContentExtensions::parseRuleList):
* css/CSSFontFaceSrcValue.cpp:
(WebCore::CSSFontFaceSrcValue::cachedFont):
* css/CSSImageSetValue.cpp:
(WebCore::CSSImageSetValue::loadBestFitImage):
* css/CSSImageValue.cpp:
(WebCore::CSSImageValue::loadImage):
* css/StyleRuleImport.cpp:
(WebCore::StyleRuleImport::requestStyleSheet):
* dom/CallbackResult.h:
(WebCore::CallbackResult<ReturnType>::type const):
(WebCore::CallbackResult<ReturnType>::releaseReturnValue):
* dom/Element.cpp:
(WebCore::Element::getIntegralAttribute const):
(WebCore::Element::getUnsignedIntegralAttribute const):
* dom/ExceptionOr.h:
(WebCore::ExceptionOr<ReturnType>::hasException const):
(WebCore::ExceptionOr<void>::hasException const):
* dom/ProcessingInstruction.cpp:
(WebCore::ProcessingInstruction::checkStyleSheet):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::maxLengthAttributeChanged):
(WebCore::HTMLInputElement::minLengthAttributeChanged):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::process):
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::maxLengthAttributeChanged):
(WebCore::HTMLTextAreaElement::minLengthAttributeChanged):
* html/parser/HTMLParserIdioms.cpp:
(WebCore::parseHTMLNonNegativeInteger):
* html/parser/HTMLParserIdioms.h:
(WebCore::limitToOnlyHTMLNonNegative):
* loader/CrossOriginPreflightChecker.cpp:
(WebCore::CrossOriginPreflightChecker::startPreflight):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::loadMainResource):
* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::loadRequest):
* loader/ImageLoader.cpp:
(WebCore::ImageLoader::updateFromElement):
* loader/LinkLoader.cpp:
(WebCore::LinkLoader::preloadIfNeeded):
(WebCore::LinkLoader::loadLink):
* loader/MediaResourceLoader.cpp:
(WebCore::MediaResourceLoader::requestResource):
* loader/TextTrackLoader.cpp:
(WebCore::TextTrackLoader::load):
* loader/cache/CachedSVGDocumentReference.cpp:
(WebCore::CachedSVGDocumentReference::load):
* loader/icon/IconLoader.cpp:
(WebCore::IconLoader::startLoading):
* platform/URLParser.cpp:
(WebCore::URLParser::parseIPv4Host):
* platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.cpp:
(WebCore::WebCoreAVCFResourceLoader::startLoading):
* platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
(WebCore::WebCoreAVFResourceLoader::startLoading):
* svg/SVGFEImageElement.cpp:
(WebCore::SVGFEImageElement::requestImageResource):
* svg/SVGFontFaceUriElement.cpp:
(WebCore::SVGFontFaceUriElement::loadFont):
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::updateExternalDocument):
* xml/XSLImportRule.cpp:
(WebCore::XSLImportRule::loadSheet):

Source/WebKit:

Update various uses of Expected, mostly renaming valueOr and
hasValue to the STL naming convention.

* NetworkProcess/cache/CacheStorageEngine.cpp:
(WebKit::CacheStorage::Engine::open):
(WebKit::CacheStorage::Engine::retrieveCaches):
(WebKit::CacheStorage::Engine::retrieveRecords):
(WebKit::CacheStorage::Engine::putRecords):
(WebKit::CacheStorage::Engine::deleteMatchingRecords):
(WebKit::CacheStorage::Engine::fetchEntries):
(WebKit::CacheStorage::Engine::clearMemoryRepresentation):
* NetworkProcess/cache/CacheStorageEngineCache.cpp:
(WebKit::CacheStorage::ReadRecordTaskCounter::appendRecord):
(WebKit::CacheStorage::Cache::updateRecordToDisk):
* NetworkProcess/cache/CacheStorageEngineCaches.cpp:
(WebKit::CacheStorage::Caches::initialize):
(WebKit::CacheStorage::Caches::readCachesFromDisk):
* NetworkProcess/webrtc/NetworkRTCProvider.cpp:
(WebKit::NetworkRTCProvider::createResolver):
* Platform/IPC/ArgumentCoders.h:

Source/WTF:

As of https://wg21.link/p0323r4 std::expected is on its way to the
Library Fundamentals v3 TS (LEWG and EWG voted for this, but LWG
hasn't done wording review yet, hence "on its way"). The API is
therefore pretty close to what will be in the TS, and I've gotten
requests for an easily usable implementation of std::expected. I
talked to our clang team and they'll help me migrate our
implementation to libc++, but our implementation has to look more
like libc++ than it does now. Once in libc++ I'll maintain changes
on both sides to make sure neither is out-of-date for too long.

- Fork std::unexpected into its own header.
- Add mild support for an exception-based implementation, but
  don't do noexcept yet.
- Rename everything to follow STL style, and keep a global using
  or variable alias where possible to reduce WebKit code churn.
- Minor API updates to remove things that aren't in the proposal
  anymore.

* wtf/Expected.h:
(std::experimental::fundamentals_v3::bad_expected_access<void>::bad_expected_access):
(std::experimental::fundamentals_v3::bad_expected_access::bad_expected_access):
(std::experimental::fundamentals_v3::bad_expected_access::error):
(std::experimental::fundamentals_v3::bad_expected_access::error const):
(std::experimental::fundamentals_v3::__expected_detail::constexpr_base::constexpr_base):
(std::experimental::fundamentals_v3::__expected_detail::base::base):
(std::experimental::fundamentals_v3::__expected_detail::base::~base):
(std::experimental::fundamentals_v3::expected::expected):
(std::experimental::fundamentals_v3::expected::operator=):
(std::experimental::fundamentals_v3::expected::swap):
(std::experimental::fundamentals_v3::expected::operator-> const):
(std::experimental::fundamentals_v3::expected::operator->):
(std::experimental::fundamentals_v3::expected::operator* const):
(std::experimental::fundamentals_v3::expected::operator*):
(std::experimental::fundamentals_v3::expected::has_value const):
(std::experimental::fundamentals_v3::expected::value const):
(std::experimental::fundamentals_v3::expected::value):
(std::experimental::fundamentals_v3::expected::error const):
(std::experimental::fundamentals_v3::expected::error):
(std::experimental::fundamentals_v3::expected::value_or const):
(std::experimental::fundamentals_v3::expected::value_or):
(std::experimental::fundamentals_v3::operator==):
(std::experimental::fundamentals_v3::operator!=):
(std::experimental::fundamentals_v3::swap):
(WTF::Unexpected::Unexpected): Deleted.
(WTF::Unexpected::value const): Deleted.
(WTF::Unexpected::value): Deleted.
(WTF::operator==): Deleted.
(WTF::operator!=): Deleted.
(WTF::makeUnexpected): Deleted.
(WTF::ExpectedDetail::Throw): Deleted.
(WTF::ExpectedDetail::destroy): Deleted.
(WTF::ExpectedDetail::std::is_trivially_destructible<T>::value): Deleted.
(WTF::ExpectedDetail::ConstexprBase::ConstexprBase): Deleted.
(WTF::ExpectedDetail::Base::Base): Deleted.
(WTF::ExpectedDetail::Base::~Base): Deleted.
(WTF::Expected::Expected): Deleted.
(WTF::Expected::operator=): Deleted.
(WTF::Expected::swap): Deleted.
(WTF::Expected::operator-> const): Deleted.
(WTF::Expected::operator->): Deleted.
(WTF::Expected::operator* const): Deleted.
(WTF::Expected::operator*): Deleted.
(WTF::Expected::operator bool const): Deleted.
(WTF::Expected::hasValue const): Deleted.
(WTF::Expected::value const): Deleted.
(WTF::Expected::value): Deleted.
(WTF::Expected::error const): Deleted.
(WTF::Expected::error): Deleted.
(WTF::Expected::getUnexpected const): Deleted.
(WTF::Expected::valueOr const): Deleted.
(WTF::Expected::valueOr): Deleted.
(WTF::swap): Deleted.
(WTF::makeExpected): Deleted.
(WTF::makeExpectedFromError): Deleted.
* wtf/Forward.h:
* wtf/Optional.h:
* wtf/StdLibExtras.h:
* wtf/Unexpected.h: Added.
(std::experimental::fundamentals_v3::unexpected::unexpected):
(std::experimental::fundamentals_v3::unexpected::value const):
(std::experimental::fundamentals_v3::unexpected::value):
(std::experimental::fundamentals_v3::operator==):
(std::experimental::fundamentals_v3::operator!=):
(makeUnexpected):

Tools:

Update tests according to name changes as well as removal of
now-gone APIs.

* TestWebKitAPI/Tests/WTF/Expected.cpp:
(std::experimental::fundamentals_v3::operator<<):
(TestWebKitAPI::TEST):
(WTF::operator<<): Deleted.
* TestWebKitAPI/Tests/WebCore/HTMLParserIdioms.cpp:
(TestWebKitAPI::testParseHTMLInteger):
(TestWebKitAPI::testParseHTMLNonNegativeInteger):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225499 268f45cc-cd09-0410-ab3c-d52691b4dbfc
58 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/wasm/WasmModule.h
Source/JavaScriptCore/wasm/WasmModuleParser.cpp
Source/JavaScriptCore/wasm/WasmParser.h
Source/JavaScriptCore/wasm/generateWasmValidateInlinesHeader.py
Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.cpp
Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h
Source/WTF/ChangeLog
Source/WTF/wtf/Expected.h
Source/WTF/wtf/Forward.h
Source/WTF/wtf/Optional.h
Source/WTF/wtf/StdLibExtras.h
Source/WTF/wtf/Unexpected.h [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/cache/DOMCache.cpp
Source/WebCore/Modules/cache/DOMCacheStorage.cpp
Source/WebCore/Modules/cache/WorkerCacheStorageConnection.cpp
Source/WebCore/bindings/js/CachedScriptFetcher.cpp
Source/WebCore/contentextensions/ContentExtensionCompiler.cpp
Source/WebCore/contentextensions/ContentExtensionParser.cpp
Source/WebCore/css/CSSFontFaceSrcValue.cpp
Source/WebCore/css/CSSImageSetValue.cpp
Source/WebCore/css/CSSImageValue.cpp
Source/WebCore/css/StyleRuleImport.cpp
Source/WebCore/dom/CallbackResult.h
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/ExceptionOr.h
Source/WebCore/dom/ProcessingInstruction.cpp
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLLinkElement.cpp
Source/WebCore/html/HTMLTextAreaElement.cpp
Source/WebCore/html/parser/HTMLParserIdioms.cpp
Source/WebCore/html/parser/HTMLParserIdioms.h
Source/WebCore/loader/CrossOriginPreflightChecker.cpp
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/loader/DocumentThreadableLoader.cpp
Source/WebCore/loader/ImageLoader.cpp
Source/WebCore/loader/LinkLoader.cpp
Source/WebCore/loader/MediaResourceLoader.cpp
Source/WebCore/loader/TextTrackLoader.cpp
Source/WebCore/loader/cache/CachedSVGDocumentReference.cpp
Source/WebCore/loader/icon/IconLoader.cpp
Source/WebCore/platform/URLParser.cpp
Source/WebCore/platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.cpp
Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm
Source/WebCore/svg/SVGFEImageElement.cpp
Source/WebCore/svg/SVGFontFaceUriElement.cpp
Source/WebCore/svg/SVGUseElement.cpp
Source/WebCore/xml/XSLImportRule.cpp
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp
Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.cpp
Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp
Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp
Source/WebKit/Platform/IPC/ArgumentCoders.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/Expected.cpp
Tools/TestWebKitAPI/Tests/WebCore/HTMLParserIdioms.cpp