Diff
Modified: branches/safari-602-branch/Source/WTF/ChangeLog (206049 => 206050)
--- branches/safari-602-branch/Source/WTF/ChangeLog 2016-09-16 21:39:28 UTC (rev 206049)
+++ branches/safari-602-branch/Source/WTF/ChangeLog 2016-09-16 21:42:58 UTC (rev 206050)
@@ -1,3 +1,20 @@
+2016-09-16 Babak Shafiei <bshaf...@apple.com>
+
+ Merge r204916. rdar://problem/27991573
+
+ 2016-08-23 Anders Carlsson <ander...@apple.com>
+
+ Add enum traits and use them in the IPC::Decoder
+ https://bugs.webkit.org/show_bug.cgi?id=161103
+
+ Reviewed by Sam Weinig.
+
+ Add EnumTraits.h which provides a forward declaration for WTF::EnumTraits as well as
+ the WTF::isValidEnum function.
+
+ * WTF.xcodeproj/project.pbxproj:
+ * wtf/EnumTraits.h: Added.
+
2016-09-13 Babak Shafiei <bshaf...@apple.com>
Merge r205895. rdar://problem/28287070
Modified: branches/safari-602-branch/Source/WTF/WTF.xcodeproj/project.pbxproj (206049 => 206050)
--- branches/safari-602-branch/Source/WTF/WTF.xcodeproj/project.pbxproj 2016-09-16 21:39:28 UTC (rev 206049)
+++ branches/safari-602-branch/Source/WTF/WTF.xcodeproj/project.pbxproj 2016-09-16 21:42:58 UTC (rev 206050)
@@ -87,6 +87,7 @@
1A6EB1E0187D0BD30030126F /* StringView.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A6EB1DF187D0BD30030126F /* StringView.h */; };
1A944F471C3D8814005BD28C /* BlockPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A944F461C3D8814005BD28C /* BlockPtr.h */; };
1ACADD841884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1ACADD821884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm */; };
+ 1AEA88E21D6BBCF400E5AD64 /* EnumTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEA88E11D6BBCF400E5AD64 /* EnumTraits.h */; };
1AFDE648195201C300C48FFA /* TypeCastsCF.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFDE647195201C300C48FFA /* TypeCastsCF.h */; };
1AFDE6531953B23D00C48FFA /* Optional.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFDE6521953B23D00C48FFA /* Optional.h */; };
1C181C7F1D3078DA00F5FA16 /* TextBreakIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C181C7D1D3078DA00F5FA16 /* TextBreakIterator.cpp */; };
@@ -421,6 +422,7 @@
1A6EB1DF187D0BD30030126F /* StringView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringView.h; sourceTree = "<group>"; };
1A944F461C3D8814005BD28C /* BlockPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlockPtr.h; sourceTree = "<group>"; };
1ACADD821884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeprecatedSymbolsUsedBySafari.mm; sourceTree = "<group>"; };
+ 1AEA88E11D6BBCF400E5AD64 /* EnumTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EnumTraits.h; sourceTree = "<group>"; };
1AFDE647195201C300C48FFA /* TypeCastsCF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypeCastsCF.h; sourceTree = "<group>"; };
1AFDE6521953B23D00C48FFA /* Optional.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Optional.h; sourceTree = "<group>"; };
1C181C7D1D3078DA00F5FA16 /* TextBreakIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextBreakIterator.cpp; sourceTree = "<group>"; };
@@ -867,6 +869,7 @@
A8A47280151A825A004123FF /* DoublyLinkedList.h */,
A8A47297151A825A004123FF /* dtoa.cpp */,
A8A47298151A825A004123FF /* dtoa.h */,
+ 1AEA88E11D6BBCF400E5AD64 /* EnumTraits.h */,
A8A4729F151A825A004123FF /* ExportMacros.h */,
0F885E0E1845AE9F00F1E3FA /* FastBitVector.cpp */,
0FD81AC4154FB22E00983E72 /* FastBitVector.h */,
@@ -1286,6 +1289,7 @@
2C05385415BC819000F21B96 /* GregorianDateTime.h in Headers */,
A8A473D3151A825B004123FF /* HashCountedSet.h in Headers */,
A8A4742D151A825B004123FF /* Hasher.h in Headers */,
+ 1AEA88E21D6BBCF400E5AD64 /* EnumTraits.h in Headers */,
1C181C901D307AB800F5FA16 /* UTextProvider.h in Headers */,
A8A473D4151A825B004123FF /* HashFunctions.h in Headers */,
A8A473D5151A825B004123FF /* HashIterators.h in Headers */,
Added: branches/safari-602-branch/Source/WTF/wtf/EnumTraits.h (0 => 206050)
--- branches/safari-602-branch/Source/WTF/wtf/EnumTraits.h (rev 0)
+++ branches/safari-602-branch/Source/WTF/wtf/EnumTraits.h 2016-09-16 21:42:58 UTC (rev 206050)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <type_traits>
+
+namespace WTF {
+
+template<typename> struct EnumTraits;
+
+template<typename E, E...> struct EnumValues;
+
+template<typename T, typename E> struct EnumValueChecker;
+
+template<typename T, typename E, E e, E... es>
+struct EnumValueChecker<T, EnumValues<E, e, es...>> {
+ static constexpr bool isValidEnum(T t)
+ {
+ if (static_cast<T>(e) == t)
+ return true;
+
+ return EnumValueChecker<T, EnumValues<E, es...>>::isValidEnum(t);
+ }
+};
+
+template<typename T, typename E>
+struct EnumValueChecker<T, EnumValues<E>> {
+ static constexpr bool isValidEnum(T t)
+ {
+ return false;
+ }
+};
+
+template<typename E, typename T>
+constexpr auto isValidEnum(T t) -> std::enable_if_t<std::is_enum<E>::value, bool>
+{
+ static_assert(sizeof(T) >= std::underlying_type_t<E>(), "Integral type must be at least the size of the underlying enum type");
+
+ return EnumValueChecker<T, typename EnumTraits<E>::values>::isValidEnum(t);
+}
+
+}
+
+using WTF::isValidEnum;
Modified: branches/safari-602-branch/Source/WebKit2/ChangeLog (206049 => 206050)
--- branches/safari-602-branch/Source/WebKit2/ChangeLog 2016-09-16 21:39:28 UTC (rev 206049)
+++ branches/safari-602-branch/Source/WebKit2/ChangeLog 2016-09-16 21:42:58 UTC (rev 206050)
@@ -1,5 +1,25 @@
2016-09-16 Babak Shafiei <bshaf...@apple.com>
+ Merge r204916. rdar://problem/27991573
+
+ 2016-08-23 Anders Carlsson <ander...@apple.com>
+
+ Add enum traits and use them in the IPC::Decoder
+ https://bugs.webkit.org/show_bug.cgi?id=161103
+
+ Reviewed by Sam Weinig.
+
+ * Platform/IPC/Decoder.h:
+ * Platform/IPC/Encoder.h:
+ Add new encode/decode functions.
+
+ * Shared/mac/ArgumentCodersMac.mm:
+ Change NSType to be a strongly typed enum. Use encode/decode
+ instead of encodeEnum/decodeEnum since the latter don't have the
+ enum check.
+
+2016-09-16 Babak Shafiei <bshaf...@apple.com>
+
Merge r205983. rdar://problem/28312297
2016-09-14 Beth Dakin <bda...@apple.com>
Modified: branches/safari-602-branch/Source/WebKit2/Platform/IPC/ArgumentDecoder.h (206049 => 206050)
--- branches/safari-602-branch/Source/WebKit2/Platform/IPC/ArgumentDecoder.h 2016-09-16 21:39:28 UTC (rev 206049)
+++ branches/safari-602-branch/Source/WebKit2/Platform/IPC/ArgumentDecoder.h 2016-09-16 21:42:58 UTC (rev 206050)
@@ -28,6 +28,7 @@
#include "ArgumentCoder.h"
#include "Attachment.h"
+#include <wtf/EnumTraits.h>
#include <wtf/Vector.h>
namespace IPC {
@@ -60,6 +61,18 @@
bool decode(float&);
bool decode(double&);
+ template<typename E>
+ auto decode(E& e) -> std::enable_if_t<std::is_enum<E>::value, bool>
+ {
+ uint64_t value;
+ if (!decode(value))
+ return false;
+ if (!isValidEnum<E>(value))
+ return false;
+
+ return true;
+ }
+
template<typename T> bool decodeEnum(T& result)
{
static_assert(sizeof(T) <= 8, "Enum type T must not be larger than 64 bits!");
@@ -83,8 +96,8 @@
return bufferIsLargeEnoughToContain(alignof(T), numElements * sizeof(T));
}
- // Generic type decode function.
- template<typename T> bool decode(T& t)
+ template<typename T>
+ auto decode(T& t) -> std::enable_if_t<!std::is_enum<T>::value, bool>
{
return ArgumentCoder<T>::decode(*this, t);
}
Modified: branches/safari-602-branch/Source/WebKit2/Platform/IPC/ArgumentEncoder.h (206049 => 206050)
--- branches/safari-602-branch/Source/WebKit2/Platform/IPC/ArgumentEncoder.h 2016-09-16 21:39:28 UTC (rev 206049)
+++ branches/safari-602-branch/Source/WebKit2/Platform/IPC/ArgumentEncoder.h 2016-09-16 21:42:58 UTC (rev 206050)
@@ -28,11 +28,11 @@
#include "ArgumentCoder.h"
#include "Attachment.h"
+#include <wtf/EnumTraits.h>
#include <wtf/Vector.h>
namespace IPC {
-class ArgumentEncoder;
class DataReference;
class ArgumentEncoder {
@@ -51,7 +51,8 @@
encode(static_cast<uint64_t>(t));
}
- template<typename T> void encode(T&& t)
+ template<typename T>
+ auto encode(T&& t) -> std::enable_if_t<!std::is_enum<typename std::remove_const_t<std::remove_reference_t<T>>>::value>
{
ArgumentCoder<typename std::remove_const<typename std::remove_reference<T>::type>::type>::encode(*this, std::forward<T>(t));
}
@@ -80,6 +81,15 @@
void encode(float);
void encode(double);
+ template<typename E>
+ auto encode(E value) -> std::enable_if_t<std::is_enum<E>::value>
+ {
+ static_assert(sizeof(E) <= sizeof(uint64_t), "Enum type must not be larger than 64 bits.");
+
+ ASSERT(isValidEnum<E>(static_cast<uint64_t>(value)));
+ encode(static_cast<uint64_t>(value));
+ }
+
uint8_t* grow(unsigned alignment, size_t size);
uint8_t m_inlineBuffer[512];
Modified: branches/safari-602-branch/Source/WebKit2/Shared/mac/ArgumentCodersMac.mm (206049 => 206050)
--- branches/safari-602-branch/Source/WebKit2/Shared/mac/ArgumentCodersMac.mm 2016-09-16 21:39:28 UTC (rev 206049)
+++ branches/safari-602-branch/Source/WebKit2/Shared/mac/ArgumentCodersMac.mm 2016-09-16 21:42:58 UTC (rev 206050)
@@ -41,98 +41,101 @@
namespace IPC {
-enum NSType {
- NSAttributedStringType,
+enum class NSType {
+ AttributedString,
#if USE(APPKIT)
- NSColorType,
+ Color,
#endif
- NSDictionaryType,
- NSArrayType,
+ Dictionary,
+ Array,
#if USE(APPKIT)
- NSFontType,
+ Font,
#endif
- NSNumberType,
- NSStringType,
- NSDateType,
- NSDataType,
- NSURLType,
+ Number,
+ String,
+ Date,
+ Data,
+ URL,
Unknown,
};
+}
+
+namespace IPC {
static NSType typeFromObject(id object)
{
ASSERT(object);
if ([object isKindOfClass:[NSAttributedString class]])
- return NSAttributedStringType;
+ return NSType::AttributedString;
#if USE(APPKIT)
if ([object isKindOfClass:[NSColor class]])
- return NSColorType;
+ return NSType::Color;
#endif
if ([object isKindOfClass:[NSDictionary class]])
- return NSDictionaryType;
+ return NSType::Dictionary;
#if USE(APPKIT)
if ([object isKindOfClass:[NSFont class]])
- return NSFontType;
+ return NSType::Font;
#endif
if ([object isKindOfClass:[NSNumber class]])
- return NSNumberType;
+ return NSType::Number;
if ([object isKindOfClass:[NSString class]])
- return NSStringType;
+ return NSType::String;
if ([object isKindOfClass:[NSArray class]])
- return NSArrayType;
+ return NSType::Array;
if ([object isKindOfClass:[NSDate class]])
- return NSDateType;
+ return NSType::Date;
if ([object isKindOfClass:[NSData class]])
- return NSDataType;
+ return NSType::Data;
if ([object isKindOfClass:[NSURL class]])
- return NSURLType;
+ return NSType::URL;
ASSERT_NOT_REACHED();
- return Unknown;
+ return NSType::Unknown;
}
void encode(ArgumentEncoder& encoder, id object)
{
NSType type = typeFromObject(object);
- encoder.encodeEnum(type);
+ encoder << type;
switch (type) {
- case NSAttributedStringType:
+ case NSType::AttributedString:
encode(encoder, static_cast<NSAttributedString *>(object));
return;
#if USE(APPKIT)
- case NSColorType:
+ case NSType::Color:
encode(encoder, static_cast<NSColor *>(object));
return;
#endif
- case NSDictionaryType:
+ case NSType::Dictionary:
encode(encoder, static_cast<NSDictionary *>(object));
return;
#if USE(APPKIT)
- case NSFontType:
+ case NSType::Font:
encode(encoder, static_cast<NSFont *>(object));
return;
#endif
- case NSNumberType:
+ case NSType::Number:
encode(encoder, static_cast<NSNumber *>(object));
return;
- case NSStringType:
+ case NSType::String:
encode(encoder, static_cast<NSString *>(object));
return;
- case NSArrayType:
+ case NSType::Array:
encode(encoder, static_cast<NSArray *>(object));
return;
- case NSDateType:
+ case NSType::Date:
encode(encoder, static_cast<NSDate *>(object));
return;
- case NSDataType:
+ case NSType::Data:
encode(encoder, static_cast<NSData *>(object));
return;
- case NSURLType:
+ case NSType::URL:
encode(encoder, static_cast<NSURL *>(object));
return;
- case Unknown:
+ case NSType::Unknown:
break;
}
@@ -146,7 +149,7 @@
return false;
switch (type) {
- case NSAttributedStringType: {
+ case NSType::AttributedString: {
RetainPtr<NSAttributedString> string;
if (!decode(decoder, string))
return false;
@@ -154,7 +157,7 @@
return true;
}
#if USE(APPKIT)
- case NSColorType: {
+ case NSType::Color: {
RetainPtr<NSColor> color;
if (!decode(decoder, color))
return false;
@@ -162,7 +165,7 @@
return true;
}
#endif
- case NSDictionaryType: {
+ case NSType::Dictionary: {
RetainPtr<NSDictionary> dictionary;
if (!decode(decoder, dictionary))
return false;
@@ -170,7 +173,7 @@
return true;
}
#if USE(APPKIT)
- case NSFontType: {
+ case NSType::Font: {
RetainPtr<NSFont> font;
if (!decode(decoder, font))
return false;
@@ -178,7 +181,7 @@
return true;
}
#endif
- case NSNumberType: {
+ case NSType::Number: {
RetainPtr<NSNumber> number;
if (!decode(decoder, number))
return false;
@@ -185,7 +188,7 @@
result = number;
return true;
}
- case NSStringType: {
+ case NSType::String: {
RetainPtr<NSString> string;
if (!decode(decoder, string))
return false;
@@ -192,7 +195,7 @@
result = string;
return true;
}
- case NSArrayType: {
+ case NSType::Array: {
RetainPtr<NSArray> array;
if (!decode(decoder, array))
return false;
@@ -199,7 +202,7 @@
result = array;
return true;
}
- case NSDateType: {
+ case NSType::Date: {
RetainPtr<NSDate> date;
if (!decode(decoder, date))
return false;
@@ -206,7 +209,7 @@
result = date;
return true;
}
- case NSDataType: {
+ case NSType::Data: {
RetainPtr<NSData> data;
if (!decode(decoder, data))
return false;
@@ -213,7 +216,7 @@
result = data;
return true;
}
- case NSURLType: {
+ case NSType::URL: {
RetainPtr<NSURL> URL;
if (!decode(decoder, URL))
return false;
@@ -220,7 +223,7 @@
result = URL;
return true;
}
- case Unknown:
+ case NSType::Unknown:
ASSERT_NOT_REACHED();
return false;
}
@@ -369,7 +372,7 @@
ASSERT(isSerializableValue(value));
// Ignore values we don't recognize.
- if (typeFromObject(value) == Unknown)
+ if (typeFromObject(value) == NSType::Unknown)
continue;
encode(encoder, (NSString *)key);
@@ -460,7 +463,7 @@
id value = [array objectAtIndex:i];
// Ignore values we don't recognize.
- if (typeFromObject(value) == Unknown)
+ if (typeFromObject(value) == NSType::Unknown)
continue;
ASSERT(isSerializableValue(value));
@@ -534,3 +537,26 @@
}
} // namespace IPC
+
+namespace WTF {
+template<> struct EnumTraits<IPC::NSType> {
+ using values = EnumValues<
+ IPC::NSType,
+ IPC::NSType::AttributedString,
+ #if USE(APPKIT)
+ IPC::NSType::Color,
+ #endif
+ IPC::NSType::Dictionary,
+ IPC::NSType::Array,
+ #if USE(APPKIT)
+ IPC::NSType::Font,
+ #endif
+ IPC::NSType::Number,
+ IPC::NSType::String,
+ IPC::NSType::Date,
+ IPC::NSType::Data,
+ IPC::NSType::URL,
+ IPC::NSType::Unknown
+ >;
+};
+}
Modified: branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp (206049 => 206050)
--- branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp 2016-09-16 21:39:28 UTC (rev 206049)
+++ branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp 2016-09-16 21:42:58 UTC (rev 206050)
@@ -2345,7 +2345,7 @@
// requestTermination() is a no-op for launching processes, so we get into an inconsistent state by calling resetStateAfterProcessExited().
// FIXME: A client can terminate the page at any time, so we should do something more meaningful than assert and fall apart in release builds.
// See also <https://bugs.webkit.org/show_bug.cgi?id=136012>.
- ASSERT(m_process->state() != WebProcessProxy::State::Launching);
+// ASSERT(m_process->state() != WebProcessProxy::State::Launching);
// NOTE: This uses a check of m_isValid rather than calling isValid() since
// we want this to run even for pages being closed or that already closed.
Modified: branches/safari-602-branch/Tools/ChangeLog (206049 => 206050)
--- branches/safari-602-branch/Tools/ChangeLog 2016-09-16 21:39:28 UTC (rev 206049)
+++ branches/safari-602-branch/Tools/ChangeLog 2016-09-16 21:42:58 UTC (rev 206050)
@@ -1,3 +1,20 @@
+2016-09-16 Babak Shafiei <bshaf...@apple.com>
+
+ Merge r204916. rdar://problem/27991573
+
+ 2016-08-23 Anders Carlsson <ander...@apple.com>
+
+ Add enum traits and use them in the IPC::Decoder
+ https://bugs.webkit.org/show_bug.cgi?id=161103
+
+ Reviewed by Sam Weinig.
+
+ Add API test.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WTF/EnumTraits.cpp: Added.
+ (TestWebKitAPI::TEST):
+
2016-09-14 Babak Shafiei <bshaf...@apple.com>
Merge r205938. rdar://problem/28227805
Modified: branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (206049 => 206050)
--- branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-09-16 21:39:28 UTC (rev 206049)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2016-09-16 21:42:58 UTC (rev 206050)
@@ -34,6 +34,7 @@
1A9E52C913E65EF4006917F5 /* 18-characters.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C045F9461385C2F800C0F3CD /* 18-characters.html */; };
1ADBEFE3130C6AA100D61D19 /* simple-accelerated-compositing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1ADBEFBC130C6A0100D61D19 /* simple-accelerated-compositing.html */; };
1AEDE22613E5E7E700E62FE8 /* InjectedBundleControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AEDE22413E5E7A000E62FE8 /* InjectedBundleControllerMac.mm */; };
+ 1AF7B21F1D6CD14D008C126C /* EnumTraits.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AF7B21D1D6CD12E008C126C /* EnumTraits.cpp */; };
1C2B81801C891E7C00A5529F /* CancelFontSubresource.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C2B817E1C891E4200A5529F /* CancelFontSubresource.mm */; };
1C2B81831C891F0900A5529F /* CancelFontSubresourcePlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C2B81811C891EFA00A5529F /* CancelFontSubresourcePlugIn.mm */; };
1C2B81861C89259D00A5529F /* webfont.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1C2B81841C8924A200A5529F /* webfont.html */; };
@@ -689,6 +690,7 @@
1AE72F47173EB214006362F0 /* TerminateTwice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TerminateTwice.cpp; sourceTree = "<group>"; };
1AEDE22413E5E7A000E62FE8 /* InjectedBundleControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InjectedBundleControllerMac.mm; sourceTree = "<group>"; };
1AEF994817A09F5300998EF0 /* GetPIDAfterAbortedProcessLaunch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetPIDAfterAbortedProcessLaunch.cpp; sourceTree = "<group>"; };
+ 1AF7B21D1D6CD12E008C126C /* EnumTraits.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = EnumTraits.cpp; sourceTree = "<group>"; };
1AFDE6541953B2C000C48FFA /* Optional.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Optional.cpp; sourceTree = "<group>"; };
1C2B817E1C891E4200A5529F /* CancelFontSubresource.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CancelFontSubresource.mm; sourceTree = "<group>"; };
1C2B81811C891EFA00A5529F /* CancelFontSubresourcePlugIn.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CancelFontSubresourcePlugIn.mm; sourceTree = "<group>"; };
@@ -1643,6 +1645,7 @@
51714EB91D087416004723C4 /* CrossThreadTask.cpp */,
7AA021BA1AB09EA70052953F /* DateMath.cpp */,
E4A757D3178AEA5B00B5D7A4 /* Deque.cpp */,
+ 1AF7B21D1D6CD12E008C126C /* EnumTraits.cpp */,
7A38D7E51C752D5F004F157D /* HashCountedSet.cpp */,
0BCD833414857CE400EA2003 /* HashMap.cpp */,
26B2DFF815BDE599004F691D /* HashSet.cpp */,
@@ -2133,6 +2136,7 @@
7C83DEE01D0A590C00FEBCF3 /* IntegerToStringConversion.cpp in Sources */,
7C83DEE81D0A590C00FEBCF3 /* ListHashSet.cpp in Sources */,
7C83DEED1D0A590C00FEBCF3 /* MathExtras.cpp in Sources */,
+ 1AF7B21F1D6CD14D008C126C /* EnumTraits.cpp in Sources */,
7C83DEEF1D0A590C00FEBCF3 /* MD5.cpp in Sources */,
7C83DEF11D0A590C00FEBCF3 /* MediaTime.cpp in Sources */,
7C83DEF61D0A590C00FEBCF3 /* MetaAllocator.cpp in Sources */,
Added: branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WTF/EnumTraits.cpp (0 => 206050)
--- branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WTF/EnumTraits.cpp (rev 0)
+++ branches/safari-602-branch/Tools/TestWebKitAPI/Tests/WTF/EnumTraits.cpp 2016-09-16 21:42:58 UTC (rev 206050)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include <wtf/EnumTraits.h>
+
+enum class TestEnum {
+ A,
+ B,
+ C,
+};
+
+namespace WTF {
+template<> struct EnumTraits<TestEnum> {
+ using values = EnumValues<TestEnum, TestEnum::A, TestEnum::B, TestEnum::C>;
+};
+}
+
+namespace TestWebKitAPI {
+
+static_assert(WTF::isValidEnum<TestEnum>(0), "");
+static_assert(!WTF::isValidEnum<TestEnum>(-1), "");
+static_assert(!WTF::isValidEnum<TestEnum>(3), "");
+
+TEST(WTF_EnumTraits, IsValidEnum)
+{
+ EXPECT_TRUE(isValidEnum<TestEnum>(0));
+ EXPECT_FALSE(isValidEnum<TestEnum>(-1));
+ EXPECT_FALSE(isValidEnum<TestEnum>(3));
+}
+
+}