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 "JSMediaStreamTrackEvent.h"
26
27#include "JSDOMAttribute.h"
28#include "JSDOMBinding.h"
29#include "JSDOMConstructor.h"
30#include "JSDOMConvertBoolean.h"
31#include "JSDOMConvertInterface.h"
32#include "JSDOMExceptionHandling.h"
33#include "JSDOMGlobalObject.h"
34#include "JSDOMWrapperCache.h"
35#include "JSMediaStreamTrack.h"
36#include "ScriptExecutionContext.h"
37#include <JavaScriptCore/HeapSnapshotBuilder.h>
38#include <JavaScriptCore/JSCInlines.h>
39#include <wtf/GetPtr.h>
40#include <wtf/PointerPreparations.h>
41#include <wtf/URL.h>
42
43#if ENABLE(MEDIA_STREAM)
44#include "JSDOMConvertStrings.h"
45#endif
46
47
48namespace WebCore {
49using namespace JSC;
50
51template<> MediaStreamTrackEvent::Init convertDictionary<MediaStreamTrackEvent::Init>(ExecState& state, JSValue value)
52{
53 VM& vm = state.vm();
54 auto throwScope = DECLARE_THROW_SCOPE(vm);
55 bool isNullOrUndefined = value.isUndefinedOrNull();
56 auto* object = isNullOrUndefined ? nullptr : value.getObject();
57 if (UNLIKELY(!isNullOrUndefined && !object)) {
58 throwTypeError(&state, throwScope);
59 return { };
60 }
61 MediaStreamTrackEvent::Init result;
62 JSValue bubblesValue;
63 if (isNullOrUndefined)
64 bubblesValue = jsUndefined();
65 else {
66 bubblesValue = object->get(&state, Identifier::fromString(&state, "bubbles"));
67 RETURN_IF_EXCEPTION(throwScope, { });
68 }
69 if (!bubblesValue.isUndefined()) {
70 result.bubbles = convert<IDLBoolean>(state, bubblesValue);
71 RETURN_IF_EXCEPTION(throwScope, { });
72 } else
73 result.bubbles = false;
74 JSValue cancelableValue;
75 if (isNullOrUndefined)
76 cancelableValue = jsUndefined();
77 else {
78 cancelableValue = object->get(&state, Identifier::fromString(&state, "cancelable"));
79 RETURN_IF_EXCEPTION(throwScope, { });
80 }
81 if (!cancelableValue.isUndefined()) {
82 result.cancelable = convert<IDLBoolean>(state, cancelableValue);
83 RETURN_IF_EXCEPTION(throwScope, { });
84 } else
85 result.cancelable = false;
86 JSValue composedValue;
87 if (isNullOrUndefined)
88 composedValue = jsUndefined();
89 else {
90 composedValue = object->get(&state, Identifier::fromString(&state, "composed"));
91 RETURN_IF_EXCEPTION(throwScope, { });
92 }
93 if (!composedValue.isUndefined()) {
94 result.composed = convert<IDLBoolean>(state, composedValue);
95 RETURN_IF_EXCEPTION(throwScope, { });
96 } else
97 result.composed = false;
98 JSValue trackValue;
99 if (isNullOrUndefined)
100 trackValue = jsUndefined();
101 else {
102 trackValue = object->get(&state, Identifier::fromString(&state, "track"));
103 RETURN_IF_EXCEPTION(throwScope, { });
104 }
105 if (!trackValue.isUndefined()) {
106 result.track = convert<IDLInterface<MediaStreamTrack>>(state, trackValue);
107 RETURN_IF_EXCEPTION(throwScope, { });
108 } else {
109 throwRequiredMemberTypeError(state, throwScope, "track", "MediaStreamTrackEventInit", "MediaStreamTrack");
110 return { };
111 }
112 return result;
113}
114
115// Attributes
116
117JSC::EncodedJSValue jsMediaStreamTrackEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
118bool setJSMediaStreamTrackEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
119JSC::EncodedJSValue jsMediaStreamTrackEventTrack(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
120
121class JSMediaStreamTrackEventPrototype : public JSC::JSNonFinalObject {
122public:
123 using Base = JSC::JSNonFinalObject;
124 static JSMediaStreamTrackEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
125 {
126 JSMediaStreamTrackEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSMediaStreamTrackEventPrototype>(vm.heap)) JSMediaStreamTrackEventPrototype(vm, globalObject, structure);
127 ptr->finishCreation(vm);
128 return ptr;
129 }
130
131 DECLARE_INFO;
132 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
133 {
134 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
135 }
136
137private:
138 JSMediaStreamTrackEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
139 : JSC::JSNonFinalObject(vm, structure)
140 {
141 }
142
143 void finishCreation(JSC::VM&);
144};
145
146using JSMediaStreamTrackEventConstructor = JSDOMConstructor<JSMediaStreamTrackEvent>;
147
148template<> EncodedJSValue JSC_HOST_CALL JSMediaStreamTrackEventConstructor::construct(ExecState* state)
149{
150 VM& vm = state->vm();
151 auto throwScope = DECLARE_THROW_SCOPE(vm);
152 UNUSED_PARAM(throwScope);
153 auto* castedThis = jsCast<JSMediaStreamTrackEventConstructor*>(state->jsCallee());
154 ASSERT(castedThis);
155 if (UNLIKELY(state->argumentCount() < 2))
156 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
157 auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
158 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
159 auto eventInitDict = convert<IDLDictionary<MediaStreamTrackEvent::Init>>(*state, state->uncheckedArgument(1));
160 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
161 auto object = MediaStreamTrackEvent::create(WTFMove(type), WTFMove(eventInitDict));
162 return JSValue::encode(toJSNewlyCreated<IDLInterface<MediaStreamTrackEvent>>(*state, *castedThis->globalObject(), WTFMove(object)));
163}
164
165template<> JSValue JSMediaStreamTrackEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
166{
167 return JSEvent::getConstructor(vm, &globalObject);
168}
169
170template<> void JSMediaStreamTrackEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
171{
172 putDirect(vm, vm.propertyNames->prototype, JSMediaStreamTrackEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
173 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("MediaStreamTrackEvent"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
174 putDirect(vm, vm.propertyNames->length, jsNumber(2), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
175}
176
177template<> const ClassInfo JSMediaStreamTrackEventConstructor::s_info = { "MediaStreamTrackEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaStreamTrackEventConstructor) };
178
179/* Hash table for prototype */
180
181static const HashTableValue JSMediaStreamTrackEventPrototypeTableValues[] =
182{
183 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaStreamTrackEventConstructor) } },
184 { "track", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaStreamTrackEventTrack), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
185};
186
187const ClassInfo JSMediaStreamTrackEventPrototype::s_info = { "MediaStreamTrackEventPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaStreamTrackEventPrototype) };
188
189void JSMediaStreamTrackEventPrototype::finishCreation(VM& vm)
190{
191 Base::finishCreation(vm);
192 reifyStaticProperties(vm, JSMediaStreamTrackEvent::info(), JSMediaStreamTrackEventPrototypeTableValues, *this);
193}
194
195const ClassInfo JSMediaStreamTrackEvent::s_info = { "MediaStreamTrackEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaStreamTrackEvent) };
196
197JSMediaStreamTrackEvent::JSMediaStreamTrackEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MediaStreamTrackEvent>&& impl)
198 : JSEvent(structure, globalObject, WTFMove(impl))
199{
200}
201
202void JSMediaStreamTrackEvent::finishCreation(VM& vm)
203{
204 Base::finishCreation(vm);
205 ASSERT(inherits(vm, info()));
206
207}
208
209JSObject* JSMediaStreamTrackEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
210{
211 return JSMediaStreamTrackEventPrototype::create(vm, &globalObject, JSMediaStreamTrackEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject)));
212}
213
214JSObject* JSMediaStreamTrackEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject)
215{
216 return getDOMPrototype<JSMediaStreamTrackEvent>(vm, globalObject);
217}
218
219JSValue JSMediaStreamTrackEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject)
220{
221 return getDOMConstructor<JSMediaStreamTrackEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
222}
223
224template<> inline JSMediaStreamTrackEvent* IDLAttribute<JSMediaStreamTrackEvent>::cast(ExecState& state, EncodedJSValue thisValue)
225{
226 return jsDynamicCast<JSMediaStreamTrackEvent*>(state.vm(), JSValue::decode(thisValue));
227}
228
229EncodedJSValue jsMediaStreamTrackEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
230{
231 VM& vm = state->vm();
232 auto throwScope = DECLARE_THROW_SCOPE(vm);
233 auto* prototype = jsDynamicCast<JSMediaStreamTrackEventPrototype*>(vm, JSValue::decode(thisValue));
234 if (UNLIKELY(!prototype))
235 return throwVMTypeError(state, throwScope);
236 return JSValue::encode(JSMediaStreamTrackEvent::getConstructor(state->vm(), prototype->globalObject()));
237}
238
239bool setJSMediaStreamTrackEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
240{
241 VM& vm = state->vm();
242 auto throwScope = DECLARE_THROW_SCOPE(vm);
243 auto* prototype = jsDynamicCast<JSMediaStreamTrackEventPrototype*>(vm, JSValue::decode(thisValue));
244 if (UNLIKELY(!prototype)) {
245 throwVMTypeError(state, throwScope);
246 return false;
247 }
248 // Shadowing a built-in constructor
249 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
250}
251
252static inline JSValue jsMediaStreamTrackEventTrackGetter(ExecState& state, JSMediaStreamTrackEvent& thisObject, ThrowScope& throwScope)
253{
254 UNUSED_PARAM(throwScope);
255 UNUSED_PARAM(state);
256 auto& impl = thisObject.wrapped();
257 JSValue result = toJS<IDLInterface<MediaStreamTrack>>(state, *thisObject.globalObject(), throwScope, impl.track());
258 return result;
259}
260
261EncodedJSValue jsMediaStreamTrackEventTrack(ExecState* state, EncodedJSValue thisValue, PropertyName)
262{
263 return IDLAttribute<JSMediaStreamTrackEvent>::get<jsMediaStreamTrackEventTrackGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "track");
264}
265
266void JSMediaStreamTrackEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
267{
268 auto* thisObject = jsCast<JSMediaStreamTrackEvent*>(cell);
269 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
270 if (thisObject->scriptExecutionContext())
271 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
272 Base::heapSnapshot(cell, builder);
273}
274
275#if ENABLE(BINDING_INTEGRITY)
276#if PLATFORM(WIN)
277#pragma warning(disable: 4483)
278extern "C" { extern void (*const __identifier("??_7MediaStreamTrackEvent@WebCore@@6B@")[])(); }
279#else
280extern "C" { extern void* _ZTVN7WebCore21MediaStreamTrackEventE[]; }
281#endif
282#endif
283
284JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MediaStreamTrackEvent>&& impl)
285{
286
287#if ENABLE(BINDING_INTEGRITY)
288 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
289#if PLATFORM(WIN)
290 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7MediaStreamTrackEvent@WebCore@@6B@"));
291#else
292 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore21MediaStreamTrackEventE[2]);
293#endif
294
295 // If this fails MediaStreamTrackEvent does not have a vtable, so you need to add the
296 // ImplementationLacksVTable attribute to the interface definition
297 static_assert(std::is_polymorphic<MediaStreamTrackEvent>::value, "MediaStreamTrackEvent is not polymorphic");
298
299 // If you hit this assertion you either have a use after free bug, or
300 // MediaStreamTrackEvent has subclasses. If MediaStreamTrackEvent has subclasses that get passed
301 // to toJS() we currently require MediaStreamTrackEvent you to opt out of binding hardening
302 // by adding the SkipVTableValidation attribute to the interface IDL definition
303 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
304#endif
305 return createWrapper<MediaStreamTrackEvent>(globalObject, WTFMove(impl));
306}
307
308JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MediaStreamTrackEvent& impl)
309{
310 return wrap(state, globalObject, impl);
311}
312
313
314}
315
316#endif // ENABLE(MEDIA_STREAM)
317