2  * Copyright (C) 2014 Apple Inc. All rights reserved. 
   4  * Redistribution and use in source and binary forms, with or without 
   5  * modification, are permitted provided that the following conditions 
   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. 
  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. 
  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 
  31 #include "generate-enum-encoding-helpers.json-TestReplayInputs.h" 
  33 #if ENABLE(WEB_REPLAY) 
  34 #include "InternalNamespaceImplIncludeDummy.h" 
  35 #include "NondeterministicInput.h" 
  36 #include "PlatformMouseEvent.h" 
  37 #include <platform/ExternalNamespaceImplIncludeDummy.h> 
  40 SavedMouseButton::SavedMouseButton(MouseButton button
) 
  41     : NondeterministicInput
<SavedMouseButton
>() 
  46 SavedMouseButton::~SavedMouseButton() 
  52 const String
& InputTraits
<Test::SavedMouseButton
>::type() 
  54     static NeverDestroyed
<const String
> type(ASCIILiteral("SavedMouseButton")); 
  58 void InputTraits
<Test::SavedMouseButton
>::encode(EncodedValue
& encodedValue
, const Test::SavedMouseButton
& input
) 
  60     encodedValue
.put
<Test::MouseButton
>(ASCIILiteral("button"), input
.button()); 
  63 bool InputTraits
<Test::SavedMouseButton
>::decode(EncodedValue
& encodedValue
, std::unique_ptr
<Test::SavedMouseButton
>& input
) 
  65     Test::MouseButton button
; 
  66     if (!encodedValue
.get
<Test::MouseButton
>(ASCIILiteral("button"), button
)) 
  69     input 
= std::make_unique
<Test::SavedMouseButton
>(button
); 
  72 EncodedValue EncodingTraits
<Test::InputQueue
>::encodeValue(const Test::InputQueue
& enumValue
) 
  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"); 
  78     default: ASSERT_NOT_REACHED(); return EncodedValue::createString("Error!"); 
  82 bool EncodingTraits
<Test::InputQueue
>::decodeValue(EncodedValue
& encodedValue
, Test::InputQueue
& enumValue
) 
  84     String enumString 
= encodedValue
.convertTo
<String
>(); 
  85     if (enumString 
== "EventLoopInput") { 
  86         enumValue 
= Test::InputQueue::EventLoopInput
; 
  89     if (enumString 
== "LoaderMemoizedData") { 
  90         enumValue 
= Test::InputQueue::LoaderMemoizedData
; 
  93     if (enumString 
== "ScriptMemoizedData") { 
  94         enumValue 
= Test::InputQueue::ScriptMemoizedData
; 
 100 EncodedValue EncodingTraits
<Test::MouseButton
>::encodeValue(const Test::MouseButton
& enumValue
) 
 102     EncodedValue encodedValue 
= EncodedValue::createArray(); 
 103     if (enumValue 
& Test::NoButton
) { 
 104         encodedValue
.append
<String
>(ASCIILiteral("NoButton")); 
 105         if (enumValue 
== Test::NoButton
) 
 108     if (enumValue 
& Test::LeftButton
) { 
 109         encodedValue
.append
<String
>(ASCIILiteral("LeftButton")); 
 110         if (enumValue 
== Test::LeftButton
) 
 113     if (enumValue 
& Test::MiddleButton
) { 
 114         encodedValue
.append
<String
>(ASCIILiteral("MiddleButton")); 
 115         if (enumValue 
== Test::MiddleButton
) 
 118     if (enumValue 
& Test::RightButton
) { 
 119         encodedValue
.append
<String
>(ASCIILiteral("RightButton")); 
 120         if (enumValue 
== Test::RightButton
) 
 126 bool EncodingTraits
<Test::MouseButton
>::decodeValue(EncodedValue
& encodedValue
, Test::MouseButton
& enumValue
) 
 128     Vector
<String
> enumStrings
; 
 129     if (!EncodingTraits
<Vector
<String
>>::decodeValue(encodedValue
, enumStrings
)) 
 132     for (const String
& enumString 
: enumStrings
) { 
 133         if (enumString 
== "NoButton") 
 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
); 
 146 EncodedValue EncodingTraits
<Test::PlatformEvent::Type
>::encodeValue(const Test::PlatformEvent::Type
& enumValue
) 
 148     EncodedValue encodedValue 
= EncodedValue::createArray(); 
 149     if (enumValue 
& Test::PlatformEvent::Mouse
) { 
 150         encodedValue
.append
<String
>(ASCIILiteral("Mouse")); 
 151         if (enumValue 
== Test::PlatformEvent::Mouse
) 
 154     if (enumValue 
& Test::PlatformEvent::Key
) { 
 155         encodedValue
.append
<String
>(ASCIILiteral("Key")); 
 156         if (enumValue 
== Test::PlatformEvent::Key
) 
 159     if (enumValue 
& Test::PlatformEvent::Touch
) { 
 160         encodedValue
.append
<String
>(ASCIILiteral("Touch")); 
 161         if (enumValue 
== Test::PlatformEvent::Touch
) 
 164     if (enumValue 
& Test::PlatformEvent::Wheel
) { 
 165         encodedValue
.append
<String
>(ASCIILiteral("Wheel")); 
 166         if (enumValue 
== Test::PlatformEvent::Wheel
) 
 172 bool EncodingTraits
<Test::PlatformEvent::Type
>::decodeValue(EncodedValue
& encodedValue
, Test::PlatformEvent::Type
& enumValue
) 
 174     Vector
<String
> enumStrings
; 
 175     if (!EncodingTraits
<Vector
<String
>>::decodeValue(encodedValue
, enumStrings
)) 
 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
); 
 193 #endif // ENABLE(WEB_REPLAY)