Unreviewed. Rebaselined run-bindings-tests.
[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 "JSArray.h"
27 #include "JSDOMBinding.h"
28 #include "JSDOMStringList.h"
29 #include "JSSVGPoint.h"
30 #include "JSSerializedScriptValue.h"
31 #include "JSTestCallback.h"
32 #include "JSTestSubObj.h"
33 #include "KURL.h"
34 #include "SerializedScriptValue.h"
35 #include "TestTypedefs.h"
36 #include <runtime/Error.h>
37 #include <runtime/JSArray.h>
38 #include <runtime/JSString.h>
39 #include <wtf/GetPtr.h>
40
41 using namespace JSC;
42
43 namespace WebCore {
44
45 /* Hash table */
46
47 static const HashTableValue JSTestTypedefsTableValues[] =
48 {
49     { "unsignedLongLongAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestTypedefsUnsignedLongLongAttr), (intptr_t)setJSTestTypedefsUnsignedLongLongAttr, NoIntrinsic },
50     { "immutableSerializedScriptValue", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestTypedefsImmutableSerializedScriptValue), (intptr_t)setJSTestTypedefsImmutableSerializedScriptValue, NoIntrinsic },
51     { "attrWithGetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestTypedefsAttrWithGetterException), (intptr_t)setJSTestTypedefsAttrWithGetterException, NoIntrinsic },
52     { "attrWithSetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestTypedefsAttrWithSetterException), (intptr_t)setJSTestTypedefsAttrWithSetterException, NoIntrinsic },
53     { "stringAttrWithGetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestTypedefsStringAttrWithGetterException), (intptr_t)setJSTestTypedefsStringAttrWithGetterException, NoIntrinsic },
54     { "stringAttrWithSetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestTypedefsStringAttrWithSetterException), (intptr_t)setJSTestTypedefsStringAttrWithSetterException, NoIntrinsic },
55     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestTypedefsConstructor), (intptr_t)0, NoIntrinsic },
56     { 0, 0, 0, 0, NoIntrinsic }
57 };
58
59 static const HashTable JSTestTypedefsTable = { 18, 15, JSTestTypedefsTableValues, 0 };
60 /* Hash table for constructor */
61
62 static const HashTableValue JSTestTypedefsConstructorTableValues[] =
63 {
64     { "TestSubObj", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestTypedefsConstructorTestSubObj), (intptr_t)0, NoIntrinsic },
65     { 0, 0, 0, 0, NoIntrinsic }
66 };
67
68 static const HashTable JSTestTypedefsConstructorTable = { 1, 0, JSTestTypedefsConstructorTableValues, 0 };
69 EncodedJSValue JSC_HOST_CALL JSTestTypedefsConstructor::constructJSTestTypedefs(ExecState* exec)
70 {
71     JSTestTypedefsConstructor* castedThis = jsCast<JSTestTypedefsConstructor*>(exec->callee());
72     if (exec->argumentCount() < 2)
73         return throwVMError(exec, createNotEnoughArgumentsError(exec));
74     const String& hello(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? String() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec));
75     if (exec->hadException())
76         return JSValue::encode(jsUndefined());
77     if (exec->argumentCount() <= 1 || !exec->argument(1).isFunction())
78         return throwVMTypeError(exec);
79     RefPtr<TestCallback> testCallback = JSTestCallback::create(asObject(exec->argument(1)), castedThis->globalObject());
80     RefPtr<TestTypedefs> object = TestTypedefs::create(hello, testCallback);
81     return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
82 }
83
84 const ClassInfo JSTestTypedefsConstructor::s_info = { "TestTypedefsConstructor", &Base::s_info, &JSTestTypedefsConstructorTable, 0, CREATE_METHOD_TABLE(JSTestTypedefsConstructor) };
85
86 JSTestTypedefsConstructor::JSTestTypedefsConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
87     : DOMConstructorObject(structure, globalObject)
88 {
89 }
90
91 void JSTestTypedefsConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
92 {
93     Base::finishCreation(exec->globalData());
94     ASSERT(inherits(&s_info));
95     putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestTypedefsPrototype::self(exec, globalObject), DontDelete | ReadOnly);
96     putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(2), ReadOnly | DontDelete | DontEnum);
97 }
98
99 bool JSTestTypedefsConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
100 {
101     return getStaticValueSlot<JSTestTypedefsConstructor, JSDOMWrapper>(exec, &JSTestTypedefsConstructorTable, jsCast<JSTestTypedefsConstructor*>(cell), propertyName, slot);
102 }
103
104 bool JSTestTypedefsConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
105 {
106     return getStaticValueDescriptor<JSTestTypedefsConstructor, JSDOMWrapper>(exec, &JSTestTypedefsConstructorTable, jsCast<JSTestTypedefsConstructor*>(object), propertyName, descriptor);
107 }
108
109 ConstructType JSTestTypedefsConstructor::getConstructData(JSCell*, ConstructData& constructData)
110 {
111     constructData.native.function = constructJSTestTypedefs;
112     return ConstructTypeHost;
113 }
114
115 /* Hash table for prototype */
116
117 static const HashTableValue JSTestTypedefsPrototypeTableValues[] =
118 {
119     { "func", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionFunc), (intptr_t)1, NoIntrinsic },
120     { "multiTransferList", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionMultiTransferList), (intptr_t)4, NoIntrinsic },
121     { "setShadow", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionSetShadow), (intptr_t)5, NoIntrinsic },
122     { "methodWithSequenceArg", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionMethodWithSequenceArg), (intptr_t)1, NoIntrinsic },
123     { "nullableArrayArg", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionNullableArrayArg), (intptr_t)1, NoIntrinsic },
124     { "funcWithClamp", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionFuncWithClamp), (intptr_t)2, NoIntrinsic },
125     { "immutablePointFunction", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionImmutablePointFunction), (intptr_t)0, NoIntrinsic },
126     { "stringArrayFunction", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionStringArrayFunction), (intptr_t)1, NoIntrinsic },
127     { "stringArrayFunction2", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionStringArrayFunction2), (intptr_t)1, NoIntrinsic },
128     { "methodWithException", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestTypedefsPrototypeFunctionMethodWithException), (intptr_t)0, NoIntrinsic },
129     { 0, 0, 0, 0, NoIntrinsic }
130 };
131
132 static const HashTable JSTestTypedefsPrototypeTable = { 34, 31, JSTestTypedefsPrototypeTableValues, 0 };
133 const ClassInfo JSTestTypedefsPrototype::s_info = { "TestTypedefsPrototype", &Base::s_info, &JSTestTypedefsPrototypeTable, 0, CREATE_METHOD_TABLE(JSTestTypedefsPrototype) };
134
135 JSObject* JSTestTypedefsPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
136 {
137     return getDOMPrototype<JSTestTypedefs>(exec, globalObject);
138 }
139
140 bool JSTestTypedefsPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
141 {
142     JSTestTypedefsPrototype* thisObject = jsCast<JSTestTypedefsPrototype*>(cell);
143     return getStaticFunctionSlot<JSObject>(exec, &JSTestTypedefsPrototypeTable, thisObject, propertyName, slot);
144 }
145
146 bool JSTestTypedefsPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
147 {
148     JSTestTypedefsPrototype* thisObject = jsCast<JSTestTypedefsPrototype*>(object);
149     return getStaticFunctionDescriptor<JSObject>(exec, &JSTestTypedefsPrototypeTable, thisObject, propertyName, descriptor);
150 }
151
152 const ClassInfo JSTestTypedefs::s_info = { "TestTypedefs", &Base::s_info, &JSTestTypedefsTable, 0 , CREATE_METHOD_TABLE(JSTestTypedefs) };
153
154 JSTestTypedefs::JSTestTypedefs(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestTypedefs> impl)
155     : JSDOMWrapper(structure, globalObject)
156     , m_impl(impl.leakRef())
157 {
158 }
159
160 void JSTestTypedefs::finishCreation(JSGlobalData& globalData)
161 {
162     Base::finishCreation(globalData);
163     ASSERT(inherits(&s_info));
164 }
165
166 JSObject* JSTestTypedefs::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
167 {
168     return JSTestTypedefsPrototype::create(exec->globalData(), globalObject, JSTestTypedefsPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
169 }
170
171 void JSTestTypedefs::destroy(JSC::JSCell* cell)
172 {
173     JSTestTypedefs* thisObject = static_cast<JSTestTypedefs*>(cell);
174     thisObject->JSTestTypedefs::~JSTestTypedefs();
175 }
176
177 JSTestTypedefs::~JSTestTypedefs()
178 {
179     releaseImplIfNotNull();
180 }
181
182 bool JSTestTypedefs::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
183 {
184     JSTestTypedefs* thisObject = jsCast<JSTestTypedefs*>(cell);
185     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
186     return getStaticValueSlot<JSTestTypedefs, Base>(exec, &JSTestTypedefsTable, thisObject, propertyName, slot);
187 }
188
189 bool JSTestTypedefs::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
190 {
191     JSTestTypedefs* thisObject = jsCast<JSTestTypedefs*>(object);
192     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
193     return getStaticValueDescriptor<JSTestTypedefs, Base>(exec, &JSTestTypedefsTable, thisObject, propertyName, descriptor);
194 }
195
196 JSValue jsTestTypedefsUnsignedLongLongAttr(ExecState* exec, JSValue slotBase, PropertyName)
197 {
198     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(asObject(slotBase));
199     UNUSED_PARAM(exec);
200     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
201     JSValue result = jsNumber(impl->unsignedLongLongAttr());
202     return result;
203 }
204
205
206 JSValue jsTestTypedefsImmutableSerializedScriptValue(ExecState* exec, JSValue slotBase, PropertyName)
207 {
208     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(asObject(slotBase));
209     UNUSED_PARAM(exec);
210     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
211     JSValue result = impl->immutableSerializedScriptValue() ? impl->immutableSerializedScriptValue()->deserialize(exec, castedThis->globalObject(), 0) : jsNull();
212     return result;
213 }
214
215
216 JSValue jsTestTypedefsConstructorTestSubObj(ExecState* exec, JSValue slotBase, PropertyName)
217 {
218     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(asObject(slotBase));
219     return JSTestSubObj::getConstructor(exec, castedThis->globalObject());
220 }
221
222
223 JSValue jsTestTypedefsAttrWithGetterException(ExecState* exec, JSValue slotBase, PropertyName)
224 {
225     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(asObject(slotBase));
226     ExceptionCode ec = 0;
227     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
228     JSC::JSValue result = jsNumber(impl->attrWithGetterException(ec));
229     setDOMException(exec, ec);
230     return result;
231 }
232
233
234 JSValue jsTestTypedefsAttrWithSetterException(ExecState* exec, JSValue slotBase, PropertyName)
235 {
236     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(asObject(slotBase));
237     UNUSED_PARAM(exec);
238     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
239     JSValue result = jsNumber(impl->attrWithSetterException());
240     return result;
241 }
242
243
244 JSValue jsTestTypedefsStringAttrWithGetterException(ExecState* exec, JSValue slotBase, PropertyName)
245 {
246     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(asObject(slotBase));
247     ExceptionCode ec = 0;
248     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
249     JSC::JSValue result = jsStringWithCache(exec, impl->stringAttrWithGetterException(ec));
250     setDOMException(exec, ec);
251     return result;
252 }
253
254
255 JSValue jsTestTypedefsStringAttrWithSetterException(ExecState* exec, JSValue slotBase, PropertyName)
256 {
257     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(asObject(slotBase));
258     UNUSED_PARAM(exec);
259     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
260     JSValue result = jsStringWithCache(exec, impl->stringAttrWithSetterException());
261     return result;
262 }
263
264
265 JSValue jsTestTypedefsConstructor(ExecState* exec, JSValue slotBase, PropertyName)
266 {
267     JSTestTypedefs* domObject = jsCast<JSTestTypedefs*>(asObject(slotBase));
268     return JSTestTypedefs::getConstructor(exec, domObject->globalObject());
269 }
270
271 void JSTestTypedefs::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
272 {
273     JSTestTypedefs* thisObject = jsCast<JSTestTypedefs*>(cell);
274     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
275     lookupPut<JSTestTypedefs, Base>(exec, propertyName, value, &JSTestTypedefsTable, thisObject, slot);
276 }
277
278 void setJSTestTypedefsUnsignedLongLongAttr(ExecState* exec, JSObject* thisObject, JSValue value)
279 {
280     UNUSED_PARAM(exec);
281     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(thisObject);
282     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
283     impl->setUnsignedLongLongAttr(static_cast<unsigned long long>(value.toInteger(exec)));
284 }
285
286
287 void setJSTestTypedefsImmutableSerializedScriptValue(ExecState* exec, JSObject* thisObject, JSValue value)
288 {
289     UNUSED_PARAM(exec);
290     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(thisObject);
291     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
292     impl->setImmutableSerializedScriptValue(SerializedScriptValue::create(exec, value, 0, 0));
293 }
294
295
296 void setJSTestTypedefsAttrWithGetterException(ExecState* exec, JSObject* thisObject, JSValue value)
297 {
298     UNUSED_PARAM(exec);
299     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(thisObject);
300     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
301     impl->setAttrWithGetterException(value.toInt32(exec));
302 }
303
304
305 void setJSTestTypedefsAttrWithSetterException(ExecState* exec, JSObject* thisObject, JSValue value)
306 {
307     UNUSED_PARAM(exec);
308     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(thisObject);
309     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
310     ExceptionCode ec = 0;
311     impl->setAttrWithSetterException(value.toInt32(exec), ec);
312     setDOMException(exec, ec);
313 }
314
315
316 void setJSTestTypedefsStringAttrWithGetterException(ExecState* exec, JSObject* thisObject, JSValue value)
317 {
318     UNUSED_PARAM(exec);
319     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(thisObject);
320     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
321     impl->setStringAttrWithGetterException(value.isEmpty() ? String() : value.toString(exec)->value(exec));
322 }
323
324
325 void setJSTestTypedefsStringAttrWithSetterException(ExecState* exec, JSObject* thisObject, JSValue value)
326 {
327     UNUSED_PARAM(exec);
328     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(thisObject);
329     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
330     ExceptionCode ec = 0;
331     impl->setStringAttrWithSetterException(value.isEmpty() ? String() : value.toString(exec)->value(exec), ec);
332     setDOMException(exec, ec);
333 }
334
335
336 JSValue JSTestTypedefs::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
337 {
338     return getDOMConstructor<JSTestTypedefsConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject));
339 }
340
341 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionFunc(ExecState* exec)
342 {
343     JSValue thisValue = exec->hostThisValue();
344     if (!thisValue.inherits(&JSTestTypedefs::s_info))
345         return throwVMTypeError(exec);
346     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(asObject(thisValue));
347     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestTypedefs::s_info);
348     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
349
350     size_t argsCount = exec->argumentCount();
351     if (argsCount <= 0) {
352         impl->func();
353         return JSValue::encode(jsUndefined());
354     }
355
356     if (exec->argumentCount() > 0 && !exec->argument(0).isUndefinedOrNull() && !exec->argument(0).inherits(&JSlong[]::s_info))
357         return throwVMTypeError(exec);
358     Vector<int> x(toNativeArray<int>(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
359     if (exec->hadException())
360         return JSValue::encode(jsUndefined());
361     impl->func(x);
362     return JSValue::encode(jsUndefined());
363 }
364
365 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionMultiTransferList(ExecState* exec)
366 {
367     JSValue thisValue = exec->hostThisValue();
368     if (!thisValue.inherits(&JSTestTypedefs::s_info))
369         return throwVMTypeError(exec);
370     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(asObject(thisValue));
371     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestTypedefs::s_info);
372     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
373     if (exec->argumentCount() < 1)
374         return throwVMError(exec, createNotEnoughArgumentsError(exec));
375     RefPtr<SerializedScriptValue> first(SerializedScriptValue::create(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined), 0, 0));
376     if (exec->hadException())
377         return JSValue::encode(jsUndefined());
378
379     size_t argsCount = exec->argumentCount();
380     if (argsCount <= 1) {
381         impl->multiTransferList(first);
382         return JSValue::encode(jsUndefined());
383     }
384
385     Array* tx(toArray(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined)));
386     if (exec->hadException())
387         return JSValue::encode(jsUndefined());
388     if (argsCount <= 2) {
389         impl->multiTransferList(first, tx);
390         return JSValue::encode(jsUndefined());
391     }
392
393     RefPtr<SerializedScriptValue> second(SerializedScriptValue::create(exec, MAYBE_MISSING_PARAMETER(exec, 2, DefaultIsUndefined), 0, 0));
394     if (exec->hadException())
395         return JSValue::encode(jsUndefined());
396     if (argsCount <= 3) {
397         impl->multiTransferList(first, tx, second);
398         return JSValue::encode(jsUndefined());
399     }
400
401     Array* txx(toArray(MAYBE_MISSING_PARAMETER(exec, 3, DefaultIsUndefined)));
402     if (exec->hadException())
403         return JSValue::encode(jsUndefined());
404     impl->multiTransferList(first, tx, second, txx);
405     return JSValue::encode(jsUndefined());
406 }
407
408 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionSetShadow(ExecState* exec)
409 {
410     JSValue thisValue = exec->hostThisValue();
411     if (!thisValue.inherits(&JSTestTypedefs::s_info))
412         return throwVMTypeError(exec);
413     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(asObject(thisValue));
414     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestTypedefs::s_info);
415     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
416     if (exec->argumentCount() < 3)
417         return throwVMError(exec, createNotEnoughArgumentsError(exec));
418     float width(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toFloat(exec));
419     if (exec->hadException())
420         return JSValue::encode(jsUndefined());
421     float height(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined).toFloat(exec));
422     if (exec->hadException())
423         return JSValue::encode(jsUndefined());
424     float blur(MAYBE_MISSING_PARAMETER(exec, 2, DefaultIsUndefined).toFloat(exec));
425     if (exec->hadException())
426         return JSValue::encode(jsUndefined());
427
428     size_t argsCount = exec->argumentCount();
429     if (argsCount <= 3) {
430         impl->setShadow(width, height, blur);
431         return JSValue::encode(jsUndefined());
432     }
433
434     const String& color(MAYBE_MISSING_PARAMETER(exec, 3, DefaultIsUndefined).isEmpty() ? String() : MAYBE_MISSING_PARAMETER(exec, 3, DefaultIsUndefined).toString(exec)->value(exec));
435     if (exec->hadException())
436         return JSValue::encode(jsUndefined());
437     if (argsCount <= 4) {
438         impl->setShadow(width, height, blur, color);
439         return JSValue::encode(jsUndefined());
440     }
441
442     float alpha(MAYBE_MISSING_PARAMETER(exec, 4, DefaultIsUndefined).toFloat(exec));
443     if (exec->hadException())
444         return JSValue::encode(jsUndefined());
445     impl->setShadow(width, height, blur, color, alpha);
446     return JSValue::encode(jsUndefined());
447 }
448
449 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionMethodWithSequenceArg(ExecState* exec)
450 {
451     JSValue thisValue = exec->hostThisValue();
452     if (!thisValue.inherits(&JSTestTypedefs::s_info))
453         return throwVMTypeError(exec);
454     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(asObject(thisValue));
455     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestTypedefs::s_info);
456     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
457     if (exec->argumentCount() < 1)
458         return throwVMError(exec, createNotEnoughArgumentsError(exec));
459     Vector<RefPtr<SerializedScriptValue>> sequenceArg((toRefPtrNativeArray<SerializedScriptValue, JSSerializedScriptValue>(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined), &toSerializedScriptValue)));
460     if (exec->hadException())
461         return JSValue::encode(jsUndefined());
462
463     JSC::JSValue result = jsNumber(impl->methodWithSequenceArg(sequenceArg));
464     return JSValue::encode(result);
465 }
466
467 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionNullableArrayArg(ExecState* exec)
468 {
469     JSValue thisValue = exec->hostThisValue();
470     if (!thisValue.inherits(&JSTestTypedefs::s_info))
471         return throwVMTypeError(exec);
472     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(asObject(thisValue));
473     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestTypedefs::s_info);
474     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
475     if (exec->argumentCount() < 1)
476         return throwVMError(exec, createNotEnoughArgumentsError(exec));
477     Vector<String> arrayArg(toNativeArray<String>(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
478     if (exec->hadException())
479         return JSValue::encode(jsUndefined());
480     impl->nullableArrayArg(arrayArg);
481     return JSValue::encode(jsUndefined());
482 }
483
484 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionFuncWithClamp(ExecState* exec)
485 {
486     JSValue thisValue = exec->hostThisValue();
487     if (!thisValue.inherits(&JSTestTypedefs::s_info))
488         return throwVMTypeError(exec);
489     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(asObject(thisValue));
490     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestTypedefs::s_info);
491     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
492     if (exec->argumentCount() < 1)
493         return throwVMError(exec, createNotEnoughArgumentsError(exec));
494     unsigned long long arg1 = 0;
495     double arg1NativeValue = exec->argument(0).toNumber(exec);
496     if (exec->hadException())
497         return JSValue::encode(jsUndefined());
498
499     if (!std::isnan(arg1NativeValue))
500         arg1 = clampTo<unsigned long long>(arg1NativeValue);
501
502
503     size_t argsCount = exec->argumentCount();
504     if (argsCount <= 1) {
505         impl->funcWithClamp(arg1);
506         return JSValue::encode(jsUndefined());
507     }
508
509     unsigned long long arg2 = 0;
510     double arg2NativeValue = exec->argument(1).toNumber(exec);
511     if (exec->hadException())
512         return JSValue::encode(jsUndefined());
513
514     if (!std::isnan(arg2NativeValue))
515         arg2 = clampTo<unsigned long long>(arg2NativeValue);
516
517     impl->funcWithClamp(arg1, arg2);
518     return JSValue::encode(jsUndefined());
519 }
520
521 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionImmutablePointFunction(ExecState* exec)
522 {
523     JSValue thisValue = exec->hostThisValue();
524     if (!thisValue.inherits(&JSTestTypedefs::s_info))
525         return throwVMTypeError(exec);
526     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(asObject(thisValue));
527     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestTypedefs::s_info);
528     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
529
530     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(SVGPropertyTearOff<FloatPoint>::create(impl->immutablePointFunction())));
531     return JSValue::encode(result);
532 }
533
534 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionStringArrayFunction(ExecState* exec)
535 {
536     JSValue thisValue = exec->hostThisValue();
537     if (!thisValue.inherits(&JSTestTypedefs::s_info))
538         return throwVMTypeError(exec);
539     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(asObject(thisValue));
540     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestTypedefs::s_info);
541     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
542     if (exec->argumentCount() < 1)
543         return throwVMError(exec, createNotEnoughArgumentsError(exec));
544     ExceptionCode ec = 0;
545     Vector<String> values(toNativeArray<String>(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
546     if (exec->hadException())
547         return JSValue::encode(jsUndefined());
548
549     JSC::JSValue result = jsArray(exec, castedThis->globalObject(), impl->stringArrayFunction(values, ec));
550     setDOMException(exec, ec);
551     return JSValue::encode(result);
552 }
553
554 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionStringArrayFunction2(ExecState* exec)
555 {
556     JSValue thisValue = exec->hostThisValue();
557     if (!thisValue.inherits(&JSTestTypedefs::s_info))
558         return throwVMTypeError(exec);
559     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(asObject(thisValue));
560     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestTypedefs::s_info);
561     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
562     if (exec->argumentCount() < 1)
563         return throwVMError(exec, createNotEnoughArgumentsError(exec));
564     ExceptionCode ec = 0;
565     Vector<String> values(toNativeArray<String>(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
566     if (exec->hadException())
567         return JSValue::encode(jsUndefined());
568
569     JSC::JSValue result = jsArray(exec, castedThis->globalObject(), impl->stringArrayFunction2(values, ec));
570     setDOMException(exec, ec);
571     return JSValue::encode(result);
572 }
573
574 EncodedJSValue JSC_HOST_CALL jsTestTypedefsPrototypeFunctionMethodWithException(ExecState* exec)
575 {
576     JSValue thisValue = exec->hostThisValue();
577     if (!thisValue.inherits(&JSTestTypedefs::s_info))
578         return throwVMTypeError(exec);
579     JSTestTypedefs* castedThis = jsCast<JSTestTypedefs*>(asObject(thisValue));
580     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestTypedefs::s_info);
581     TestTypedefs* impl = static_cast<TestTypedefs*>(castedThis->impl());
582     ExceptionCode ec = 0;
583     impl->methodWithException(ec);
584     setDOMException(exec, ec);
585     return JSValue::encode(jsUndefined());
586 }
587
588 static inline bool isObservable(JSTestTypedefs* jsTestTypedefs)
589 {
590     if (jsTestTypedefs->hasCustomProperties())
591         return true;
592     return false;
593 }
594
595 bool JSTestTypedefsOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
596 {
597     JSTestTypedefs* jsTestTypedefs = jsCast<JSTestTypedefs*>(handle.get().asCell());
598     if (!isObservable(jsTestTypedefs))
599         return false;
600     UNUSED_PARAM(visitor);
601     return false;
602 }
603
604 void JSTestTypedefsOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
605 {
606     JSTestTypedefs* jsTestTypedefs = jsCast<JSTestTypedefs*>(handle.get().asCell());
607     DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
608     uncacheWrapper(world, jsTestTypedefs->impl(), jsTestTypedefs);
609     jsTestTypedefs->releaseImpl();
610 }
611
612 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestTypedefs* impl)
613 {
614     return wrap<JSTestTypedefs>(exec, globalObject, impl);
615 }
616
617 TestTypedefs* toTestTypedefs(JSC::JSValue value)
618 {
619     return value.inherits(&JSTestTypedefs::s_info) ? jsCast<JSTestTypedefs*>(asObject(value))->impl() : 0;
620 }
621
622 }