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