Improve code generator scripts to support converting ScriptString.
[WebKit-https.git] / WebCore / bindings / scripts / test / JS / JSTestObj.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 "JSTestObj.h"
23
24 #include "JSEventListener.h"
25 #include "JSTestObj.h"
26 #include "JSlog.h"
27 #include "KURL.h"
28 #include "ScriptCallStack.h"
29 #include "SerializedScriptValue.h"
30 #include "TestObj.h"
31 #include <runtime/Error.h>
32 #include <runtime/JSNumberCell.h>
33 #include <runtime/JSString.h>
34 #include <wtf/GetPtr.h>
35
36 using namespace JSC;
37
38 namespace WebCore {
39
40 ASSERT_CLASS_FITS_IN_CELL(JSTestObj);
41
42 /* Hash table */
43 #if ENABLE(JIT)
44 #define THUNK_GENERATOR(generator) , generator
45 #else
46 #define THUNK_GENERATOR(generator)
47 #endif
48
49 static const HashTableValue JSTestObjTableValues[15] =
50 {
51     { "readOnlyIntAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyIntAttr), (intptr_t)0 THUNK_GENERATOR(0) },
52     { "readOnlyStringAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyStringAttr), (intptr_t)0 THUNK_GENERATOR(0) },
53     { "readOnlyTestObjAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyTestObjAttr), (intptr_t)0 THUNK_GENERATOR(0) },
54     { "intAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjIntAttr), (intptr_t)setJSTestObjIntAttr THUNK_GENERATOR(0) },
55     { "longLongAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjLongLongAttr), (intptr_t)setJSTestObjLongLongAttr THUNK_GENERATOR(0) },
56     { "unsignedLongLongAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjUnsignedLongLongAttr), (intptr_t)setJSTestObjUnsignedLongLongAttr THUNK_GENERATOR(0) },
57     { "stringAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStringAttr), (intptr_t)setJSTestObjStringAttr THUNK_GENERATOR(0) },
58     { "testObjAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjTestObjAttr), (intptr_t)setJSTestObjTestObjAttr THUNK_GENERATOR(0) },
59     { "attrWithException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithException), (intptr_t)setJSTestObjAttrWithException THUNK_GENERATOR(0) },
60     { "attrWithSetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithSetterException), (intptr_t)setJSTestObjAttrWithSetterException THUNK_GENERATOR(0) },
61     { "attrWithGetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithGetterException), (intptr_t)setJSTestObjAttrWithGetterException THUNK_GENERATOR(0) },
62     { "customAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCustomAttr), (intptr_t)setJSTestObjCustomAttr THUNK_GENERATOR(0) },
63     { "scriptStringAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjScriptStringAttr), (intptr_t)0 THUNK_GENERATOR(0) },
64     { "constructor", DontEnum|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructor), (intptr_t)0 THUNK_GENERATOR(0) },
65     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
66 };
67
68 #undef THUNK_GENERATOR
69 static JSC_CONST_HASHTABLE HashTable JSTestObjTable =
70 #if ENABLE(PERFECT_HASH_SIZE)
71     { 127, JSTestObjTableValues, 0 };
72 #else
73     { 34, 31, JSTestObjTableValues, 0 };
74 #endif
75
76 /* Hash table for constructor */
77 #if ENABLE(JIT)
78 #define THUNK_GENERATOR(generator) , generator
79 #else
80 #define THUNK_GENERATOR(generator)
81 #endif
82
83 static const HashTableValue JSTestObjConstructorTableValues[1] =
84 {
85     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
86 };
87
88 #undef THUNK_GENERATOR
89 static JSC_CONST_HASHTABLE HashTable JSTestObjConstructorTable =
90 #if ENABLE(PERFECT_HASH_SIZE)
91     { 0, JSTestObjConstructorTableValues, 0 };
92 #else
93     { 1, 0, JSTestObjConstructorTableValues, 0 };
94 #endif
95
96 class JSTestObjConstructor : public DOMConstructorObject {
97 public:
98     JSTestObjConstructor(ExecState* exec, JSDOMGlobalObject* globalObject)
99         : DOMConstructorObject(JSTestObjConstructor::createStructure(globalObject->objectPrototype()), globalObject)
100     {
101         putDirect(exec->propertyNames().prototype, JSTestObjPrototype::self(exec, globalObject), None);
102     }
103     virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
104     virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
105     virtual const ClassInfo* classInfo() const { return &s_info; }
106     static const ClassInfo s_info;
107
108     static PassRefPtr<Structure> createStructure(JSValue proto) 
109     { 
110         return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount); 
111     }
112     
113 protected:
114     static const unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | DOMConstructorObject::StructureFlags;
115 };
116
117 const ClassInfo JSTestObjConstructor::s_info = { "TestObjConstructor", 0, &JSTestObjConstructorTable, 0 };
118
119 bool JSTestObjConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
120 {
121     return getStaticValueSlot<JSTestObjConstructor, DOMObject>(exec, &JSTestObjConstructorTable, this, propertyName, slot);
122 }
123
124 bool JSTestObjConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
125 {
126     return getStaticValueDescriptor<JSTestObjConstructor, DOMObject>(exec, &JSTestObjConstructorTable, this, propertyName, descriptor);
127 }
128
129 /* Hash table for prototype */
130 #if ENABLE(JIT)
131 #define THUNK_GENERATOR(generator) , generator
132 #else
133 #define THUNK_GENERATOR(generator)
134 #endif
135
136 static const HashTableValue JSTestObjPrototypeTableValues[26] =
137 {
138     { "voidMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethod), (intptr_t)0 THUNK_GENERATOR(0) },
139     { "voidMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) },
140     { "intMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionIntMethod), (intptr_t)0 THUNK_GENERATOR(0) },
141     { "intMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionIntMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) },
142     { "objMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionObjMethod), (intptr_t)0 THUNK_GENERATOR(0) },
143     { "objMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionObjMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) },
144     { "serializedValue", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionSerializedValue), (intptr_t)1 THUNK_GENERATOR(0) },
145     { "methodWithException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithException), (intptr_t)0 THUNK_GENERATOR(0) },
146     { "customMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethod), (intptr_t)0 THUNK_GENERATOR(0) },
147     { "customMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) },
148     { "customArgsAndException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomArgsAndException), (intptr_t)1 THUNK_GENERATOR(0) },
149     { "addEventListener", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionAddEventListener), (intptr_t)3 THUNK_GENERATOR(0) },
150     { "removeEventListener", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionRemoveEventListener), (intptr_t)3 THUNK_GENERATOR(0) },
151     { "withDynamicFrame", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrame), (intptr_t)0 THUNK_GENERATOR(0) },
152     { "withDynamicFrameAndArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndArg), (intptr_t)1 THUNK_GENERATOR(0) },
153     { "withDynamicFrameAndOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg), (intptr_t)2 THUNK_GENERATOR(0) },
154     { "withDynamicFrameAndUserGesture", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture), (intptr_t)1 THUNK_GENERATOR(0) },
155     { "withDynamicFrameAndUserGestureASAD", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD), (intptr_t)2 THUNK_GENERATOR(0) },
156     { "withScriptStateVoid", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateVoid), (intptr_t)0 THUNK_GENERATOR(0) },
157     { "withScriptStateObj", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateObj), (intptr_t)0 THUNK_GENERATOR(0) },
158     { "withScriptStateVoidException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateVoidException), (intptr_t)0 THUNK_GENERATOR(0) },
159     { "withScriptStateObjException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateObjException), (intptr_t)0 THUNK_GENERATOR(0) },
160     { "methodWithOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalArg), (intptr_t)1 THUNK_GENERATOR(0) },
161     { "methodWithNonOptionalArgAndOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg), (intptr_t)2 THUNK_GENERATOR(0) },
162     { "methodWithNonOptionalArgAndTwoOptionalArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs), (intptr_t)3 THUNK_GENERATOR(0) },
163     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
164 };
165
166 #undef THUNK_GENERATOR
167 static JSC_CONST_HASHTABLE HashTable JSTestObjPrototypeTable =
168 #if ENABLE(PERFECT_HASH_SIZE)
169     { 8191, JSTestObjPrototypeTableValues, 0 };
170 #else
171     { 67, 63, JSTestObjPrototypeTableValues, 0 };
172 #endif
173
174 const ClassInfo JSTestObjPrototype::s_info = { "TestObjPrototype", 0, &JSTestObjPrototypeTable, 0 };
175
176 JSObject* JSTestObjPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
177 {
178     return getDOMPrototype<JSTestObj>(exec, globalObject);
179 }
180
181 bool JSTestObjPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
182 {
183     return getStaticFunctionSlot<JSObject>(exec, &JSTestObjPrototypeTable, this, propertyName, slot);
184 }
185
186 bool JSTestObjPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
187 {
188     return getStaticFunctionDescriptor<JSObject>(exec, &JSTestObjPrototypeTable, this, propertyName, descriptor);
189 }
190
191 const ClassInfo JSTestObj::s_info = { "TestObj", 0, &JSTestObjTable, 0 };
192
193 JSTestObj::JSTestObj(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestObj> impl)
194     : DOMObjectWithGlobalPointer(structure, globalObject)
195     , m_impl(impl)
196 {
197 }
198
199 JSTestObj::~JSTestObj()
200 {
201     forgetDOMObject(this, impl());
202 }
203
204 JSObject* JSTestObj::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
205 {
206     return new (exec) JSTestObjPrototype(JSTestObjPrototype::createStructure(globalObject->objectPrototype()));
207 }
208
209 bool JSTestObj::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
210 {
211     return getStaticValueSlot<JSTestObj, Base>(exec, &JSTestObjTable, this, propertyName, slot);
212 }
213
214 bool JSTestObj::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
215 {
216     return getStaticValueDescriptor<JSTestObj, Base>(exec, &JSTestObjTable, this, propertyName, descriptor);
217 }
218
219 JSValue jsTestObjReadOnlyIntAttr(ExecState* exec, JSValue slotBase, const Identifier&)
220 {
221     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase));
222     UNUSED_PARAM(exec);
223     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
224     JSValue result = jsNumber(exec, imp->readOnlyIntAttr());
225     return result;
226 }
227
228 JSValue jsTestObjReadOnlyStringAttr(ExecState* exec, JSValue slotBase, const Identifier&)
229 {
230     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase));
231     UNUSED_PARAM(exec);
232     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
233     JSValue result = jsString(exec, imp->readOnlyStringAttr());
234     return result;
235 }
236
237 JSValue jsTestObjReadOnlyTestObjAttr(ExecState* exec, JSValue slotBase, const Identifier&)
238 {
239     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase));
240     UNUSED_PARAM(exec);
241     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
242     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->readOnlyTestObjAttr()));
243     return result;
244 }
245
246 JSValue jsTestObjIntAttr(ExecState* exec, JSValue slotBase, const Identifier&)
247 {
248     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase));
249     UNUSED_PARAM(exec);
250     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
251     JSValue result = jsNumber(exec, imp->intAttr());
252     return result;
253 }
254
255 JSValue jsTestObjLongLongAttr(ExecState* exec, JSValue slotBase, const Identifier&)
256 {
257     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase));
258     UNUSED_PARAM(exec);
259     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
260     JSValue result = jsNumber(exec, imp->longLongAttr());
261     return result;
262 }
263
264 JSValue jsTestObjUnsignedLongLongAttr(ExecState* exec, JSValue slotBase, const Identifier&)
265 {
266     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase));
267     UNUSED_PARAM(exec);
268     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
269     JSValue result = jsNumber(exec, imp->unsignedLongLongAttr());
270     return result;
271 }
272
273 JSValue jsTestObjStringAttr(ExecState* exec, JSValue slotBase, const Identifier&)
274 {
275     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase));
276     UNUSED_PARAM(exec);
277     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
278     JSValue result = jsString(exec, imp->stringAttr());
279     return result;
280 }
281
282 JSValue jsTestObjTestObjAttr(ExecState* exec, JSValue slotBase, const Identifier&)
283 {
284     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase));
285     UNUSED_PARAM(exec);
286     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
287     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->testObjAttr()));
288     return result;
289 }
290
291 JSValue jsTestObjAttrWithException(ExecState* exec, JSValue slotBase, const Identifier&)
292 {
293     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase));
294     UNUSED_PARAM(exec);
295     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
296     JSValue result = jsNumber(exec, imp->attrWithException());
297     return result;
298 }
299
300 JSValue jsTestObjAttrWithSetterException(ExecState* exec, JSValue slotBase, const Identifier&)
301 {
302     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase));
303     UNUSED_PARAM(exec);
304     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
305     JSValue result = jsNumber(exec, imp->attrWithSetterException());
306     return result;
307 }
308
309 JSValue jsTestObjAttrWithGetterException(ExecState* exec, JSValue slotBase, const Identifier&)
310 {
311     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase));
312     UNUSED_PARAM(exec);
313     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
314     JSValue result = jsNumber(exec, imp->attrWithGetterException());
315     return result;
316 }
317
318 JSValue jsTestObjCustomAttr(ExecState* exec, JSValue slotBase, const Identifier&)
319 {
320     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase));
321     return castedThis->customAttr(exec);
322 }
323
324 JSValue jsTestObjScriptStringAttr(ExecState* exec, JSValue slotBase, const Identifier&)
325 {
326     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase));
327     UNUSED_PARAM(exec);
328     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
329     JSValue result = jsOwnedStringOrNull(exec, imp->scriptStringAttr());
330     return result;
331 }
332
333 JSValue jsTestObjConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
334 {
335     JSTestObj* domObject = static_cast<JSTestObj*>(asObject(slotBase));
336     return JSTestObj::getConstructor(exec, domObject->globalObject());
337 }
338 void JSTestObj::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
339 {
340     lookupPut<JSTestObj, Base>(exec, propertyName, value, &JSTestObjTable, this, slot);
341 }
342
343 void setJSTestObjIntAttr(ExecState* exec, JSObject* thisObject, JSValue value)
344 {
345     JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject);
346     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
347     imp->setIntAttr(value.toInt32(exec));
348 }
349
350 void setJSTestObjLongLongAttr(ExecState* exec, JSObject* thisObject, JSValue value)
351 {
352     JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject);
353     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
354     imp->setLongLongAttr(static_cast<long long>(value.toInteger(exec)));
355 }
356
357 void setJSTestObjUnsignedLongLongAttr(ExecState* exec, JSObject* thisObject, JSValue value)
358 {
359     JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject);
360     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
361     imp->setUnsignedLongLongAttr(static_cast<unsigned long long>(value.toInteger(exec)));
362 }
363
364 void setJSTestObjStringAttr(ExecState* exec, JSObject* thisObject, JSValue value)
365 {
366     JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject);
367     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
368     imp->setStringAttr(ustringToString(value.toString(exec)));
369 }
370
371 void setJSTestObjTestObjAttr(ExecState* exec, JSObject* thisObject, JSValue value)
372 {
373     JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject);
374     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
375     imp->setTestObjAttr(toTestObj(value));
376 }
377
378 void setJSTestObjAttrWithException(ExecState* exec, JSObject* thisObject, JSValue value)
379 {
380     JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject);
381     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
382     imp->setAttrWithException(value.toInt32(exec));
383 }
384
385 void setJSTestObjAttrWithSetterException(ExecState* exec, JSObject* thisObject, JSValue value)
386 {
387     JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject);
388     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
389     imp->setAttrWithSetterException(value.toInt32(exec));
390 }
391
392 void setJSTestObjAttrWithGetterException(ExecState* exec, JSObject* thisObject, JSValue value)
393 {
394     JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject);
395     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
396     imp->setAttrWithGetterException(value.toInt32(exec));
397 }
398
399 void setJSTestObjCustomAttr(ExecState* exec, JSObject* thisObject, JSValue value)
400 {
401     static_cast<JSTestObj*>(thisObject)->setCustomAttr(exec, value);
402 }
403
404 JSValue JSTestObj::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
405 {
406     return getDOMConstructor<JSTestObjConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
407 }
408
409 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethod(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
410 {
411     UNUSED_PARAM(args);
412     if (!thisValue.inherits(&JSTestObj::s_info))
413         return throwError(exec, TypeError);
414     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
415     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
416
417     imp->voidMethod();
418     return jsUndefined();
419 }
420
421 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethodWithArgs(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
422 {
423     UNUSED_PARAM(args);
424     if (!thisValue.inherits(&JSTestObj::s_info))
425         return throwError(exec, TypeError);
426     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
427     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
428     int intArg = args.at(0).toInt32(exec);
429     const String& strArg = ustringToString(args.at(1).toString(exec));
430     TestObj* objArg = toTestObj(args.at(2));
431
432     imp->voidMethodWithArgs(intArg, strArg, objArg);
433     return jsUndefined();
434 }
435
436 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethod(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
437 {
438     UNUSED_PARAM(args);
439     if (!thisValue.inherits(&JSTestObj::s_info))
440         return throwError(exec, TypeError);
441     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
442     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
443
444
445     JSC::JSValue result = jsNumber(exec, imp->intMethod());
446     return result;
447 }
448
449 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethodWithArgs(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
450 {
451     UNUSED_PARAM(args);
452     if (!thisValue.inherits(&JSTestObj::s_info))
453         return throwError(exec, TypeError);
454     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
455     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
456     int intArg = args.at(0).toInt32(exec);
457     const String& strArg = ustringToString(args.at(1).toString(exec));
458     TestObj* objArg = toTestObj(args.at(2));
459
460
461     JSC::JSValue result = jsNumber(exec, imp->intMethodWithArgs(intArg, strArg, objArg));
462     return result;
463 }
464
465 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethod(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
466 {
467     UNUSED_PARAM(args);
468     if (!thisValue.inherits(&JSTestObj::s_info))
469         return throwError(exec, TypeError);
470     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
471     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
472
473
474     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->objMethod()));
475     return result;
476 }
477
478 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
479 {
480     UNUSED_PARAM(args);
481     if (!thisValue.inherits(&JSTestObj::s_info))
482         return throwError(exec, TypeError);
483     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
484     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
485     int intArg = args.at(0).toInt32(exec);
486     const String& strArg = ustringToString(args.at(1).toString(exec));
487     TestObj* objArg = toTestObj(args.at(2));
488
489
490     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->objMethodWithArgs(intArg, strArg, objArg)));
491     return result;
492 }
493
494 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
495 {
496     UNUSED_PARAM(args);
497     if (!thisValue.inherits(&JSTestObj::s_info))
498         return throwError(exec, TypeError);
499     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
500     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
501     RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(exec, args.at(0));
502
503     imp->serializedValue(serializedArg);
504     return jsUndefined();
505 }
506
507 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithException(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
508 {
509     UNUSED_PARAM(args);
510     if (!thisValue.inherits(&JSTestObj::s_info))
511         return throwError(exec, TypeError);
512     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
513     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
514     ExceptionCode ec = 0;
515
516     imp->methodWithException(ec);
517     setDOMException(exec, ec);
518     return jsUndefined();
519 }
520
521 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethod(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
522 {
523     UNUSED_PARAM(args);
524     if (!thisValue.inherits(&JSTestObj::s_info))
525         return throwError(exec, TypeError);
526     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
527     return castedThis->customMethod(exec, args);
528 }
529
530 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethodWithArgs(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
531 {
532     UNUSED_PARAM(args);
533     if (!thisValue.inherits(&JSTestObj::s_info))
534         return throwError(exec, TypeError);
535     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
536     return castedThis->customMethodWithArgs(exec, args);
537 }
538
539 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomArgsAndException(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
540 {
541     UNUSED_PARAM(args);
542     if (!thisValue.inherits(&JSTestObj::s_info))
543         return throwError(exec, TypeError);
544     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
545     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
546     ExceptionCode ec = 0;
547     ScriptCallStack callStack(exec, args, 1);
548     log* intArg = tolog(args.at(0));
549
550     imp->customArgsAndException(intArg, &callStack, ec);
551     setDOMException(exec, ec);
552     return jsUndefined();
553 }
554
555 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAddEventListener(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
556 {
557     UNUSED_PARAM(args);
558     if (!thisValue.inherits(&JSTestObj::s_info))
559         return throwError(exec, TypeError);
560     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
561     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
562     JSValue listener = args.at(1);
563     if (!listener.isObject())
564         return jsUndefined();
565     imp->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)), args.at(2).toBoolean(exec));
566     return jsUndefined();
567 }
568
569 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionRemoveEventListener(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
570 {
571     UNUSED_PARAM(args);
572     if (!thisValue.inherits(&JSTestObj::s_info))
573         return throwError(exec, TypeError);
574     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
575     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
576     JSValue listener = args.at(1);
577     if (!listener.isObject())
578         return jsUndefined();
579     imp->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec));
580     return jsUndefined();
581 }
582
583 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrame(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
584 {
585     UNUSED_PARAM(args);
586     if (!thisValue.inherits(&JSTestObj::s_info))
587         return throwError(exec, TypeError);
588     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
589     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
590     Frame* dynamicFrame = toDynamicFrame(exec);
591     if (!dynamicFrame)
592         return jsUndefined();
593
594     imp->withDynamicFrame(dynamicFrame);
595     return jsUndefined();
596 }
597
598 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndArg(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
599 {
600     UNUSED_PARAM(args);
601     if (!thisValue.inherits(&JSTestObj::s_info))
602         return throwError(exec, TypeError);
603     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
604     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
605     Frame* dynamicFrame = toDynamicFrame(exec);
606     if (!dynamicFrame)
607         return jsUndefined();
608     int intArg = args.at(1).toInt32(exec);
609
610     imp->withDynamicFrameAndArg(dynamicFrame, intArg);
611     return jsUndefined();
612 }
613
614 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
615 {
616     UNUSED_PARAM(args);
617     if (!thisValue.inherits(&JSTestObj::s_info))
618         return throwError(exec, TypeError);
619     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
620     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
621     Frame* dynamicFrame = toDynamicFrame(exec);
622     if (!dynamicFrame)
623         return jsUndefined();
624     int intArg = args.at(1).toInt32(exec);
625
626     int argsCount = args.size();
627     if (argsCount < 3) {
628         imp->withDynamicFrameAndOptionalArg(dynamicFrame, intArg);
629         return jsUndefined();
630     }
631
632     int optionalArg = args.at(2).toInt32(exec);
633
634     imp->withDynamicFrameAndOptionalArg(dynamicFrame, intArg, optionalArg);
635     return jsUndefined();
636 }
637
638 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
639 {
640     UNUSED_PARAM(args);
641     if (!thisValue.inherits(&JSTestObj::s_info))
642         return throwError(exec, TypeError);
643     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
644     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
645     Frame* dynamicFrame = toDynamicFrame(exec);
646     if (!dynamicFrame)
647         return jsUndefined();
648     int intArg = args.at(1).toInt32(exec);
649
650     imp->withDynamicFrameAndUserGesture(dynamicFrame, intArg, processingUserGesture(exec));
651     return jsUndefined();
652 }
653
654 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
655 {
656     UNUSED_PARAM(args);
657     if (!thisValue.inherits(&JSTestObj::s_info))
658         return throwError(exec, TypeError);
659     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
660     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
661     Frame* dynamicFrame = toDynamicFrame(exec);
662     if (!dynamicFrame)
663         return jsUndefined();
664     int intArg = args.at(1).toInt32(exec);
665
666     int argsCount = args.size();
667     if (argsCount < 3) {
668         imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg);
669         return jsUndefined();
670     }
671
672     int optionalArg = args.at(2).toInt32(exec);
673
674     imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg, optionalArg, processingUserGesture(exec));
675     return jsUndefined();
676 }
677
678 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoid(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
679 {
680     UNUSED_PARAM(args);
681     if (!thisValue.inherits(&JSTestObj::s_info))
682         return throwError(exec, TypeError);
683     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
684     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
685
686     imp->withScriptStateVoid(exec);
687     return jsUndefined();
688 }
689
690 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObj(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
691 {
692     UNUSED_PARAM(args);
693     if (!thisValue.inherits(&JSTestObj::s_info))
694         return throwError(exec, TypeError);
695     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
696     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
697
698
699     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->withScriptStateObj(exec)));
700     if (exec->hadException())
701         return jsUndefined();
702     return result;
703 }
704
705 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoidException(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
706 {
707     UNUSED_PARAM(args);
708     if (!thisValue.inherits(&JSTestObj::s_info))
709         return throwError(exec, TypeError);
710     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
711     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
712     ExceptionCode ec = 0;
713
714     imp->withScriptStateVoidException(exec, ec);
715     setDOMException(exec, ec);
716     return jsUndefined();
717 }
718
719 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObjException(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
720 {
721     UNUSED_PARAM(args);
722     if (!thisValue.inherits(&JSTestObj::s_info))
723         return throwError(exec, TypeError);
724     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
725     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
726     ExceptionCode ec = 0;
727
728
729     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->withScriptStateObjException(exec, ec)));
730     setDOMException(exec, ec);
731     if (exec->hadException())
732         return jsUndefined();
733     return result;
734 }
735
736 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
737 {
738     UNUSED_PARAM(args);
739     if (!thisValue.inherits(&JSTestObj::s_info))
740         return throwError(exec, TypeError);
741     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
742     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
743
744     int argsCount = args.size();
745     if (argsCount < 1) {
746         imp->methodWithOptionalArg();
747         return jsUndefined();
748     }
749
750     int opt = args.at(0).toInt32(exec);
751
752     imp->methodWithOptionalArg(opt);
753     return jsUndefined();
754 }
755
756 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
757 {
758     UNUSED_PARAM(args);
759     if (!thisValue.inherits(&JSTestObj::s_info))
760         return throwError(exec, TypeError);
761     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
762     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
763     int nonOpt = args.at(0).toInt32(exec);
764
765     int argsCount = args.size();
766     if (argsCount < 2) {
767         imp->methodWithNonOptionalArgAndOptionalArg(nonOpt);
768         return jsUndefined();
769     }
770
771     int opt = args.at(1).toInt32(exec);
772
773     imp->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt);
774     return jsUndefined();
775 }
776
777 JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
778 {
779     UNUSED_PARAM(args);
780     if (!thisValue.inherits(&JSTestObj::s_info))
781         return throwError(exec, TypeError);
782     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue));
783     TestObj* imp = static_cast<TestObj*>(castedThis->impl());
784     int nonOpt = args.at(0).toInt32(exec);
785
786     int argsCount = args.size();
787     if (argsCount < 2) {
788         imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt);
789         return jsUndefined();
790     }
791
792     int opt1 = args.at(1).toInt32(exec);
793     if (argsCount < 3) {
794         imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1);
795         return jsUndefined();
796     }
797
798     int opt2 = args.at(2).toInt32(exec);
799
800     imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2);
801     return jsUndefined();
802 }
803
804 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestObj* object)
805 {
806     return getDOMObjectWrapper<JSTestObj>(exec, globalObject, object);
807 }
808 TestObj* toTestObj(JSC::JSValue value)
809 {
810     return value.inherits(&JSTestObj::s_info) ? static_cast<JSTestObj*>(asObject(value))->impl() : 0;
811 }
812
813 }