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