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 "JSSVGLengthList.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructorNotConstructable.h"
27#include "JSDOMConvertInterface.h"
28#include "JSDOMConvertNumbers.h"
29#include "JSDOMExceptionHandling.h"
30#include "JSDOMGlobalObject.h"
31#include "JSDOMOperation.h"
32#include "JSDOMWrapperCache.h"
33#include "JSSVGLength.h"
34#include "ScriptExecutionContext.h"
35#include <JavaScriptCore/FunctionPrototype.h>
36#include <JavaScriptCore/HeapSnapshotBuilder.h>
37#include <JavaScriptCore/JSCInlines.h>
38#include <wtf/GetPtr.h>
39#include <wtf/PointerPreparations.h>
40#include <wtf/URL.h>
41
42
43namespace WebCore {
44using namespace JSC;
45
46// Functions
47
48JSC::EncodedJSValue JSC_HOST_CALL jsSVGLengthListPrototypeFunctionClear(JSC::ExecState*);
49JSC::EncodedJSValue JSC_HOST_CALL jsSVGLengthListPrototypeFunctionInitialize(JSC::ExecState*);
50JSC::EncodedJSValue JSC_HOST_CALL jsSVGLengthListPrototypeFunctionGetItem(JSC::ExecState*);
51JSC::EncodedJSValue JSC_HOST_CALL jsSVGLengthListPrototypeFunctionInsertItemBefore(JSC::ExecState*);
52JSC::EncodedJSValue JSC_HOST_CALL jsSVGLengthListPrototypeFunctionReplaceItem(JSC::ExecState*);
53JSC::EncodedJSValue JSC_HOST_CALL jsSVGLengthListPrototypeFunctionRemoveItem(JSC::ExecState*);
54JSC::EncodedJSValue JSC_HOST_CALL jsSVGLengthListPrototypeFunctionAppendItem(JSC::ExecState*);
55
56// Attributes
57
58JSC::EncodedJSValue jsSVGLengthListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
59bool setJSSVGLengthListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
60JSC::EncodedJSValue jsSVGLengthListNumberOfItems(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
61
62class JSSVGLengthListPrototype : public JSC::JSNonFinalObject {
63public:
64 using Base = JSC::JSNonFinalObject;
65 static JSSVGLengthListPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
66 {
67 JSSVGLengthListPrototype* ptr = new (NotNull, JSC::allocateCell<JSSVGLengthListPrototype>(vm.heap)) JSSVGLengthListPrototype(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
78private:
79 JSSVGLengthListPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
80 : JSC::JSNonFinalObject(vm, structure)
81 {
82 }
83
84 void finishCreation(JSC::VM&);
85};
86
87using JSSVGLengthListConstructor = JSDOMConstructorNotConstructable<JSSVGLengthList>;
88
89template<> JSValue JSSVGLengthListConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
90{
91 UNUSED_PARAM(vm);
92 return globalObject.functionPrototype();
93}
94
95template<> void JSSVGLengthListConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
96{
97 putDirect(vm, vm.propertyNames->prototype, JSSVGLengthList::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
98 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("SVGLengthList"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
99 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
100}
101
102template<> const ClassInfo JSSVGLengthListConstructor::s_info = { "SVGLengthList", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGLengthListConstructor) };
103
104/* Hash table for prototype */
105
106static const HashTableValue JSSVGLengthListPrototypeTableValues[] =
107{
108 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGLengthListConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGLengthListConstructor) } },
109 { "numberOfItems", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGLengthListNumberOfItems), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
110 { "clear", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGLengthListPrototypeFunctionClear), (intptr_t) (0) } },
111 { "initialize", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGLengthListPrototypeFunctionInitialize), (intptr_t) (1) } },
112 { "getItem", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGLengthListPrototypeFunctionGetItem), (intptr_t) (1) } },
113 { "insertItemBefore", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGLengthListPrototypeFunctionInsertItemBefore), (intptr_t) (2) } },
114 { "replaceItem", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGLengthListPrototypeFunctionReplaceItem), (intptr_t) (2) } },
115 { "removeItem", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGLengthListPrototypeFunctionRemoveItem), (intptr_t) (1) } },
116 { "appendItem", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsSVGLengthListPrototypeFunctionAppendItem), (intptr_t) (1) } },
117};
118
119const ClassInfo JSSVGLengthListPrototype::s_info = { "SVGLengthListPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGLengthListPrototype) };
120
121void JSSVGLengthListPrototype::finishCreation(VM& vm)
122{
123 Base::finishCreation(vm);
124 reifyStaticProperties(vm, JSSVGLengthList::info(), JSSVGLengthListPrototypeTableValues, *this);
125}
126
127const ClassInfo JSSVGLengthList::s_info = { "SVGLengthList", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSSVGLengthList) };
128
129JSSVGLengthList::JSSVGLengthList(Structure* structure, JSDOMGlobalObject& globalObject, Ref<SVGLengthList>&& impl)
130 : JSDOMWrapper<SVGLengthList>(structure, globalObject, WTFMove(impl))
131{
132}
133
134void JSSVGLengthList::finishCreation(VM& vm)
135{
136 Base::finishCreation(vm);
137 ASSERT(inherits(vm, info()));
138
139}
140
141JSObject* JSSVGLengthList::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
142{
143 return JSSVGLengthListPrototype::create(vm, &globalObject, JSSVGLengthListPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
144}
145
146JSObject* JSSVGLengthList::prototype(VM& vm, JSDOMGlobalObject& globalObject)
147{
148 return getDOMPrototype<JSSVGLengthList>(vm, globalObject);
149}
150
151JSValue JSSVGLengthList::getConstructor(VM& vm, const JSGlobalObject* globalObject)
152{
153 return getDOMConstructor<JSSVGLengthListConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
154}
155
156void JSSVGLengthList::destroy(JSC::JSCell* cell)
157{
158 JSSVGLengthList* thisObject = static_cast<JSSVGLengthList*>(cell);
159 thisObject->JSSVGLengthList::~JSSVGLengthList();
160}
161
162template<> inline JSSVGLengthList* IDLAttribute<JSSVGLengthList>::cast(ExecState& state, EncodedJSValue thisValue)
163{
164 return jsDynamicCast<JSSVGLengthList*>(state.vm(), JSValue::decode(thisValue));
165}
166
167template<> inline JSSVGLengthList* IDLOperation<JSSVGLengthList>::cast(ExecState& state)
168{
169 return jsDynamicCast<JSSVGLengthList*>(state.vm(), state.thisValue());
170}
171
172EncodedJSValue jsSVGLengthListConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
173{
174 VM& vm = state->vm();
175 auto throwScope = DECLARE_THROW_SCOPE(vm);
176 auto* prototype = jsDynamicCast<JSSVGLengthListPrototype*>(vm, JSValue::decode(thisValue));
177 if (UNLIKELY(!prototype))
178 return throwVMTypeError(state, throwScope);
179 return JSValue::encode(JSSVGLengthList::getConstructor(state->vm(), prototype->globalObject()));
180}
181
182bool setJSSVGLengthListConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
183{
184 VM& vm = state->vm();
185 auto throwScope = DECLARE_THROW_SCOPE(vm);
186 auto* prototype = jsDynamicCast<JSSVGLengthListPrototype*>(vm, JSValue::decode(thisValue));
187 if (UNLIKELY(!prototype)) {
188 throwVMTypeError(state, throwScope);
189 return false;
190 }
191 // Shadowing a built-in constructor
192 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
193}
194
195static inline JSValue jsSVGLengthListNumberOfItemsGetter(ExecState& state, JSSVGLengthList& thisObject, ThrowScope& throwScope)
196{
197 UNUSED_PARAM(throwScope);
198 UNUSED_PARAM(state);
199 auto& impl = thisObject.wrapped();
200 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.numberOfItems());
201 return result;
202}
203
204EncodedJSValue jsSVGLengthListNumberOfItems(ExecState* state, EncodedJSValue thisValue, PropertyName)
205{
206 return IDLAttribute<JSSVGLengthList>::get<jsSVGLengthListNumberOfItemsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "numberOfItems");
207}
208
209static inline JSC::EncodedJSValue jsSVGLengthListPrototypeFunctionClearBody(JSC::ExecState* state, typename IDLOperation<JSSVGLengthList>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
210{
211 UNUSED_PARAM(state);
212 UNUSED_PARAM(throwScope);
213 auto& impl = castedThis->wrapped();
214 propagateException(*state, throwScope, impl.clear());
215 return JSValue::encode(jsUndefined());
216}
217
218EncodedJSValue JSC_HOST_CALL jsSVGLengthListPrototypeFunctionClear(ExecState* state)
219{
220 return IDLOperation<JSSVGLengthList>::call<jsSVGLengthListPrototypeFunctionClearBody>(*state, "clear");
221}
222
223static inline JSC::EncodedJSValue jsSVGLengthListPrototypeFunctionInitializeBody(JSC::ExecState* state, typename IDLOperation<JSSVGLengthList>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
224{
225 UNUSED_PARAM(state);
226 UNUSED_PARAM(throwScope);
227 auto& impl = castedThis->wrapped();
228 if (UNLIKELY(state->argumentCount() < 1))
229 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
230 auto item = convert<IDLInterface<SVGLength>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "item", "SVGLengthList", "initialize", "SVGLength"); });
231 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
232 return JSValue::encode(toJS<IDLInterface<SVGLength>>(*state, *castedThis->globalObject(), throwScope, impl.initialize(*item)));
233}
234
235EncodedJSValue JSC_HOST_CALL jsSVGLengthListPrototypeFunctionInitialize(ExecState* state)
236{
237 return IDLOperation<JSSVGLengthList>::call<jsSVGLengthListPrototypeFunctionInitializeBody>(*state, "initialize");
238}
239
240static inline JSC::EncodedJSValue jsSVGLengthListPrototypeFunctionGetItemBody(JSC::ExecState* state, typename IDLOperation<JSSVGLengthList>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
241{
242 UNUSED_PARAM(state);
243 UNUSED_PARAM(throwScope);
244 auto& impl = castedThis->wrapped();
245 if (UNLIKELY(state->argumentCount() < 1))
246 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
247 auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0));
248 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
249 return JSValue::encode(toJS<IDLInterface<SVGLength>>(*state, *castedThis->globalObject(), throwScope, impl.getItem(WTFMove(index))));
250}
251
252EncodedJSValue JSC_HOST_CALL jsSVGLengthListPrototypeFunctionGetItem(ExecState* state)
253{
254 return IDLOperation<JSSVGLengthList>::call<jsSVGLengthListPrototypeFunctionGetItemBody>(*state, "getItem");
255}
256
257static inline JSC::EncodedJSValue jsSVGLengthListPrototypeFunctionInsertItemBeforeBody(JSC::ExecState* state, typename IDLOperation<JSSVGLengthList>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
258{
259 UNUSED_PARAM(state);
260 UNUSED_PARAM(throwScope);
261 auto& impl = castedThis->wrapped();
262 if (UNLIKELY(state->argumentCount() < 2))
263 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
264 auto item = convert<IDLInterface<SVGLength>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "item", "SVGLengthList", "insertItemBefore", "SVGLength"); });
265 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
266 auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(1));
267 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
268 return JSValue::encode(toJS<IDLInterface<SVGLength>>(*state, *castedThis->globalObject(), throwScope, impl.insertItemBefore(*item, WTFMove(index))));
269}
270
271EncodedJSValue JSC_HOST_CALL jsSVGLengthListPrototypeFunctionInsertItemBefore(ExecState* state)
272{
273 return IDLOperation<JSSVGLengthList>::call<jsSVGLengthListPrototypeFunctionInsertItemBeforeBody>(*state, "insertItemBefore");
274}
275
276static inline JSC::EncodedJSValue jsSVGLengthListPrototypeFunctionReplaceItemBody(JSC::ExecState* state, typename IDLOperation<JSSVGLengthList>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
277{
278 UNUSED_PARAM(state);
279 UNUSED_PARAM(throwScope);
280 auto& impl = castedThis->wrapped();
281 if (UNLIKELY(state->argumentCount() < 2))
282 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
283 auto item = convert<IDLInterface<SVGLength>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "item", "SVGLengthList", "replaceItem", "SVGLength"); });
284 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
285 auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(1));
286 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
287 return JSValue::encode(toJS<IDLInterface<SVGLength>>(*state, *castedThis->globalObject(), throwScope, impl.replaceItem(*item, WTFMove(index))));
288}
289
290EncodedJSValue JSC_HOST_CALL jsSVGLengthListPrototypeFunctionReplaceItem(ExecState* state)
291{
292 return IDLOperation<JSSVGLengthList>::call<jsSVGLengthListPrototypeFunctionReplaceItemBody>(*state, "replaceItem");
293}
294
295static inline JSC::EncodedJSValue jsSVGLengthListPrototypeFunctionRemoveItemBody(JSC::ExecState* state, typename IDLOperation<JSSVGLengthList>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
296{
297 UNUSED_PARAM(state);
298 UNUSED_PARAM(throwScope);
299 auto& impl = castedThis->wrapped();
300 if (UNLIKELY(state->argumentCount() < 1))
301 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
302 auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0));
303 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
304 return JSValue::encode(toJS<IDLInterface<SVGLength>>(*state, *castedThis->globalObject(), throwScope, impl.removeItem(WTFMove(index))));
305}
306
307EncodedJSValue JSC_HOST_CALL jsSVGLengthListPrototypeFunctionRemoveItem(ExecState* state)
308{
309 return IDLOperation<JSSVGLengthList>::call<jsSVGLengthListPrototypeFunctionRemoveItemBody>(*state, "removeItem");
310}
311
312static inline JSC::EncodedJSValue jsSVGLengthListPrototypeFunctionAppendItemBody(JSC::ExecState* state, typename IDLOperation<JSSVGLengthList>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
313{
314 UNUSED_PARAM(state);
315 UNUSED_PARAM(throwScope);
316 auto& impl = castedThis->wrapped();
317 if (UNLIKELY(state->argumentCount() < 1))
318 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
319 auto item = convert<IDLInterface<SVGLength>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "item", "SVGLengthList", "appendItem", "SVGLength"); });
320 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
321 return JSValue::encode(toJS<IDLInterface<SVGLength>>(*state, *castedThis->globalObject(), throwScope, impl.appendItem(*item)));
322}
323
324EncodedJSValue JSC_HOST_CALL jsSVGLengthListPrototypeFunctionAppendItem(ExecState* state)
325{
326 return IDLOperation<JSSVGLengthList>::call<jsSVGLengthListPrototypeFunctionAppendItemBody>(*state, "appendItem");
327}
328
329void JSSVGLengthList::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
330{
331 auto* thisObject = jsCast<JSSVGLengthList*>(cell);
332 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
333 if (thisObject->scriptExecutionContext())
334 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
335 Base::heapSnapshot(cell, builder);
336}
337
338bool JSSVGLengthListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
339{
340 UNUSED_PARAM(handle);
341 UNUSED_PARAM(visitor);
342 UNUSED_PARAM(reason);
343 return false;
344}
345
346void JSSVGLengthListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
347{
348 auto* jsSVGLengthList = static_cast<JSSVGLengthList*>(handle.slot()->asCell());
349 auto& world = *static_cast<DOMWrapperWorld*>(context);
350 uncacheWrapper(world, &jsSVGLengthList->wrapped(), jsSVGLengthList);
351}
352
353JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<SVGLengthList>&& impl)
354{
355 return createWrapper<SVGLengthList>(globalObject, WTFMove(impl));
356}
357
358JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, SVGLengthList& impl)
359{
360 return wrap(state, globalObject, impl);
361}
362
363SVGLengthList* JSSVGLengthList::toWrapped(JSC::VM& vm, JSC::JSValue value)
364{
365 if (auto* wrapper = jsDynamicCast<JSSVGLengthList*>(vm, value))
366 return &wrapper->wrapped();
367 return nullptr;
368}
369
370}
371