1926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)/*
253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    This file is part of the Blink open source project.
353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    This file has been auto-generated by CodeGeneratorV8.pm. DO NOT MODIFY!
4926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
5926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    This library is free software; you can redistribute it and/or
6926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    modify it under the terms of the GNU Library General Public
7926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    License as published by the Free Software Foundation; either
8926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    version 2 of the License, or (at your option) any later version.
9926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
10926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    This library is distributed in the hope that it will be useful,
11926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    but WITHOUT ANY WARRANTY; without even the implied warranty of
12926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    Library General Public License for more details.
14926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
15926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    You should have received a copy of the GNU Library General Public License
16926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    along with this library; see the file COPYING.LIB.  If not, write to
17926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    Boston, MA 02111-1307, USA.
19926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)*/
20926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
21926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#include "config.h"
22926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#include "V8TestTypedefs.h"
23926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
24926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#include "RuntimeEnabledFeatures.h"
25926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#include "V8SVGPoint.h"
26926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#include "V8SerializedScriptValue.h"
27926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#include "V8TestCallback.h"
28926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#include "V8TestSubObj.h"
29e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "bindings/v8/ExceptionState.h"
3053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "bindings/v8/ScriptController.h"
3153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "bindings/v8/SerializedScriptValue.h"
3253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "bindings/v8/V8Binding.h"
33e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)#include "bindings/v8/V8DOMConfiguration.h"
3453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "bindings/v8/V8DOMWrapper.h"
35e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)#include "bindings/v8/V8ObjectConstructor.h"
3653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/dom/ContextFeatures.h"
37e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)#include "core/dom/Document.h"
3853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/page/Frame.h"
39591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "core/platform/chromium/TraceEvent.h"
4053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/svg/properties/SVGPropertyTearOff.h"
4181a5157921f1d2a7ff6aae115bfe3c139b38a5c8Torne (Richard Coles)#include "wtf/UnusedParam.h"
42926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
43926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)namespace WebCore {
44926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
455267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void initializeScriptWrappableForInterface(TestTypedefs* object)
4653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles){
4753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    if (ScriptWrappable::wrapperCanBeStoredInObject(object))
4853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)        ScriptWrappable::setTypeInfoInObject(object, &V8TestTypedefs::info);
4993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    else
5093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        ASSERT_NOT_REACHED();
5153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)}
525267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
535267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)} // namespace WebCore
545267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
555267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)// In ScriptWrappable::init, the use of a local function declaration has an issue on Windows:
565267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)// the local declaration does not pick up the surrounding namespace. Therefore, we provide this function
575267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)// in the global namespace.
585267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)// (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/feedback/details/664619/the-namespace-of-local-function-declarations-in-c)
595267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)void webCoreInitializeScriptWrappableForInterface(WebCore::TestTypedefs* object)
605267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles){
615267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    WebCore::initializeScriptWrappableForInterface(object);
625267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)}
635267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
6453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)namespace WebCore {
65926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)WrapperTypeInfo V8TestTypedefs::info = { V8TestTypedefs::GetTemplate, V8TestTypedefs::derefObject, 0, 0, 0, V8TestTypedefs::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
66926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
67926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)namespace TestTypedefsV8Internal {
68926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
69926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)template <typename T> void V8_USE(T) { }
70926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
715267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void unsignedLongLongAttrAttrGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
72926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
73926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder());
745267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    v8SetReturnValue(info, static_cast<double>(imp->unsignedLongLongAttr()));
755267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    return;
76926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
77926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
785267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void unsignedLongLongAttrAttrGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
79926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
80e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
815267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    TestTypedefsV8Internal::unsignedLongLongAttrAttrGetter(name, info);
82e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
83926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
84926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
855267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void unsignedLongLongAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
86926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
87926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder());
8853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    V8TRYCATCH_VOID(unsigned long long, v, toUInt64(value));
89926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    imp->setUnsignedLongLongAttr(v);
90926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    return;
91926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
92926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
935267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void unsignedLongLongAttrAttrSetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
94926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
95e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
96926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefsV8Internal::unsignedLongLongAttrAttrSetter(name, value, info);
97e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
98926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
99926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
1005267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void immutableSerializedScriptValueAttrGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
101926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
102926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder());
103591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    v8SetReturnValue(info, imp->immutableSerializedScriptValue() ? imp->immutableSerializedScriptValue()->deserialize() : v8::Handle<v8::Value>(v8::Null(info.GetIsolate())));
1045267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    return;
105926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
106926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
1075267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void immutableSerializedScriptValueAttrGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
108926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
109e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
1105267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    TestTypedefsV8Internal::immutableSerializedScriptValueAttrGetter(name, info);
111e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
112926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
113926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
1145267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void immutableSerializedScriptValueAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
115926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
116926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder());
11753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    V8TRYCATCH_VOID(RefPtr<SerializedScriptValue>, v, SerializedScriptValue::create(value, info.GetIsolate()));
118926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    imp->setImmutableSerializedScriptValue(WTF::getPtr(v));
119926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    return;
120926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
121926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
1225267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void immutableSerializedScriptValueAttrSetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
123926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
124e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
125926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefsV8Internal::immutableSerializedScriptValueAttrSetter(name, value, info);
126e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
127926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
128926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
1295267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void attrWithGetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
130926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
131926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder());
132e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    ExceptionState es(info.GetIsolate());
133e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    int v = imp->attrWithGetterException(es);
134e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    if (UNLIKELY(es.throwIfNeeded()))
1355267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        return;
1365267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    v8SetReturnValueInt(info, v);
1375267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    return;
138926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
139926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
1405267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void attrWithGetterExceptionAttrGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
141926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
142e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
1435267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    TestTypedefsV8Internal::attrWithGetterExceptionAttrGetter(name, info);
144e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
145926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
146926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
1475267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void attrWithGetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
148926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
149926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder());
15053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    V8TRYCATCH_VOID(int, v, toInt32(value));
151926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    imp->setAttrWithGetterException(v);
152926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    return;
153926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
154926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
1555267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void attrWithGetterExceptionAttrSetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
156926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
157e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
158926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefsV8Internal::attrWithGetterExceptionAttrSetter(name, value, info);
159e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
160926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
161926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
1625267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void attrWithSetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
163926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
164926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder());
1655267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    v8SetReturnValueInt(info, imp->attrWithSetterException());
1665267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    return;
167926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
168926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
1695267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void attrWithSetterExceptionAttrGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
170926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
171e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
1725267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    TestTypedefsV8Internal::attrWithSetterExceptionAttrGetter(name, info);
173e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
174926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
175926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
1765267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void attrWithSetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
177926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
178926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder());
17953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    V8TRYCATCH_VOID(int, v, toInt32(value));
180e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    ExceptionState es(info.GetIsolate());
181e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    imp->setAttrWithSetterException(v, es);
182e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    es.throwIfNeeded();
183926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    return;
184926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
185926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
1865267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void attrWithSetterExceptionAttrSetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
187926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
188e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
189926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefsV8Internal::attrWithSetterExceptionAttrSetter(name, value, info);
190e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
191926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
192926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
1935267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void stringAttrWithGetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
194926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
195926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder());
196e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    ExceptionState es(info.GetIsolate());
197e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    String v = imp->stringAttrWithGetterException(es);
198e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    if (UNLIKELY(es.throwIfNeeded()))
1995267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        return;
2003464d02a173573db42f8ee6bb07bb74fabf4f5f2Ben Murdoch    v8SetReturnValueString(info, v, info.GetIsolate());
2015267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    return;
202926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
203926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
2045267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void stringAttrWithGetterExceptionAttrGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
205926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
206e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
2075267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    TestTypedefsV8Internal::stringAttrWithGetterExceptionAttrGetter(name, info);
208e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
209926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
210926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
2115267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void stringAttrWithGetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
212926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
213926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder());
214926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, v, value);
215926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    imp->setStringAttrWithGetterException(v);
216926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    return;
217926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
218926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
2195267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void stringAttrWithGetterExceptionAttrSetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
220926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
221e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
222926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefsV8Internal::stringAttrWithGetterExceptionAttrSetter(name, value, info);
223e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
224926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
225926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
2265267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void stringAttrWithSetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
227926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
228926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder());
2293464d02a173573db42f8ee6bb07bb74fabf4f5f2Ben Murdoch    v8SetReturnValueString(info, imp->stringAttrWithSetterException(), info.GetIsolate());
2305267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    return;
231926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
232926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
2335267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void stringAttrWithSetterExceptionAttrGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
234926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
235e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
2365267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    TestTypedefsV8Internal::stringAttrWithSetterExceptionAttrGetter(name, info);
237e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
238926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
239926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
2405267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void stringAttrWithSetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
241926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
242926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(info.Holder());
243926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, v, value);
244e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    ExceptionState es(info.GetIsolate());
245e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    imp->setStringAttrWithSetterException(v, es);
246e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    es.throwIfNeeded();
247926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    return;
248926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
249926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
2505267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void stringAttrWithSetterExceptionAttrSetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
251926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
252e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
253926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefsV8Internal::stringAttrWithSetterExceptionAttrSetter(name, value, info);
254e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
255926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
256926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
2575267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void TestTypedefsConstructorGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
258926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
259926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    v8::Handle<v8::Value> data = info.Data();
260926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    ASSERT(data->IsExternal());
261926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext());
262926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    if (!perContextData)
2635267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        return;
2645267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::unwrap(data)));
265926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
2665267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void TestTypedefsReplaceableAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
267926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
268926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    info.This()->ForceSet(name, value);
269926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
270926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
2715267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void TestTypedefsReplaceableAttrSetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
272926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
2735267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    TestTypedefsV8Internal::TestTypedefsReplaceableAttrSetter(name, value, info);
274926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
275926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
2765267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void funcMethod(const v8::FunctionCallbackInfo<v8::Value>& args)
277926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
278926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(args.Holder());
279926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    if (args.Length() <= 0) {
280926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        imp->func();
2815267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
2825267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        return;
283926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    }
28402772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch    V8TRYCATCH_VOID(Vector<int>, x, toNativeArray<int>(args[0], args.GetIsolate()));
285926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    imp->func(x);
2865267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
2875267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    return;
288926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
289926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
2905267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void funcMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
291926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
292e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
2935267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    TestTypedefsV8Internal::funcMethod(args);
294e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
295926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
296926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
2975267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void setShadowMethod(const v8::FunctionCallbackInfo<v8::Value>& args)
298926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
2995267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    if (args.Length() < 3) {
3005267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        throwNotEnoughArgumentsError(args.GetIsolate());
3015267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        return;
3025267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    }
303926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(args.Holder());
3045267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    V8TRYCATCH_VOID(float, width, static_cast<float>(args[0]->NumberValue()));
3055267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    V8TRYCATCH_VOID(float, height, static_cast<float>(args[1]->NumberValue()));
3065267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    V8TRYCATCH_VOID(float, blur, static_cast<float>(args[2]->NumberValue()));
307926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    if (args.Length() <= 3) {
308926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        imp->setShadow(width, height, blur);
3095267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
3105267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        return;
311926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    }
3125267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, color, args[3]);
313926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    if (args.Length() <= 4) {
314926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        imp->setShadow(width, height, blur, color);
3155267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
3165267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        return;
317926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    }
3185267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    V8TRYCATCH_VOID(float, alpha, static_cast<float>(args[4]->NumberValue()));
319926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    imp->setShadow(width, height, blur, color, alpha);
3205267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
3215267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    return;
322926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
323926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
3245267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void setShadowMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
325926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
326e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
3275267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    TestTypedefsV8Internal::setShadowMethod(args);
328e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
329926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
330926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
3315267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void methodWithSequenceArgMethod(const v8::FunctionCallbackInfo<v8::Value>& args)
332926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
3335267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    if (args.Length() < 1) {
3345267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        throwNotEnoughArgumentsError(args.GetIsolate());
3355267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        return;
3365267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    }
337926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(args.Holder());
3385267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    V8TRYCATCH_VOID(Vector<RefPtr<SerializedScriptValue> >, sequenceArg, (toRefPtrNativeArray<SerializedScriptValue, V8SerializedScriptValue>(args[0], args.GetIsolate())));
3395267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    v8SetReturnValue(args, static_cast<double>(imp->methodWithSequenceArg(sequenceArg)));
3405267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    return;
341926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
342926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
3435267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void methodWithSequenceArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
344926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
345e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
3465267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    TestTypedefsV8Internal::methodWithSequenceArgMethod(args);
347e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
348926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
349926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
3505267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void nullableArrayArgMethod(const v8::FunctionCallbackInfo<v8::Value>& args)
351926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
3525267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    if (args.Length() < 1) {
3535267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        throwNotEnoughArgumentsError(args.GetIsolate());
3545267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        return;
3555267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    }
356926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(args.Holder());
35702772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch    V8TRYCATCH_VOID(Vector<String>, arrayArg, toNativeArray<String>(args[0], args.GetIsolate()));
358926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    imp->nullableArrayArg(arrayArg);
3595267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
3605267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    return;
361926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
362926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
3635267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void nullableArrayArgMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
364926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
365e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
3665267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    TestTypedefsV8Internal::nullableArrayArgMethod(args);
367e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
368926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
369926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
3705267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void funcWithClampMethod(const v8::FunctionCallbackInfo<v8::Value>& args)
371926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
3725267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    if (args.Length() < 1) {
3735267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        throwNotEnoughArgumentsError(args.GetIsolate());
3745267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        return;
3755267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    }
376926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(args.Holder());
377926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    unsigned long long arg1 = 0;
3785267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    V8TRYCATCH_VOID(double, arg1NativeValue, args[0]->NumberValue());
379926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    if (!std::isnan(arg1NativeValue))
380926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        arg1 = clampTo<unsigned long long>(arg1NativeValue);
381926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    if (args.Length() <= 1) {
382926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        imp->funcWithClamp(arg1);
3835267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
3845267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        return;
385926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    }
386926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    unsigned long long arg2 = 0;
3875267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    V8TRYCATCH_VOID(double, arg2NativeValue, args[1]->NumberValue());
388926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    if (!std::isnan(arg2NativeValue))
389926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        arg2 = clampTo<unsigned long long>(arg2NativeValue);
390926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    imp->funcWithClamp(arg1, arg2);
3915267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
3925267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    return;
393926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
394926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
3955267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void funcWithClampMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
396926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
397e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
3985267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    TestTypedefsV8Internal::funcWithClampMethod(args);
399e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
400926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
401926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
4025267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void immutablePointFunctionMethod(const v8::FunctionCallbackInfo<v8::Value>& args)
403926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
404926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(args.Holder());
405e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    v8SetReturnValue(args, toV8(WTF::getPtr(SVGPropertyTearOff<SVGPoint>::create(imp->immutablePointFunction())), args.Holder(), args.GetIsolate()));
4065267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    return;
407926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
408926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
4095267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void immutablePointFunctionMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
410926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
411e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
4125267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    TestTypedefsV8Internal::immutablePointFunctionMethod(args);
413e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
414926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
415926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
4165267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void stringArrayFunctionMethod(const v8::FunctionCallbackInfo<v8::Value>& args)
417926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
4185267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    if (args.Length() < 1) {
4195267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        throwNotEnoughArgumentsError(args.GetIsolate());
4205267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        return;
4215267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    }
422926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(args.Holder());
423e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    ExceptionState es(args.GetIsolate());
42402772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch    V8TRYCATCH_VOID(Vector<String>, values, toNativeArray<String>(args[0], args.GetIsolate()));
425e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    Vector<String> result = imp->stringArrayFunction(values, es);
426e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    if (es.throwIfNeeded())
4275267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        return;
4285267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    v8SetReturnValue(args, v8Array(result, args.GetIsolate()));
4295267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    return;
430926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
431926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
4325267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void stringArrayFunctionMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
433926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
434e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
4355267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    TestTypedefsV8Internal::stringArrayFunctionMethod(args);
436e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
437926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
438926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
4395267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void stringArrayFunction2Method(const v8::FunctionCallbackInfo<v8::Value>& args)
440926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
4415267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    if (args.Length() < 1) {
4425267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        throwNotEnoughArgumentsError(args.GetIsolate());
4435267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        return;
4445267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    }
445926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(args.Holder());
446e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    ExceptionState es(args.GetIsolate());
44702772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch    V8TRYCATCH_VOID(Vector<String>, values, toNativeArray<String>(args[0], args.GetIsolate()));
448e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    Vector<String> result = imp->stringArrayFunction2(values, es);
449e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    if (es.throwIfNeeded())
4505267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        return;
4515267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    v8SetReturnValue(args, v8Array(result, args.GetIsolate()));
4525267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    return;
453926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
454926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
4555267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void stringArrayFunction2MethodCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
456926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
457e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
4585267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    TestTypedefsV8Internal::stringArrayFunction2Method(args);
459e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
460926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
461926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
4625267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void methodWithExceptionMethod(const v8::FunctionCallbackInfo<v8::Value>& args)
463926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
464926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    TestTypedefs* imp = V8TestTypedefs::toNative(args.Holder());
465e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    ExceptionState es(args.GetIsolate());
466e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    imp->methodWithException(es);
467e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    if (es.throwIfNeeded())
4685267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        return;
4695267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
4705267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    return;
471926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
472926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
4735267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static void methodWithExceptionMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
474926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
475e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
4765267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    TestTypedefsV8Internal::methodWithExceptionMethod(args);
477e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
478926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
479926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
48093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)static void constructor(const v8::FunctionCallbackInfo<v8::Value>& args)
481926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
48293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    if (args.Length() < 2) {
48393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        throwNotEnoughArgumentsError(args.GetIsolate());
48493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        return;
48593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    }
48693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, hello, args[0]);
48793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    if (args.Length() <= 1 || !args[1]->IsFunction()) {
4887757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch        throwTypeError(args.GetIsolate());
48993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        return;
49093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    }
491926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    RefPtr<TestCallback> testCallback = V8TestCallback::create(args[1], getScriptExecutionContext());
492926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
493926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    RefPtr<TestTypedefs> impl = TestTypedefs::create(hello, testCallback);
494926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    v8::Handle<v8::Object> wrapper = args.Holder();
495926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
496e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    V8DOMWrapper::associateObjectWithWrapper<V8TestTypedefs>(impl.release(), &V8TestTypedefs::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent);
49793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    args.GetReturnValue().Set(wrapper);
498926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
499926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
500926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)} // namespace TestTypedefsV8Internal
501926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
502926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)static const V8DOMConfiguration::BatchedAttribute V8TestTypedefsAttrs[] = {
503521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)    // Attribute 'unsignedLongLongAttr'
504926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    {"unsignedLongLongAttr", TestTypedefsV8Internal::unsignedLongLongAttrAttrGetterCallback, TestTypedefsV8Internal::unsignedLongLongAttrAttrSetterCallback, 0, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
505521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)    // Attribute 'immutableSerializedScriptValue'
506926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    {"immutableSerializedScriptValue", TestTypedefsV8Internal::immutableSerializedScriptValueAttrGetterCallback, TestTypedefsV8Internal::immutableSerializedScriptValueAttrSetterCallback, 0, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
507521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)    // Attribute 'TestSubObj'
50853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    {"TestSubObj", TestTypedefsV8Internal::TestTypedefsConstructorGetter, 0, 0, 0, &V8TestSubObj::info, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None | v8::DontEnum), 0 /* on instance */},
509521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)    // Attribute 'attrWithGetterException'
510926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    {"attrWithGetterException", TestTypedefsV8Internal::attrWithGetterExceptionAttrGetterCallback, TestTypedefsV8Internal::attrWithGetterExceptionAttrSetterCallback, 0, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
511521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)    // Attribute 'attrWithSetterException'
512926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    {"attrWithSetterException", TestTypedefsV8Internal::attrWithSetterExceptionAttrGetterCallback, TestTypedefsV8Internal::attrWithSetterExceptionAttrSetterCallback, 0, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
513521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)    // Attribute 'stringAttrWithGetterException'
514926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    {"stringAttrWithGetterException", TestTypedefsV8Internal::stringAttrWithGetterExceptionAttrGetterCallback, TestTypedefsV8Internal::stringAttrWithGetterExceptionAttrSetterCallback, 0, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
515521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)    // Attribute 'stringAttrWithSetterException'
516926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    {"stringAttrWithSetterException", TestTypedefsV8Internal::stringAttrWithSetterExceptionAttrGetterCallback, TestTypedefsV8Internal::stringAttrWithSetterExceptionAttrSetterCallback, 0, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
517926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)};
518926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
519926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)static const V8DOMConfiguration::BatchedMethod V8TestTypedefsMethods[] = {
52053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    {"func", TestTypedefsV8Internal::funcMethodCallback, 0, 0},
52153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    {"setShadow", TestTypedefsV8Internal::setShadowMethodCallback, 0, 3},
522e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    {"methodWithSequenceArg", TestTypedefsV8Internal::methodWithSequenceArgMethodCallback, 0, 1},
523e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    {"nullableArrayArg", TestTypedefsV8Internal::nullableArrayArgMethodCallback, 0, 1},
52453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    {"funcWithClamp", TestTypedefsV8Internal::funcWithClampMethodCallback, 0, 1},
52553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    {"immutablePointFunction", TestTypedefsV8Internal::immutablePointFunctionMethodCallback, 0, 0},
526e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    {"stringArrayFunction", TestTypedefsV8Internal::stringArrayFunctionMethodCallback, 0, 1},
527e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)    {"stringArrayFunction2", TestTypedefsV8Internal::stringArrayFunction2MethodCallback, 0, 1},
52853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    {"methodWithException", TestTypedefsV8Internal::methodWithExceptionMethodCallback, 0, 0},
529926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)};
530926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
53193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)void V8TestTypedefs::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
532926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
533e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor");
53493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    if (!args.IsConstructCall()) {
53593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
53693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        return;
53793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    }
538926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
53993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) {
54093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        args.GetReturnValue().Set(args.Holder());
54193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)        return;
54293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    }
543926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
54493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)    TestTypedefsV8Internal::constructor(args);
545926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
546926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
5475267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)static v8::Handle<v8::FunctionTemplate> ConfigureV8TestTypedefsTemplate(v8::Handle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWorldType)
548926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
549926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    desc->ReadOnlyPrototype();
550926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
551926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    v8::Local<v8::Signature> defaultSignature;
5525267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    defaultSignature = V8DOMConfiguration::configureTemplate(desc, "TestTypedefs", v8::Local<v8::FunctionTemplate>(), V8TestTypedefs::internalFieldCount,
553926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        V8TestTypedefsAttrs, WTF_ARRAY_LENGTH(V8TestTypedefsAttrs),
554926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        V8TestTypedefsMethods, WTF_ARRAY_LENGTH(V8TestTypedefsMethods), isolate, currentWorldType);
555926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
556926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    desc->SetCallHandler(V8TestTypedefs::constructorCallback);
55753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)    desc->SetLength(2);
558926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
559926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
560926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    UNUSED_PARAM(instance); // In some cases, it will not be used.
561926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    UNUSED_PARAM(proto); // In some cases, it will not be used.
562926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
563926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    // Custom toString template
564926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
565926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    return desc;
566926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
567926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
5685267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)v8::Handle<v8::FunctionTemplate> V8TestTypedefs::GetTemplate(v8::Isolate* isolate, WrapperWorldType currentWorldType)
569926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
570926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    V8PerIsolateData* data = V8PerIsolateData::from(isolate);
571926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWorldType).find(&info);
572926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    if (result != data->templateMap(currentWorldType).end())
5735267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)        return result->value.newLocal(isolate);
574926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
575e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
5765267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    v8::HandleScope handleScope(isolate);
5775267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    v8::Handle<v8::FunctionTemplate> templ =
578926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        ConfigureV8TestTypedefsTemplate(data->rawTemplate(&info, currentWorldType), isolate, currentWorldType);
5795267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    data->templateMap(currentWorldType).add(&info, UnsafePersistent<v8::FunctionTemplate>(isolate, templ));
5805267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    return handleScope.Close(templ);
581926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
582926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
583926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)bool V8TestTypedefs::HasInstance(v8::Handle<v8::Value> value, v8::Isolate* isolate, WrapperWorldType currentWorldType)
584926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
585926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWorldType);
586926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
587926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
588926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)bool V8TestTypedefs::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::Isolate* isolate)
589926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
590926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld)
591926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWorld)
592926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorld);
593926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
594926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
595926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
596926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)v8::Handle<v8::Object> V8TestTypedefs::createWrapper(PassRefPtr<TestTypedefs> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
597926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
598926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    ASSERT(impl.get());
599e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    ASSERT(DOMDataStore::getWrapper<V8TestTypedefs>(impl.get(), isolate).IsEmpty());
6007757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch    if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
6017757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch        const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObject(impl.get());
6027757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch        // Might be a XXXConstructor::info instead of an XXX::info. These will both have
6037757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch        // the same object de-ref functions, though, so use that as the basis of the check.
6047757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == info.derefObjectFunction);
6057757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch    }
6067757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch
607926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
608e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &info, toInternalPointer(impl.get()), isolate);
609926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    if (UNLIKELY(wrapper.IsEmpty()))
610926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)        return wrapper;
611926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    installPerContextProperties(wrapper, impl.get(), isolate);
612e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    V8DOMWrapper::associateObjectWithWrapper<V8TestTypedefs>(impl, &info, wrapper, isolate, WrapperConfiguration::Independent);
613926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)    return wrapper;
614926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
615926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)void V8TestTypedefs::derefObject(void* object)
616926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles){
617e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    fromInternalPointer(object)->deref();
618926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}
619926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)
620926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)} // namespace WebCore
621