Changeset 206050 in webkit
- Timestamp:
- Sep 16, 2016 2:42:58 PM (8 years ago)
- Location:
- branches/safari-602-branch
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-602-branch/Source/WTF/ChangeLog
r205903 r206050 1 2016-09-16 Babak Shafiei <bshafiei@apple.com> 2 3 Merge r204916. rdar://problem/27991573 4 5 2016-08-23 Anders Carlsson <andersca@apple.com> 6 7 Add enum traits and use them in the IPC::Decoder 8 https://bugs.webkit.org/show_bug.cgi?id=161103 9 10 Reviewed by Sam Weinig. 11 12 Add EnumTraits.h which provides a forward declaration for WTF::EnumTraits as well as 13 the WTF::isValidEnum function. 14 15 * WTF.xcodeproj/project.pbxproj: 16 * wtf/EnumTraits.h: Added. 17 1 18 2016-09-13 Babak Shafiei <bshafiei@apple.com> 2 19 -
branches/safari-602-branch/Source/WTF/WTF.xcodeproj/project.pbxproj
r203038 r206050 88 88 1A944F471C3D8814005BD28C /* BlockPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A944F461C3D8814005BD28C /* BlockPtr.h */; }; 89 89 1ACADD841884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1ACADD821884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm */; }; 90 1AEA88E21D6BBCF400E5AD64 /* EnumTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEA88E11D6BBCF400E5AD64 /* EnumTraits.h */; }; 90 91 1AFDE648195201C300C48FFA /* TypeCastsCF.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFDE647195201C300C48FFA /* TypeCastsCF.h */; }; 91 92 1AFDE6531953B23D00C48FFA /* Optional.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFDE6521953B23D00C48FFA /* Optional.h */; }; … … 422 423 1A944F461C3D8814005BD28C /* BlockPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlockPtr.h; sourceTree = "<group>"; }; 423 424 1ACADD821884480100D8B71D /* DeprecatedSymbolsUsedBySafari.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeprecatedSymbolsUsedBySafari.mm; sourceTree = "<group>"; }; 425 1AEA88E11D6BBCF400E5AD64 /* EnumTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EnumTraits.h; sourceTree = "<group>"; }; 424 426 1AFDE647195201C300C48FFA /* TypeCastsCF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypeCastsCF.h; sourceTree = "<group>"; }; 425 427 1AFDE6521953B23D00C48FFA /* Optional.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Optional.h; sourceTree = "<group>"; }; … … 868 870 A8A47297151A825A004123FF /* dtoa.cpp */, 869 871 A8A47298151A825A004123FF /* dtoa.h */, 872 1AEA88E11D6BBCF400E5AD64 /* EnumTraits.h */, 870 873 A8A4729F151A825A004123FF /* ExportMacros.h */, 871 874 0F885E0E1845AE9F00F1E3FA /* FastBitVector.cpp */, … … 1287 1290 A8A473D3151A825B004123FF /* HashCountedSet.h in Headers */, 1288 1291 A8A4742D151A825B004123FF /* Hasher.h in Headers */, 1292 1AEA88E21D6BBCF400E5AD64 /* EnumTraits.h in Headers */, 1289 1293 1C181C901D307AB800F5FA16 /* UTextProvider.h in Headers */, 1290 1294 A8A473D4151A825B004123FF /* HashFunctions.h in Headers */, -
branches/safari-602-branch/Source/WebKit2/ChangeLog
r206013 r206050 1 2016-09-16 Babak Shafiei <bshafiei@apple.com> 2 3 Merge r204916. rdar://problem/27991573 4 5 2016-08-23 Anders Carlsson <andersca@apple.com> 6 7 Add enum traits and use them in the IPC::Decoder 8 https://bugs.webkit.org/show_bug.cgi?id=161103 9 10 Reviewed by Sam Weinig. 11 12 * Platform/IPC/Decoder.h: 13 * Platform/IPC/Encoder.h: 14 Add new encode/decode functions. 15 16 * Shared/mac/ArgumentCodersMac.mm: 17 Change NSType to be a strongly typed enum. Use encode/decode 18 instead of encodeEnum/decodeEnum since the latter don't have the 19 enum check. 20 1 21 2016-09-16 Babak Shafiei <bshafiei@apple.com> 2 22 -
branches/safari-602-branch/Source/WebKit2/Platform/IPC/ArgumentDecoder.h
r176762 r206050 29 29 #include "ArgumentCoder.h" 30 30 #include "Attachment.h" 31 #include <wtf/EnumTraits.h> 31 32 #include <wtf/Vector.h> 32 33 … … 61 62 bool decode(double&); 62 63 64 template<typename E> 65 auto decode(E& e) -> std::enable_if_t<std::is_enum<E>::value, bool> 66 { 67 uint64_t value; 68 if (!decode(value)) 69 return false; 70 if (!isValidEnum<E>(value)) 71 return false; 72 73 return true; 74 } 75 63 76 template<typename T> bool decodeEnum(T& result) 64 77 { … … 84 97 } 85 98 86 // Generic type decode function.87 template<typename T> bool decode(T& t)99 template<typename T> 100 auto decode(T& t) -> std::enable_if_t<!std::is_enum<T>::value, bool> 88 101 { 89 102 return ArgumentCoder<T>::decode(*this, t); -
branches/safari-602-branch/Source/WebKit2/Platform/IPC/ArgumentEncoder.h
r183189 r206050 29 29 #include "ArgumentCoder.h" 30 30 #include "Attachment.h" 31 #include <wtf/EnumTraits.h> 31 32 #include <wtf/Vector.h> 32 33 33 34 namespace IPC { 34 35 35 class ArgumentEncoder;36 36 class DataReference; 37 37 … … 52 52 } 53 53 54 template<typename T> void encode(T&& t) 54 template<typename T> 55 auto encode(T&& t) -> std::enable_if_t<!std::is_enum<typename std::remove_const_t<std::remove_reference_t<T>>>::value> 55 56 { 56 57 ArgumentCoder<typename std::remove_const<typename std::remove_reference<T>::type>::type>::encode(*this, std::forward<T>(t)); … … 81 82 void encode(double); 82 83 84 template<typename E> 85 auto encode(E value) -> std::enable_if_t<std::is_enum<E>::value> 86 { 87 static_assert(sizeof(E) <= sizeof(uint64_t), "Enum type must not be larger than 64 bits."); 88 89 ASSERT(isValidEnum<E>(static_cast<uint64_t>(value))); 90 encode(static_cast<uint64_t>(value)); 91 } 92 83 93 uint8_t* grow(unsigned alignment, size_t size); 84 94 -
branches/safari-602-branch/Source/WebKit2/Shared/mac/ArgumentCodersMac.mm
r202889 r206050 42 42 namespace IPC { 43 43 44 enum NSType {45 NSAttributedStringType,46 #if USE(APPKIT) 47 NSColorType,48 #endif 49 NSDictionaryType,50 NSArrayType,51 #if USE(APPKIT) 52 NSFontType,53 #endif 54 N SNumberType,55 NSStringType,56 NSDateType,57 NSDataType,58 NSURLType,44 enum class NSType { 45 AttributedString, 46 #if USE(APPKIT) 47 Color, 48 #endif 49 Dictionary, 50 Array, 51 #if USE(APPKIT) 52 Font, 53 #endif 54 Number, 55 String, 56 Date, 57 Data, 58 URL, 59 59 Unknown, 60 60 }; 61 61 62 } 63 64 namespace IPC { 62 65 static NSType typeFromObject(id object) 63 66 { … … 65 68 66 69 if ([object isKindOfClass:[NSAttributedString class]]) 67 return NS AttributedStringType;70 return NSType::AttributedString; 68 71 #if USE(APPKIT) 69 72 if ([object isKindOfClass:[NSColor class]]) 70 return NS ColorType;73 return NSType::Color; 71 74 #endif 72 75 if ([object isKindOfClass:[NSDictionary class]]) 73 return NS DictionaryType;76 return NSType::Dictionary; 74 77 #if USE(APPKIT) 75 78 if ([object isKindOfClass:[NSFont class]]) 76 return NS FontType;79 return NSType::Font; 77 80 #endif 78 81 if ([object isKindOfClass:[NSNumber class]]) 79 return NS NumberType;82 return NSType::Number; 80 83 if ([object isKindOfClass:[NSString class]]) 81 return NS StringType;84 return NSType::String; 82 85 if ([object isKindOfClass:[NSArray class]]) 83 return NS ArrayType;86 return NSType::Array; 84 87 if ([object isKindOfClass:[NSDate class]]) 85 return NS DateType;88 return NSType::Date; 86 89 if ([object isKindOfClass:[NSData class]]) 87 return NS DataType;90 return NSType::Data; 88 91 if ([object isKindOfClass:[NSURL class]]) 89 return NS URLType;92 return NSType::URL; 90 93 91 94 ASSERT_NOT_REACHED(); 92 return Unknown;95 return NSType::Unknown; 93 96 } 94 97 … … 96 99 { 97 100 NSType type = typeFromObject(object); 98 encoder .encodeEnum(type);101 encoder << type; 99 102 100 103 switch (type) { 101 case NS AttributedStringType:104 case NSType::AttributedString: 102 105 encode(encoder, static_cast<NSAttributedString *>(object)); 103 106 return; 104 107 #if USE(APPKIT) 105 case NS ColorType:108 case NSType::Color: 106 109 encode(encoder, static_cast<NSColor *>(object)); 107 110 return; 108 111 #endif 109 case NS DictionaryType:112 case NSType::Dictionary: 110 113 encode(encoder, static_cast<NSDictionary *>(object)); 111 114 return; 112 115 #if USE(APPKIT) 113 case NS FontType:116 case NSType::Font: 114 117 encode(encoder, static_cast<NSFont *>(object)); 115 118 return; 116 119 #endif 117 case NS NumberType:120 case NSType::Number: 118 121 encode(encoder, static_cast<NSNumber *>(object)); 119 122 return; 120 case NS StringType:123 case NSType::String: 121 124 encode(encoder, static_cast<NSString *>(object)); 122 125 return; 123 case NS ArrayType:126 case NSType::Array: 124 127 encode(encoder, static_cast<NSArray *>(object)); 125 128 return; 126 case NS DateType:129 case NSType::Date: 127 130 encode(encoder, static_cast<NSDate *>(object)); 128 131 return; 129 case NS DataType:132 case NSType::Data: 130 133 encode(encoder, static_cast<NSData *>(object)); 131 134 return; 132 case NS URLType:135 case NSType::URL: 133 136 encode(encoder, static_cast<NSURL *>(object)); 134 137 return; 135 case Unknown:138 case NSType::Unknown: 136 139 break; 137 140 } … … 147 150 148 151 switch (type) { 149 case NS AttributedStringType: {152 case NSType::AttributedString: { 150 153 RetainPtr<NSAttributedString> string; 151 154 if (!decode(decoder, string)) … … 155 158 } 156 159 #if USE(APPKIT) 157 case NS ColorType: {160 case NSType::Color: { 158 161 RetainPtr<NSColor> color; 159 162 if (!decode(decoder, color)) … … 163 166 } 164 167 #endif 165 case NS DictionaryType: {168 case NSType::Dictionary: { 166 169 RetainPtr<NSDictionary> dictionary; 167 170 if (!decode(decoder, dictionary)) … … 171 174 } 172 175 #if USE(APPKIT) 173 case NS FontType: {176 case NSType::Font: { 174 177 RetainPtr<NSFont> font; 175 178 if (!decode(decoder, font)) … … 179 182 } 180 183 #endif 181 case NS NumberType: {184 case NSType::Number: { 182 185 RetainPtr<NSNumber> number; 183 186 if (!decode(decoder, number)) … … 186 189 return true; 187 190 } 188 case NS StringType: {191 case NSType::String: { 189 192 RetainPtr<NSString> string; 190 193 if (!decode(decoder, string)) … … 193 196 return true; 194 197 } 195 case NS ArrayType: {198 case NSType::Array: { 196 199 RetainPtr<NSArray> array; 197 200 if (!decode(decoder, array)) … … 200 203 return true; 201 204 } 202 case NS DateType: {205 case NSType::Date: { 203 206 RetainPtr<NSDate> date; 204 207 if (!decode(decoder, date)) … … 207 210 return true; 208 211 } 209 case NS DataType: {212 case NSType::Data: { 210 213 RetainPtr<NSData> data; 211 214 if (!decode(decoder, data)) … … 214 217 return true; 215 218 } 216 case NS URLType: {219 case NSType::URL: { 217 220 RetainPtr<NSURL> URL; 218 221 if (!decode(decoder, URL)) … … 221 224 return true; 222 225 } 223 case Unknown:226 case NSType::Unknown: 224 227 ASSERT_NOT_REACHED(); 225 228 return false; … … 370 373 371 374 // Ignore values we don't recognize. 372 if (typeFromObject(value) == Unknown)375 if (typeFromObject(value) == NSType::Unknown) 373 376 continue; 374 377 … … 461 464 462 465 // Ignore values we don't recognize. 463 if (typeFromObject(value) == Unknown)466 if (typeFromObject(value) == NSType::Unknown) 464 467 continue; 465 468 … … 535 538 536 539 } // namespace IPC 540 541 namespace WTF { 542 template<> struct EnumTraits<IPC::NSType> { 543 using values = EnumValues< 544 IPC::NSType, 545 IPC::NSType::AttributedString, 546 #if USE(APPKIT) 547 IPC::NSType::Color, 548 #endif 549 IPC::NSType::Dictionary, 550 IPC::NSType::Array, 551 #if USE(APPKIT) 552 IPC::NSType::Font, 553 #endif 554 IPC::NSType::Number, 555 IPC::NSType::String, 556 IPC::NSType::Date, 557 IPC::NSType::Data, 558 IPC::NSType::URL, 559 IPC::NSType::Unknown 560 >; 561 }; 562 } -
branches/safari-602-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp
r205952 r206050 2346 2346 // 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. 2347 2347 // See also <https://bugs.webkit.org/show_bug.cgi?id=136012>. 2348 ASSERT(m_process->state() != WebProcessProxy::State::Launching);2348 // ASSERT(m_process->state() != WebProcessProxy::State::Launching); 2349 2349 2350 2350 // NOTE: This uses a check of m_isValid rather than calling isValid() since -
branches/safari-602-branch/Tools/ChangeLog
r205952 r206050 1 2016-09-16 Babak Shafiei <bshafiei@apple.com> 2 3 Merge r204916. rdar://problem/27991573 4 5 2016-08-23 Anders Carlsson <andersca@apple.com> 6 7 Add enum traits and use them in the IPC::Decoder 8 https://bugs.webkit.org/show_bug.cgi?id=161103 9 10 Reviewed by Sam Weinig. 11 12 Add API test. 13 14 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 15 * TestWebKitAPI/Tests/WTF/EnumTraits.cpp: Added. 16 (TestWebKitAPI::TEST): 17 1 18 2016-09-14 Babak Shafiei <bshafiei@apple.com> 2 19 -
branches/safari-602-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r205952 r206050 35 35 1ADBEFE3130C6AA100D61D19 /* simple-accelerated-compositing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1ADBEFBC130C6A0100D61D19 /* simple-accelerated-compositing.html */; }; 36 36 1AEDE22613E5E7E700E62FE8 /* InjectedBundleControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AEDE22413E5E7A000E62FE8 /* InjectedBundleControllerMac.mm */; }; 37 1AF7B21F1D6CD14D008C126C /* EnumTraits.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AF7B21D1D6CD12E008C126C /* EnumTraits.cpp */; }; 37 38 1C2B81801C891E7C00A5529F /* CancelFontSubresource.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C2B817E1C891E4200A5529F /* CancelFontSubresource.mm */; }; 38 39 1C2B81831C891F0900A5529F /* CancelFontSubresourcePlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C2B81811C891EFA00A5529F /* CancelFontSubresourcePlugIn.mm */; }; … … 690 691 1AEDE22413E5E7A000E62FE8 /* InjectedBundleControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = InjectedBundleControllerMac.mm; sourceTree = "<group>"; }; 691 692 1AEF994817A09F5300998EF0 /* GetPIDAfterAbortedProcessLaunch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GetPIDAfterAbortedProcessLaunch.cpp; sourceTree = "<group>"; }; 693 1AF7B21D1D6CD12E008C126C /* EnumTraits.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = EnumTraits.cpp; sourceTree = "<group>"; }; 692 694 1AFDE6541953B2C000C48FFA /* Optional.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Optional.cpp; sourceTree = "<group>"; }; 693 695 1C2B817E1C891E4200A5529F /* CancelFontSubresource.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CancelFontSubresource.mm; sourceTree = "<group>"; }; … … 1644 1646 7AA021BA1AB09EA70052953F /* DateMath.cpp */, 1645 1647 E4A757D3178AEA5B00B5D7A4 /* Deque.cpp */, 1648 1AF7B21D1D6CD12E008C126C /* EnumTraits.cpp */, 1646 1649 7A38D7E51C752D5F004F157D /* HashCountedSet.cpp */, 1647 1650 0BCD833414857CE400EA2003 /* HashMap.cpp */, … … 2134 2137 7C83DEE81D0A590C00FEBCF3 /* ListHashSet.cpp in Sources */, 2135 2138 7C83DEED1D0A590C00FEBCF3 /* MathExtras.cpp in Sources */, 2139 1AF7B21F1D6CD14D008C126C /* EnumTraits.cpp in Sources */, 2136 2140 7C83DEEF1D0A590C00FEBCF3 /* MD5.cpp in Sources */, 2137 2141 7C83DEF11D0A590C00FEBCF3 /* MediaTime.cpp in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.