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 | #include "JSMediaList.h" |
23 | |
24 | #include "JSDOMAttribute.h" |
25 | #include "JSDOMBinding.h" |
26 | #include "JSDOMConstructorNotConstructable.h" |
27 | #include "JSDOMConvertNullable.h" |
28 | #include "JSDOMConvertNumbers.h" |
29 | #include "JSDOMConvertStrings.h" |
30 | #include "JSDOMExceptionHandling.h" |
31 | #include "JSDOMOperation.h" |
32 | #include "JSDOMWrapperCache.h" |
33 | #include "ScriptExecutionContext.h" |
34 | #include <JavaScriptCore/ArrayPrototype.h> |
35 | #include <JavaScriptCore/BuiltinNames.h> |
36 | #include <JavaScriptCore/FunctionPrototype.h> |
37 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
38 | #include <JavaScriptCore/JSCInlines.h> |
39 | #include <JavaScriptCore/PropertyNameArray.h> |
40 | #include <wtf/GetPtr.h> |
41 | #include <wtf/PointerPreparations.h> |
42 | #include <wtf/URL.h> |
43 | |
44 | |
45 | namespace WebCore { |
46 | using namespace JSC; |
47 | |
48 | // Functions |
49 | |
50 | JSC::EncodedJSValue JSC_HOST_CALL jsMediaListPrototypeFunctionItem(JSC::ExecState*); |
51 | JSC::EncodedJSValue JSC_HOST_CALL jsMediaListPrototypeFunctionDeleteMedium(JSC::ExecState*); |
52 | JSC::EncodedJSValue JSC_HOST_CALL jsMediaListPrototypeFunctionAppendMedium(JSC::ExecState*); |
53 | |
54 | // Attributes |
55 | |
56 | JSC::EncodedJSValue jsMediaListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
57 | bool setJSMediaListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
58 | JSC::EncodedJSValue jsMediaListMediaText(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
59 | bool setJSMediaListMediaText(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
60 | JSC::EncodedJSValue jsMediaListLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
61 | |
62 | class JSMediaListPrototype : public JSC::JSNonFinalObject { |
63 | public: |
64 | using Base = JSC::JSNonFinalObject; |
65 | static JSMediaListPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
66 | { |
67 | JSMediaListPrototype* ptr = new (NotNull, JSC::allocateCell<JSMediaListPrototype>(vm.heap)) JSMediaListPrototype(vm, globalObject, structure); |
68 | ptr->finishCreation(vm); |
69 | return ptr; |
70 | } |
71 | |
72 | DECLARE_INFO; |
73 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
74 | { |
75 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
76 | } |
77 | |
78 | private: |
79 | JSMediaListPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
80 | : JSC::JSNonFinalObject(vm, structure) |
81 | { |
82 | } |
83 | |
84 | void finishCreation(JSC::VM&); |
85 | }; |
86 | |
87 | using JSMediaListConstructor = JSDOMConstructorNotConstructable<JSMediaList>; |
88 | |
89 | template<> JSValue JSMediaListConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
90 | { |
91 | UNUSED_PARAM(vm); |
92 | return globalObject.functionPrototype(); |
93 | } |
94 | |
95 | template<> void JSMediaListConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
96 | { |
97 | putDirect(vm, vm.propertyNames->prototype, JSMediaList::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
98 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("MediaList"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
99 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
100 | } |
101 | |
102 | template<> const ClassInfo JSMediaListConstructor::s_info = { "MediaList" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaListConstructor) }; |
103 | |
104 | /* Hash table for prototype */ |
105 | |
106 | static const HashTableValue JSMediaListPrototypeTableValues[] = |
107 | { |
108 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaListConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaListConstructor) } }, |
109 | { "mediaText" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaListMediaText), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaListMediaText) } }, |
110 | { "length" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaListLength), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
111 | { "item" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaListPrototypeFunctionItem), (intptr_t) (1) } }, |
112 | { "deleteMedium" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaListPrototypeFunctionDeleteMedium), (intptr_t) (1) } }, |
113 | { "appendMedium" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaListPrototypeFunctionAppendMedium), (intptr_t) (1) } }, |
114 | }; |
115 | |
116 | const ClassInfo JSMediaListPrototype::s_info = { "MediaListPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaListPrototype) }; |
117 | |
118 | void JSMediaListPrototype::finishCreation(VM& vm) |
119 | { |
120 | Base::finishCreation(vm); |
121 | reifyStaticProperties(vm, JSMediaList::info(), JSMediaListPrototypeTableValues, *this); |
122 | putDirect(vm, vm.propertyNames->iteratorSymbol, globalObject()->arrayPrototype()->getDirect(vm, vm.propertyNames->builtinNames().valuesPrivateName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)); |
123 | } |
124 | |
125 | const ClassInfo JSMediaList::s_info = { "MediaList" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaList) }; |
126 | |
127 | JSMediaList::JSMediaList(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MediaList>&& impl) |
128 | : JSDOMWrapper<MediaList>(structure, globalObject, WTFMove(impl)) |
129 | { |
130 | } |
131 | |
132 | void JSMediaList::finishCreation(VM& vm) |
133 | { |
134 | Base::finishCreation(vm); |
135 | ASSERT(inherits(vm, info())); |
136 | |
137 | } |
138 | |
139 | JSObject* JSMediaList::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
140 | { |
141 | return JSMediaListPrototype::create(vm, &globalObject, JSMediaListPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
142 | } |
143 | |
144 | JSObject* JSMediaList::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
145 | { |
146 | return getDOMPrototype<JSMediaList>(vm, globalObject); |
147 | } |
148 | |
149 | JSValue JSMediaList::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
150 | { |
151 | return getDOMConstructor<JSMediaListConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
152 | } |
153 | |
154 | void JSMediaList::destroy(JSC::JSCell* cell) |
155 | { |
156 | JSMediaList* thisObject = static_cast<JSMediaList*>(cell); |
157 | thisObject->JSMediaList::~JSMediaList(); |
158 | } |
159 | |
160 | bool JSMediaList::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot) |
161 | { |
162 | auto* thisObject = jsCast<JSMediaList*>(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<IDLNullable<IDLDOMString>>(*state, 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 | |
174 | bool JSMediaList::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot) |
175 | { |
176 | auto* thisObject = jsCast<JSMediaList*>(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<IDLNullable<IDLDOMString>>(*state, 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 | |
188 | void JSMediaList::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode) |
189 | { |
190 | auto* thisObject = jsCast<JSMediaList*>(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 | |
197 | template<> inline JSMediaList* IDLAttribute<JSMediaList>::cast(ExecState& state, EncodedJSValue thisValue) |
198 | { |
199 | return jsDynamicCast<JSMediaList*>(state.vm(), JSValue::decode(thisValue)); |
200 | } |
201 | |
202 | template<> inline JSMediaList* IDLOperation<JSMediaList>::cast(ExecState& state) |
203 | { |
204 | return jsDynamicCast<JSMediaList*>(state.vm(), state.thisValue()); |
205 | } |
206 | |
207 | EncodedJSValue jsMediaListConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
208 | { |
209 | VM& vm = state->vm(); |
210 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
211 | auto* prototype = jsDynamicCast<JSMediaListPrototype*>(vm, JSValue::decode(thisValue)); |
212 | if (UNLIKELY(!prototype)) |
213 | return throwVMTypeError(state, throwScope); |
214 | return JSValue::encode(JSMediaList::getConstructor(state->vm(), prototype->globalObject())); |
215 | } |
216 | |
217 | bool setJSMediaListConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
218 | { |
219 | VM& vm = state->vm(); |
220 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
221 | auto* prototype = jsDynamicCast<JSMediaListPrototype*>(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 | |
230 | static inline JSValue jsMediaListMediaTextGetter(ExecState& state, JSMediaList& thisObject, ThrowScope& throwScope) |
231 | { |
232 | UNUSED_PARAM(throwScope); |
233 | UNUSED_PARAM(state); |
234 | auto& impl = thisObject.wrapped(); |
235 | JSValue result = toJS<IDLTreatNullAsEmptyAdaptor<IDLDOMString>>(state, throwScope, impl.mediaText()); |
236 | return result; |
237 | } |
238 | |
239 | EncodedJSValue jsMediaListMediaText(ExecState* state, EncodedJSValue thisValue, PropertyName) |
240 | { |
241 | return IDLAttribute<JSMediaList>::get<jsMediaListMediaTextGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "mediaText" ); |
242 | } |
243 | |
244 | static inline bool setJSMediaListMediaTextSetter(ExecState& state, JSMediaList& thisObject, JSValue value, ThrowScope& throwScope) |
245 | { |
246 | UNUSED_PARAM(throwScope); |
247 | auto& impl = thisObject.wrapped(); |
248 | auto nativeValue = convert<IDLTreatNullAsEmptyAdaptor<IDLDOMString>>(state, value); |
249 | RETURN_IF_EXCEPTION(throwScope, false); |
250 | AttributeSetter::call(state, throwScope, [&] { |
251 | return impl.setMediaText(WTFMove(nativeValue)); |
252 | }); |
253 | return true; |
254 | } |
255 | |
256 | bool setJSMediaListMediaText(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
257 | { |
258 | return IDLAttribute<JSMediaList>::set<setJSMediaListMediaTextSetter>(*state, thisValue, encodedValue, "mediaText" ); |
259 | } |
260 | |
261 | static inline JSValue jsMediaListLengthGetter(ExecState& state, JSMediaList& thisObject, ThrowScope& throwScope) |
262 | { |
263 | UNUSED_PARAM(throwScope); |
264 | UNUSED_PARAM(state); |
265 | auto& impl = thisObject.wrapped(); |
266 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.length()); |
267 | return result; |
268 | } |
269 | |
270 | EncodedJSValue jsMediaListLength(ExecState* state, EncodedJSValue thisValue, PropertyName) |
271 | { |
272 | return IDLAttribute<JSMediaList>::get<jsMediaListLengthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "length" ); |
273 | } |
274 | |
275 | static inline JSC::EncodedJSValue jsMediaListPrototypeFunctionItemBody(JSC::ExecState* state, typename IDLOperation<JSMediaList>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
276 | { |
277 | UNUSED_PARAM(state); |
278 | UNUSED_PARAM(throwScope); |
279 | auto& impl = castedThis->wrapped(); |
280 | if (UNLIKELY(state->argumentCount() < 1)) |
281 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
282 | auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
283 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
284 | return JSValue::encode(toJS<IDLNullable<IDLDOMString>>(*state, impl.item(WTFMove(index)))); |
285 | } |
286 | |
287 | EncodedJSValue JSC_HOST_CALL jsMediaListPrototypeFunctionItem(ExecState* state) |
288 | { |
289 | return IDLOperation<JSMediaList>::call<jsMediaListPrototypeFunctionItemBody>(*state, "item" ); |
290 | } |
291 | |
292 | static inline JSC::EncodedJSValue jsMediaListPrototypeFunctionDeleteMediumBody(JSC::ExecState* state, typename IDLOperation<JSMediaList>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
293 | { |
294 | UNUSED_PARAM(state); |
295 | UNUSED_PARAM(throwScope); |
296 | auto& impl = castedThis->wrapped(); |
297 | if (UNLIKELY(state->argumentCount() < 1)) |
298 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
299 | auto oldMedium = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
300 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
301 | propagateException(*state, throwScope, impl.deleteMedium(WTFMove(oldMedium))); |
302 | return JSValue::encode(jsUndefined()); |
303 | } |
304 | |
305 | EncodedJSValue JSC_HOST_CALL jsMediaListPrototypeFunctionDeleteMedium(ExecState* state) |
306 | { |
307 | return IDLOperation<JSMediaList>::call<jsMediaListPrototypeFunctionDeleteMediumBody>(*state, "deleteMedium" ); |
308 | } |
309 | |
310 | static inline JSC::EncodedJSValue jsMediaListPrototypeFunctionAppendMediumBody(JSC::ExecState* state, typename IDLOperation<JSMediaList>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
311 | { |
312 | UNUSED_PARAM(state); |
313 | UNUSED_PARAM(throwScope); |
314 | auto& impl = castedThis->wrapped(); |
315 | if (UNLIKELY(state->argumentCount() < 1)) |
316 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
317 | auto newMedium = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
318 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
319 | impl.appendMedium(WTFMove(newMedium)); |
320 | return JSValue::encode(jsUndefined()); |
321 | } |
322 | |
323 | EncodedJSValue JSC_HOST_CALL jsMediaListPrototypeFunctionAppendMedium(ExecState* state) |
324 | { |
325 | return IDLOperation<JSMediaList>::call<jsMediaListPrototypeFunctionAppendMediumBody>(*state, "appendMedium" ); |
326 | } |
327 | |
328 | void JSMediaList::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
329 | { |
330 | auto* thisObject = jsCast<JSMediaList*>(cell); |
331 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
332 | if (thisObject->scriptExecutionContext()) |
333 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
334 | Base::heapSnapshot(cell, builder); |
335 | } |
336 | |
337 | bool JSMediaListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
338 | { |
339 | auto* jsMediaList = jsCast<JSMediaList*>(handle.slot()->asCell()); |
340 | void* root = WebCore::root(&jsMediaList->wrapped()); |
341 | if (UNLIKELY(reason)) |
342 | *reason = "Reachable from jsMediaList" ; |
343 | return visitor.containsOpaqueRoot(root); |
344 | } |
345 | |
346 | void JSMediaListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
347 | { |
348 | auto* jsMediaList = static_cast<JSMediaList*>(handle.slot()->asCell()); |
349 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
350 | uncacheWrapper(world, &jsMediaList->wrapped(), jsMediaList); |
351 | } |
352 | |
353 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MediaList>&& impl) |
354 | { |
355 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
356 | // attribute. You should remove that attribute. If the class has subclasses |
357 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
358 | // attribute to MediaList. |
359 | static_assert(!std::is_polymorphic<MediaList>::value, "MediaList is polymorphic but the IDL claims it is not" ); |
360 | return createWrapper<MediaList>(globalObject, WTFMove(impl)); |
361 | } |
362 | |
363 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MediaList& impl) |
364 | { |
365 | return wrap(state, globalObject, impl); |
366 | } |
367 | |
368 | MediaList* JSMediaList::toWrapped(JSC::VM& vm, JSC::JSValue value) |
369 | { |
370 | if (auto* wrapper = jsDynamicCast<JSMediaList*>(vm, value)) |
371 | return &wrapper->wrapped(); |
372 | return nullptr; |
373 | } |
374 | |
375 | } |
376 | |