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