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 "JSRTCIceCandidate.h" |
26 | |
27 | #include "JSDOMAttribute.h" |
28 | #include "JSDOMBinding.h" |
29 | #include "JSDOMConstructor.h" |
30 | #include "JSDOMConvertInterface.h" |
31 | #include "JSDOMConvertNullable.h" |
32 | #include "JSDOMConvertNumbers.h" |
33 | #include "JSDOMConvertStrings.h" |
34 | #include "JSDOMExceptionHandling.h" |
35 | #include "JSDOMOperation.h" |
36 | #include "JSDOMWrapperCache.h" |
37 | #include "ScriptExecutionContext.h" |
38 | #include <JavaScriptCore/FunctionPrototype.h> |
39 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
40 | #include <JavaScriptCore/JSCInlines.h> |
41 | #include <JavaScriptCore/ObjectConstructor.h> |
42 | #include <wtf/GetPtr.h> |
43 | #include <wtf/PointerPreparations.h> |
44 | #include <wtf/URL.h> |
45 | |
46 | |
47 | namespace WebCore { |
48 | using namespace JSC; |
49 | |
50 | #if ENABLE(WEB_RTC) |
51 | |
52 | template<> RTCIceCandidate::Init convertDictionary<RTCIceCandidate::Init>(ExecState& state, JSValue value) |
53 | { |
54 | VM& vm = state.vm(); |
55 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
56 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
57 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
58 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
59 | throwTypeError(&state, throwScope); |
60 | return { }; |
61 | } |
62 | RTCIceCandidate::Init result; |
63 | JSValue candidateValue; |
64 | if (isNullOrUndefined) |
65 | candidateValue = jsUndefined(); |
66 | else { |
67 | candidateValue = object->get(&state, Identifier::fromString(&state, "candidate" )); |
68 | RETURN_IF_EXCEPTION(throwScope, { }); |
69 | } |
70 | if (!candidateValue.isUndefined()) { |
71 | result.candidate = convert<IDLDOMString>(state, candidateValue); |
72 | RETURN_IF_EXCEPTION(throwScope, { }); |
73 | } else |
74 | result.candidate = emptyString(); |
75 | JSValue sdpMLineIndexValue; |
76 | if (isNullOrUndefined) |
77 | sdpMLineIndexValue = jsUndefined(); |
78 | else { |
79 | sdpMLineIndexValue = object->get(&state, Identifier::fromString(&state, "sdpMLineIndex" )); |
80 | RETURN_IF_EXCEPTION(throwScope, { }); |
81 | } |
82 | if (!sdpMLineIndexValue.isUndefined()) { |
83 | result.sdpMLineIndex = convert<IDLNullable<IDLUnsignedShort>>(state, sdpMLineIndexValue); |
84 | RETURN_IF_EXCEPTION(throwScope, { }); |
85 | } else |
86 | result.sdpMLineIndex = WTF::nullopt; |
87 | JSValue sdpMidValue; |
88 | if (isNullOrUndefined) |
89 | sdpMidValue = jsUndefined(); |
90 | else { |
91 | sdpMidValue = object->get(&state, Identifier::fromString(&state, "sdpMid" )); |
92 | RETURN_IF_EXCEPTION(throwScope, { }); |
93 | } |
94 | if (!sdpMidValue.isUndefined()) { |
95 | result.sdpMid = convert<IDLNullable<IDLDOMString>>(state, sdpMidValue); |
96 | RETURN_IF_EXCEPTION(throwScope, { }); |
97 | } else |
98 | result.sdpMid = String(); |
99 | return result; |
100 | } |
101 | |
102 | #endif |
103 | |
104 | // Functions |
105 | |
106 | JSC::EncodedJSValue JSC_HOST_CALL jsRTCIceCandidatePrototypeFunctionToJSON(JSC::ExecState*); |
107 | |
108 | // Attributes |
109 | |
110 | JSC::EncodedJSValue jsRTCIceCandidateConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
111 | bool setJSRTCIceCandidateConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
112 | JSC::EncodedJSValue jsRTCIceCandidateCandidate(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
113 | JSC::EncodedJSValue jsRTCIceCandidateSdpMid(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
114 | JSC::EncodedJSValue jsRTCIceCandidateSdpMLineIndex(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
115 | |
116 | class JSRTCIceCandidatePrototype : public JSC::JSNonFinalObject { |
117 | public: |
118 | using Base = JSC::JSNonFinalObject; |
119 | static JSRTCIceCandidatePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
120 | { |
121 | JSRTCIceCandidatePrototype* ptr = new (NotNull, JSC::allocateCell<JSRTCIceCandidatePrototype>(vm.heap)) JSRTCIceCandidatePrototype(vm, globalObject, structure); |
122 | ptr->finishCreation(vm); |
123 | return ptr; |
124 | } |
125 | |
126 | DECLARE_INFO; |
127 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
128 | { |
129 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
130 | } |
131 | |
132 | private: |
133 | JSRTCIceCandidatePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
134 | : JSC::JSNonFinalObject(vm, structure) |
135 | { |
136 | } |
137 | |
138 | void finishCreation(JSC::VM&); |
139 | }; |
140 | |
141 | using JSRTCIceCandidateConstructor = JSDOMConstructor<JSRTCIceCandidate>; |
142 | |
143 | template<> EncodedJSValue JSC_HOST_CALL JSRTCIceCandidateConstructor::construct(ExecState* state) |
144 | { |
145 | VM& vm = state->vm(); |
146 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
147 | UNUSED_PARAM(throwScope); |
148 | auto* castedThis = jsCast<JSRTCIceCandidateConstructor*>(state->jsCallee()); |
149 | ASSERT(castedThis); |
150 | if (UNLIKELY(state->argumentCount() < 1)) |
151 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
152 | auto candidateInitDict = convert<IDLDictionary<RTCIceCandidate::Init>>(*state, state->uncheckedArgument(0)); |
153 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
154 | auto object = RTCIceCandidate::create(WTFMove(candidateInitDict)); |
155 | return JSValue::encode(toJSNewlyCreated<IDLInterface<RTCIceCandidate>>(*state, *castedThis->globalObject(), throwScope, WTFMove(object))); |
156 | } |
157 | |
158 | template<> JSValue JSRTCIceCandidateConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
159 | { |
160 | UNUSED_PARAM(vm); |
161 | return globalObject.functionPrototype(); |
162 | } |
163 | |
164 | template<> void JSRTCIceCandidateConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
165 | { |
166 | putDirect(vm, vm.propertyNames->prototype, JSRTCIceCandidate::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
167 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("RTCIceCandidate"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
168 | putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
169 | } |
170 | |
171 | template<> const ClassInfo JSRTCIceCandidateConstructor::s_info = { "RTCIceCandidate" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCIceCandidateConstructor) }; |
172 | |
173 | /* Hash table for prototype */ |
174 | |
175 | static const HashTableValue JSRTCIceCandidatePrototypeTableValues[] = |
176 | { |
177 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCIceCandidateConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCIceCandidateConstructor) } }, |
178 | { "candidate" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCIceCandidateCandidate), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
179 | { "sdpMid" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCIceCandidateSdpMid), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
180 | { "sdpMLineIndex" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCIceCandidateSdpMLineIndex), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
181 | { "toJSON" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCIceCandidatePrototypeFunctionToJSON), (intptr_t) (0) } }, |
182 | }; |
183 | |
184 | const ClassInfo JSRTCIceCandidatePrototype::s_info = { "RTCIceCandidatePrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCIceCandidatePrototype) }; |
185 | |
186 | void JSRTCIceCandidatePrototype::finishCreation(VM& vm) |
187 | { |
188 | Base::finishCreation(vm); |
189 | reifyStaticProperties(vm, JSRTCIceCandidate::info(), JSRTCIceCandidatePrototypeTableValues, *this); |
190 | } |
191 | |
192 | const ClassInfo JSRTCIceCandidate::s_info = { "RTCIceCandidate" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCIceCandidate) }; |
193 | |
194 | JSRTCIceCandidate::JSRTCIceCandidate(Structure* structure, JSDOMGlobalObject& globalObject, Ref<RTCIceCandidate>&& impl) |
195 | : JSDOMWrapper<RTCIceCandidate>(structure, globalObject, WTFMove(impl)) |
196 | { |
197 | } |
198 | |
199 | void JSRTCIceCandidate::finishCreation(VM& vm) |
200 | { |
201 | Base::finishCreation(vm); |
202 | ASSERT(inherits(vm, info())); |
203 | |
204 | } |
205 | |
206 | JSObject* JSRTCIceCandidate::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
207 | { |
208 | return JSRTCIceCandidatePrototype::create(vm, &globalObject, JSRTCIceCandidatePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
209 | } |
210 | |
211 | JSObject* JSRTCIceCandidate::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
212 | { |
213 | return getDOMPrototype<JSRTCIceCandidate>(vm, globalObject); |
214 | } |
215 | |
216 | JSValue JSRTCIceCandidate::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
217 | { |
218 | return getDOMConstructor<JSRTCIceCandidateConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
219 | } |
220 | |
221 | void JSRTCIceCandidate::destroy(JSC::JSCell* cell) |
222 | { |
223 | JSRTCIceCandidate* thisObject = static_cast<JSRTCIceCandidate*>(cell); |
224 | thisObject->JSRTCIceCandidate::~JSRTCIceCandidate(); |
225 | } |
226 | |
227 | template<> inline JSRTCIceCandidate* IDLAttribute<JSRTCIceCandidate>::cast(ExecState& state, EncodedJSValue thisValue) |
228 | { |
229 | return jsDynamicCast<JSRTCIceCandidate*>(state.vm(), JSValue::decode(thisValue)); |
230 | } |
231 | |
232 | template<> inline JSRTCIceCandidate* IDLOperation<JSRTCIceCandidate>::cast(ExecState& state) |
233 | { |
234 | return jsDynamicCast<JSRTCIceCandidate*>(state.vm(), state.thisValue()); |
235 | } |
236 | |
237 | EncodedJSValue jsRTCIceCandidateConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
238 | { |
239 | VM& vm = state->vm(); |
240 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
241 | auto* prototype = jsDynamicCast<JSRTCIceCandidatePrototype*>(vm, JSValue::decode(thisValue)); |
242 | if (UNLIKELY(!prototype)) |
243 | return throwVMTypeError(state, throwScope); |
244 | return JSValue::encode(JSRTCIceCandidate::getConstructor(state->vm(), prototype->globalObject())); |
245 | } |
246 | |
247 | bool setJSRTCIceCandidateConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
248 | { |
249 | VM& vm = state->vm(); |
250 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
251 | auto* prototype = jsDynamicCast<JSRTCIceCandidatePrototype*>(vm, JSValue::decode(thisValue)); |
252 | if (UNLIKELY(!prototype)) { |
253 | throwVMTypeError(state, throwScope); |
254 | return false; |
255 | } |
256 | // Shadowing a built-in constructor |
257 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
258 | } |
259 | |
260 | static inline JSValue jsRTCIceCandidateCandidateGetter(ExecState& state, JSRTCIceCandidate& thisObject, ThrowScope& throwScope) |
261 | { |
262 | UNUSED_PARAM(throwScope); |
263 | UNUSED_PARAM(state); |
264 | auto& impl = thisObject.wrapped(); |
265 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.candidate()); |
266 | return result; |
267 | } |
268 | |
269 | EncodedJSValue jsRTCIceCandidateCandidate(ExecState* state, EncodedJSValue thisValue, PropertyName) |
270 | { |
271 | return IDLAttribute<JSRTCIceCandidate>::get<jsRTCIceCandidateCandidateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "candidate" ); |
272 | } |
273 | |
274 | static inline JSValue jsRTCIceCandidateSdpMidGetter(ExecState& state, JSRTCIceCandidate& thisObject, ThrowScope& throwScope) |
275 | { |
276 | UNUSED_PARAM(throwScope); |
277 | UNUSED_PARAM(state); |
278 | auto& impl = thisObject.wrapped(); |
279 | JSValue result = toJS<IDLNullable<IDLDOMString>>(state, throwScope, impl.sdpMid()); |
280 | return result; |
281 | } |
282 | |
283 | EncodedJSValue jsRTCIceCandidateSdpMid(ExecState* state, EncodedJSValue thisValue, PropertyName) |
284 | { |
285 | return IDLAttribute<JSRTCIceCandidate>::get<jsRTCIceCandidateSdpMidGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "sdpMid" ); |
286 | } |
287 | |
288 | static inline JSValue jsRTCIceCandidateSdpMLineIndexGetter(ExecState& state, JSRTCIceCandidate& thisObject, ThrowScope& throwScope) |
289 | { |
290 | UNUSED_PARAM(throwScope); |
291 | UNUSED_PARAM(state); |
292 | auto& impl = thisObject.wrapped(); |
293 | JSValue result = toJS<IDLNullable<IDLUnsignedShort>>(state, throwScope, impl.sdpMLineIndex()); |
294 | return result; |
295 | } |
296 | |
297 | EncodedJSValue jsRTCIceCandidateSdpMLineIndex(ExecState* state, EncodedJSValue thisValue, PropertyName) |
298 | { |
299 | return IDLAttribute<JSRTCIceCandidate>::get<jsRTCIceCandidateSdpMLineIndexGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "sdpMLineIndex" ); |
300 | } |
301 | |
302 | JSC::JSObject* JSRTCIceCandidate::serialize(ExecState& state, JSRTCIceCandidate& thisObject, JSDOMGlobalObject& globalObject, ThrowScope& throwScope) |
303 | { |
304 | auto& vm = state.vm(); |
305 | auto* result = constructEmptyObject(&state, globalObject.objectPrototype()); |
306 | |
307 | auto candidateValue = jsRTCIceCandidateCandidateGetter(state, thisObject, throwScope); |
308 | throwScope.assertNoException(); |
309 | result->putDirect(vm, Identifier::fromString(&vm, "candidate" ), candidateValue); |
310 | |
311 | auto sdpMidValue = jsRTCIceCandidateSdpMidGetter(state, thisObject, throwScope); |
312 | throwScope.assertNoException(); |
313 | result->putDirect(vm, Identifier::fromString(&vm, "sdpMid" ), sdpMidValue); |
314 | |
315 | auto sdpMLineIndexValue = jsRTCIceCandidateSdpMLineIndexGetter(state, thisObject, throwScope); |
316 | throwScope.assertNoException(); |
317 | result->putDirect(vm, Identifier::fromString(&vm, "sdpMLineIndex" ), sdpMLineIndexValue); |
318 | |
319 | return result; |
320 | } |
321 | |
322 | static inline EncodedJSValue jsRTCIceCandidatePrototypeFunctionToJSONBody(ExecState* state, JSRTCIceCandidate* thisObject, JSC::ThrowScope& throwScope) |
323 | { |
324 | return JSValue::encode(JSRTCIceCandidate::serialize(*state, *thisObject, *thisObject->globalObject(), throwScope)); |
325 | } |
326 | |
327 | EncodedJSValue JSC_HOST_CALL jsRTCIceCandidatePrototypeFunctionToJSON(ExecState* state) |
328 | { |
329 | return IDLOperation<JSRTCIceCandidate>::call<jsRTCIceCandidatePrototypeFunctionToJSONBody>(*state, "toJSON" ); |
330 | } |
331 | |
332 | void JSRTCIceCandidate::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
333 | { |
334 | auto* thisObject = jsCast<JSRTCIceCandidate*>(cell); |
335 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
336 | if (thisObject->scriptExecutionContext()) |
337 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
338 | Base::heapSnapshot(cell, builder); |
339 | } |
340 | |
341 | bool JSRTCIceCandidateOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
342 | { |
343 | UNUSED_PARAM(handle); |
344 | UNUSED_PARAM(visitor); |
345 | UNUSED_PARAM(reason); |
346 | return false; |
347 | } |
348 | |
349 | void JSRTCIceCandidateOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
350 | { |
351 | auto* jsRTCIceCandidate = static_cast<JSRTCIceCandidate*>(handle.slot()->asCell()); |
352 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
353 | uncacheWrapper(world, &jsRTCIceCandidate->wrapped(), jsRTCIceCandidate); |
354 | } |
355 | |
356 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<RTCIceCandidate>&& impl) |
357 | { |
358 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
359 | // attribute. You should remove that attribute. If the class has subclasses |
360 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
361 | // attribute to RTCIceCandidate. |
362 | static_assert(!std::is_polymorphic<RTCIceCandidate>::value, "RTCIceCandidate is polymorphic but the IDL claims it is not" ); |
363 | return createWrapper<RTCIceCandidate>(globalObject, WTFMove(impl)); |
364 | } |
365 | |
366 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RTCIceCandidate& impl) |
367 | { |
368 | return wrap(state, globalObject, impl); |
369 | } |
370 | |
371 | RTCIceCandidate* JSRTCIceCandidate::toWrapped(JSC::VM& vm, JSC::JSValue value) |
372 | { |
373 | if (auto* wrapper = jsDynamicCast<JSRTCIceCandidate*>(vm, value)) |
374 | return &wrapper->wrapped(); |
375 | return nullptr; |
376 | } |
377 | |
378 | } |
379 | |
380 | #endif // ENABLE(WEB_RTC) |
381 | |