]>
Commit | Line | Data |
---|---|---|
81345200 A |
1 | /* |
2 | * Copyright (C) 2014 Apple Inc. All rights reserved. | |
3 | * | |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions | |
6 | * are met: | |
7 | * | |
8 | * 1. Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * 2. Redistributions in binary form must reproduce the above copyright | |
11 | * notice, this list of conditions and the following disclaimer in the | |
12 | * documentation and/or other materials provided with the distribution. | |
13 | * | |
14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | |
15 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
16 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | |
17 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
18 | * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
19 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
20 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
25 | */ | |
26 | ||
27 | // DO NOT EDIT THIS FILE. It is automatically generated from generate-enum-encoding-helpers.json | |
28 | // by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py | |
29 | ||
30 | #include "config.h" | |
31 | #include "generate-enum-encoding-helpers.json-TestReplayInputs.h" | |
32 | ||
33 | #if ENABLE(WEB_REPLAY) | |
34 | #include "InternalNamespaceImplIncludeDummy.h" | |
ed1e77d3 A |
35 | #include "NondeterministicInput.h" |
36 | #include "PlatformMouseEvent.h" | |
81345200 | 37 | #include <platform/ExternalNamespaceImplIncludeDummy.h> |
81345200 A |
38 | |
39 | namespace Test { | |
40 | SavedMouseButton::SavedMouseButton(MouseButton button) | |
41 | : NondeterministicInput<SavedMouseButton>() | |
42 | , m_button(button) | |
43 | { | |
44 | } | |
45 | ||
46 | SavedMouseButton::~SavedMouseButton() | |
47 | { | |
48 | } | |
49 | } // namespace Test | |
50 | ||
51 | namespace JSC { | |
ed1e77d3 | 52 | const String& InputTraits<Test::SavedMouseButton>::type() |
81345200 | 53 | { |
ed1e77d3 | 54 | static NeverDestroyed<const String> type(ASCIILiteral("SavedMouseButton")); |
81345200 A |
55 | return type; |
56 | } | |
57 | ||
58 | void InputTraits<Test::SavedMouseButton>::encode(EncodedValue& encodedValue, const Test::SavedMouseButton& input) | |
59 | { | |
ed1e77d3 | 60 | encodedValue.put<Test::MouseButton>(ASCIILiteral("button"), input.button()); |
81345200 A |
61 | } |
62 | ||
63 | bool InputTraits<Test::SavedMouseButton>::decode(EncodedValue& encodedValue, std::unique_ptr<Test::SavedMouseButton>& input) | |
64 | { | |
ed1e77d3 A |
65 | Test::MouseButton button; |
66 | if (!encodedValue.get<Test::MouseButton>(ASCIILiteral("button"), button)) | |
81345200 A |
67 | return false; |
68 | ||
69 | input = std::make_unique<Test::SavedMouseButton>(button); | |
70 | return true; | |
71 | } | |
ed1e77d3 | 72 | EncodedValue EncodingTraits<Test::InputQueue>::encodeValue(const Test::InputQueue& enumValue) |
81345200 A |
73 | { |
74 | switch (enumValue) { | |
ed1e77d3 A |
75 | case Test::InputQueue::EventLoopInput: return EncodedValue::createString("EventLoopInput"); |
76 | case Test::InputQueue::LoaderMemoizedData: return EncodedValue::createString("LoaderMemoizedData"); | |
77 | case Test::InputQueue::ScriptMemoizedData: return EncodedValue::createString("ScriptMemoizedData"); | |
81345200 A |
78 | default: ASSERT_NOT_REACHED(); return EncodedValue::createString("Error!"); |
79 | } | |
80 | } | |
81 | ||
ed1e77d3 | 82 | bool EncodingTraits<Test::InputQueue>::decodeValue(EncodedValue& encodedValue, Test::InputQueue& enumValue) |
81345200 A |
83 | { |
84 | String enumString = encodedValue.convertTo<String>(); | |
85 | if (enumString == "EventLoopInput") { | |
ed1e77d3 | 86 | enumValue = Test::InputQueue::EventLoopInput; |
81345200 A |
87 | return true; |
88 | } | |
89 | if (enumString == "LoaderMemoizedData") { | |
ed1e77d3 | 90 | enumValue = Test::InputQueue::LoaderMemoizedData; |
81345200 A |
91 | return true; |
92 | } | |
93 | if (enumString == "ScriptMemoizedData") { | |
ed1e77d3 | 94 | enumValue = Test::InputQueue::ScriptMemoizedData; |
81345200 A |
95 | return true; |
96 | } | |
97 | return false; | |
98 | } | |
99 | ||
ed1e77d3 | 100 | EncodedValue EncodingTraits<Test::MouseButton>::encodeValue(const Test::MouseButton& enumValue) |
81345200 A |
101 | { |
102 | EncodedValue encodedValue = EncodedValue::createArray(); | |
ed1e77d3 | 103 | if (enumValue & Test::NoButton) { |
81345200 | 104 | encodedValue.append<String>(ASCIILiteral("NoButton")); |
ed1e77d3 | 105 | if (enumValue == Test::NoButton) |
81345200 A |
106 | return encodedValue; |
107 | } | |
ed1e77d3 | 108 | if (enumValue & Test::LeftButton) { |
81345200 | 109 | encodedValue.append<String>(ASCIILiteral("LeftButton")); |
ed1e77d3 | 110 | if (enumValue == Test::LeftButton) |
81345200 A |
111 | return encodedValue; |
112 | } | |
ed1e77d3 | 113 | if (enumValue & Test::MiddleButton) { |
81345200 | 114 | encodedValue.append<String>(ASCIILiteral("MiddleButton")); |
ed1e77d3 | 115 | if (enumValue == Test::MiddleButton) |
81345200 A |
116 | return encodedValue; |
117 | } | |
ed1e77d3 | 118 | if (enumValue & Test::RightButton) { |
81345200 | 119 | encodedValue.append<String>(ASCIILiteral("RightButton")); |
ed1e77d3 | 120 | if (enumValue == Test::RightButton) |
81345200 A |
121 | return encodedValue; |
122 | } | |
123 | return encodedValue; | |
124 | } | |
125 | ||
ed1e77d3 | 126 | bool EncodingTraits<Test::MouseButton>::decodeValue(EncodedValue& encodedValue, Test::MouseButton& enumValue) |
81345200 A |
127 | { |
128 | Vector<String> enumStrings; | |
129 | if (!EncodingTraits<Vector<String>>::decodeValue(encodedValue, enumStrings)) | |
130 | return false; | |
131 | ||
ed1e77d3 | 132 | for (const String& enumString : enumStrings) { |
81345200 | 133 | if (enumString == "NoButton") |
ed1e77d3 A |
134 | enumValue = static_cast<Test::MouseButton>(enumValue | Test::NoButton); |
135 | else if (enumString == "LeftButton") | |
136 | enumValue = static_cast<Test::MouseButton>(enumValue | Test::LeftButton); | |
137 | else if (enumString == "MiddleButton") | |
138 | enumValue = static_cast<Test::MouseButton>(enumValue | Test::MiddleButton); | |
139 | else if (enumString == "RightButton") | |
140 | enumValue = static_cast<Test::MouseButton>(enumValue | Test::RightButton); | |
141 | } | |
142 | ||
143 | return true; | |
144 | } | |
145 | ||
146 | EncodedValue EncodingTraits<Test::PlatformEvent::Type>::encodeValue(const Test::PlatformEvent::Type& enumValue) | |
147 | { | |
148 | EncodedValue encodedValue = EncodedValue::createArray(); | |
149 | if (enumValue & Test::PlatformEvent::Mouse) { | |
150 | encodedValue.append<String>(ASCIILiteral("Mouse")); | |
151 | if (enumValue == Test::PlatformEvent::Mouse) | |
152 | return encodedValue; | |
153 | } | |
154 | if (enumValue & Test::PlatformEvent::Key) { | |
155 | encodedValue.append<String>(ASCIILiteral("Key")); | |
156 | if (enumValue == Test::PlatformEvent::Key) | |
157 | return encodedValue; | |
158 | } | |
159 | if (enumValue & Test::PlatformEvent::Touch) { | |
160 | encodedValue.append<String>(ASCIILiteral("Touch")); | |
161 | if (enumValue == Test::PlatformEvent::Touch) | |
162 | return encodedValue; | |
163 | } | |
164 | if (enumValue & Test::PlatformEvent::Wheel) { | |
165 | encodedValue.append<String>(ASCIILiteral("Wheel")); | |
166 | if (enumValue == Test::PlatformEvent::Wheel) | |
167 | return encodedValue; | |
168 | } | |
169 | return encodedValue; | |
170 | } | |
171 | ||
172 | bool EncodingTraits<Test::PlatformEvent::Type>::decodeValue(EncodedValue& encodedValue, Test::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<Test::PlatformEvent::Type>(enumValue | Test::PlatformEvent::Mouse); | |
181 | else if (enumString == "Key") | |
182 | enumValue = static_cast<Test::PlatformEvent::Type>(enumValue | Test::PlatformEvent::Key); | |
183 | else if (enumString == "Touch") | |
184 | enumValue = static_cast<Test::PlatformEvent::Type>(enumValue | Test::PlatformEvent::Touch); | |
185 | else if (enumString == "Wheel") | |
186 | enumValue = static_cast<Test::PlatformEvent::Type>(enumValue | Test::PlatformEvent::Wheel); | |
81345200 A |
187 | } |
188 | ||
189 | return true; | |
190 | } | |
191 | } // namespace JSC | |
192 | ||
193 | #endif // ENABLE(WEB_REPLAY) |