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 "JSRTCIceServer.h"
26
27#include "JSDOMConvertSequences.h"
28#include "JSDOMConvertStrings.h"
29#include "JSDOMConvertUnion.h"
30#include "JSDOMGlobalObject.h"
31#include <JavaScriptCore/JSArray.h>
32#include <JavaScriptCore/JSCInlines.h>
33#include <JavaScriptCore/ObjectConstructor.h>
34#include <wtf/Variant.h>
35
36
37namespace WebCore {
38using namespace JSC;
39
40#if ENABLE(WEB_RTC)
41
42template<> RTCIceServer convertDictionary<RTCIceServer>(ExecState& state, JSValue value)
43{
44 VM& vm = state.vm();
45 auto throwScope = DECLARE_THROW_SCOPE(vm);
46 bool isNullOrUndefined = value.isUndefinedOrNull();
47 auto* object = isNullOrUndefined ? nullptr : value.getObject();
48 if (UNLIKELY(!isNullOrUndefined && !object)) {
49 throwTypeError(&state, throwScope);
50 return { };
51 }
52 RTCIceServer result;
53 JSValue credentialValue;
54 if (isNullOrUndefined)
55 credentialValue = jsUndefined();
56 else {
57 credentialValue = object->get(&state, Identifier::fromString(&state, "credential"));
58 RETURN_IF_EXCEPTION(throwScope, { });
59 }
60 if (!credentialValue.isUndefined()) {
61 result.credential = convert<IDLDOMString>(state, credentialValue);
62 RETURN_IF_EXCEPTION(throwScope, { });
63 }
64 JSValue urlsValue;
65 if (isNullOrUndefined)
66 urlsValue = jsUndefined();
67 else {
68 urlsValue = object->get(&state, Identifier::fromString(&state, "urls"));
69 RETURN_IF_EXCEPTION(throwScope, { });
70 }
71 if (!urlsValue.isUndefined()) {
72 result.urls = convert<IDLUnion<IDLDOMString, IDLSequence<IDLDOMString>>>(state, urlsValue);
73 RETURN_IF_EXCEPTION(throwScope, { });
74 } else {
75 throwRequiredMemberTypeError(state, throwScope, "urls", "RTCIceServer", "(DOMString or sequence)");
76 return { };
77 }
78 JSValue usernameValue;
79 if (isNullOrUndefined)
80 usernameValue = jsUndefined();
81 else {
82 usernameValue = object->get(&state, Identifier::fromString(&state, "username"));
83 RETURN_IF_EXCEPTION(throwScope, { });
84 }
85 if (!usernameValue.isUndefined()) {
86 result.username = convert<IDLDOMString>(state, usernameValue);
87 RETURN_IF_EXCEPTION(throwScope, { });
88 }
89 return result;
90}
91
92JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const RTCIceServer& dictionary)
93{
94 auto& vm = state.vm();
95
96 auto result = constructEmptyObject(&state, globalObject.objectPrototype());
97
98 if (!IDLDOMString::isNullValue(dictionary.credential)) {
99 auto credentialValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.credential));
100 result->putDirect(vm, JSC::Identifier::fromString(&vm, "credential"), credentialValue);
101 }
102 auto urlsValue = toJS<IDLUnion<IDLDOMString, IDLSequence<IDLDOMString>>>(state, globalObject, dictionary.urls);
103 result->putDirect(vm, JSC::Identifier::fromString(&vm, "urls"), urlsValue);
104 if (!IDLDOMString::isNullValue(dictionary.username)) {
105 auto usernameValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.username));
106 result->putDirect(vm, JSC::Identifier::fromString(&vm, "username"), usernameValue);
107 }
108 return result;
109}
110
111#endif
112
113} // namespace WebCore
114
115#endif // ENABLE(WEB_RTC)
116