]> git.saurik.com Git - apple/javascriptcore.git/blob - replay/scripts/tests/expected/generate-enum-encoding-helpers.json-TestReplayInputs.cpp
JavaScriptCore-7600.1.4.9.tar.gz
[apple/javascriptcore.git] / replay / scripts / tests / expected / generate-enum-encoding-helpers.json-TestReplayInputs.cpp
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"
35 #include <platform/ExternalNamespaceImplIncludeDummy.h>
36 #include <platform/PlatformMouseEvent.h>
37 #include <replay/NondeterministicInput.h>
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 {
52 const AtomicString& InputTraits<Test::SavedMouseButton>::type()
53 {
54 static NeverDestroyed<const AtomicString> type("SavedMouseButton", AtomicString::ConstructFromLiteral);
55 return type;
56 }
57
58 void InputTraits<Test::SavedMouseButton>::encode(EncodedValue& encodedValue, const Test::SavedMouseButton& input)
59 {
60 encodedValue.put<WebCore::MouseButton>(ASCIILiteral("button"), input.button());
61 }
62
63 bool InputTraits<Test::SavedMouseButton>::decode(EncodedValue& encodedValue, std::unique_ptr<Test::SavedMouseButton>& input)
64 {
65 WebCore::MouseButton button;
66 if (!encodedValue.get<WebCore::MouseButton>(ASCIILiteral("button"), button))
67 return false;
68
69 input = std::make_unique<Test::SavedMouseButton>(button);
70 return true;
71 }
72 EncodedValue EncodingTraits<InputQueue>::encodeValue(const InputQueue& enumValue)
73 {
74 switch (enumValue) {
75 case InputQueue::EventLoopInput: return EncodedValue::createString("EventLoopInput");
76 case InputQueue::LoaderMemoizedData: return EncodedValue::createString("LoaderMemoizedData");
77 case InputQueue::ScriptMemoizedData: return EncodedValue::createString("ScriptMemoizedData");
78 default: ASSERT_NOT_REACHED(); return EncodedValue::createString("Error!");
79 }
80 }
81
82 bool EncodingTraits<InputQueue>::decodeValue(EncodedValue& encodedValue, InputQueue& enumValue)
83 {
84 String enumString = encodedValue.convertTo<String>();
85 if (enumString == "EventLoopInput") {
86 enumValue = InputQueue::EventLoopInput;
87 return true;
88 }
89 if (enumString == "LoaderMemoizedData") {
90 enumValue = InputQueue::LoaderMemoizedData;
91 return true;
92 }
93 if (enumString == "ScriptMemoizedData") {
94 enumValue = InputQueue::ScriptMemoizedData;
95 return true;
96 }
97 return false;
98 }
99
100 EncodedValue EncodingTraits<WebCore::MouseButton>::encodeValue(const WebCore::MouseButton& enumValue)
101 {
102 EncodedValue encodedValue = EncodedValue::createArray();
103 if (enumValue & WebCore::NoButton) {
104 encodedValue.append<String>(ASCIILiteral("NoButton"));
105 if (enumValue == WebCore::NoButton)
106 return encodedValue;
107 }
108 if (enumValue & WebCore::LeftButton) {
109 encodedValue.append<String>(ASCIILiteral("LeftButton"));
110 if (enumValue == WebCore::LeftButton)
111 return encodedValue;
112 }
113 if (enumValue & WebCore::MiddleButton) {
114 encodedValue.append<String>(ASCIILiteral("MiddleButton"));
115 if (enumValue == WebCore::MiddleButton)
116 return encodedValue;
117 }
118 if (enumValue & WebCore::RightButton) {
119 encodedValue.append<String>(ASCIILiteral("RightButton"));
120 if (enumValue == WebCore::RightButton)
121 return encodedValue;
122 }
123 return encodedValue;
124 }
125
126 bool EncodingTraits<WebCore::MouseButton>::decodeValue(EncodedValue& encodedValue, WebCore::MouseButton& enumValue)
127 {
128 Vector<String> enumStrings;
129 if (!EncodingTraits<Vector<String>>::decodeValue(encodedValue, enumStrings))
130 return false;
131
132 for (String enumString : enumStrings) {
133 if (enumString == "NoButton")
134 enumValue = static_cast<WebCore::MouseButton>(enumValue | WebCore::NoButton);
135 if (enumString == "LeftButton")
136 enumValue = static_cast<WebCore::MouseButton>(enumValue | WebCore::LeftButton);
137 if (enumString == "MiddleButton")
138 enumValue = static_cast<WebCore::MouseButton>(enumValue | WebCore::MiddleButton);
139 if (enumString == "RightButton")
140 enumValue = static_cast<WebCore::MouseButton>(enumValue | WebCore::RightButton);
141 }
142
143 return true;
144 }
145 } // namespace JSC
146
147 #endif // ENABLE(WEB_REPLAY)