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-enums-with-same-base-name.json
28 // by the script: JavaScriptCore/replay/scripts/CodeGeneratorReplayInputs.py
31 #include "generate-enums-with-same-base-name.json-TestReplayInputs.h"
33 #if ENABLE(WEB_REPLAY)
34 #include "InternalNamespaceImplIncludeDummy.h"
35 #include <platform/ExternalNamespaceImplIncludeDummy.h>
38 FormCombo::FormCombo(PlatformEvent1::Type eventType1
, PlatformEvent2::Type eventType2
, FormData1::Type formType1
, FormData2::Type formType2
)
39 : NondeterministicInput
<FormCombo
>()
40 , m_eventType1(eventType1
)
41 , m_eventType2(eventType2
)
42 , m_formType1(formType1
)
43 , m_formType2(formType2
)
47 FormCombo::~FormCombo()
53 const String
& InputTraits
<Test::FormCombo
>::type()
55 static NeverDestroyed
<const String
> type(ASCIILiteral("FormCombo"));
59 void InputTraits
<Test::FormCombo
>::encode(EncodedValue
& encodedValue
, const Test::FormCombo
& input
)
61 encodedValue
.put
<PlatformEvent1::Type
>(ASCIILiteral("eventType1"), input
.eventType1());
62 encodedValue
.put
<PlatformEvent2::Type
>(ASCIILiteral("eventType2"), input
.eventType2());
63 encodedValue
.put
<Test::FormData1::Type
>(ASCIILiteral("formType1"), input
.formType1());
64 encodedValue
.put
<Test::FormData2::Type
>(ASCIILiteral("formType2"), input
.formType2());
67 bool InputTraits
<Test::FormCombo
>::decode(EncodedValue
& encodedValue
, std::unique_ptr
<Test::FormCombo
>& input
)
69 PlatformEvent1::Type eventType1
;
70 if (!encodedValue
.get
<PlatformEvent1::Type
>(ASCIILiteral("eventType1"), eventType1
))
73 PlatformEvent2::Type eventType2
;
74 if (!encodedValue
.get
<PlatformEvent2::Type
>(ASCIILiteral("eventType2"), eventType2
))
77 Test::FormData1::Type formType1
;
78 if (!encodedValue
.get
<Test::FormData1::Type
>(ASCIILiteral("formType1"), formType1
))
81 Test::FormData2::Type formType2
;
82 if (!encodedValue
.get
<Test::FormData2::Type
>(ASCIILiteral("formType2"), formType2
))
85 input
= std::make_unique
<Test::FormCombo
>(eventType1
, eventType2
, formType1
, formType2
);
88 EncodedValue EncodingTraits
<Test::FormData1::Type
>::encodeValue(const Test::FormData1::Type
& enumValue
)
90 EncodedValue encodedValue
= EncodedValue::createArray();
91 if (enumValue
& Test::FormData1::Text
) {
92 encodedValue
.append
<String
>(ASCIILiteral("Text"));
93 if (enumValue
== Test::FormData1::Text
)
96 if (enumValue
& Test::FormData1::Blob
) {
97 encodedValue
.append
<String
>(ASCIILiteral("Blob"));
98 if (enumValue
== Test::FormData1::Blob
)
104 bool EncodingTraits
<Test::FormData1::Type
>::decodeValue(EncodedValue
& encodedValue
, Test::FormData1::Type
& enumValue
)
106 Vector
<String
> enumStrings
;
107 if (!EncodingTraits
<Vector
<String
>>::decodeValue(encodedValue
, enumStrings
))
110 for (const String
& enumString
: enumStrings
) {
111 if (enumString
== "Text")
112 enumValue
= static_cast<Test::FormData1::Type
>(enumValue
| Test::FormData1::Text
);
113 else if (enumString
== "Blob")
114 enumValue
= static_cast<Test::FormData1::Type
>(enumValue
| Test::FormData1::Blob
);
120 EncodedValue EncodingTraits
<Test::FormData2::Type
>::encodeValue(const Test::FormData2::Type
& enumValue
)
123 case Test::FormData2::Type::Text
: return EncodedValue::createString("Text");
124 case Test::FormData2::Type::Blob
: return EncodedValue::createString("Blob");
125 default: ASSERT_NOT_REACHED(); return EncodedValue::createString("Error!");
129 bool EncodingTraits
<Test::FormData2::Type
>::decodeValue(EncodedValue
& encodedValue
, Test::FormData2::Type
& enumValue
)
131 String enumString
= encodedValue
.convertTo
<String
>();
132 if (enumString
== "Text") {
133 enumValue
= Test::FormData2::Type::Text
;
136 if (enumString
== "Blob") {
137 enumValue
= Test::FormData2::Type::Blob
;
144 #endif // ENABLE(WEB_REPLAY)