Ignore:
Timestamp:
Dec 4, 2017, 3:34:57 PM (7 years ago)
Author:
[email protected]
Message:

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):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSImageSetValue.cpp

    r223728 r225499  
    11/*
    2  * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    104104            request.updateForAccessControl(*document);
    105105
    106         m_cachedImage = loader.requestImage(WTFMove(request)).valueOr(nullptr);
     106        m_cachedImage = loader.requestImage(WTFMove(request)).value_or(nullptr);
    107107        m_bestFitImageScaleFactor = image.scaleFactor;
    108108    }
Note: See TracChangeset for help on using the changeset viewer.