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