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 "JSSVGStringList.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructorNotConstructable.h"
27#include "JSDOMConvertNumbers.h"
28#include "JSDOMConvertStrings.h"
29#include "JSDOMExceptionHandling.h"
30#include "JSDOMOperation.h"
31#include "JSDOMWrapperCache.h"
32#include "ScriptExecutionContext.h"
33#include <JavaScriptCore/FunctionPrototype.h>
34#include <JavaScriptCore/HeapSnapshotBuilder.h>
35#include <JavaScriptCore/JSCInlines.h>
36#include <wtf/GetPtr.h>
37#include <wtf/PointerPreparations.h>
38#include <wtf/URL.h>
39
40
41namespace WebCore {
42using namespace JSC;
43
44// Functions
45
46JSC::EncodedJSValue JSC_HOST_CALL jsSVGStringListPrototypeFunctionClear(JSC::ExecState*);
47JSC::EncodedJSValue JSC_HOST_CALL jsSVGStringListPrototypeFunctionInitialize(JSC::ExecState*);
48JSC::EncodedJSValue JSC_HOST_CALL jsSVGStringListPrototypeFunctionGetItem(JSC::ExecState*);
49JSC::EncodedJSValue JSC_HOST_CALL jsSVGStringListPrototypeFunctionInsertItemBefore(JSC::ExecState*);
50JSC::EncodedJSValue JSC_HOST_CALL jsSVGStringListPrototypeFunctionReplaceItem(JSC::ExecState*);
51JSC::EncodedJSValue JSC_HOST_CALL jsSVGStringListPrototypeFunctionRemoveItem(JSC::ExecState*);
52JSC::EncodedJSValue JSC_HOST_CALL jsSVGStringListPrototypeFunctionAppendItem(JSC::ExecState*);
53
54// Attributes
55
56JSC::EncodedJSValue jsSVGStringListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
57bool setJSSVGStringListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
58JSC::EncodedJSValue jsSVGStringListNumberOfItems(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
59
60class JSSVGStringListPrototype : public JSC::JSNonFinalObject {
61public:
62 using Base = JSC::JSNonFinalObject;
63 static JSSVGStringListPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
64 {
65 JSSVGStringListPrototype* ptr = new (NotNull, JSC::allocateCell<JSSVGStringListPrototype>(vm.heap)) JSSVGStringListPrototype(vm, globalObject, structure);
66 ptr->finishCreation(vm);
67 return ptr;
68 }
69
70 DECLARE_INFO;
71 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
72 {
73 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
74 }
75
76private:
77 JSSVGStringListPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
78 : JSC::JSNonFinalObject(vm, structure)
79 {
80 }
81
82 void finishCreation(JSC::VM&);
83};
84
85using JSSVGStringListConstructor = JSDOMConstructorNotConstructable<JSSVGStringList>;
86
87template<> JSValue JSSVGStringListConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
88{
89 UNUSED_PARAM(vm);
90 return globalObject.functionPrototype();
91}
92
93template<> void JSSVGStringListConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
94{
95 putDirect(vm, vm.propertyNames->prototype, JSSVGStringList::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
96 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("SVGStringList"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
97 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
98}
99
100template<> const ClassInfo JSSVGStringListConstructor::s_info = { "SVGStringList", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGStringListConstructor) };
101
102/* Hash table for prototype */
103
104static const HashTableValue JSSVGStringListPrototypeTableValues[] =
105{
106 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGStringListConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGStringListConstructor) } },
107 { "numberOfItems", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGStringListNumberOfItems), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
108 { "clear", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGStringListPrototypeFunctionClear), (intptr_t) (0) } },
109 { "initialize", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGStringListPrototypeFunctionInitialize), (intptr_t) (1) } },
110 { "getItem", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGStringListPrototypeFunctionGetItem), (intptr_t) (1) } },
111 { "insertItemBefore", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGStringListPrototypeFunctionInsertItemBefore), (intptr_t) (2) } },
112 { "replaceItem", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGStringListPrototypeFunctionReplaceItem), (intptr_t) (2) } },
113 { "removeItem", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGStringListPrototypeFunctionRemoveItem), (intptr_t) (1) } },
114 { "appendItem", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGStringListPrototypeFunctionAppendItem), (intptr_t) (1) } },
115};
116
117const ClassInfo JSSVGStringListPrototype::s_info = { "SVGStringListPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGStringListPrototype) };
118
119void JSSVGStringListPrototype::finishCreation(VM& vm)
120{
121 Base::finishCreation(vm);
122 reifyStaticProperties(vm, JSSVGStringList::info(), JSSVGStringListPrototypeTableValues, *this);
123}
124
125const ClassInfo JSSVGStringList::s_info = { "SVGStringList", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGStringList) };
126
127JSSVGStringList::JSSVGStringList(Structure* structure, JSDOMGlobalObject& globalObject, Ref<SVGStringList>&& impl)
128 : JSDOMWrapper<SVGStringList>(structure, globalObject, WTFMove(impl))
129{
130}
131
132void JSSVGStringList::finishCreation(VM& vm)
133{
134 Base::finishCreation(vm);
135 ASSERT(inherits(vm, info()));
136
137}
138
139JSObject* JSSVGStringList::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
140{
141 return JSSVGStringListPrototype::create(vm, &globalObject, JSSVGStringListPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
142}
143
144JSObject* JSSVGStringList::prototype(VM& vm, JSDOMGlobalObject& globalObject)
145{
146 return getDOMPrototype<JSSVGStringList>(vm, globalObject);
147}
148
149JSValue JSSVGStringList::getConstructor(VM& vm, const JSGlobalObject* globalObject)
150{
151 return getDOMConstructor<JSSVGStringListConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
152}
153
154void JSSVGStringList::destroy(JSC::JSCell* cell)
155{
156 JSSVGStringList* thisObject = static_cast<JSSVGStringList*>(cell);
157 thisObject->JSSVGStringList::~JSSVGStringList();
158}
159
160template<> inline JSSVGStringList* IDLAttribute<JSSVGStringList>::cast(ExecState& state, EncodedJSValue thisValue)
161{
162 return jsDynamicCast<JSSVGStringList*>(state.vm(), JSValue::decode(thisValue));
163}
164
165template<> inline JSSVGStringList* IDLOperation<JSSVGStringList>::cast(ExecState& state)
166{
167 return jsDynamicCast<JSSVGStringList*>(state.vm(), state.thisValue());
168}
169
170EncodedJSValue jsSVGStringListConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
171{
172 VM& vm = state->vm();
173 auto throwScope = DECLARE_THROW_SCOPE(vm);
174 auto* prototype = jsDynamicCast<JSSVGStringListPrototype*>(vm, JSValue::decode(thisValue));
175 if (UNLIKELY(!prototype))
176 return throwVMTypeError(state, throwScope);
177 return JSValue::encode(JSSVGStringList::getConstructor(state->vm(), prototype->globalObject()));
178}
179
180bool setJSSVGStringListConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
181{
182 VM& vm = state->vm();
183 auto throwScope = DECLARE_THROW_SCOPE(vm);
184 auto* prototype = jsDynamicCast<JSSVGStringListPrototype*>(vm, JSValue::decode(thisValue));
185 if (UNLIKELY(!prototype)) {
186 throwVMTypeError(state, throwScope);
187 return false;
188 }
189 // Shadowing a built-in constructor
190 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
191}
192
193static inline JSValue jsSVGStringListNumberOfItemsGetter(ExecState& state, JSSVGStringList& thisObject, ThrowScope& throwScope)
194{
195 UNUSED_PARAM(throwScope);
196 UNUSED_PARAM(state);
197 auto& impl = thisObject.wrapped();
198 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.numberOfItems());
199 return result;
200}
201
202EncodedJSValue jsSVGStringListNumberOfItems(ExecState* state, EncodedJSValue thisValue, PropertyName)
203{
204 return IDLAttribute<JSSVGStringList>::get<jsSVGStringListNumberOfItemsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "numberOfItems");
205}
206
207static inline JSC::EncodedJSValue jsSVGStringListPrototypeFunctionClearBody(JSC::ExecState* state, typename IDLOperation<JSSVGStringList>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
208{
209 UNUSED_PARAM(state);
210 UNUSED_PARAM(throwScope);
211 auto& impl = castedThis->wrapped();
212 propagateException(*state, throwScope, impl.clear());
213 return JSValue::encode(jsUndefined());
214}
215
216EncodedJSValue JSC_HOST_CALL jsSVGStringListPrototypeFunctionClear(ExecState* state)
217{
218 return IDLOperation<JSSVGStringList>::call<jsSVGStringListPrototypeFunctionClearBody>(*state, "clear");
219}
220
221static inline JSC::EncodedJSValue jsSVGStringListPrototypeFunctionInitializeBody(JSC::ExecState* state, typename IDLOperation<JSSVGStringList>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
222{
223 UNUSED_PARAM(state);
224 UNUSED_PARAM(throwScope);
225 auto& impl = castedThis->wrapped();
226 if (UNLIKELY(state->argumentCount() < 1))
227 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
228 auto item = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
229 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
230 return JSValue::encode(toJS<IDLDOMString>(*state, throwScope, impl.initialize(WTFMove(item))));
231}
232
233EncodedJSValue JSC_HOST_CALL jsSVGStringListPrototypeFunctionInitialize(ExecState* state)
234{
235 return IDLOperation<JSSVGStringList>::call<jsSVGStringListPrototypeFunctionInitializeBody>(*state, "initialize");
236}
237
238static inline JSC::EncodedJSValue jsSVGStringListPrototypeFunctionGetItemBody(JSC::ExecState* state, typename IDLOperation<JSSVGStringList>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
239{
240 UNUSED_PARAM(state);
241 UNUSED_PARAM(throwScope);
242 auto& impl = castedThis->wrapped();
243 if (UNLIKELY(state->argumentCount() < 1))
244 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
245 auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0));
246 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
247 return JSValue::encode(toJS<IDLDOMString>(*state, throwScope, impl.getItem(WTFMove(index))));
248}
249
250EncodedJSValue JSC_HOST_CALL jsSVGStringListPrototypeFunctionGetItem(ExecState* state)
251{
252 return IDLOperation<JSSVGStringList>::call<jsSVGStringListPrototypeFunctionGetItemBody>(*state, "getItem");
253}
254
255static inline JSC::EncodedJSValue jsSVGStringListPrototypeFunctionInsertItemBeforeBody(JSC::ExecState* state, typename IDLOperation<JSSVGStringList>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
256{
257 UNUSED_PARAM(state);
258 UNUSED_PARAM(throwScope);
259 auto& impl = castedThis->wrapped();
260 if (UNLIKELY(state->argumentCount() < 2))
261 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
262 auto item = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
263 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
264 auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(1));
265 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
266 return JSValue::encode(toJS<IDLDOMString>(*state, throwScope, impl.insertItemBefore(WTFMove(item), WTFMove(index))));
267}
268
269EncodedJSValue JSC_HOST_CALL jsSVGStringListPrototypeFunctionInsertItemBefore(ExecState* state)
270{
271 return IDLOperation<JSSVGStringList>::call<jsSVGStringListPrototypeFunctionInsertItemBeforeBody>(*state, "insertItemBefore");
272}
273
274static inline JSC::EncodedJSValue jsSVGStringListPrototypeFunctionReplaceItemBody(JSC::ExecState* state, typename IDLOperation<JSSVGStringList>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
275{
276 UNUSED_PARAM(state);
277 UNUSED_PARAM(throwScope);
278 auto& impl = castedThis->wrapped();
279 if (UNLIKELY(state->argumentCount() < 2))
280 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
281 auto item = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
282 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
283 auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(1));
284 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
285 return JSValue::encode(toJS<IDLDOMString>(*state, throwScope, impl.replaceItem(WTFMove(item), WTFMove(index))));
286}
287
288EncodedJSValue JSC_HOST_CALL jsSVGStringListPrototypeFunctionReplaceItem(ExecState* state)
289{
290 return IDLOperation<JSSVGStringList>::call<jsSVGStringListPrototypeFunctionReplaceItemBody>(*state, "replaceItem");
291}
292
293static inline JSC::EncodedJSValue jsSVGStringListPrototypeFunctionRemoveItemBody(JSC::ExecState* state, typename IDLOperation<JSSVGStringList>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
294{
295 UNUSED_PARAM(state);
296 UNUSED_PARAM(throwScope);
297 auto& impl = castedThis->wrapped();
298 if (UNLIKELY(state->argumentCount() < 1))
299 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
300 auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0));
301 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
302 return JSValue::encode(toJS<IDLDOMString>(*state, throwScope, impl.removeItem(WTFMove(index))));
303}
304
305EncodedJSValue JSC_HOST_CALL jsSVGStringListPrototypeFunctionRemoveItem(ExecState* state)
306{
307 return IDLOperation<JSSVGStringList>::call<jsSVGStringListPrototypeFunctionRemoveItemBody>(*state, "removeItem");
308}
309
310static inline JSC::EncodedJSValue jsSVGStringListPrototypeFunctionAppendItemBody(JSC::ExecState* state, typename IDLOperation<JSSVGStringList>::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 item = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
318 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
319 return JSValue::encode(toJS<IDLDOMString>(*state, throwScope, impl.appendItem(WTFMove(item))));
320}
321
322EncodedJSValue JSC_HOST_CALL jsSVGStringListPrototypeFunctionAppendItem(ExecState* state)
323{
324 return IDLOperation<JSSVGStringList>::call<jsSVGStringListPrototypeFunctionAppendItemBody>(*state, "appendItem");
325}
326
327void JSSVGStringList::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
328{
329 auto* thisObject = jsCast<JSSVGStringList*>(cell);
330 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
331 if (thisObject->scriptExecutionContext())
332 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
333 Base::heapSnapshot(cell, builder);
334}
335
336bool JSSVGStringListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
337{
338 UNUSED_PARAM(handle);
339 UNUSED_PARAM(visitor);
340 UNUSED_PARAM(reason);
341 return false;
342}
343
344void JSSVGStringListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
345{
346 auto* jsSVGStringList = static_cast<JSSVGStringList*>(handle.slot()->asCell());
347 auto& world = *static_cast<DOMWrapperWorld*>(context);
348 uncacheWrapper(world, &jsSVGStringList->wrapped(), jsSVGStringList);
349}
350
351#if ENABLE(BINDING_INTEGRITY)
352#if PLATFORM(WIN)
353#pragma warning(disable: 4483)
354extern "C" { extern void (*const __identifier("??_7SVGStringList@WebCore@@6B@")[])(); }
355#else
356extern "C" { extern void* _ZTVN7WebCore13SVGStringListE[]; }
357#endif
358#endif
359
360JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<SVGStringList>&& impl)
361{
362
363#if ENABLE(BINDING_INTEGRITY)
364 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
365#if PLATFORM(WIN)
366 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7SVGStringList@WebCore@@6B@"));
367#else
368 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore13SVGStringListE[2]);
369#endif
370
371 // If this fails SVGStringList does not have a vtable, so you need to add the
372 // ImplementationLacksVTable attribute to the interface definition
373 static_assert(std::is_polymorphic<SVGStringList>::value, "SVGStringList is not polymorphic");
374
375 // If you hit this assertion you either have a use after free bug, or
376 // SVGStringList has subclasses. If SVGStringList has subclasses that get passed
377 // to toJS() we currently require SVGStringList you to opt out of binding hardening
378 // by adding the SkipVTableValidation attribute to the interface IDL definition
379 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
380#endif
381 return createWrapper<SVGStringList>(globalObject, WTFMove(impl));
382}
383
384JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, SVGStringList& impl)
385{
386 return wrap(state, globalObject, impl);
387}
388
389SVGStringList* JSSVGStringList::toWrapped(JSC::VM& vm, JSC::JSValue value)
390{
391 if (auto* wrapper = jsDynamicCast<JSSVGStringList*>(vm, value))
392 return &wrapper->wrapped();
393 return nullptr;
394}
395
396}
397