Changeset 174863 in webkit for trunk/Source/JavaScriptCore/replay
- Timestamp:
- Oct 18, 2014, 11:13:05 AM (11 years ago)
- Location:
- trunk/Source/JavaScriptCore/replay/scripts
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py
r174113 r174863 455 455 raise ParseException("Malformed specification: enum %s does not supply a list of values" % type_name) 456 456 457 if _type.is_enum() and "storage" not in json:458 raise ParseException("Could not parse enum %s: C-style enums must alsospecify their storage type so they can be forward declared." % type_name)457 if _type.is_enum() and enclosing_class is None and type_storage is None: 458 raise ParseException("Could not parse enum %s: C-style enums not enclosed by a class must specify their storage type so they can be forward declared." % type_name) 459 459 460 460 self.types.append(_type) … … 836 836 # Generate body for decode. 837 837 decodeLines = [] 838 for _value in _type.values: 838 for i, _value in enumerate(_type.values): 839 839 840 template_arguments = { 841 'branchKeyword': "else if" if i > 0 else "if", 840 842 'enumStringValue': _value, 841 843 'qualifiedEnumValue': "%s%s" % (enum_prefix, _value), … … 846 848 for guard, guard_values in _type.guard_values_map.iteritems(): 847 849 guardedLines = [] 848 for guard_value in guard_values:850 for i, guard_value in enumerate(guard_values): 849 851 template_arguments = { 852 'branchKeyword': "else if" if i > 0 else "if", 850 853 'enumStringValue': guard_value, 851 854 'qualifiedEnumValue': "%s%s" % (enum_prefix, guard_value), -
trunk/Source/JavaScriptCore/replay/scripts/CodeGeneratorReplayInputsTemplates.py
r174113 r174863 210 210 return false; 211 211 212 for ( StringenumString : enumStrings) {212 for (const String& enumString : enumStrings) { 213 213 ${decodeCases} 214 214 } … … 225 225 226 226 EnumDecodeCase = ( 227 """ if(enumString == "${enumStringValue}")227 """ ${branchKeyword} (enumString == "${enumStringValue}") 228 228 enumValue = static_cast<${qualifiedEnumName}>(enumValue | ${qualifiedEnumValue});""") 229 229 -
trunk/Source/JavaScriptCore/replay/scripts/tests/expected/fail-on-c-style-enum-no-storage.json-error
r163918 r174863 1 ERROR: Could not parse enum MouseButton: C-style enums must alsospecify their storage type so they can be forward declared.1 ERROR: Could not parse enum MouseButton: C-style enums not enclosed by a class must specify their storage type so they can be forward declared. -
trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers-with-guarded-values.json-TestReplayInputs.cpp
r174113 r174863 120 120 return false; 121 121 122 for ( StringenumString : enumStrings) {122 for (const String& enumString : enumStrings) { 123 123 if (enumString == "NoButton") 124 124 enumValue = static_cast<WebCore::MouseButton>(enumValue | WebCore::NoButton); 125 if (enumString == "LeftButton")125 else if (enumString == "LeftButton") 126 126 enumValue = static_cast<WebCore::MouseButton>(enumValue | WebCore::LeftButton); 127 if (enumString == "MiddleButton")127 else if (enumString == "MiddleButton") 128 128 enumValue = static_cast<WebCore::MouseButton>(enumValue | WebCore::MiddleButton); 129 if (enumString == "RightButton")129 else if (enumString == "RightButton") 130 130 enumValue = static_cast<WebCore::MouseButton>(enumValue | WebCore::RightButton); 131 131 #if ENABLE(SIDE_BUTTONS) 132 132 if (enumString == "LeftSideButton") 133 133 enumValue = static_cast<WebCore::MouseButton>(enumValue | WebCore::LeftSideButton); 134 if (enumString == "RightSideButton")134 else if (enumString == "RightSideButton") 135 135 enumValue = static_cast<WebCore::MouseButton>(enumValue | WebCore::RightSideButton); 136 136 #endif // ENABLE(SIDE_BUTTONS) -
trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.cpp
r174113 r174863 130 130 return false; 131 131 132 for ( StringenumString : enumStrings) {132 for (const String& enumString : enumStrings) { 133 133 if (enumString == "NoButton") 134 134 enumValue = static_cast<WebCore::MouseButton>(enumValue | WebCore::NoButton); 135 if (enumString == "LeftButton")135 else if (enumString == "LeftButton") 136 136 enumValue = static_cast<WebCore::MouseButton>(enumValue | WebCore::LeftButton); 137 if (enumString == "MiddleButton")137 else if (enumString == "MiddleButton") 138 138 enumValue = static_cast<WebCore::MouseButton>(enumValue | WebCore::MiddleButton); 139 if (enumString == "RightButton")139 else if (enumString == "RightButton") 140 140 enumValue = static_cast<WebCore::MouseButton>(enumValue | WebCore::RightButton); 141 } 142 143 return true; 144 } 145 146 EncodedValue EncodingTraits<WebCore::PlatformEvent::Type>::encodeValue(const WebCore::PlatformEvent::Type& enumValue) 147 { 148 EncodedValue encodedValue = EncodedValue::createArray(); 149 if (enumValue & WebCore::PlatformEvent::Mouse) { 150 encodedValue.append<String>(ASCIILiteral("Mouse")); 151 if (enumValue == WebCore::PlatformEvent::Mouse) 152 return encodedValue; 153 } 154 if (enumValue & WebCore::PlatformEvent::Key) { 155 encodedValue.append<String>(ASCIILiteral("Key")); 156 if (enumValue == WebCore::PlatformEvent::Key) 157 return encodedValue; 158 } 159 if (enumValue & WebCore::PlatformEvent::Touch) { 160 encodedValue.append<String>(ASCIILiteral("Touch")); 161 if (enumValue == WebCore::PlatformEvent::Touch) 162 return encodedValue; 163 } 164 if (enumValue & WebCore::PlatformEvent::Wheel) { 165 encodedValue.append<String>(ASCIILiteral("Wheel")); 166 if (enumValue == WebCore::PlatformEvent::Wheel) 167 return encodedValue; 168 } 169 return encodedValue; 170 } 171 172 bool EncodingTraits<WebCore::PlatformEvent::Type>::decodeValue(EncodedValue& encodedValue, WebCore::PlatformEvent::Type& enumValue) 173 { 174 Vector<String> enumStrings; 175 if (!EncodingTraits<Vector<String>>::decodeValue(encodedValue, enumStrings)) 176 return false; 177 178 for (const String& enumString : enumStrings) { 179 if (enumString == "Mouse") 180 enumValue = static_cast<WebCore::PlatformEvent::Type>(enumValue | WebCore::PlatformEvent::Mouse); 181 else if (enumString == "Key") 182 enumValue = static_cast<WebCore::PlatformEvent::Type>(enumValue | WebCore::PlatformEvent::Key); 183 else if (enumString == "Touch") 184 enumValue = static_cast<WebCore::PlatformEvent::Type>(enumValue | WebCore::PlatformEvent::Touch); 185 else if (enumString == "Wheel") 186 enumValue = static_cast<WebCore::PlatformEvent::Type>(enumValue | WebCore::PlatformEvent::Wheel); 141 187 } 142 188 -
trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.h
r174113 r174863 34 34 #include "InternalNamespaceHeaderIncludeDummy.h" 35 35 #include <platform/ExternalNamespaceHeaderIncludeDummy.h> 36 #include <platform/PlatformEvent.h> 36 37 37 38 namespace WebCore { … … 69 70 static bool decodeValue(EncodedValue&, WebCore::MouseButton& value); 70 71 }; 72 73 template<> struct EncodingTraits<WebCore::PlatformEvent::Type> { 74 typedef WebCore::PlatformEvent::Type DecodedType; 75 76 static EncodedValue encodeValue(const WebCore::PlatformEvent::Type& value); 77 static bool decodeValue(EncodedValue&, WebCore::PlatformEvent::Type& value); 78 }; 71 79 } // namespace JSC 72 80 -
trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enum-with-guard.json-TestReplayInputs.cpp
r174113 r174863 87 87 return false; 88 88 89 for ( StringenumString : enumStrings) {89 for (const String& enumString : enumStrings) { 90 90 if (enumString == "PlatformWheelEventPhaseNone") 91 91 enumValue = static_cast<WebCore::PlatformWheelEventPhase>(enumValue | WebCore::PlatformWheelEventPhaseNone); -
trunk/Source/JavaScriptCore/replay/scripts/tests/expected/generate-enums-with-same-base-name.json-TestReplayInputs.cpp
r174113 r174863 108 108 return false; 109 109 110 for ( StringenumString : enumStrings) {110 for (const String& enumString : enumStrings) { 111 111 if (enumString == "Text") 112 112 enumValue = static_cast<WebCore::FormData1::Type>(enumValue | WebCore::FormData1::Text); 113 if (enumString == "Blob")113 else if (enumString == "Blob") 114 114 enumValue = static_cast<WebCore::FormData1::Type>(enumValue | WebCore::FormData1::Blob); 115 115 } … … 163 163 return false; 164 164 165 for ( StringenumString : enumStrings) {165 for (const String& enumString : enumStrings) { 166 166 if (enumString == "Mouse") 167 167 enumValue = static_cast<PlatformEvent1::Type>(enumValue | PlatformEvent1::Mouse); 168 if (enumString == "Keyboard")168 else if (enumString == "Keyboard") 169 169 enumValue = static_cast<PlatformEvent1::Type>(enumValue | PlatformEvent1::Keyboard); 170 170 } -
trunk/Source/JavaScriptCore/replay/scripts/tests/generate-enum-encoding-helpers.json
r163918 r174863 15 15 "values": ["NoButton", "LeftButton", "MiddleButton", "RightButton"], 16 16 "header": "platform/PlatformMouseEvent.h" 17 }, 18 { 19 "name": "Type", "mode": "SCALAR", 20 "flags": ["ENUM"], 21 "enclosing_class": "PlatformEvent", 22 "values": ["Mouse", "Key", "Touch", "Wheel"], 23 "header": "platform/PlatformEvent.h" 17 24 } 18 25 ]
Note:
See TracChangeset
for help on using the changeset viewer.