Source/WTF/ChangeLog

112014-06-20 Anders Carlsson <andersca@apple.com>
22
 3 Add encoding and decoding support for WTF::Optional
 4 https://bugs.webkit.org/show_bug.cgi?id=134125
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * wtf/Optional.h:
 9 (WTF::Optional::operator=):
 10
 112014-06-20 Anders Carlsson <andersca@apple.com>
 12
313 Add copy/move constructors and assignment operators to WTF::Optional
414 https://bugs.webkit.org/show_bug.cgi?id=134119
515

Source/WebKit2/ChangeLog

112014-06-20 Anders Carlsson <andersca@apple.com>
22
 3 Add encoding and decoding support for WTF::Optional
 4 https://bugs.webkit.org/show_bug.cgi?id=134125
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * Platform/IPC/ArgumentCoders.h:
 9 (IPC::ArgumentCoder<WTF::Optional<T>>::encode):
 10 (IPC::ArgumentCoder<WTF::Optional<T>>::decode):
 11
 122014-06-20 Anders Carlsson <andersca@apple.com>
 13
314 Give NPAPI post requests a default content type
415 https://bugs.webkit.org/show_bug.cgi?id=134120
516

Source/WTF/wtf/Optional.h

@@public:
9191 m_value.~T();
9292 }
9393
 94 Optional& operator=(NulloptTag)
 95 {
 96 if (m_isEngaged) {
 97 m_value.~T();
 98 m_isEngaged = false;
 99 }
 100 return *this;
 101 }
 102
94103 Optional& operator=(const Optional& other)
95104 {
96105 if (m_isEngaged == other.m_isEngaged) {

Source/WebKit2/Platform/IPC/ArgumentCoders.h

3232#include <wtf/Forward.h>
3333#include <wtf/HashMap.h>
3434#include <wtf/HashSet.h>
 35#include <wtf/Optional.h>
3536#include <wtf/Vector.h>
3637
3738namespace IPC {

@@template<typename T> struct SimpleArgumentCoder {
4950 }
5051};
5152
 53template<typename T> struct ArgumentCoder<WTF::Optional<T>> {
 54 static void encode(ArgumentEncoder& encoder, const WTF::Optional<T>& optional)
 55 {
 56 if (!optional) {
 57 encoder << false;
 58 return;
 59 }
 60
 61 encoder << true;
 62 encoder << optional.value();
 63 }
 64
 65 static bool decode(ArgumentDecoder& decoder, WTF::Optional<T>& optional)
 66 {
 67 bool isEngaged;
 68 if (!decoder.decode(isEngaged))
 69 return false;
 70
 71 if (!isEngaged) {
 72 optional = Nullopt;
 73 return true;
 74 }
 75
 76 T value;
 77 if (!decoder.decode(value))
 78 return false;
 79
 80 optional = std::move(value);
 81 return true;
 82 }
 83};
 84
5285template<typename T, typename U> struct ArgumentCoder<std::pair<T, U>> {
5386 static void encode(ArgumentEncoder& encoder, const std::pair<T, U>& pair)
5487 {