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