2 This file is part of the WebKit open source project.
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
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.
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.
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.
22 #include "V8TestOverloadedConstructors.h"
24 #include "BindingState.h"
25 #include "ContextFeatures.h"
26 #include "ExceptionCode.h"
28 #include "RuntimeEnabledFeatures.h"
29 #include "V8ArrayBuffer.h"
30 #include "V8ArrayBufferView.h"
31 #include "V8Binding.h"
33 #include "V8DOMWrapper.h"
34 #include <wtf/ArrayBuffer.h>
35 #include <wtf/ArrayBufferView.h>
36 #include <wtf/UnusedParam.h>
38 #if ENABLE(BINDING_INTEGRITY)
40 #pragma warning(disable: 4483)
41 extern "C" { extern void (*const __identifier("??_7TestOverloadedConstructors@WebCore@@6B@")[])(); }
43 extern "C" { extern void* _ZTVN7WebCore26TestOverloadedConstructorsE[]; }
45 #endif // ENABLE(BINDING_INTEGRITY)
49 #if ENABLE(BINDING_INTEGRITY)
50 inline void checkTypeOrDieTrying(TestOverloadedConstructors* object)
52 void* actualVTablePointer = *(reinterpret_cast<void**>(object));
54 void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestOverloadedConstructors@WebCore@@6B@"));
56 void* expectedVTablePointer = &_ZTVN7WebCore26TestOverloadedConstructorsE[2];
58 if (actualVTablePointer != expectedVTablePointer)
61 #endif // ENABLE(BINDING_INTEGRITY)
63 WrapperTypeInfo V8TestOverloadedConstructors::info = { V8TestOverloadedConstructors::GetTemplate, V8TestOverloadedConstructors::derefObject, 0, 0, 0, V8TestOverloadedConstructors::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
65 namespace TestOverloadedConstructorsV8Internal {
67 template <typename T> void V8_USE(T) { }
69 } // namespace TestOverloadedConstructorsV8Internal
71 v8::Handle<v8::Value> V8TestOverloadedConstructors::constructor1Callback(const v8::Arguments& args)
74 V8TRYCATCH(ArrayBuffer*, arrayBuffer, V8ArrayBuffer::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined), args.GetIsolate()) ? V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0);
76 RefPtr<TestOverloadedConstructors> impl = TestOverloadedConstructors::create(arrayBuffer);
77 v8::Handle<v8::Object> wrapper = args.Holder();
79 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent);
83 v8::Handle<v8::Value> V8TestOverloadedConstructors::constructor2Callback(const v8::Arguments& args)
86 V8TRYCATCH(ArrayBufferView*, arrayBufferView, V8ArrayBufferView::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined), args.GetIsolate()) ? V8ArrayBufferView::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0);
88 RefPtr<TestOverloadedConstructors> impl = TestOverloadedConstructors::create(arrayBufferView);
89 v8::Handle<v8::Object> wrapper = args.Holder();
91 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent);
95 v8::Handle<v8::Value> V8TestOverloadedConstructors::constructor3Callback(const v8::Arguments& args)
98 V8TRYCATCH(Blob*, blob, V8Blob::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined), args.GetIsolate()) ? V8Blob::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0);
100 RefPtr<TestOverloadedConstructors> impl = TestOverloadedConstructors::create(blob);
101 v8::Handle<v8::Object> wrapper = args.Holder();
103 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent);
107 v8::Handle<v8::Value> V8TestOverloadedConstructors::constructor4Callback(const v8::Arguments& args)
110 V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, string, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined));
112 RefPtr<TestOverloadedConstructors> impl = TestOverloadedConstructors::create(string);
113 v8::Handle<v8::Object> wrapper = args.Holder();
115 V8DOMWrapper::associateObjectWithWrapper(impl.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent);
119 v8::Handle<v8::Value> V8TestOverloadedConstructors::constructorCallback(const v8::Arguments& args)
121 if (!args.IsConstructCall())
122 return throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
124 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
125 return args.Holder();
126 if ((args.Length() == 1 && (V8ArrayBuffer::HasInstance(args[0], args.GetIsolate()))))
127 return constructor1Callback(args);
128 if ((args.Length() == 1 && (V8ArrayBufferView::HasInstance(args[0], args.GetIsolate()))))
129 return constructor2Callback(args);
130 if ((args.Length() == 1 && (V8Blob::HasInstance(args[0], args.GetIsolate()))))
131 return constructor3Callback(args);
132 if (args.Length() == 1)
133 return constructor4Callback(args);
134 if (args.Length() < 1)
135 return throwNotEnoughArgumentsError(args.GetIsolate());
136 return throwTypeError(0, args.GetIsolate());
139 static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestOverloadedConstructorsTemplate(v8::Persistent<v8::FunctionTemplate> desc, v8::Isolate* isolate)
141 desc->ReadOnlyPrototype();
143 v8::Local<v8::Signature> defaultSignature;
144 defaultSignature = V8DOMConfiguration::configureTemplate(desc, "TestOverloadedConstructors", v8::Persistent<v8::FunctionTemplate>(), V8TestOverloadedConstructors::internalFieldCount,
147 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
148 desc->SetCallHandler(V8TestOverloadedConstructors::constructorCallback);
151 // Custom toString template
152 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
156 v8::Persistent<v8::FunctionTemplate> V8TestOverloadedConstructors::GetRawTemplate(v8::Isolate* isolate)
158 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
159 V8PerIsolateData::TemplateMap::iterator result = data->rawTemplateMap().find(&info);
160 if (result != data->rawTemplateMap().end())
161 return result->value;
163 v8::HandleScope handleScope;
164 v8::Persistent<v8::FunctionTemplate> templ = createRawTemplate();
165 data->rawTemplateMap().add(&info, templ);
169 v8::Persistent<v8::FunctionTemplate> V8TestOverloadedConstructors::GetTemplate(v8::Isolate* isolate)
171 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
172 V8PerIsolateData::TemplateMap::iterator result = data->templateMap().find(&info);
173 if (result != data->templateMap().end())
174 return result->value;
176 v8::HandleScope handleScope;
177 v8::Persistent<v8::FunctionTemplate> templ =
178 ConfigureV8TestOverloadedConstructorsTemplate(GetRawTemplate(isolate), isolate);
179 data->templateMap().add(&info, templ);
183 bool V8TestOverloadedConstructors::HasInstance(v8::Handle<v8::Value> value, v8::Isolate* isolate)
185 return GetRawTemplate(isolate)->HasInstance(value);
189 v8::Handle<v8::Object> V8TestOverloadedConstructors::createWrapper(PassRefPtr<TestOverloadedConstructors> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
192 ASSERT(DOMDataStore::getWrapper(impl.get(), isolate).IsEmpty());
194 #if ENABLE(BINDING_INTEGRITY)
195 checkTypeOrDieTrying(impl.get());
198 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &info, impl.get(), isolate);
199 if (UNLIKELY(wrapper.IsEmpty()))
202 installPerContextProperties(wrapper, impl.get(), isolate);
203 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasDependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Independent);
206 void V8TestOverloadedConstructors::derefObject(void* object)
208 static_cast<TestOverloadedConstructors*>(object)->deref();
211 } // namespace WebCore