2010-07-20 Jessie Berlin <jberlin@apple.com>
[WebKit-https.git] / WebCore / bindings / scripts / test / V8 / V8TestObj.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., 59 Temple Place - Suite 330,
18     Boston, MA 02111-1307, USA.
19 */
20
21 #include "config.h"
22 #include "V8TestObj.h"
23
24 #include "ExceptionCode.h"
25 #include "HTMLNames.h"
26 #include "IDBBindingUtilities.h"
27 #include "IDBKey.h"
28 #include "RuntimeEnabledFeatures.h"
29 #include "ScriptCallStack.h"
30 #include "SerializedScriptValue.h"
31 #include "V8Binding.h"
32 #include "V8BindingState.h"
33 #include "V8DOMWrapper.h"
34 #include "V8IsolatedContext.h"
35 #include "V8Proxy.h"
36 #include "V8log.h"
37 #include <wtf/GetPtr.h>
38 #include <wtf/RefCounted.h>
39 #include <wtf/RefPtr.h>
40
41 namespace WebCore {
42
43 WrapperTypeInfo V8TestObj::info = { V8TestObj::GetTemplate, V8TestObj::derefObject, 0 };
44
45 namespace TestObjInternal {
46
47 template <typename T> void V8_USE(T) { }
48
49 static v8::Handle<v8::Value> readOnlyIntAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
50 {
51     INC_STATS("DOM.TestObj.readOnlyIntAttr._get");
52     TestObj* imp = V8TestObj::toNative(info.Holder());
53     return v8::Integer::New(imp->readOnlyIntAttr());
54 }
55
56 static v8::Handle<v8::Value> readOnlyStringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
57 {
58     INC_STATS("DOM.TestObj.readOnlyStringAttr._get");
59     TestObj* imp = V8TestObj::toNative(info.Holder());
60     return v8String(imp->readOnlyStringAttr());
61 }
62
63 static v8::Handle<v8::Value> readOnlyTestObjAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
64 {
65     INC_STATS("DOM.TestObj.readOnlyTestObjAttr._get");
66     TestObj* imp = V8TestObj::toNative(info.Holder());
67     RefPtr<TestObj> result = imp->readOnlyTestObjAttr();
68     v8::Handle<v8::Value> wrapper = result.get() ? getDOMObjectMap().get(result.get()) : v8::Handle<v8::Value>();
69     if (wrapper.IsEmpty()) {
70         wrapper = toV8(result.get());
71         if (!wrapper.IsEmpty())
72             V8DOMWrapper::setHiddenReference(info.Holder(), wrapper);
73     }
74     return wrapper;
75 }
76
77 static v8::Handle<v8::Value> intAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
78 {
79     INC_STATS("DOM.TestObj.intAttr._get");
80     TestObj* imp = V8TestObj::toNative(info.Holder());
81     return v8::Integer::New(imp->intAttr());
82 }
83
84 static void intAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
85 {
86     INC_STATS("DOM.TestObj.intAttr._set");
87     TestObj* imp = V8TestObj::toNative(info.Holder());
88     int v = toInt32(value);
89     imp->setIntAttr(v);
90     return;
91 }
92
93 static v8::Handle<v8::Value> longLongAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
94 {
95     INC_STATS("DOM.TestObj.longLongAttr._get");
96     TestObj* imp = V8TestObj::toNative(info.Holder());
97     return v8::Number::New(static_cast<double>(imp->longLongAttr()));
98 }
99
100 static void longLongAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
101 {
102     INC_STATS("DOM.TestObj.longLongAttr._set");
103     TestObj* imp = V8TestObj::toNative(info.Holder());
104     long long v = toInt64(value);
105     imp->setLongLongAttr(WTF::getPtr(v));
106     return;
107 }
108
109 static v8::Handle<v8::Value> unsignedLongLongAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
110 {
111     INC_STATS("DOM.TestObj.unsignedLongLongAttr._get");
112     TestObj* imp = V8TestObj::toNative(info.Holder());
113     return v8::Number::New(static_cast<double>(imp->unsignedLongLongAttr()));
114 }
115
116 static void unsignedLongLongAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
117 {
118     INC_STATS("DOM.TestObj.unsignedLongLongAttr._set");
119     TestObj* imp = V8TestObj::toNative(info.Holder());
120     unsigned long long v = toInt64(value);
121     imp->setUnsignedLongLongAttr(WTF::getPtr(v));
122     return;
123 }
124
125 static v8::Handle<v8::Value> stringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
126 {
127     INC_STATS("DOM.TestObj.stringAttr._get");
128     TestObj* imp = V8TestObj::toNative(info.Holder());
129     return v8String(imp->stringAttr());
130 }
131
132 static void stringAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
133 {
134     INC_STATS("DOM.TestObj.stringAttr._set");
135     TestObj* imp = V8TestObj::toNative(info.Holder());
136     V8Parameter<> v = value;
137     imp->setStringAttr(v);
138     return;
139 }
140
141 static v8::Handle<v8::Value> testObjAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
142 {
143     INC_STATS("DOM.TestObj.testObjAttr._get");
144     TestObj* imp = V8TestObj::toNative(info.Holder());
145     return toV8(imp->testObjAttr());
146 }
147
148 static void testObjAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
149 {
150     INC_STATS("DOM.TestObj.testObjAttr._set");
151     TestObj* imp = V8TestObj::toNative(info.Holder());
152     TestObj* v = V8TestObj::HasInstance(value) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(value)) : 0;
153     imp->setTestObjAttr(WTF::getPtr(v));
154     return;
155 }
156
157 static v8::Handle<v8::Value> reflectedStringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
158 {
159     INC_STATS("DOM.TestObj.reflectedStringAttr._get");
160     TestObj* imp = V8TestObj::toNative(info.Holder());
161     return v8String(imp->getAttribute(WebCore::HTMLNames::reflectedstringattrAttr));
162 }
163
164 static void reflectedStringAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
165 {
166     INC_STATS("DOM.TestObj.reflectedStringAttr._set");
167     TestObj* imp = V8TestObj::toNative(info.Holder());
168     V8Parameter<WithNullCheck> v = value;
169     imp->setAttribute(WebCore::HTMLNames::reflectedstringattrAttr, v);
170     return;
171 }
172
173 static v8::Handle<v8::Value> reflectedIntegralAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
174 {
175     INC_STATS("DOM.TestObj.reflectedIntegralAttr._get");
176     TestObj* imp = V8TestObj::toNative(info.Holder());
177     return v8::Integer::New(imp->getIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr));
178 }
179
180 static void reflectedIntegralAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
181 {
182     INC_STATS("DOM.TestObj.reflectedIntegralAttr._set");
183     TestObj* imp = V8TestObj::toNative(info.Holder());
184     int v = toInt32(value);
185     imp->setIntegralAttribute(WebCore::HTMLNames::reflectedintegralattrAttr, v);
186     return;
187 }
188
189 static v8::Handle<v8::Value> reflectedBooleanAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
190 {
191     INC_STATS("DOM.TestObj.reflectedBooleanAttr._get");
192     TestObj* imp = V8TestObj::toNative(info.Holder());
193     return v8Boolean(imp->hasAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr));
194 }
195
196 static void reflectedBooleanAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
197 {
198     INC_STATS("DOM.TestObj.reflectedBooleanAttr._set");
199     TestObj* imp = V8TestObj::toNative(info.Holder());
200     bool v = value->BooleanValue();
201     imp->setBooleanAttribute(WebCore::HTMLNames::reflectedbooleanattrAttr, v);
202     return;
203 }
204
205 static v8::Handle<v8::Value> reflectedURLAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
206 {
207     INC_STATS("DOM.TestObj.reflectedURLAttr._get");
208     TestObj* imp = V8TestObj::toNative(info.Holder());
209     return v8String(imp->getURLAttribute(WebCore::HTMLNames::reflectedurlattrAttr));
210 }
211
212 static void reflectedURLAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
213 {
214     INC_STATS("DOM.TestObj.reflectedURLAttr._set");
215     TestObj* imp = V8TestObj::toNative(info.Holder());
216     V8Parameter<WithNullCheck> v = value;
217     imp->setAttribute(WebCore::HTMLNames::reflectedurlattrAttr, v);
218     return;
219 }
220
221 static v8::Handle<v8::Value> reflectedNonEmptyURLAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
222 {
223     INC_STATS("DOM.TestObj.reflectedNonEmptyURLAttr._get");
224     TestObj* imp = V8TestObj::toNative(info.Holder());
225     return v8String(imp->getNonEmptyURLAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr));
226 }
227
228 static void reflectedNonEmptyURLAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
229 {
230     INC_STATS("DOM.TestObj.reflectedNonEmptyURLAttr._set");
231     TestObj* imp = V8TestObj::toNative(info.Holder());
232     V8Parameter<WithNullCheck> v = value;
233     imp->setAttribute(WebCore::HTMLNames::reflectednonemptyurlattrAttr, v);
234     return;
235 }
236
237 static v8::Handle<v8::Value> reflectedStringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
238 {
239     INC_STATS("DOM.TestObj.reflectedStringAttr._get");
240     TestObj* imp = V8TestObj::toNative(info.Holder());
241     return v8String(imp->getAttribute(WebCore::HTMLNames::customContentStringAttrAttr));
242 }
243
244 static void reflectedStringAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
245 {
246     INC_STATS("DOM.TestObj.reflectedStringAttr._set");
247     TestObj* imp = V8TestObj::toNative(info.Holder());
248     V8Parameter<WithNullCheck> v = value;
249     imp->setAttribute(WebCore::HTMLNames::customContentStringAttrAttr, v);
250     return;
251 }
252
253 static v8::Handle<v8::Value> reflectedCustomIntegralAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
254 {
255     INC_STATS("DOM.TestObj.reflectedCustomIntegralAttr._get");
256     TestObj* imp = V8TestObj::toNative(info.Holder());
257     return v8::Integer::New(imp->getIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr));
258 }
259
260 static void reflectedCustomIntegralAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
261 {
262     INC_STATS("DOM.TestObj.reflectedCustomIntegralAttr._set");
263     TestObj* imp = V8TestObj::toNative(info.Holder());
264     int v = toInt32(value);
265     imp->setIntegralAttribute(WebCore::HTMLNames::customContentIntegralAttrAttr, v);
266     return;
267 }
268
269 static v8::Handle<v8::Value> reflectedCustomBooleanAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
270 {
271     INC_STATS("DOM.TestObj.reflectedCustomBooleanAttr._get");
272     TestObj* imp = V8TestObj::toNative(info.Holder());
273     return v8Boolean(imp->hasAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr));
274 }
275
276 static void reflectedCustomBooleanAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
277 {
278     INC_STATS("DOM.TestObj.reflectedCustomBooleanAttr._set");
279     TestObj* imp = V8TestObj::toNative(info.Holder());
280     bool v = value->BooleanValue();
281     imp->setBooleanAttribute(WebCore::HTMLNames::customContentBooleanAttrAttr, v);
282     return;
283 }
284
285 static v8::Handle<v8::Value> reflectedCustomURLAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
286 {
287     INC_STATS("DOM.TestObj.reflectedCustomURLAttr._get");
288     TestObj* imp = V8TestObj::toNative(info.Holder());
289     return v8String(imp->getURLAttribute(WebCore::HTMLNames::customContentURLAttrAttr));
290 }
291
292 static void reflectedCustomURLAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
293 {
294     INC_STATS("DOM.TestObj.reflectedCustomURLAttr._set");
295     TestObj* imp = V8TestObj::toNative(info.Holder());
296     V8Parameter<WithNullCheck> v = value;
297     imp->setAttribute(WebCore::HTMLNames::customContentURLAttrAttr, v);
298     return;
299 }
300
301 static v8::Handle<v8::Value> reflectedCustomNonEmptyURLAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
302 {
303     INC_STATS("DOM.TestObj.reflectedCustomNonEmptyURLAttr._get");
304     TestObj* imp = V8TestObj::toNative(info.Holder());
305     return v8String(imp->getNonEmptyURLAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr));
306 }
307
308 static void reflectedCustomNonEmptyURLAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
309 {
310     INC_STATS("DOM.TestObj.reflectedCustomNonEmptyURLAttr._set");
311     TestObj* imp = V8TestObj::toNative(info.Holder());
312     V8Parameter<WithNullCheck> v = value;
313     imp->setAttribute(WebCore::HTMLNames::customContentNonEmptyURLAttrAttr, v);
314     return;
315 }
316
317 static v8::Handle<v8::Value> attrWithGetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
318 {
319     INC_STATS("DOM.TestObj.attrWithGetterException._get");
320     TestObj* imp = V8TestObj::toNative(info.Holder());
321     ExceptionCode ec = 0;
322     int v = imp->attrWithGetterException(ec);
323     if (UNLIKELY(ec)) {
324         V8Proxy::setDOMException(ec);
325         return v8::Handle<v8::Value>();
326     }
327     return v8::Integer::New(v);
328 }
329
330 static void attrWithGetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
331 {
332     INC_STATS("DOM.TestObj.attrWithGetterException._set");
333     TestObj* imp = V8TestObj::toNative(info.Holder());
334     int v = toInt32(value);
335     ExceptionCode ec = 0;
336     imp->setAttrWithGetterException(v, ec);
337     if (UNLIKELY(ec))
338         V8Proxy::setDOMException(ec);
339     return;
340 }
341
342 static v8::Handle<v8::Value> attrWithSetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
343 {
344     INC_STATS("DOM.TestObj.attrWithSetterException._get");
345     TestObj* imp = V8TestObj::toNative(info.Holder());
346     return v8::Integer::New(imp->attrWithSetterException());
347 }
348
349 static void attrWithSetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
350 {
351     INC_STATS("DOM.TestObj.attrWithSetterException._set");
352     TestObj* imp = V8TestObj::toNative(info.Holder());
353     int v = toInt32(value);
354     ExceptionCode ec = 0;
355     imp->setAttrWithSetterException(v, ec);
356     if (UNLIKELY(ec))
357         V8Proxy::setDOMException(ec);
358     return;
359 }
360
361 static v8::Handle<v8::Value> stringAttrWithGetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
362 {
363     INC_STATS("DOM.TestObj.stringAttrWithGetterException._get");
364     TestObj* imp = V8TestObj::toNative(info.Holder());
365     ExceptionCode ec = 0;
366     String v = imp->stringAttrWithGetterException(ec);
367     if (UNLIKELY(ec)) {
368         V8Proxy::setDOMException(ec);
369         return v8::Handle<v8::Value>();
370     }
371     return v8String(v);
372 }
373
374 static void stringAttrWithGetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
375 {
376     INC_STATS("DOM.TestObj.stringAttrWithGetterException._set");
377     TestObj* imp = V8TestObj::toNative(info.Holder());
378     V8Parameter<> v = value;
379     ExceptionCode ec = 0;
380     imp->setStringAttrWithGetterException(v, ec);
381     if (UNLIKELY(ec))
382         V8Proxy::setDOMException(ec);
383     return;
384 }
385
386 static v8::Handle<v8::Value> stringAttrWithSetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
387 {
388     INC_STATS("DOM.TestObj.stringAttrWithSetterException._get");
389     TestObj* imp = V8TestObj::toNative(info.Holder());
390     return v8String(imp->stringAttrWithSetterException());
391 }
392
393 static void stringAttrWithSetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
394 {
395     INC_STATS("DOM.TestObj.stringAttrWithSetterException._set");
396     TestObj* imp = V8TestObj::toNative(info.Holder());
397     V8Parameter<> v = value;
398     ExceptionCode ec = 0;
399     imp->setStringAttrWithSetterException(v, ec);
400     if (UNLIKELY(ec))
401         V8Proxy::setDOMException(ec);
402     return;
403 }
404
405 static v8::Handle<v8::Value> scriptStringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
406 {
407     INC_STATS("DOM.TestObj.scriptStringAttr._get");
408     TestObj* imp = V8TestObj::toNative(info.Holder());
409     return v8StringOrNull(imp->scriptStringAttr());
410 }
411
412 #if ENABLE(Condition1)
413
414 static v8::Handle<v8::Value> conditionalAttr1AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
415 {
416     INC_STATS("DOM.TestObj.conditionalAttr1._get");
417     TestObj* imp = V8TestObj::toNative(info.Holder());
418     return v8::Integer::New(imp->conditionalAttr1());
419 }
420
421 #endif // ENABLE(Condition1)
422
423 #if ENABLE(Condition1)
424
425 static void conditionalAttr1AttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
426 {
427     INC_STATS("DOM.TestObj.conditionalAttr1._set");
428     TestObj* imp = V8TestObj::toNative(info.Holder());
429     int v = toInt32(value);
430     imp->setConditionalAttr1(v);
431     return;
432 }
433
434 #endif // ENABLE(Condition1)
435
436 #if ENABLE(Condition1) && ENABLE(Condition2)
437
438 static v8::Handle<v8::Value> conditionalAttr2AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
439 {
440     INC_STATS("DOM.TestObj.conditionalAttr2._get");
441     TestObj* imp = V8TestObj::toNative(info.Holder());
442     return v8::Integer::New(imp->conditionalAttr2());
443 }
444
445 #endif // ENABLE(Condition1) && ENABLE(Condition2)
446
447 #if ENABLE(Condition1) && ENABLE(Condition2)
448
449 static void conditionalAttr2AttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
450 {
451     INC_STATS("DOM.TestObj.conditionalAttr2._set");
452     TestObj* imp = V8TestObj::toNative(info.Holder());
453     int v = toInt32(value);
454     imp->setConditionalAttr2(v);
455     return;
456 }
457
458 #endif // ENABLE(Condition1) && ENABLE(Condition2)
459
460 #if ENABLE(Condition1) || ENABLE(Condition2)
461
462 static v8::Handle<v8::Value> conditionalAttr3AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
463 {
464     INC_STATS("DOM.TestObj.conditionalAttr3._get");
465     TestObj* imp = V8TestObj::toNative(info.Holder());
466     return v8::Integer::New(imp->conditionalAttr3());
467 }
468
469 #endif // ENABLE(Condition1) || ENABLE(Condition2)
470
471 #if ENABLE(Condition1) || ENABLE(Condition2)
472
473 static void conditionalAttr3AttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
474 {
475     INC_STATS("DOM.TestObj.conditionalAttr3._set");
476     TestObj* imp = V8TestObj::toNative(info.Holder());
477     int v = toInt32(value);
478     imp->setConditionalAttr3(v);
479     return;
480 }
481
482 #endif // ENABLE(Condition1) || ENABLE(Condition2)
483
484 static v8::Handle<v8::Value> descriptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
485 {
486     INC_STATS("DOM.TestObj.description._get");
487     TestObj* imp = V8TestObj::toNative(info.Holder());
488     return v8::Integer::New(imp->description());
489 }
490
491 static v8::Handle<v8::Value> idAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
492 {
493     INC_STATS("DOM.TestObj.id._get");
494     TestObj* imp = V8TestObj::toNative(info.Holder());
495     return v8::Integer::New(imp->id());
496 }
497
498 static void idAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
499 {
500     INC_STATS("DOM.TestObj.id._set");
501     TestObj* imp = V8TestObj::toNative(info.Holder());
502     int v = toInt32(value);
503     imp->setId(v);
504     return;
505 }
506
507 static v8::Handle<v8::Value> hashAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
508 {
509     INC_STATS("DOM.TestObj.hash._get");
510     TestObj* imp = V8TestObj::toNative(info.Holder());
511     return v8String(imp->hash());
512 }
513
514 static v8::Handle<v8::Value> voidMethodCallback(const v8::Arguments& args)
515 {
516     INC_STATS("DOM.TestObj.voidMethod");
517     TestObj* imp = V8TestObj::toNative(args.Holder());
518     imp->voidMethod();
519     return v8::Handle<v8::Value>();
520 }
521
522 static v8::Handle<v8::Value> voidMethodWithArgsCallback(const v8::Arguments& args)
523 {
524     INC_STATS("DOM.TestObj.voidMethodWithArgs");
525     TestObj* imp = V8TestObj::toNative(args.Holder());
526     int intArg = toInt32(args[0]);
527     V8Parameter<> strArg = args[1];
528     TestObj* objArg = V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0;
529     imp->voidMethodWithArgs(intArg, strArg, objArg);
530     return v8::Handle<v8::Value>();
531 }
532
533 static v8::Handle<v8::Value> intMethodCallback(const v8::Arguments& args)
534 {
535     INC_STATS("DOM.TestObj.intMethod");
536     TestObj* imp = V8TestObj::toNative(args.Holder());
537     return v8::Integer::New(imp->intMethod());
538 }
539
540 static v8::Handle<v8::Value> intMethodWithArgsCallback(const v8::Arguments& args)
541 {
542     INC_STATS("DOM.TestObj.intMethodWithArgs");
543     TestObj* imp = V8TestObj::toNative(args.Holder());
544     int intArg = toInt32(args[0]);
545     V8Parameter<> strArg = args[1];
546     TestObj* objArg = V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0;
547     return v8::Integer::New(imp->intMethodWithArgs(intArg, strArg, objArg));
548 }
549
550 static v8::Handle<v8::Value> objMethodCallback(const v8::Arguments& args)
551 {
552     INC_STATS("DOM.TestObj.objMethod");
553     TestObj* imp = V8TestObj::toNative(args.Holder());
554     return toV8(imp->objMethod());
555 }
556
557 static v8::Handle<v8::Value> objMethodWithArgsCallback(const v8::Arguments& args)
558 {
559     INC_STATS("DOM.TestObj.objMethodWithArgs");
560     TestObj* imp = V8TestObj::toNative(args.Holder());
561     int intArg = toInt32(args[0]);
562     V8Parameter<> strArg = args[1];
563     TestObj* objArg = V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0;
564     return toV8(imp->objMethodWithArgs(intArg, strArg, objArg));
565 }
566
567 static v8::Handle<v8::Value> methodThatRequiresAllArgsCallback(const v8::Arguments& args)
568 {
569     INC_STATS("DOM.TestObj.methodThatRequiresAllArgs");
570     if (args.Length() < 2)
571         return v8::Handle<v8::Value>();
572     TestObj* imp = V8TestObj::toNative(args.Holder());
573     V8Parameter<> strArg = args[0];
574     TestObj* objArg = V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0;
575     return toV8(imp->methodThatRequiresAllArgs(strArg, objArg));
576 }
577
578 static v8::Handle<v8::Value> methodThatRequiresAllArgsAndThrowsCallback(const v8::Arguments& args)
579 {
580     INC_STATS("DOM.TestObj.methodThatRequiresAllArgsAndThrows");
581     if (args.Length() < 2)
582         return throwError("Not enough arguments", V8Proxy::SyntaxError);
583     TestObj* imp = V8TestObj::toNative(args.Holder());
584     ExceptionCode ec = 0;
585     {
586     V8Parameter<> strArg = args[0];
587     TestObj* objArg = V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0;
588     RefPtr<TestObj> result = imp->methodThatRequiresAllArgsAndThrows(strArg, objArg, ec);
589     if (UNLIKELY(ec))
590         goto fail;
591     return toV8(result.release());
592     }
593     fail:
594     V8Proxy::setDOMException(ec);
595     return v8::Handle<v8::Value>();
596 }
597
598 static v8::Handle<v8::Value> serializedValueCallback(const v8::Arguments& args)
599 {
600     INC_STATS("DOM.TestObj.serializedValue");
601     TestObj* imp = V8TestObj::toNative(args.Holder());
602     bool serializedArgDidThrow = false;
603     RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(args[0], serializedArgDidThrow);
604     if (serializedArgDidThrow)
605         return v8::Undefined();
606     imp->serializedValue(serializedArg);
607     return v8::Handle<v8::Value>();
608 }
609
610 static v8::Handle<v8::Value> idbKeyCallback(const v8::Arguments& args)
611 {
612     INC_STATS("DOM.TestObj.idbKey");
613     TestObj* imp = V8TestObj::toNative(args.Holder());
614     RefPtr<IDBKey> key = createIDBKeyFromValue(args[0]);
615     imp->idbKey(key);
616     return v8::Handle<v8::Value>();
617 }
618
619 static v8::Handle<v8::Value> methodWithExceptionCallback(const v8::Arguments& args)
620 {
621     INC_STATS("DOM.TestObj.methodWithException");
622     TestObj* imp = V8TestObj::toNative(args.Holder());
623     ExceptionCode ec = 0;
624     {
625     imp->methodWithException(ec);
626     if (UNLIKELY(ec))
627         goto fail;
628     return v8::Handle<v8::Value>();
629     }
630     fail:
631     V8Proxy::setDOMException(ec);
632     return v8::Handle<v8::Value>();
633 }
634
635 static v8::Handle<v8::Value> customArgsAndExceptionCallback(const v8::Arguments& args)
636 {
637     INC_STATS("DOM.TestObj.customArgsAndException");
638     TestObj* imp = V8TestObj::toNative(args.Holder());
639     ExceptionCode ec = 0;
640     {
641     OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, 1));
642     if (!callStack)
643         return v8::Undefined();
644     log* intArg = V8log::HasInstance(args[0]) ? V8log::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
645     imp->customArgsAndException(intArg, callStack.get(), ec);
646     if (UNLIKELY(ec))
647         goto fail;
648     return v8::Handle<v8::Value>();
649     }
650     fail:
651     V8Proxy::setDOMException(ec);
652     return v8::Handle<v8::Value>();
653 }
654
655 static v8::Handle<v8::Value> addEventListenerCallback(const v8::Arguments& args)
656 {
657     INC_STATS("DOM.TestObj.addEventListener()");
658     RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(args[1], false, ListenerFindOrCreate);
659     if (listener) {
660         V8TestObj::toNative(args.Holder())->addEventListener(v8ValueToAtomicWebCoreString(args[0]), listener, args[2]->BooleanValue());
661         createHiddenDependency(args.Holder(), args[1], V8TestObj::eventListenerCacheIndex);
662     }
663     return v8::Undefined();
664 }
665
666 static v8::Handle<v8::Value> removeEventListenerCallback(const v8::Arguments& args)
667 {
668     INC_STATS("DOM.TestObj.removeEventListener()");
669     RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(args[1], false, ListenerFindOnly);
670     if (listener) {
671         V8TestObj::toNative(args.Holder())->removeEventListener(v8ValueToAtomicWebCoreString(args[0]), listener.get(), args[2]->BooleanValue());
672         removeHiddenDependency(args.Holder(), args[1], V8TestObj::eventListenerCacheIndex);
673     }
674     return v8::Undefined();
675 }
676
677 static v8::Handle<v8::Value> withDynamicFrameCallback(const v8::Arguments& args)
678 {
679     INC_STATS("DOM.TestObj.withDynamicFrame");
680     TestObj* imp = V8TestObj::toNative(args.Holder());
681     Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
682     if (!enteredFrame)
683         return v8::Undefined();
684     imp->withDynamicFrame(enteredFrame);
685     return v8::Handle<v8::Value>();
686 }
687
688 static v8::Handle<v8::Value> withDynamicFrameAndArgCallback(const v8::Arguments& args)
689 {
690     INC_STATS("DOM.TestObj.withDynamicFrameAndArg");
691     TestObj* imp = V8TestObj::toNative(args.Holder());
692     int intArg = toInt32(args[0]);
693     Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
694     if (!enteredFrame)
695         return v8::Undefined();
696     imp->withDynamicFrameAndArg(enteredFrame, intArg);
697     return v8::Handle<v8::Value>();
698 }
699
700 static v8::Handle<v8::Value> withDynamicFrameAndOptionalArgCallback(const v8::Arguments& args)
701 {
702     INC_STATS("DOM.TestObj.withDynamicFrameAndOptionalArg");
703     TestObj* imp = V8TestObj::toNative(args.Holder());
704     int intArg = toInt32(args[0]);
705     if (args.Length() <= 1) {
706         Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
707         if (!enteredFrame)
708             return v8::Undefined();
709         imp->withDynamicFrameAndOptionalArg(enteredFrame, intArg);
710         return v8::Handle<v8::Value>();
711     }
712     int optionalArg = toInt32(args[1]);
713     Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
714     if (!enteredFrame)
715         return v8::Undefined();
716     imp->withDynamicFrameAndOptionalArg(enteredFrame, intArg, optionalArg);
717     return v8::Handle<v8::Value>();
718 }
719
720 static v8::Handle<v8::Value> withDynamicFrameAndUserGestureCallback(const v8::Arguments& args)
721 {
722     INC_STATS("DOM.TestObj.withDynamicFrameAndUserGesture");
723     TestObj* imp = V8TestObj::toNative(args.Holder());
724     int intArg = toInt32(args[0]);
725     Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
726     if (!enteredFrame)
727         return v8::Undefined();
728     imp->withDynamicFrameAndUserGesture(enteredFrame, intArg, processingUserGesture());
729     return v8::Handle<v8::Value>();
730 }
731
732 static v8::Handle<v8::Value> withDynamicFrameAndUserGestureASADCallback(const v8::Arguments& args)
733 {
734     INC_STATS("DOM.TestObj.withDynamicFrameAndUserGestureASAD");
735     TestObj* imp = V8TestObj::toNative(args.Holder());
736     int intArg = toInt32(args[0]);
737     if (args.Length() <= 1) {
738         Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
739         if (!enteredFrame)
740             return v8::Undefined();
741         imp->withDynamicFrameAndUserGestureASAD(enteredFrame, intArg, processingUserGesture());
742         return v8::Handle<v8::Value>();
743     }
744     int optionalArg = toInt32(args[1]);
745     Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();
746     if (!enteredFrame)
747         return v8::Undefined();
748     imp->withDynamicFrameAndUserGestureASAD(enteredFrame, intArg, optionalArg, processingUserGesture());
749     return v8::Handle<v8::Value>();
750 }
751
752 static v8::Handle<v8::Value> withScriptStateVoidCallback(const v8::Arguments& args)
753 {
754     INC_STATS("DOM.TestObj.withScriptStateVoid");
755     TestObj* imp = V8TestObj::toNative(args.Holder());
756     EmptyScriptState state;
757     imp->withScriptStateVoid(&state);
758     if (state.hadException())
759         return throwError(state.exception());
760     return v8::Handle<v8::Value>();
761 }
762
763 static v8::Handle<v8::Value> withScriptStateObjCallback(const v8::Arguments& args)
764 {
765     INC_STATS("DOM.TestObj.withScriptStateObj");
766     TestObj* imp = V8TestObj::toNative(args.Holder());
767     EmptyScriptState state;
768     RefPtr<TestObj> result = imp->withScriptStateObj(&state);
769     if (state.hadException())
770         return throwError(state.exception());
771     return toV8(result.release());
772 }
773
774 static v8::Handle<v8::Value> withScriptStateVoidExceptionCallback(const v8::Arguments& args)
775 {
776     INC_STATS("DOM.TestObj.withScriptStateVoidException");
777     TestObj* imp = V8TestObj::toNative(args.Holder());
778     ExceptionCode ec = 0;
779     {
780     EmptyScriptState state;
781     imp->withScriptStateVoidException(&state, ec);
782     if (UNLIKELY(ec))
783         goto fail;
784     if (state.hadException())
785         return throwError(state.exception());
786     return v8::Handle<v8::Value>();
787     }
788     fail:
789     V8Proxy::setDOMException(ec);
790     return v8::Handle<v8::Value>();
791 }
792
793 static v8::Handle<v8::Value> withScriptStateObjExceptionCallback(const v8::Arguments& args)
794 {
795     INC_STATS("DOM.TestObj.withScriptStateObjException");
796     TestObj* imp = V8TestObj::toNative(args.Holder());
797     ExceptionCode ec = 0;
798     {
799     EmptyScriptState state;
800     RefPtr<TestObj> result = imp->withScriptStateObjException(&state, ec);
801     if (UNLIKELY(ec))
802         goto fail;
803     if (state.hadException())
804         return throwError(state.exception());
805     return toV8(result.release());
806     }
807     fail:
808     V8Proxy::setDOMException(ec);
809     return v8::Handle<v8::Value>();
810 }
811
812 static v8::Handle<v8::Value> withScriptExecutionContextCallback(const v8::Arguments& args)
813 {
814     INC_STATS("DOM.TestObj.withScriptExecutionContext");
815     TestObj* imp = V8TestObj::toNative(args.Holder());
816     ScriptExecutionContext* scriptContext = getScriptExecutionContext();
817     if (!scriptContext)
818         return v8::Undefined();
819     imp->withScriptExecutionContext(scriptContext);
820     return v8::Handle<v8::Value>();
821 }
822
823 static v8::Handle<v8::Value> methodWithOptionalArgCallback(const v8::Arguments& args)
824 {
825     INC_STATS("DOM.TestObj.methodWithOptionalArg");
826     TestObj* imp = V8TestObj::toNative(args.Holder());
827     if (args.Length() <= 0) {
828         imp->methodWithOptionalArg();
829         return v8::Handle<v8::Value>();
830     }
831     int opt = toInt32(args[0]);
832     imp->methodWithOptionalArg(opt);
833     return v8::Handle<v8::Value>();
834 }
835
836 static v8::Handle<v8::Value> methodWithNonOptionalArgAndOptionalArgCallback(const v8::Arguments& args)
837 {
838     INC_STATS("DOM.TestObj.methodWithNonOptionalArgAndOptionalArg");
839     TestObj* imp = V8TestObj::toNative(args.Holder());
840     int nonOpt = toInt32(args[0]);
841     if (args.Length() <= 1) {
842         imp->methodWithNonOptionalArgAndOptionalArg(nonOpt);
843         return v8::Handle<v8::Value>();
844     }
845     int opt = toInt32(args[1]);
846     imp->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt);
847     return v8::Handle<v8::Value>();
848 }
849
850 static v8::Handle<v8::Value> methodWithNonOptionalArgAndTwoOptionalArgsCallback(const v8::Arguments& args)
851 {
852     INC_STATS("DOM.TestObj.methodWithNonOptionalArgAndTwoOptionalArgs");
853     TestObj* imp = V8TestObj::toNative(args.Holder());
854     int nonOpt = toInt32(args[0]);
855     if (args.Length() <= 1) {
856         imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt);
857         return v8::Handle<v8::Value>();
858     }
859     int opt1 = toInt32(args[1]);
860     int opt2 = toInt32(args[2]);
861     imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2);
862     return v8::Handle<v8::Value>();
863 }
864
865 static v8::Handle<v8::Value> overloadedMethod1Callback(const v8::Arguments& args)
866 {
867     INC_STATS("DOM.TestObj.overloadedMethod1");
868     TestObj* imp = V8TestObj::toNative(args.Holder());
869     TestObj* objArg = V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
870     V8Parameter<> strArg = args[1];
871     imp->overloadedMethod(objArg, strArg);
872     return v8::Handle<v8::Value>();
873 }
874
875 static v8::Handle<v8::Value> overloadedMethod2Callback(const v8::Arguments& args)
876 {
877     INC_STATS("DOM.TestObj.overloadedMethod2");
878     TestObj* imp = V8TestObj::toNative(args.Holder());
879     TestObj* objArg = V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
880     if (args.Length() <= 1) {
881         imp->overloadedMethod(objArg);
882         return v8::Handle<v8::Value>();
883     }
884     int intArg = toInt32(args[1]);
885     imp->overloadedMethod(objArg, intArg);
886     return v8::Handle<v8::Value>();
887 }
888
889 static v8::Handle<v8::Value> overloadedMethod3Callback(const v8::Arguments& args)
890 {
891     INC_STATS("DOM.TestObj.overloadedMethod3");
892     TestObj* imp = V8TestObj::toNative(args.Holder());
893     V8Parameter<> strArg = args[0];
894     imp->overloadedMethod(strArg);
895     return v8::Handle<v8::Value>();
896 }
897
898 static v8::Handle<v8::Value> overloadedMethod4Callback(const v8::Arguments& args)
899 {
900     INC_STATS("DOM.TestObj.overloadedMethod4");
901     TestObj* imp = V8TestObj::toNative(args.Holder());
902     int intArg = toInt32(args[0]);
903     imp->overloadedMethod(intArg);
904     return v8::Handle<v8::Value>();
905 }
906
907 static v8::Handle<v8::Value> overloadedMethodCallback(const v8::Arguments& args)
908 {
909     INC_STATS("DOM.TestObj.overloadedMethod");
910     if ((args.Length() == 2 && (args[0]->IsNull() || V8TestObj::HasInstance(args[0])) && (args[1]->IsNull() || args[1]->IsUndefined() || args[1]->IsString() || args[1]->IsObject())))
911         return overloadedMethod1Callback(args);
912     if ((args.Length() == 1 && (args[0]->IsNull() || V8TestObj::HasInstance(args[0]))) || (args.Length() == 2 && (args[0]->IsNull() || V8TestObj::HasInstance(args[0]))))
913         return overloadedMethod2Callback(args);
914     if ((args.Length() == 1 && (args[0]->IsNull() || args[0]->IsUndefined() || args[0]->IsString() || args[0]->IsObject())))
915         return overloadedMethod3Callback(args);
916     if (args.Length() == 1)
917         return overloadedMethod4Callback(args);
918     V8Proxy::throwTypeError();
919     return notHandledByInterceptor();
920 }
921
922 } // namespace TestObjInternal
923
924 static const BatchedAttribute TestObjAttrs[] = {
925     // Attribute 'readOnlyIntAttr' (Type: 'readonly attribute' ExtAttr: '')
926     {"readOnlyIntAttr", TestObjInternal::readOnlyIntAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
927     // Attribute 'readOnlyStringAttr' (Type: 'readonly attribute' ExtAttr: '')
928     {"readOnlyStringAttr", TestObjInternal::readOnlyStringAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
929     // Attribute 'readOnlyTestObjAttr' (Type: 'readonly attribute' ExtAttr: '')
930     {"readOnlyTestObjAttr", TestObjInternal::readOnlyTestObjAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
931     // Attribute 'intAttr' (Type: 'attribute' ExtAttr: '')
932     {"intAttr", TestObjInternal::intAttrAttrGetter, TestObjInternal::intAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
933     // Attribute 'longLongAttr' (Type: 'attribute' ExtAttr: '')
934     {"longLongAttr", TestObjInternal::longLongAttrAttrGetter, TestObjInternal::longLongAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
935     // Attribute 'unsignedLongLongAttr' (Type: 'attribute' ExtAttr: '')
936     {"unsignedLongLongAttr", TestObjInternal::unsignedLongLongAttrAttrGetter, TestObjInternal::unsignedLongLongAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
937     // Attribute 'stringAttr' (Type: 'attribute' ExtAttr: '')
938     {"stringAttr", TestObjInternal::stringAttrAttrGetter, TestObjInternal::stringAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
939     // Attribute 'testObjAttr' (Type: 'attribute' ExtAttr: '')
940     {"testObjAttr", TestObjInternal::testObjAttrAttrGetter, TestObjInternal::testObjAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
941     // Attribute 'reflectedStringAttr' (Type: 'attribute' ExtAttr: 'Reflect')
942     {"reflectedStringAttr", TestObjInternal::reflectedStringAttrAttrGetter, TestObjInternal::reflectedStringAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
943     // Attribute 'reflectedIntegralAttr' (Type: 'attribute' ExtAttr: 'Reflect')
944     {"reflectedIntegralAttr", TestObjInternal::reflectedIntegralAttrAttrGetter, TestObjInternal::reflectedIntegralAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
945     // Attribute 'reflectedBooleanAttr' (Type: 'attribute' ExtAttr: 'Reflect')
946     {"reflectedBooleanAttr", TestObjInternal::reflectedBooleanAttrAttrGetter, TestObjInternal::reflectedBooleanAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
947     // Attribute 'reflectedURLAttr' (Type: 'attribute' ExtAttr: 'URL Reflect')
948     {"reflectedURLAttr", TestObjInternal::reflectedURLAttrAttrGetter, TestObjInternal::reflectedURLAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
949     // Attribute 'reflectedNonEmptyURLAttr' (Type: 'attribute' ExtAttr: 'URL NonEmpty Reflect')
950     {"reflectedNonEmptyURLAttr", TestObjInternal::reflectedNonEmptyURLAttrAttrGetter, TestObjInternal::reflectedNonEmptyURLAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
951     // Attribute 'reflectedStringAttr' (Type: 'attribute' ExtAttr: 'Reflect')
952     {"reflectedStringAttr", TestObjInternal::reflectedStringAttrAttrGetter, TestObjInternal::reflectedStringAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
953     // Attribute 'reflectedCustomIntegralAttr' (Type: 'attribute' ExtAttr: 'Reflect')
954     {"reflectedCustomIntegralAttr", TestObjInternal::reflectedCustomIntegralAttrAttrGetter, TestObjInternal::reflectedCustomIntegralAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
955     // Attribute 'reflectedCustomBooleanAttr' (Type: 'attribute' ExtAttr: 'Reflect')
956     {"reflectedCustomBooleanAttr", TestObjInternal::reflectedCustomBooleanAttrAttrGetter, TestObjInternal::reflectedCustomBooleanAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
957     // Attribute 'reflectedCustomURLAttr' (Type: 'attribute' ExtAttr: 'URL Reflect')
958     {"reflectedCustomURLAttr", TestObjInternal::reflectedCustomURLAttrAttrGetter, TestObjInternal::reflectedCustomURLAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
959     // Attribute 'reflectedCustomNonEmptyURLAttr' (Type: 'attribute' ExtAttr: 'URL NonEmpty Reflect')
960     {"reflectedCustomNonEmptyURLAttr", TestObjInternal::reflectedCustomNonEmptyURLAttrAttrGetter, TestObjInternal::reflectedCustomNonEmptyURLAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
961     // Attribute 'attrWithGetterException' (Type: 'attribute' ExtAttr: '')
962     {"attrWithGetterException", TestObjInternal::attrWithGetterExceptionAttrGetter, TestObjInternal::attrWithGetterExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
963     // Attribute 'attrWithSetterException' (Type: 'attribute' ExtAttr: '')
964     {"attrWithSetterException", TestObjInternal::attrWithSetterExceptionAttrGetter, TestObjInternal::attrWithSetterExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
965     // Attribute 'stringAttrWithGetterException' (Type: 'attribute' ExtAttr: '')
966     {"stringAttrWithGetterException", TestObjInternal::stringAttrWithGetterExceptionAttrGetter, TestObjInternal::stringAttrWithGetterExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
967     // Attribute 'stringAttrWithSetterException' (Type: 'attribute' ExtAttr: '')
968     {"stringAttrWithSetterException", TestObjInternal::stringAttrWithSetterExceptionAttrGetter, TestObjInternal::stringAttrWithSetterExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
969     // Attribute 'customAttr' (Type: 'attribute' ExtAttr: 'Custom')
970     {"customAttr", V8TestObj::customAttrAccessorGetter, V8TestObj::customAttrAccessorSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
971     // Attribute 'scriptStringAttr' (Type: 'readonly attribute' ExtAttr: 'ConvertScriptString')
972     {"scriptStringAttr", TestObjInternal::scriptStringAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
973 #if ENABLE(Condition1)
974     // Attribute 'conditionalAttr1' (Type: 'attribute' ExtAttr: 'Conditional')
975     {"conditionalAttr1", TestObjInternal::conditionalAttr1AttrGetter, TestObjInternal::conditionalAttr1AttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
976 #endif // ENABLE(Condition1)
977 #if ENABLE(Condition1) && ENABLE(Condition2)
978     // Attribute 'conditionalAttr2' (Type: 'attribute' ExtAttr: 'Conditional')
979     {"conditionalAttr2", TestObjInternal::conditionalAttr2AttrGetter, TestObjInternal::conditionalAttr2AttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
980 #endif // ENABLE(Condition1) && ENABLE(Condition2)
981 #if ENABLE(Condition1) || ENABLE(Condition2)
982     // Attribute 'conditionalAttr3' (Type: 'attribute' ExtAttr: 'Conditional')
983     {"conditionalAttr3", TestObjInternal::conditionalAttr3AttrGetter, TestObjInternal::conditionalAttr3AttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
984 #endif // ENABLE(Condition1) || ENABLE(Condition2)
985     // Attribute 'description' (Type: 'readonly attribute' ExtAttr: '')
986     {"description", TestObjInternal::descriptionAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
987     // Attribute 'id' (Type: 'attribute' ExtAttr: '')
988     {"id", TestObjInternal::idAttrGetter, TestObjInternal::idAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
989     // Attribute 'hash' (Type: 'readonly attribute' ExtAttr: '')
990     {"hash", TestObjInternal::hashAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
991 };
992 static const BatchedCallback TestObjCallbacks[] = {
993     {"voidMethod", TestObjInternal::voidMethodCallback},
994     {"intMethod", TestObjInternal::intMethodCallback},
995     {"objMethod", TestObjInternal::objMethodCallback},
996     {"serializedValue", TestObjInternal::serializedValueCallback},
997     {"idbKey", TestObjInternal::idbKeyCallback},
998     {"methodWithException", TestObjInternal::methodWithExceptionCallback},
999     {"customMethod", V8TestObj::customMethodCallback},
1000     {"customMethodWithArgs", V8TestObj::customMethodWithArgsCallback},
1001     {"addEventListener", TestObjInternal::addEventListenerCallback},
1002     {"removeEventListener", TestObjInternal::removeEventListenerCallback},
1003     {"withDynamicFrame", TestObjInternal::withDynamicFrameCallback},
1004     {"withDynamicFrameAndArg", TestObjInternal::withDynamicFrameAndArgCallback},
1005     {"withDynamicFrameAndOptionalArg", TestObjInternal::withDynamicFrameAndOptionalArgCallback},
1006     {"withDynamicFrameAndUserGesture", TestObjInternal::withDynamicFrameAndUserGestureCallback},
1007     {"withDynamicFrameAndUserGestureASAD", TestObjInternal::withDynamicFrameAndUserGestureASADCallback},
1008     {"withScriptStateVoid", TestObjInternal::withScriptStateVoidCallback},
1009     {"withScriptStateObj", TestObjInternal::withScriptStateObjCallback},
1010     {"withScriptStateVoidException", TestObjInternal::withScriptStateVoidExceptionCallback},
1011     {"withScriptStateObjException", TestObjInternal::withScriptStateObjExceptionCallback},
1012     {"withScriptExecutionContext", TestObjInternal::withScriptExecutionContextCallback},
1013     {"methodWithOptionalArg", TestObjInternal::methodWithOptionalArgCallback},
1014     {"methodWithNonOptionalArgAndOptionalArg", TestObjInternal::methodWithNonOptionalArgAndOptionalArgCallback},
1015     {"methodWithNonOptionalArgAndTwoOptionalArgs", TestObjInternal::methodWithNonOptionalArgAndTwoOptionalArgsCallback},
1016     {"overloadedMethod", TestObjInternal::overloadedMethodCallback},
1017 };
1018 static const BatchedConstant TestObjConsts[] = {
1019     {"CONST_VALUE_0", static_cast<signed int>(0)},
1020     {"CONST_VALUE_1", static_cast<signed int>(1)},
1021     {"CONST_VALUE_2", static_cast<signed int>(2)},
1022     {"CONST_VALUE_4", static_cast<signed int>(4)},
1023     {"CONST_VALUE_8", static_cast<signed int>(8)},
1024     {"CONST_VALUE_9", static_cast<signed int>(-1)},
1025     {"CONST_VALUE_10", static_cast<signed int>("my constant string")},
1026     {"CONST_VALUE_11", static_cast<signed int>(0xffffffff)},
1027     {"CONST_VALUE_12", static_cast<signed int>(0x01)},
1028     {"CONST_VALUE_13", static_cast<signed int>(0X20)},
1029     {"CONST_VALUE_14", static_cast<signed int>(0x1abc)},
1030 };
1031
1032 COMPILE_ASSERT(0 == TestObj::CONST_VALUE_0, TestObjEnumCONST_VALUE_0IsWrongUseDontCheckEnums);
1033 COMPILE_ASSERT(1 == TestObj::CONST_VALUE_1, TestObjEnumCONST_VALUE_1IsWrongUseDontCheckEnums);
1034 COMPILE_ASSERT(2 == TestObj::CONST_VALUE_2, TestObjEnumCONST_VALUE_2IsWrongUseDontCheckEnums);
1035 COMPILE_ASSERT(4 == TestObj::CONST_VALUE_4, TestObjEnumCONST_VALUE_4IsWrongUseDontCheckEnums);
1036 COMPILE_ASSERT(8 == TestObj::CONST_VALUE_8, TestObjEnumCONST_VALUE_8IsWrongUseDontCheckEnums);
1037 COMPILE_ASSERT(-1 == TestObj::CONST_VALUE_9, TestObjEnumCONST_VALUE_9IsWrongUseDontCheckEnums);
1038 COMPILE_ASSERT("my constant string" == TestObj::CONST_VALUE_10, TestObjEnumCONST_VALUE_10IsWrongUseDontCheckEnums);
1039 COMPILE_ASSERT(0xffffffff == TestObj::CONST_VALUE_11, TestObjEnumCONST_VALUE_11IsWrongUseDontCheckEnums);
1040 COMPILE_ASSERT(0x01 == TestObj::CONST_VALUE_12, TestObjEnumCONST_VALUE_12IsWrongUseDontCheckEnums);
1041 COMPILE_ASSERT(0X20 == TestObj::CONST_VALUE_13, TestObjEnumCONST_VALUE_13IsWrongUseDontCheckEnums);
1042 COMPILE_ASSERT(0x1abc == TestObj::CONST_VALUE_14, TestObjEnumCONST_VALUE_14IsWrongUseDontCheckEnums);
1043
1044 static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestObjTemplate(v8::Persistent<v8::FunctionTemplate> desc)
1045 {
1046     v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "TestObj", v8::Persistent<v8::FunctionTemplate>(), V8TestObj::internalFieldCount,
1047         TestObjAttrs, sizeof(TestObjAttrs) / sizeof(*TestObjAttrs),
1048         TestObjCallbacks, sizeof(TestObjCallbacks) / sizeof(*TestObjCallbacks));
1049     v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
1050     v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
1051     
1052
1053     // Custom Signature 'voidMethodWithArgs'
1054     const int voidMethodWithArgsArgc = 3;
1055     v8::Handle<v8::FunctionTemplate> voidMethodWithArgsArgv[voidMethodWithArgsArgc] = { v8::Handle<v8::FunctionTemplate>(), v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() };
1056     v8::Handle<v8::Signature> voidMethodWithArgsSignature = v8::Signature::New(desc, voidMethodWithArgsArgc, voidMethodWithArgsArgv);
1057     proto->Set(v8::String::New("voidMethodWithArgs"), v8::FunctionTemplate::New(TestObjInternal::voidMethodWithArgsCallback, v8::Handle<v8::Value>(), voidMethodWithArgsSignature));
1058
1059     // Custom Signature 'intMethodWithArgs'
1060     const int intMethodWithArgsArgc = 3;
1061     v8::Handle<v8::FunctionTemplate> intMethodWithArgsArgv[intMethodWithArgsArgc] = { v8::Handle<v8::FunctionTemplate>(), v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() };
1062     v8::Handle<v8::Signature> intMethodWithArgsSignature = v8::Signature::New(desc, intMethodWithArgsArgc, intMethodWithArgsArgv);
1063     proto->Set(v8::String::New("intMethodWithArgs"), v8::FunctionTemplate::New(TestObjInternal::intMethodWithArgsCallback, v8::Handle<v8::Value>(), intMethodWithArgsSignature));
1064
1065     // Custom Signature 'objMethodWithArgs'
1066     const int objMethodWithArgsArgc = 3;
1067     v8::Handle<v8::FunctionTemplate> objMethodWithArgsArgv[objMethodWithArgsArgc] = { v8::Handle<v8::FunctionTemplate>(), v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() };
1068     v8::Handle<v8::Signature> objMethodWithArgsSignature = v8::Signature::New(desc, objMethodWithArgsArgc, objMethodWithArgsArgv);
1069     proto->Set(v8::String::New("objMethodWithArgs"), v8::FunctionTemplate::New(TestObjInternal::objMethodWithArgsCallback, v8::Handle<v8::Value>(), objMethodWithArgsSignature));
1070
1071     // Custom Signature 'methodThatRequiresAllArgs'
1072     const int methodThatRequiresAllArgsArgc = 2;
1073     v8::Handle<v8::FunctionTemplate> methodThatRequiresAllArgsArgv[methodThatRequiresAllArgsArgc] = { v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() };
1074     v8::Handle<v8::Signature> methodThatRequiresAllArgsSignature = v8::Signature::New(desc, methodThatRequiresAllArgsArgc, methodThatRequiresAllArgsArgv);
1075     proto->Set(v8::String::New("methodThatRequiresAllArgs"), v8::FunctionTemplate::New(TestObjInternal::methodThatRequiresAllArgsCallback, v8::Handle<v8::Value>(), methodThatRequiresAllArgsSignature));
1076
1077     // Custom Signature 'methodThatRequiresAllArgsAndThrows'
1078     const int methodThatRequiresAllArgsAndThrowsArgc = 2;
1079     v8::Handle<v8::FunctionTemplate> methodThatRequiresAllArgsAndThrowsArgv[methodThatRequiresAllArgsAndThrowsArgc] = { v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() };
1080     v8::Handle<v8::Signature> methodThatRequiresAllArgsAndThrowsSignature = v8::Signature::New(desc, methodThatRequiresAllArgsAndThrowsArgc, methodThatRequiresAllArgsAndThrowsArgv);
1081     proto->Set(v8::String::New("methodThatRequiresAllArgsAndThrows"), v8::FunctionTemplate::New(TestObjInternal::methodThatRequiresAllArgsAndThrowsCallback, v8::Handle<v8::Value>(), methodThatRequiresAllArgsAndThrowsSignature));
1082
1083     // Custom Signature 'customArgsAndException'
1084     const int customArgsAndExceptionArgc = 1;
1085     v8::Handle<v8::FunctionTemplate> customArgsAndExceptionArgv[customArgsAndExceptionArgc] = { V8log::GetRawTemplate() };
1086     v8::Handle<v8::Signature> customArgsAndExceptionSignature = v8::Signature::New(desc, customArgsAndExceptionArgc, customArgsAndExceptionArgv);
1087     proto->Set(v8::String::New("customArgsAndException"), v8::FunctionTemplate::New(TestObjInternal::customArgsAndExceptionCallback, v8::Handle<v8::Value>(), customArgsAndExceptionSignature));
1088     batchConfigureConstants(desc, proto, TestObjConsts, sizeof(TestObjConsts) / sizeof(*TestObjConsts));
1089
1090     // Custom toString template
1091     desc->Set(getToStringName(), getToStringTemplate());
1092     return desc;
1093 }
1094
1095 v8::Persistent<v8::FunctionTemplate> V8TestObj::GetRawTemplate()
1096 {
1097     static v8::Persistent<v8::FunctionTemplate> V8TestObjRawCache = createRawTemplate();
1098     return V8TestObjRawCache;
1099 }
1100
1101 v8::Persistent<v8::FunctionTemplate> V8TestObj::GetTemplate()
1102 {
1103     static v8::Persistent<v8::FunctionTemplate> V8TestObjCache = ConfigureV8TestObjTemplate(GetRawTemplate());
1104     return V8TestObjCache;
1105 }
1106
1107 TestObj* V8TestObj::toNative(v8::Handle<v8::Object> object)
1108 {
1109     return reinterpret_cast<TestObj*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex));
1110 }
1111
1112 bool V8TestObj::HasInstance(v8::Handle<v8::Value> value)
1113 {
1114     return GetRawTemplate()->HasInstance(value);
1115 }
1116
1117
1118 v8::Handle<v8::Object> V8TestObj::wrap(TestObj* impl)
1119 {
1120     v8::Handle<v8::Object> wrapper;
1121     V8Proxy* proxy = 0;
1122         wrapper = getDOMObjectMap().get(impl);
1123         if (!wrapper.IsEmpty())
1124             return wrapper;
1125     wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl);
1126     if (wrapper.IsEmpty())
1127         return wrapper;
1128
1129     impl->ref();
1130     getDOMObjectMap().set(impl, v8::Persistent<v8::Object>::New(wrapper));
1131     return wrapper;
1132 }
1133
1134 v8::Handle<v8::Value> toV8(PassRefPtr<TestObj > impl)
1135 {
1136     return toV8(impl.get());
1137 }
1138
1139 v8::Handle<v8::Value> toV8(TestObj* impl)
1140 {
1141     if (!impl)
1142         return v8::Null();
1143     return V8TestObj::wrap(impl);
1144 }
1145
1146 void V8TestObj::derefObject(void* object)
1147 {
1148     static_cast<TestObj*>(object)->deref();
1149 }
1150
1151 } // namespace WebCore