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