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(MEDIA_STREAM) |
24 | |
25 | #include "JSMediaTrackSupportedConstraints.h" |
26 | |
27 | #include "JSDOMConvertBoolean.h" |
28 | #include "JSDOMGlobalObject.h" |
29 | #include <JavaScriptCore/JSCInlines.h> |
30 | #include <JavaScriptCore/ObjectConstructor.h> |
31 | |
32 | |
33 | namespace WebCore { |
34 | using namespace JSC; |
35 | |
36 | #if ENABLE(MEDIA_STREAM) |
37 | |
38 | template<> MediaTrackSupportedConstraints convertDictionary<MediaTrackSupportedConstraints>(ExecState& state, JSValue value) |
39 | { |
40 | VM& vm = state.vm(); |
41 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
42 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
43 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
44 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
45 | throwTypeError(&state, throwScope); |
46 | return { }; |
47 | } |
48 | MediaTrackSupportedConstraints result; |
49 | JSValue aspectRatioValue; |
50 | if (isNullOrUndefined) |
51 | aspectRatioValue = jsUndefined(); |
52 | else { |
53 | aspectRatioValue = object->get(&state, Identifier::fromString(&state, "aspectRatio" )); |
54 | RETURN_IF_EXCEPTION(throwScope, { }); |
55 | } |
56 | if (!aspectRatioValue.isUndefined()) { |
57 | result.aspectRatio = convert<IDLBoolean>(state, aspectRatioValue); |
58 | RETURN_IF_EXCEPTION(throwScope, { }); |
59 | } else |
60 | result.aspectRatio = true; |
61 | JSValue deviceIdValue; |
62 | if (isNullOrUndefined) |
63 | deviceIdValue = jsUndefined(); |
64 | else { |
65 | deviceIdValue = object->get(&state, Identifier::fromString(&state, "deviceId" )); |
66 | RETURN_IF_EXCEPTION(throwScope, { }); |
67 | } |
68 | if (!deviceIdValue.isUndefined()) { |
69 | result.deviceId = convert<IDLBoolean>(state, deviceIdValue); |
70 | RETURN_IF_EXCEPTION(throwScope, { }); |
71 | } else |
72 | result.deviceId = true; |
73 | JSValue echoCancellationValue; |
74 | if (isNullOrUndefined) |
75 | echoCancellationValue = jsUndefined(); |
76 | else { |
77 | echoCancellationValue = object->get(&state, Identifier::fromString(&state, "echoCancellation" )); |
78 | RETURN_IF_EXCEPTION(throwScope, { }); |
79 | } |
80 | if (!echoCancellationValue.isUndefined()) { |
81 | result.echoCancellation = convert<IDLBoolean>(state, echoCancellationValue); |
82 | RETURN_IF_EXCEPTION(throwScope, { }); |
83 | } else |
84 | result.echoCancellation = true; |
85 | JSValue facingModeValue; |
86 | if (isNullOrUndefined) |
87 | facingModeValue = jsUndefined(); |
88 | else { |
89 | facingModeValue = object->get(&state, Identifier::fromString(&state, "facingMode" )); |
90 | RETURN_IF_EXCEPTION(throwScope, { }); |
91 | } |
92 | if (!facingModeValue.isUndefined()) { |
93 | result.facingMode = convert<IDLBoolean>(state, facingModeValue); |
94 | RETURN_IF_EXCEPTION(throwScope, { }); |
95 | } else |
96 | result.facingMode = true; |
97 | JSValue frameRateValue; |
98 | if (isNullOrUndefined) |
99 | frameRateValue = jsUndefined(); |
100 | else { |
101 | frameRateValue = object->get(&state, Identifier::fromString(&state, "frameRate" )); |
102 | RETURN_IF_EXCEPTION(throwScope, { }); |
103 | } |
104 | if (!frameRateValue.isUndefined()) { |
105 | result.frameRate = convert<IDLBoolean>(state, frameRateValue); |
106 | RETURN_IF_EXCEPTION(throwScope, { }); |
107 | } else |
108 | result.frameRate = true; |
109 | JSValue groupIdValue; |
110 | if (isNullOrUndefined) |
111 | groupIdValue = jsUndefined(); |
112 | else { |
113 | groupIdValue = object->get(&state, Identifier::fromString(&state, "groupId" )); |
114 | RETURN_IF_EXCEPTION(throwScope, { }); |
115 | } |
116 | if (!groupIdValue.isUndefined()) { |
117 | result.groupId = convert<IDLBoolean>(state, groupIdValue); |
118 | RETURN_IF_EXCEPTION(throwScope, { }); |
119 | } else |
120 | result.groupId = true; |
121 | JSValue heightValue; |
122 | if (isNullOrUndefined) |
123 | heightValue = jsUndefined(); |
124 | else { |
125 | heightValue = object->get(&state, Identifier::fromString(&state, "height" )); |
126 | RETURN_IF_EXCEPTION(throwScope, { }); |
127 | } |
128 | if (!heightValue.isUndefined()) { |
129 | result.height = convert<IDLBoolean>(state, heightValue); |
130 | RETURN_IF_EXCEPTION(throwScope, { }); |
131 | } else |
132 | result.height = true; |
133 | JSValue sampleRateValue; |
134 | if (isNullOrUndefined) |
135 | sampleRateValue = jsUndefined(); |
136 | else { |
137 | sampleRateValue = object->get(&state, Identifier::fromString(&state, "sampleRate" )); |
138 | RETURN_IF_EXCEPTION(throwScope, { }); |
139 | } |
140 | if (!sampleRateValue.isUndefined()) { |
141 | result.sampleRate = convert<IDLBoolean>(state, sampleRateValue); |
142 | RETURN_IF_EXCEPTION(throwScope, { }); |
143 | } else |
144 | result.sampleRate = true; |
145 | JSValue sampleSizeValue; |
146 | if (isNullOrUndefined) |
147 | sampleSizeValue = jsUndefined(); |
148 | else { |
149 | sampleSizeValue = object->get(&state, Identifier::fromString(&state, "sampleSize" )); |
150 | RETURN_IF_EXCEPTION(throwScope, { }); |
151 | } |
152 | if (!sampleSizeValue.isUndefined()) { |
153 | result.sampleSize = convert<IDLBoolean>(state, sampleSizeValue); |
154 | RETURN_IF_EXCEPTION(throwScope, { }); |
155 | } else |
156 | result.sampleSize = true; |
157 | JSValue volumeValue; |
158 | if (isNullOrUndefined) |
159 | volumeValue = jsUndefined(); |
160 | else { |
161 | volumeValue = object->get(&state, Identifier::fromString(&state, "volume" )); |
162 | RETURN_IF_EXCEPTION(throwScope, { }); |
163 | } |
164 | if (!volumeValue.isUndefined()) { |
165 | result.volume = convert<IDLBoolean>(state, volumeValue); |
166 | RETURN_IF_EXCEPTION(throwScope, { }); |
167 | } else |
168 | result.volume = true; |
169 | JSValue widthValue; |
170 | if (isNullOrUndefined) |
171 | widthValue = jsUndefined(); |
172 | else { |
173 | widthValue = object->get(&state, Identifier::fromString(&state, "width" )); |
174 | RETURN_IF_EXCEPTION(throwScope, { }); |
175 | } |
176 | if (!widthValue.isUndefined()) { |
177 | result.width = convert<IDLBoolean>(state, widthValue); |
178 | RETURN_IF_EXCEPTION(throwScope, { }); |
179 | } else |
180 | result.width = true; |
181 | return result; |
182 | } |
183 | |
184 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const MediaTrackSupportedConstraints& dictionary) |
185 | { |
186 | auto& vm = state.vm(); |
187 | |
188 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
189 | |
190 | auto aspectRatioValue = toJS<IDLBoolean>(dictionary.aspectRatio); |
191 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "aspectRatio" ), aspectRatioValue); |
192 | auto deviceIdValue = toJS<IDLBoolean>(dictionary.deviceId); |
193 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "deviceId" ), deviceIdValue); |
194 | auto echoCancellationValue = toJS<IDLBoolean>(dictionary.echoCancellation); |
195 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "echoCancellation" ), echoCancellationValue); |
196 | auto facingModeValue = toJS<IDLBoolean>(dictionary.facingMode); |
197 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "facingMode" ), facingModeValue); |
198 | auto frameRateValue = toJS<IDLBoolean>(dictionary.frameRate); |
199 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "frameRate" ), frameRateValue); |
200 | auto groupIdValue = toJS<IDLBoolean>(dictionary.groupId); |
201 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "groupId" ), groupIdValue); |
202 | auto heightValue = toJS<IDLBoolean>(dictionary.height); |
203 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "height" ), heightValue); |
204 | auto sampleRateValue = toJS<IDLBoolean>(dictionary.sampleRate); |
205 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "sampleRate" ), sampleRateValue); |
206 | auto sampleSizeValue = toJS<IDLBoolean>(dictionary.sampleSize); |
207 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "sampleSize" ), sampleSizeValue); |
208 | auto volumeValue = toJS<IDLBoolean>(dictionary.volume); |
209 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "volume" ), volumeValue); |
210 | auto widthValue = toJS<IDLBoolean>(dictionary.width); |
211 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "width" ), widthValue); |
212 | return result; |
213 | } |
214 | |
215 | #endif |
216 | |
217 | } // namespace WebCore |
218 | |
219 | #endif // ENABLE(MEDIA_STREAM) |
220 | |