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