1 | /* |
2 | This file is part of the WebKit open source project. |
3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. |
9 | |
10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #include "config.h" |
22 | |
23 | #if ENABLE(WEB_RTC) |
24 | |
25 | #include "JSRTCIceTransportState.h" |
26 | |
27 | #include <JavaScriptCore/JSCInlines.h> |
28 | #include <JavaScriptCore/JSString.h> |
29 | #include <wtf/NeverDestroyed.h> |
30 | |
31 | |
32 | namespace WebCore { |
33 | using namespace JSC; |
34 | |
35 | String convertEnumerationToString(RTCIceTransportState enumerationValue) |
36 | { |
37 | static const NeverDestroyed<String> values[] = { |
38 | MAKE_STATIC_STRING_IMPL("new" ), |
39 | MAKE_STATIC_STRING_IMPL("checking" ), |
40 | MAKE_STATIC_STRING_IMPL("connected" ), |
41 | MAKE_STATIC_STRING_IMPL("completed" ), |
42 | MAKE_STATIC_STRING_IMPL("failed" ), |
43 | MAKE_STATIC_STRING_IMPL("disconnected" ), |
44 | MAKE_STATIC_STRING_IMPL("closed" ), |
45 | }; |
46 | static_assert(static_cast<size_t>(RTCIceTransportState::New) == 0, "RTCIceTransportState::New is not 0 as expected" ); |
47 | static_assert(static_cast<size_t>(RTCIceTransportState::Checking) == 1, "RTCIceTransportState::Checking is not 1 as expected" ); |
48 | static_assert(static_cast<size_t>(RTCIceTransportState::Connected) == 2, "RTCIceTransportState::Connected is not 2 as expected" ); |
49 | static_assert(static_cast<size_t>(RTCIceTransportState::Completed) == 3, "RTCIceTransportState::Completed is not 3 as expected" ); |
50 | static_assert(static_cast<size_t>(RTCIceTransportState::Failed) == 4, "RTCIceTransportState::Failed is not 4 as expected" ); |
51 | static_assert(static_cast<size_t>(RTCIceTransportState::Disconnected) == 5, "RTCIceTransportState::Disconnected is not 5 as expected" ); |
52 | static_assert(static_cast<size_t>(RTCIceTransportState::Closed) == 6, "RTCIceTransportState::Closed is not 6 as expected" ); |
53 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
54 | return values[static_cast<size_t>(enumerationValue)]; |
55 | } |
56 | |
57 | template<> JSString* convertEnumerationToJS(ExecState& state, RTCIceTransportState enumerationValue) |
58 | { |
59 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
60 | } |
61 | |
62 | template<> Optional<RTCIceTransportState> parseEnumeration<RTCIceTransportState>(ExecState& state, JSValue value) |
63 | { |
64 | auto stringValue = value.toWTFString(&state); |
65 | if (stringValue == "new" ) |
66 | return RTCIceTransportState::New; |
67 | if (stringValue == "checking" ) |
68 | return RTCIceTransportState::Checking; |
69 | if (stringValue == "connected" ) |
70 | return RTCIceTransportState::Connected; |
71 | if (stringValue == "completed" ) |
72 | return RTCIceTransportState::Completed; |
73 | if (stringValue == "failed" ) |
74 | return RTCIceTransportState::Failed; |
75 | if (stringValue == "disconnected" ) |
76 | return RTCIceTransportState::Disconnected; |
77 | if (stringValue == "closed" ) |
78 | return RTCIceTransportState::Closed; |
79 | return WTF::nullopt; |
80 | } |
81 | |
82 | template<> const char* expectedEnumerationValues<RTCIceTransportState>() |
83 | { |
84 | return "\"new\", \"checking\", \"connected\", \"completed\", \"failed\", \"disconnected\", \"closed\"" ; |
85 | } |
86 | |
87 | } // namespace WebCore |
88 | |
89 | #endif // ENABLE(WEB_RTC) |
90 | |