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 "JSRTCSignalingState.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(RTCSignalingState enumerationValue) |
36 | { |
37 | static const NeverDestroyed<String> values[] = { |
38 | MAKE_STATIC_STRING_IMPL("stable" ), |
39 | MAKE_STATIC_STRING_IMPL("have-local-offer" ), |
40 | MAKE_STATIC_STRING_IMPL("have-remote-offer" ), |
41 | MAKE_STATIC_STRING_IMPL("have-local-pranswer" ), |
42 | MAKE_STATIC_STRING_IMPL("have-remote-pranswer" ), |
43 | MAKE_STATIC_STRING_IMPL("closed" ), |
44 | }; |
45 | static_assert(static_cast<size_t>(RTCSignalingState::Stable) == 0, "RTCSignalingState::Stable is not 0 as expected" ); |
46 | static_assert(static_cast<size_t>(RTCSignalingState::HaveLocalOffer) == 1, "RTCSignalingState::HaveLocalOffer is not 1 as expected" ); |
47 | static_assert(static_cast<size_t>(RTCSignalingState::HaveRemoteOffer) == 2, "RTCSignalingState::HaveRemoteOffer is not 2 as expected" ); |
48 | static_assert(static_cast<size_t>(RTCSignalingState::HaveLocalPranswer) == 3, "RTCSignalingState::HaveLocalPranswer is not 3 as expected" ); |
49 | static_assert(static_cast<size_t>(RTCSignalingState::HaveRemotePranswer) == 4, "RTCSignalingState::HaveRemotePranswer is not 4 as expected" ); |
50 | static_assert(static_cast<size_t>(RTCSignalingState::Closed) == 5, "RTCSignalingState::Closed is not 5 as expected" ); |
51 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
52 | return values[static_cast<size_t>(enumerationValue)]; |
53 | } |
54 | |
55 | template<> JSString* convertEnumerationToJS(ExecState& state, RTCSignalingState enumerationValue) |
56 | { |
57 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
58 | } |
59 | |
60 | template<> Optional<RTCSignalingState> parseEnumeration<RTCSignalingState>(ExecState& state, JSValue value) |
61 | { |
62 | auto stringValue = value.toWTFString(&state); |
63 | if (stringValue == "stable" ) |
64 | return RTCSignalingState::Stable; |
65 | if (stringValue == "have-local-offer" ) |
66 | return RTCSignalingState::HaveLocalOffer; |
67 | if (stringValue == "have-remote-offer" ) |
68 | return RTCSignalingState::HaveRemoteOffer; |
69 | if (stringValue == "have-local-pranswer" ) |
70 | return RTCSignalingState::HaveLocalPranswer; |
71 | if (stringValue == "have-remote-pranswer" ) |
72 | return RTCSignalingState::HaveRemotePranswer; |
73 | if (stringValue == "closed" ) |
74 | return RTCSignalingState::Closed; |
75 | return WTF::nullopt; |
76 | } |
77 | |
78 | template<> const char* expectedEnumerationValues<RTCSignalingState>() |
79 | { |
80 | return "\"stable\", \"have-local-offer\", \"have-remote-offer\", \"have-local-pranswer\", \"have-remote-pranswer\", \"closed\"" ; |
81 | } |
82 | |
83 | } // namespace WebCore |
84 | |
85 | #endif // ENABLE(WEB_RTC) |
86 | |