Use WTF::Variant for WebPreferencesStore::Value
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Aug 2018 21:48:21 +0000 (21:48 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Aug 2018 21:48:21 +0000 (21:48 +0000)
commit0d7104921b6888deacee933ae8d34d22f550eae8
tree4077a992f96ff20289bfce0e1538cb9432a129ba
parente1a3f2d4eec68c23067529f7fe02659d0fc2a840
Use WTF::Variant for WebPreferencesStore::Value
https://bugs.webkit.org/show_bug.cgi?id=188250

Reviewed by Sam Weinig.

It was conceptually a variant. This just uses an actual WTF::Variant.
Since it's encoded and decoded, I wrote variadic template encoders and decoders
like we have for other types (Expected, std::tuple, KeyValuePair, etc.)

* Platform/IPC/ArgumentCoders.h:
(IPC::VariantCoder::encode):
(IPC::VariantCoder::decode):
Introduce ArgumentCoder<Variant>, which encodes which type the Variant currently
holds followed by the encoding of the current type.
* Platform/IPC/Decoder.cpp:
(IPC::Decoder::Decoder):
* Platform/IPC/Decoder.h:
* Platform/IPC/mac/ConnectionMac.mm:
(IPC::createMessageDecoder):
Use move semantics to prevent an unnecessary copy of the Vector<Attachment>
* Scripts/PreferencesTemplates/WebPreferencesStoreDefaultsMap.cpp.erb:
* Shared/WebPreferencesStore.cpp:
(WebKit::WebPreferencesStore::decode):
Use modern std::optional-based decoding supported by the new Variant decoding.
(WebKit::valueForKey):
Use WTF::get and WTF::holds_alternative instead of custom type checks.
(WebKit::WebPreferencesStore::Value::encode const): Deleted.
(WebKit::WebPreferencesStore::Value::decode): Deleted.
(WebKit::as<String>): Deleted.
(WebKit::as<bool>): Deleted.
(WebKit::as<uint32_t>): Deleted.
(WebKit::as<double>): Deleted.
* Shared/WebPreferencesStore.h:
(WebKit::WebPreferencesStore::Value::Value): Deleted.
(WebKit::WebPreferencesStore::Value::operator=): Deleted.
(WebKit::WebPreferencesStore::Value::~Value): Deleted.
(WebKit::WebPreferencesStore::Value::type const): Deleted.
(WebKit::WebPreferencesStore::Value::asString const): Deleted.
(WebKit::WebPreferencesStore::Value::asBool const): Deleted.
(WebKit::WebPreferencesStore::Value::asUInt32 const): Deleted.
(WebKit::WebPreferencesStore::Value::asDouble const): Deleted.
(WebKit::WebPreferencesStore::Value::destroy): Deleted.
(): Deleted.
Use WTF::Variant instead of a custom type/union pair.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234516 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/ChangeLog
Source/WebKit/Platform/IPC/ArgumentCoders.h
Source/WebKit/Platform/IPC/Decoder.cpp
Source/WebKit/Platform/IPC/Decoder.h
Source/WebKit/Platform/IPC/mac/ConnectionMac.mm
Source/WebKit/Scripts/PreferencesTemplates/WebPreferencesStoreDefaultsMap.cpp.erb
Source/WebKit/Shared/WebPreferencesStore.cpp
Source/WebKit/Shared/WebPreferencesStore.h