| 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 "JSRTCPeerConnectionState.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(RTCPeerConnectionState enumerationValue) | 
| 36 | { | 
| 37 |     static const NeverDestroyed<String> values[] = { | 
| 38 |         MAKE_STATIC_STRING_IMPL("new" ), | 
| 39 |         MAKE_STATIC_STRING_IMPL("connecting" ), | 
| 40 |         MAKE_STATIC_STRING_IMPL("connected" ), | 
| 41 |         MAKE_STATIC_STRING_IMPL("disconnected" ), | 
| 42 |         MAKE_STATIC_STRING_IMPL("failed" ), | 
| 43 |         MAKE_STATIC_STRING_IMPL("closed" ), | 
| 44 |     }; | 
| 45 |     static_assert(static_cast<size_t>(RTCPeerConnectionState::New) == 0, "RTCPeerConnectionState::New is not 0 as expected" ); | 
| 46 |     static_assert(static_cast<size_t>(RTCPeerConnectionState::Connecting) == 1, "RTCPeerConnectionState::Connecting is not 1 as expected" ); | 
| 47 |     static_assert(static_cast<size_t>(RTCPeerConnectionState::Connected) == 2, "RTCPeerConnectionState::Connected is not 2 as expected" ); | 
| 48 |     static_assert(static_cast<size_t>(RTCPeerConnectionState::Disconnected) == 3, "RTCPeerConnectionState::Disconnected is not 3 as expected" ); | 
| 49 |     static_assert(static_cast<size_t>(RTCPeerConnectionState::Failed) == 4, "RTCPeerConnectionState::Failed is not 4 as expected" ); | 
| 50 |     static_assert(static_cast<size_t>(RTCPeerConnectionState::Closed) == 5, "RTCPeerConnectionState::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, RTCPeerConnectionState enumerationValue) | 
| 56 | { | 
| 57 |     return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); | 
| 58 | } | 
| 59 |  | 
| 60 | template<> Optional<RTCPeerConnectionState> parseEnumeration<RTCPeerConnectionState>(ExecState& state, JSValue value) | 
| 61 | { | 
| 62 |     auto stringValue = value.toWTFString(&state); | 
| 63 |     if (stringValue == "new" ) | 
| 64 |         return RTCPeerConnectionState::New; | 
| 65 |     if (stringValue == "connecting" ) | 
| 66 |         return RTCPeerConnectionState::Connecting; | 
| 67 |     if (stringValue == "connected" ) | 
| 68 |         return RTCPeerConnectionState::Connected; | 
| 69 |     if (stringValue == "disconnected" ) | 
| 70 |         return RTCPeerConnectionState::Disconnected; | 
| 71 |     if (stringValue == "failed" ) | 
| 72 |         return RTCPeerConnectionState::Failed; | 
| 73 |     if (stringValue == "closed" ) | 
| 74 |         return RTCPeerConnectionState::Closed; | 
| 75 |     return WTF::nullopt; | 
| 76 | } | 
| 77 |  | 
| 78 | template<> const char* expectedEnumerationValues<RTCPeerConnectionState>() | 
| 79 | { | 
| 80 |     return "\"new\", \"connecting\", \"connected\", \"disconnected\", \"failed\", \"closed\"" ; | 
| 81 | } | 
| 82 |  | 
| 83 | } // namespace WebCore | 
| 84 |  | 
| 85 | #endif // ENABLE(WEB_RTC) | 
| 86 |  |