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