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