Generate Element casting helper functions
[WebKit.git] / Source / WebCore / bindings / scripts / test / JS / JSTestTypedefs.cpp
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 "JSTestTypedefs.h"
23
24 #include "DOMStringList.h"
25 #include "ExceptionCode.h"
26 #include "JSDOMBinding.h"
27 #include "JSDOMStringList.h"
28 #include "JSSVGPoint.h"
29 #include "JSSerializedScriptValue.h"
30 #include "JSTestCallback.h"
31 #include "JSTestEventTarget.h"
32 #include "JSTestSubObj.h"
33 #include "SVGPoint.h"
34 #include "ScriptExecutionContext.h"
35 #include "SerializedScriptValue.h"
36 #include "TestTypedefs.h"
37 #include "URL.h"
38 #include <runtime/Error.h>
39 #include <runtime/JSArray.h>
40 #include <runtime/JSString.h>
41 #include <wtf/GetPtr.h>
42
43 using namespace JSC;
44
45 namespace WebCore {
46
47 // Functions
48
49 JSC::EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionFunc(JSC::ExecState*);
50 JSC::EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionSetShadow(JSC::ExecState*);
51 JSC::EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionMethodWithSequenceArg(JSC::ExecState*);
52 JSC::EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionNullableArrayArg(JSC::ExecState*);
53 JSC::EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionFuncWithClamp(JSC::ExecState*);
54 JSC::EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionImmutablePointFunction(JSC::ExecState*);
55 JSC::EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionStringArrayFunction(JSC::ExecState*);
56 JSC::EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionStringArrayFunction2(JSC::ExecState*);
57 JSC::EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionCallWithSequenceThatRequiresInclude(JSC::ExecState*);
58 JSC::EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionMethodWithException(JSC::ExecState*);
59
60 // Attributes
61
62 JSC::EncodedJSValue jsTestTypedefsUnsignedLongLongAttr(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
63 void setJSTestTypedefsUnsignedLongLongAttr(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
64 JSC::EncodedJSValue jsTestTypedefsImmutableSerializedScriptValue(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
65 void setJSTestTypedefsImmutableSerializedScriptValue(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
66 JSC::EncodedJSValue jsTestTypedefsConstructorTestSubObj(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
67 JSC::EncodedJSValue jsTestTypedefsAttrWithGetterException(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
68 void setJSTestTypedefsAttrWithGetterException(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
69 JSC::EncodedJSValue jsTestTypedefsAttrWithSetterException(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
70 void setJSTestTypedefsAttrWithSetterException(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
71 JSC::EncodedJSValue jsTestTypedefsStringAttrWithGetterException(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
72 void setJSTestTypedefsStringAttrWithGetterException(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
73 JSC::EncodedJSValue jsTestTypedefsStringAttrWithSetterException(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
74 void setJSTestTypedefsStringAttrWithSetterException(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
75 JSC::EncodedJSValue jsTestTypedefsConstructor(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
76
77 class JSTestTypedefsPrototype : public JSC::JSNonFinalObject {
78 public:
79     typedef JSC::JSNonFinalObject Base;
80     static JSTestTypedefsPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
81     {
82         JSTestTypedefsPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestTypedefsPrototype>(vm.heap)) JSTestTypedefsPrototype(vm, globalObject, structure);
83         ptr->finishCreation(vm);
84         return ptr;
85     }
86
87     DECLARE_INFO;
88     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
89     {
90         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
91     }
92
93 private:
94     JSTestTypedefsPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
95         : JSC::JSNonFinalObject(vm, structure)
96     {
97     }
98
99     void finishCreation(JSC::VM&);
100 };
101
102 class JSTestTypedefsConstructor : public DOMConstructorObject {
103 private:
104     JSTestTypedefsConstructor(JSC::Structure*, JSDOMGlobalObject*);
105     void finishCreation(JSC::VM&, JSDOMGlobalObject*);
106
107 public:
108     typedef DOMConstructorObject Base;
109     static JSTestTypedefsConstructor* create(JSC::VM& vm, JSC::Structure* structure, JSDOMGlobalObject* globalObject)
110     {
111         JSTestTypedefsConstructor* ptr = new (NotNull, JSC::allocateCell<JSTestTypedefsConstructor>(vm.heap)) JSTestTypedefsConstructor(structure, globalObject);
112         ptr->finishCreation(vm, globalObject);
113         return ptr;
114     }
115
116     DECLARE_INFO;
117     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
118     {
119         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
120     }
121 protected:
122     static JSC::EncodedJSValue JSC_HOST_CALL constructJSTestTypedefs(JSC::ExecState*);
123     static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);
124 };
125
126 /* Hash table */
127
128 static const struct CompactHashIndex JSTestTypedefsTableIndex[2] = {
129     { -1, -1 },
130     { -1, -1 },
131 };
132
133
134 static const HashTableValue JSTestTypedefsTableValues[] =
135 {
136     { 0, 0, NoIntrinsic, 0, 0 }
137 };
138
139 static const HashTable JSTestTypedefsTable = { 0, 1, false, JSTestTypedefsTableValues, 0, JSTestTypedefsTableIndex };
140 /* Hash table for constructor */
141
142 static const HashTableValue JSTestTypedefsConstructorTableValues[] =
143 {
144     { "TestSubObj", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestTypedefsConstructorTestSubObj), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
145 };
146
147 EncodedJSValue JSC_HOST_CALL JSTestTypedefsConstructor::constructJSTestTypedefs(ExecState* exec)
148 {
149     JSTestTypedefsConstructor* castedThis = jsCast<JSTestTypedefsConstructor*>(exec->callee());
150     if (exec->argumentCount() < 2)
151         return throwVMError(exec, createNotEnoughArgumentsError(exec));
152     const String& hello(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec));
153     if (UNLIKELY(exec->hadException()))
154         return JSValue::encode(jsUndefined());
155     if (!exec->argument(1).isFunction())
156         return throwArgumentMustBeFunctionError(*exec, 1, "testCallback", "TestTypedefs", nullptr);
157     RefPtr<TestCallback> testCallback = JSTestCallback::create(asObject(exec->uncheckedArgument(1)), castedThis->globalObject());
158     RefPtr<TestTypedefs> object = TestTypedefs::create(hello, testCallback);
159     return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
160 }
161
162 const ClassInfo JSTestTypedefsConstructor::s_info = { "TestTypedefsConstructor", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestTypedefsConstructor) };
163
164 JSTestTypedefsConstructor::JSTestTypedefsConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
165     : DOMConstructorObject(structure, globalObject)
166 {
167 }
168
169 void JSTestTypedefsConstructor::finishCreation(VM& vm, JSDOMGlobalObject* globalObject)
170 {
171     Base::finishCreation(vm);
172     ASSERT(inherits(info()));
173     putDirect(vm, vm.propertyNames->prototype, JSTestTypedefs::getPrototype(vm, globalObject), DontDelete | ReadOnly);
174     putDirect(vm, vm.propertyNames->length, jsNumber(2), ReadOnly | DontDelete | DontEnum);
175     reifyStaticProperties(vm, JSTestTypedefsConstructorTableValues, *this);
176 }
177
178 ConstructType JSTestTypedefsConstructor::getConstructData(JSCell*, ConstructData& constructData)
179 {
180     constructData.native.function = constructJSTestTypedefs;
181     return ConstructTypeHost;
182 }
183
184 /* Hash table for prototype */
185
186 static const HashTableValue JSTestTypedefsPrototypeTableValues[] =
187 {
188     { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestTypedefsConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
189     { "unsignedLongLongAttr", DontDelete | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestTypedefsUnsignedLongLongAttr), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestTypedefsUnsignedLongLongAttr) },
190     { "immutableSerializedScriptValue", DontDelete | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestTypedefsImmutableSerializedScriptValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestTypedefsImmutableSerializedScriptValue) },
191     { "attrWithGetterException", DontDelete | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestTypedefsAttrWithGetterException), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestTypedefsAttrWithGetterException) },
192     { "attrWithSetterException", DontDelete | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestTypedefsAttrWithSetterException), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestTypedefsAttrWithSetterException) },
193     { "stringAttrWithGetterException", DontDelete | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestTypedefsStringAttrWithGetterException), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestTypedefsStringAttrWithGetterException) },
194     { "stringAttrWithSetterException", DontDelete | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestTypedefsStringAttrWithSetterException), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestTypedefsStringAttrWithSetterException) },
195     { "func", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionFunc), (intptr_t) (0) },
196     { "setShadow", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionSetShadow), (intptr_t) (3) },
197     { "methodWithSequenceArg", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionMethodWithSequenceArg), (intptr_t) (1) },
198     { "nullableArrayArg", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionNullableArrayArg), (intptr_t) (1) },
199     { "funcWithClamp", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionFuncWithClamp), (intptr_t) (1) },
200     { "immutablePointFunction", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionImmutablePointFunction), (intptr_t) (0) },
201     { "stringArrayFunction", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionStringArrayFunction), (intptr_t) (1) },
202     { "stringArrayFunction2", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionStringArrayFunction2), (intptr_t) (1) },
203     { "callWithSequenceThatRequiresInclude", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionCallWithSequenceThatRequiresInclude), (intptr_t) (1) },
204     { "methodWithException", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionMethodWithException), (intptr_t) (0) },
205 };
206
207 WEBCORE_EXPORT const ClassInfo JSTestTypedefsPrototype::s_info = { "TestTypedefsPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestTypedefsPrototype) };
208
209 void JSTestTypedefsPrototype::finishCreation(VM& vm)
210 {
211     Base::finishCreation(vm);
212     reifyStaticProperties(vm, JSTestTypedefsPrototypeTableValues, *this);
213 }
214
215 WEBCORE_EXPORT const ClassInfo JSTestTypedefs::s_info = { "TestTypedefs", &Base::s_info, &JSTestTypedefsTable, CREATE_METHOD_TABLE(JSTestTypedefs) };
216
217 JSTestTypedefs::JSTestTypedefs(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestTypedefs> impl)
218     : JSDOMWrapper(structure, globalObject)
219     , m_impl(impl.leakRef())
220 {
221 }
222
223 JSObject* JSTestTypedefs::createPrototype(VM& vm, JSGlobalObject* globalObject)
224 {
225     return JSTestTypedefsPrototype::create(vm, globalObject, JSTestTypedefsPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
226 }
227
228 JSObject* JSTestTypedefs::getPrototype(VM& vm, JSGlobalObject* globalObject)
229 {
230     return getDOMPrototype<JSTestTypedefs>(vm, globalObject);
231 }
232
233 void JSTestTypedefs::destroy(JSC::JSCell* cell)
234 {
235     JSTestTypedefs* thisObject = static_cast<JSTestTypedefs*>(cell);
236     thisObject->JSTestTypedefs::~JSTestTypedefs();
237 }
238
239 JSTestTypedefs::~JSTestTypedefs()
240 {
241     releaseImplIfNotNull();
242 }
243
244 bool JSTestTypedefs::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
245 {
246     JSTestTypedefs* thisObject = jsCast<JSTestTypedefs*>(object);
247     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
248     return getStaticValueSlot<JSTestTypedefs, Base>(exec, JSTestTypedefsTable, thisObject, propertyName, slot);
249 }
250
251 EncodedJSValue jsTestTypedefsUnsignedLongLongAttr(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
252 {
253     UNUSED_PARAM(exec);
254     UNUSED_PARAM(slotBase);
255     UNUSED_PARAM(thisValue);
256     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
257     if (UNLIKELY(!castedThis)) {
258         if (jsDynamicCast<JSTestTypedefsPrototype*>(slotBase))
259             return reportDeprecatedGetterError(*exec, "TestTypedefs", "unsignedLongLongAttr");
260         return throwGetterTypeError(*exec, "TestTypedefs", "unsignedLongLongAttr");
261     }
262     TestTypedefs& impl = castedThis->impl();
263     JSValue result = jsNumber(impl.unsignedLongLongAttr());
264     return JSValue::encode(result);
265 }
266
267
268 EncodedJSValue jsTestTypedefsImmutableSerializedScriptValue(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
269 {
270     UNUSED_PARAM(exec);
271     UNUSED_PARAM(slotBase);
272     UNUSED_PARAM(thisValue);
273     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
274     if (UNLIKELY(!castedThis)) {
275         if (jsDynamicCast<JSTestTypedefsPrototype*>(slotBase))
276             return reportDeprecatedGetterError(*exec, "TestTypedefs", "immutableSerializedScriptValue");
277         return throwGetterTypeError(*exec, "TestTypedefs", "immutableSerializedScriptValue");
278     }
279     TestTypedefs& impl = castedThis->impl();
280     JSValue result = impl.immutableSerializedScriptValue() ? impl.immutableSerializedScriptValue()->deserialize(exec, castedThis->globalObject(), 0) : jsNull();
281     return JSValue::encode(result);
282 }
283
284
285 EncodedJSValue jsTestTypedefsConstructorTestSubObj(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
286 {
287     UNUSED_PARAM(exec);
288     UNUSED_PARAM(slotBase);
289     UNUSED_PARAM(thisValue);
290     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(slotBase);
291     return JSValue::encode(JSTestSubObj::getConstructor(exec->vm(), castedThis->globalObject()));
292 }
293
294
295 EncodedJSValue jsTestTypedefsAttrWithGetterException(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
296 {
297     UNUSED_PARAM(exec);
298     UNUSED_PARAM(slotBase);
299     UNUSED_PARAM(thisValue);
300     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
301     if (UNLIKELY(!castedThis)) {
302         if (jsDynamicCast<JSTestTypedefsPrototype*>(slotBase))
303             return reportDeprecatedGetterError(*exec, "TestTypedefs", "attrWithGetterException");
304         return throwGetterTypeError(*exec, "TestTypedefs", "attrWithGetterException");
305     }
306     ExceptionCode ec = 0;
307     TestTypedefs& impl = castedThis->impl();
308     JSValue result = jsNumber(impl.attrWithGetterException(ec));
309     setDOMException(exec, ec);
310     return JSValue::encode(result);
311 }
312
313
314 EncodedJSValue jsTestTypedefsAttrWithSetterException(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
315 {
316     UNUSED_PARAM(exec);
317     UNUSED_PARAM(slotBase);
318     UNUSED_PARAM(thisValue);
319     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
320     if (UNLIKELY(!castedThis)) {
321         if (jsDynamicCast<JSTestTypedefsPrototype*>(slotBase))
322             return reportDeprecatedGetterError(*exec, "TestTypedefs", "attrWithSetterException");
323         return throwGetterTypeError(*exec, "TestTypedefs", "attrWithSetterException");
324     }
325     TestTypedefs& impl = castedThis->impl();
326     JSValue result = jsNumber(impl.attrWithSetterException());
327     return JSValue::encode(result);
328 }
329
330
331 EncodedJSValue jsTestTypedefsStringAttrWithGetterException(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
332 {
333     UNUSED_PARAM(exec);
334     UNUSED_PARAM(slotBase);
335     UNUSED_PARAM(thisValue);
336     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
337     if (UNLIKELY(!castedThis)) {
338         if (jsDynamicCast<JSTestTypedefsPrototype*>(slotBase))
339             return reportDeprecatedGetterError(*exec, "TestTypedefs", "stringAttrWithGetterException");
340         return throwGetterTypeError(*exec, "TestTypedefs", "stringAttrWithGetterException");
341     }
342     ExceptionCode ec = 0;
343     TestTypedefs& impl = castedThis->impl();
344     JSValue result = jsStringWithCache(exec, impl.stringAttrWithGetterException(ec));
345     setDOMException(exec, ec);
346     return JSValue::encode(result);
347 }
348
349
350 EncodedJSValue jsTestTypedefsStringAttrWithSetterException(ExecState* exec, JSObject* slotBase, EncodedJSValue thisValue, PropertyName)
351 {
352     UNUSED_PARAM(exec);
353     UNUSED_PARAM(slotBase);
354     UNUSED_PARAM(thisValue);
355     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
356     if (UNLIKELY(!castedThis)) {
357         if (jsDynamicCast<JSTestTypedefsPrototype*>(slotBase))
358             return reportDeprecatedGetterError(*exec, "TestTypedefs", "stringAttrWithSetterException");
359         return throwGetterTypeError(*exec, "TestTypedefs", "stringAttrWithSetterException");
360     }
361     TestTypedefs& impl = castedThis->impl();
362     JSValue result = jsStringWithCache(exec, impl.stringAttrWithSetterException());
363     return JSValue::encode(result);
364 }
365
366
367 EncodedJSValue jsTestTypedefsConstructor(ExecState* exec, JSObject* baseValue, EncodedJSValue, PropertyName)
368 {
369     JSTestTypedefsPrototype* domObject = jsDynamicCast<JSTestTypedefsPrototype*>(baseValue);
370     if (!domObject)
371         return throwVMTypeError(exec);
372     return JSValue::encode(JSTestTypedefs::getConstructor(exec->vm(), domObject->globalObject()));
373 }
374
375 void setJSTestTypedefsUnsignedLongLongAttr(ExecState* exec, JSObject* baseObject, EncodedJSValue thisValue, EncodedJSValue encodedValue)
376 {
377     JSValue value = JSValue::decode(encodedValue);
378     UNUSED_PARAM(baseObject);
379     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
380     if (UNLIKELY(!castedThis)) {
381         if (jsDynamicCast<JSTestTypedefsPrototype*>(JSValue::decode(thisValue)))
382             reportDeprecatedSetterError(*exec, "TestTypedefs", "unsignedLongLongAttr");
383         else
384             throwSetterTypeError(*exec, "TestTypedefs", "unsignedLongLongAttr");
385         return;
386     }
387     TestTypedefs& impl = castedThis->impl();
388     unsigned long long nativeValue(toUInt64(exec, value, NormalConversion));
389     if (UNLIKELY(exec->hadException()))
390         return;
391     impl.setUnsignedLongLongAttr(nativeValue);
392 }
393
394
395 void setJSTestTypedefsImmutableSerializedScriptValue(ExecState* exec, JSObject* baseObject, EncodedJSValue thisValue, EncodedJSValue encodedValue)
396 {
397     JSValue value = JSValue::decode(encodedValue);
398     UNUSED_PARAM(baseObject);
399     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
400     if (UNLIKELY(!castedThis)) {
401         if (jsDynamicCast<JSTestTypedefsPrototype*>(JSValue::decode(thisValue)))
402             reportDeprecatedSetterError(*exec, "TestTypedefs", "immutableSerializedScriptValue");
403         else
404             throwSetterTypeError(*exec, "TestTypedefs", "immutableSerializedScriptValue");
405         return;
406     }
407     TestTypedefs& impl = castedThis->impl();
408     RefPtr<SerializedScriptValue> nativeValue(SerializedScriptValue::create(exec, value, 0, 0));
409     if (UNLIKELY(exec->hadException()))
410         return;
411     impl.setImmutableSerializedScriptValue(nativeValue);
412 }
413
414
415 void setJSTestTypedefsAttrWithGetterException(ExecState* exec, JSObject* baseObject, EncodedJSValue thisValue, EncodedJSValue encodedValue)
416 {
417     JSValue value = JSValue::decode(encodedValue);
418     UNUSED_PARAM(baseObject);
419     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
420     if (UNLIKELY(!castedThis)) {
421         if (jsDynamicCast<JSTestTypedefsPrototype*>(JSValue::decode(thisValue)))
422             reportDeprecatedSetterError(*exec, "TestTypedefs", "attrWithGetterException");
423         else
424             throwSetterTypeError(*exec, "TestTypedefs", "attrWithGetterException");
425         return;
426     }
427     TestTypedefs& impl = castedThis->impl();
428     int nativeValue(toInt32(exec, value, NormalConversion));
429     if (UNLIKELY(exec->hadException()))
430         return;
431     impl.setAttrWithGetterException(nativeValue);
432 }
433
434
435 void setJSTestTypedefsAttrWithSetterException(ExecState* exec, JSObject* baseObject, EncodedJSValue thisValue, EncodedJSValue encodedValue)
436 {
437     JSValue value = JSValue::decode(encodedValue);
438     UNUSED_PARAM(baseObject);
439     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
440     if (UNLIKELY(!castedThis)) {
441         if (jsDynamicCast<JSTestTypedefsPrototype*>(JSValue::decode(thisValue)))
442             reportDeprecatedSetterError(*exec, "TestTypedefs", "attrWithSetterException");
443         else
444             throwSetterTypeError(*exec, "TestTypedefs", "attrWithSetterException");
445         return;
446     }
447     TestTypedefs& impl = castedThis->impl();
448     ExceptionCode ec = 0;
449     int nativeValue(toInt32(exec, value, NormalConversion));
450     if (UNLIKELY(exec->hadException()))
451         return;
452     impl.setAttrWithSetterException(nativeValue, ec);
453     setDOMException(exec, ec);
454 }
455
456
457 void setJSTestTypedefsStringAttrWithGetterException(ExecState* exec, JSObject* baseObject, EncodedJSValue thisValue, EncodedJSValue encodedValue)
458 {
459     JSValue value = JSValue::decode(encodedValue);
460     UNUSED_PARAM(baseObject);
461     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
462     if (UNLIKELY(!castedThis)) {
463         if (jsDynamicCast<JSTestTypedefsPrototype*>(JSValue::decode(thisValue)))
464             reportDeprecatedSetterError(*exec, "TestTypedefs", "stringAttrWithGetterException");
465         else
466             throwSetterTypeError(*exec, "TestTypedefs", "stringAttrWithGetterException");
467         return;
468     }
469     TestTypedefs& impl = castedThis->impl();
470     const String& nativeValue(value.isEmpty() ? String() : value.toString(exec)->value(exec));
471     if (UNLIKELY(exec->hadException()))
472         return;
473     impl.setStringAttrWithGetterException(nativeValue);
474 }
475
476
477 void setJSTestTypedefsStringAttrWithSetterException(ExecState* exec, JSObject* baseObject, EncodedJSValue thisValue, EncodedJSValue encodedValue)
478 {
479     JSValue value = JSValue::decode(encodedValue);
480     UNUSED_PARAM(baseObject);
481     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(JSValue::decode(thisValue));
482     if (UNLIKELY(!castedThis)) {
483         if (jsDynamicCast<JSTestTypedefsPrototype*>(JSValue::decode(thisValue)))
484             reportDeprecatedSetterError(*exec, "TestTypedefs", "stringAttrWithSetterException");
485         else
486             throwSetterTypeError(*exec, "TestTypedefs", "stringAttrWithSetterException");
487         return;
488     }
489     TestTypedefs& impl = castedThis->impl();
490     ExceptionCode ec = 0;
491     const String& nativeValue(value.isEmpty() ? String() : value.toString(exec)->value(exec));
492     if (UNLIKELY(exec->hadException()))
493         return;
494     impl.setStringAttrWithSetterException(nativeValue, ec);
495     setDOMException(exec, ec);
496 }
497
498
499 JSValue JSTestTypedefs::getConstructor(VM& vm, JSGlobalObject* globalObject)
500 {
501     return getDOMConstructor<JSTestTypedefsConstructor>(vm, jsCast<JSDOMGlobalObject*>(globalObject));
502 }
503
504 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionFunc(ExecState* exec)
505 {
506     JSValue thisValue = exec->thisValue();
507     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(thisValue);
508     if (UNLIKELY(!castedThis))
509         return throwThisTypeError(*exec, "TestTypedefs", "func");
510     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestTypedefs::info());
511     TestTypedefs& impl = castedThis->impl();
512
513     size_t argsCount = exec->argumentCount();
514     if (argsCount <= 0) {
515         impl.func();
516         return JSValue::encode(jsUndefined());
517     }
518
519     Vector<int> x(toNativeArray<int>(exec, exec->argument(0)));
520     if (UNLIKELY(exec->hadException()))
521         return JSValue::encode(jsUndefined());
522     impl.func(x);
523     return JSValue::encode(jsUndefined());
524 }
525
526 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionSetShadow(ExecState* exec)
527 {
528     JSValue thisValue = exec->thisValue();
529     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(thisValue);
530     if (UNLIKELY(!castedThis))
531         return throwThisTypeError(*exec, "TestTypedefs", "setShadow");
532     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestTypedefs::info());
533     TestTypedefs& impl = castedThis->impl();
534     if (exec->argumentCount() < 3)
535         return throwVMError(exec, createNotEnoughArgumentsError(exec));
536     float width(exec->argument(0).toFloat(exec));
537     if (UNLIKELY(exec->hadException()))
538         return JSValue::encode(jsUndefined());
539     float height(exec->argument(1).toFloat(exec));
540     if (UNLIKELY(exec->hadException()))
541         return JSValue::encode(jsUndefined());
542     float blur(exec->argument(2).toFloat(exec));
543     if (UNLIKELY(exec->hadException()))
544         return JSValue::encode(jsUndefined());
545
546     size_t argsCount = exec->argumentCount();
547     if (argsCount <= 3) {
548         impl.setShadow(width, height, blur);
549         return JSValue::encode(jsUndefined());
550     }
551
552     const String& color(exec->argument(3).isEmpty() ? String() : exec->argument(3).toString(exec)->value(exec));
553     if (UNLIKELY(exec->hadException()))
554         return JSValue::encode(jsUndefined());
555     if (argsCount <= 4) {
556         impl.setShadow(width, height, blur, color);
557         return JSValue::encode(jsUndefined());
558     }
559
560     float alpha(exec->argument(4).toFloat(exec));
561     if (UNLIKELY(exec->hadException()))
562         return JSValue::encode(jsUndefined());
563     impl.setShadow(width, height, blur, color, alpha);
564     return JSValue::encode(jsUndefined());
565 }
566
567 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionMethodWithSequenceArg(ExecState* exec)
568 {
569     JSValue thisValue = exec->thisValue();
570     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(thisValue);
571     if (UNLIKELY(!castedThis))
572         return throwThisTypeError(*exec, "TestTypedefs", "methodWithSequenceArg");
573     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestTypedefs::info());
574     TestTypedefs& impl = castedThis->impl();
575     if (exec->argumentCount() < 1)
576         return throwVMError(exec, createNotEnoughArgumentsError(exec));
577     Vector<RefPtr<SerializedScriptValue>> sequenceArg((toRefPtrNativeArray<SerializedScriptValue, JSSerializedScriptValue>(exec, exec->argument(0), &JSSerializedScriptValue::toWrapped)));
578     if (UNLIKELY(exec->hadException()))
579         return JSValue::encode(jsUndefined());
580     JSValue result = jsNumber(impl.methodWithSequenceArg(sequenceArg));
581     return JSValue::encode(result);
582 }
583
584 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionNullableArrayArg(ExecState* exec)
585 {
586     JSValue thisValue = exec->thisValue();
587     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(thisValue);
588     if (UNLIKELY(!castedThis))
589         return throwThisTypeError(*exec, "TestTypedefs", "nullableArrayArg");
590     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestTypedefs::info());
591     TestTypedefs& impl = castedThis->impl();
592     if (exec->argumentCount() < 1)
593         return throwVMError(exec, createNotEnoughArgumentsError(exec));
594     Vector<String> arrayArg(toNativeArray<String>(exec, exec->argument(0)));
595     if (UNLIKELY(exec->hadException()))
596         return JSValue::encode(jsUndefined());
597     impl.nullableArrayArg(arrayArg);
598     return JSValue::encode(jsUndefined());
599 }
600
601 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionFuncWithClamp(ExecState* exec)
602 {
603     JSValue thisValue = exec->thisValue();
604     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(thisValue);
605     if (UNLIKELY(!castedThis))
606         return throwThisTypeError(*exec, "TestTypedefs", "funcWithClamp");
607     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestTypedefs::info());
608     TestTypedefs& impl = castedThis->impl();
609     if (exec->argumentCount() < 1)
610         return throwVMError(exec, createNotEnoughArgumentsError(exec));
611     unsigned long long arg1 = 0;
612     double arg1NativeValue = exec->argument(0).toNumber(exec);
613     if (UNLIKELY(exec->hadException()))
614         return JSValue::encode(jsUndefined());
615
616     if (!std::isnan(arg1NativeValue))
617         arg1 = clampTo<unsigned long long>(arg1NativeValue);
618
619
620     size_t argsCount = exec->argumentCount();
621     if (argsCount <= 1) {
622         impl.funcWithClamp(arg1);
623         return JSValue::encode(jsUndefined());
624     }
625
626     unsigned long long arg2 = 0;
627     double arg2NativeValue = exec->argument(1).toNumber(exec);
628     if (UNLIKELY(exec->hadException()))
629         return JSValue::encode(jsUndefined());
630
631     if (!std::isnan(arg2NativeValue))
632         arg2 = clampTo<unsigned long long>(arg2NativeValue);
633
634     impl.funcWithClamp(arg1, arg2);
635     return JSValue::encode(jsUndefined());
636 }
637
638 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionImmutablePointFunction(ExecState* exec)
639 {
640     JSValue thisValue = exec->thisValue();
641     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(thisValue);
642     if (UNLIKELY(!castedThis))
643         return throwThisTypeError(*exec, "TestTypedefs", "immutablePointFunction");
644     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestTypedefs::info());
645     TestTypedefs& impl = castedThis->impl();
646     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(SVGPropertyTearOff<SVGPoint>::create(impl.immutablePointFunction())));
647     return JSValue::encode(result);
648 }
649
650 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionStringArrayFunction(ExecState* exec)
651 {
652     JSValue thisValue = exec->thisValue();
653     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(thisValue);
654     if (UNLIKELY(!castedThis))
655         return throwThisTypeError(*exec, "TestTypedefs", "stringArrayFunction");
656     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestTypedefs::info());
657     TestTypedefs& impl = castedThis->impl();
658     if (exec->argumentCount() < 1)
659         return throwVMError(exec, createNotEnoughArgumentsError(exec));
660     ExceptionCode ec = 0;
661     Vector<String> values(toNativeArray<String>(exec, exec->argument(0)));
662     if (UNLIKELY(exec->hadException()))
663         return JSValue::encode(jsUndefined());
664     JSValue result = jsArray(exec, castedThis->globalObject(), impl.stringArrayFunction(values, ec));
665
666     setDOMException(exec, ec);
667     return JSValue::encode(result);
668 }
669
670 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionStringArrayFunction2(ExecState* exec)
671 {
672     JSValue thisValue = exec->thisValue();
673     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(thisValue);
674     if (UNLIKELY(!castedThis))
675         return throwThisTypeError(*exec, "TestTypedefs", "stringArrayFunction2");
676     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestTypedefs::info());
677     TestTypedefs& impl = castedThis->impl();
678     if (exec->argumentCount() < 1)
679         return throwVMError(exec, createNotEnoughArgumentsError(exec));
680     ExceptionCode ec = 0;
681     Vector<String> values(toNativeArray<String>(exec, exec->argument(0)));
682     if (UNLIKELY(exec->hadException()))
683         return JSValue::encode(jsUndefined());
684     JSValue result = jsArray(exec, castedThis->globalObject(), impl.stringArrayFunction2(values, ec));
685
686     setDOMException(exec, ec);
687     return JSValue::encode(result);
688 }
689
690 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionCallWithSequenceThatRequiresInclude(ExecState* exec)
691 {
692     JSValue thisValue = exec->thisValue();
693     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(thisValue);
694     if (UNLIKELY(!castedThis))
695         return throwThisTypeError(*exec, "TestTypedefs", "callWithSequenceThatRequiresInclude");
696     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestTypedefs::info());
697     TestTypedefs& impl = castedThis->impl();
698     if (exec->argumentCount() < 1)
699         return throwVMError(exec, createNotEnoughArgumentsError(exec));
700     Vector<RefPtr<TestEventTarget>> sequenceArg((toRefPtrNativeArray<TestEventTarget, JSTestEventTarget>(exec, exec->argument(0), &JSTestEventTarget::toWrapped)));
701     if (UNLIKELY(exec->hadException()))
702         return JSValue::encode(jsUndefined());
703     JSValue result = jsBoolean(impl.callWithSequenceThatRequiresInclude(sequenceArg));
704     return JSValue::encode(result);
705 }
706
707 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionMethodWithException(ExecState* exec)
708 {
709     JSValue thisValue = exec->thisValue();
710     JSTestTypedefs* castedThis = jsDynamicCast<JSTestTypedefs*>(thisValue);
711     if (UNLIKELY(!castedThis))
712         return throwThisTypeError(*exec, "TestTypedefs", "methodWithException");
713     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestTypedefs::info());
714     TestTypedefs& impl = castedThis->impl();
715     ExceptionCode ec = 0;
716     impl.methodWithException(ec);
717     setDOMException(exec, ec);
718     return JSValue::encode(jsUndefined());
719 }
720
721 bool JSTestTypedefsOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
722 {
723     UNUSED_PARAM(handle);
724     UNUSED_PARAM(visitor);
725     return false;
726 }
727
728 void JSTestTypedefsOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
729 {
730     JSTestTypedefs* jsTestTypedefs = jsCast<JSTestTypedefs*>(handle.slot()->asCell());
731     DOMWrapperWorld& world = *static_cast<DOMWrapperWorld*>(context);
732     uncacheWrapper(world, &jsTestTypedefs->impl(), jsTestTypedefs);
733     jsTestTypedefs->releaseImpl();
734 }
735
736 #if ENABLE(BINDING_INTEGRITY)
737 #if PLATFORM(WIN)
738 #pragma warning(disable: 4483)
739 extern "C" { extern void (*const __identifier("??_7TestTypedefs@WebCore@@6B@")[])(); }
740 #else
741 extern "C" { extern void* _ZTVN7WebCore12TestTypedefsE[]; }
742 #endif
743 #endif
744 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestTypedefs* impl)
745 {
746     if (!impl)
747         return jsNull();
748     if (JSValue result = getExistingWrapper<JSTestTypedefs>(globalObject, impl))
749         return result;
750
751 #if ENABLE(BINDING_INTEGRITY)
752     void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
753 #if PLATFORM(WIN)
754     void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestTypedefs@WebCore@@6B@"));
755 #else
756     void* expectedVTablePointer = &_ZTVN7WebCore12TestTypedefsE[2];
757 #if COMPILER(CLANG)
758     // If this fails TestTypedefs does not have a vtable, so you need to add the
759     // ImplementationLacksVTable attribute to the interface definition
760     COMPILE_ASSERT(__is_polymorphic(TestTypedefs), TestTypedefs_is_not_polymorphic);
761 #endif
762 #endif
763     // If you hit this assertion you either have a use after free bug, or
764     // TestTypedefs has subclasses. If TestTypedefs has subclasses that get passed
765     // to toJS() we currently require TestTypedefs you to opt out of binding hardening
766     // by adding the SkipVTableValidation attribute to the interface IDL definition
767     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
768 #endif
769     return createNewWrapper<JSTestTypedefs>(globalObject, impl);
770 }
771
772 TestTypedefs* JSTestTypedefs::toWrapped(JSC::JSValue value)
773 {
774     if (auto* wrapper = jsDynamicCast<JSTestTypedefs*>(value))
775         return &wrapper->impl();
776     return nullptr;
777 }
778
779 }