2 * Copyright (C) 2013 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 // This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY!
34 #include "V8TestInterfaceEventConstructor.h"
36 #include "RuntimeEnabledFeatures.h"
37 #include "V8TestInterfaceEmpty.h"
38 #include "bindings/v8/Dictionary.h"
39 #include "bindings/v8/ExceptionState.h"
40 #include "bindings/v8/ScriptValue.h"
41 #include "bindings/v8/SerializedScriptValue.h"
42 #include "bindings/v8/V8DOMConfiguration.h"
43 #include "bindings/v8/V8ObjectConstructor.h"
44 #include "bindings/v8/custom/V8Uint8ArrayCustom.h"
45 #include "core/dom/ContextFeatures.h"
46 #include "core/dom/Document.h"
47 #include "core/frame/UseCounter.h"
48 #include "platform/TraceEvent.h"
49 #include "wtf/GetPtr.h"
50 #include "wtf/RefPtr.h"
54 static void initializeScriptWrappableForInterface(TestInterfaceEventConstructor* object)
56 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
57 ScriptWrappable::setTypeInfoInObject(object, &V8TestInterfaceEventConstructor::wrapperTypeInfo);
62 } // namespace WebCore
64 // In ScriptWrappable::init, the use of a local function declaration has an issue on Windows:
65 // the local declaration does not pick up the surrounding namespace. Therefore, we provide this function
66 // in the global namespace.
67 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/feedback/details/664619/the-namespace-of-local-function-declarations-in-c)
68 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfaceEventConstructor* object)
70 WebCore::initializeScriptWrappableForInterface(object);
74 const WrapperTypeInfo V8TestInterfaceEventConstructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceEventConstructor::domTemplate, V8TestInterfaceEventConstructor::derefObject, 0, 0, 0, V8TestInterfaceEventConstructor::installPerContextEnabledMethods, &V8Event::wrapperTypeInfo, WrapperTypeObjectPrototype, false };
76 namespace TestInterfaceEventConstructorV8Internal {
78 template <typename T> void V8_USE(T) { }
80 static void readonlyStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
82 TestInterfaceEventConstructor* imp = V8TestInterfaceEventConstructor::toNative(info.Holder());
83 v8SetReturnValueString(info, imp->readonlyStringAttribute(), info.GetIsolate());
86 static void readonlyStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
88 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
89 TestInterfaceEventConstructorV8Internal::readonlyStringAttributeAttributeGetter(info);
90 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
93 static void initializedByEventConstructorReadonlyStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
95 TestInterfaceEventConstructor* imp = V8TestInterfaceEventConstructor::toNative(info.Holder());
96 v8SetReturnValueString(info, imp->initializedByEventConstructorReadonlyStringAttribute(), info.GetIsolate());
99 static void initializedByEventConstructorReadonlyStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
101 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
102 TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyStringAttributeAttributeGetter(info);
103 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
106 static void initializedByEventConstructorReadonlyAnyAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
108 TestInterfaceEventConstructor* imp = V8TestInterfaceEventConstructor::toNative(info.Holder());
109 v8SetReturnValue(info, imp->initializedByEventConstructorReadonlyAnyAttribute().v8Value());
112 static void initializedByEventConstructorReadonlyAnyAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
114 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
115 TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyAnyAttributeAttributeGetter(info);
116 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
119 static void initializedByEventConstructorReadonlyBooleanAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
121 TestInterfaceEventConstructor* imp = V8TestInterfaceEventConstructor::toNative(info.Holder());
122 v8SetReturnValueBool(info, imp->initializedByEventConstructorReadonlyBooleanAttribute());
125 static void initializedByEventConstructorReadonlyBooleanAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
127 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
128 TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyBooleanAttributeAttributeGetter(info);
129 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
132 static void initializedByEventConstructorReadonlyLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
134 TestInterfaceEventConstructor* imp = V8TestInterfaceEventConstructor::toNative(info.Holder());
135 v8SetReturnValueInt(info, imp->initializedByEventConstructorReadonlyLongAttribute());
138 static void initializedByEventConstructorReadonlyLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
140 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
141 TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyLongAttributeAttributeGetter(info);
142 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
145 static void initializedByEventConstructorReadonlyUint8ArrayAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
147 TestInterfaceEventConstructor* imp = V8TestInterfaceEventConstructor::toNative(info.Holder());
148 RefPtr<Uint8Array> result = imp->initializedByEventConstructorReadonlyUint8ArrayAttribute();
149 if (result && DOMDataStore::setReturnValueFromWrapper<V8Uint8Array>(info.GetReturnValue(), result.get()))
151 v8::Handle<v8::Value> wrapper = toV8(result.get(), info.Holder(), info.GetIsolate());
152 if (!wrapper.IsEmpty()) {
153 setHiddenValue(info.GetIsolate(), info.Holder(), "initializedByEventConstructorReadonlyUint8ArrayAttribute", wrapper);
154 v8SetReturnValue(info, wrapper);
158 static void initializedByEventConstructorReadonlyUint8ArrayAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
160 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
161 TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyUint8ArrayAttributeAttributeGetter(info);
162 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
165 static void initializedByEventConstructorReadonlyTestInterfaceEmptyAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
167 TestInterfaceEventConstructor* imp = V8TestInterfaceEventConstructor::toNative(info.Holder());
168 RefPtr<TestInterfaceEmpty> result = imp->initializedByEventConstructorReadonlyTestInterfaceEmptyAttribute();
169 if (result && DOMDataStore::setReturnValueFromWrapper<V8TestInterfaceEmpty>(info.GetReturnValue(), result.get()))
171 v8::Handle<v8::Value> wrapper = toV8(result.get(), info.Holder(), info.GetIsolate());
172 if (!wrapper.IsEmpty()) {
173 setHiddenValue(info.GetIsolate(), info.Holder(), "initializedByEventConstructorReadonlyTestInterfaceEmptyAttribute", wrapper);
174 v8SetReturnValue(info, wrapper);
178 static void initializedByEventConstructorReadonlyTestInterfaceEmptyAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
180 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
181 TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyTestInterfaceEmptyAttributeAttributeGetter(info);
182 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
185 static void initializedByEventConstructorReadonlyTestInterfaceEmptyArrayAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
187 TestInterfaceEventConstructor* imp = V8TestInterfaceEventConstructor::toNative(info.Holder());
188 v8SetReturnValue(info, v8Array(imp->initializedByEventConstructorReadonlyTestInterfaceEmptyArrayAttribute(), info.GetIsolate()));
191 static void initializedByEventConstructorReadonlyTestInterfaceEmptyArrayAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
193 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
194 TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyTestInterfaceEmptyArrayAttributeAttributeGetter(info);
195 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
198 static void initializedByEventConstructorReadonlyNullableTestInterfaceEmptyAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
200 TestInterfaceEventConstructor* imp = V8TestInterfaceEventConstructor::toNative(info.Holder());
202 RefPtr<TestInterfaceEmpty> jsValue = imp->initializedByEventConstructorReadonlyNullableTestInterfaceEmptyAttribute(isNull);
204 v8SetReturnValueNull(info);
207 RefPtr<TestInterfaceEmpty> result = jsValue;
208 if (result && DOMDataStore::setReturnValueFromWrapper<V8TestInterfaceEmpty>(info.GetReturnValue(), result.get()))
210 v8::Handle<v8::Value> wrapper = toV8(result.get(), info.Holder(), info.GetIsolate());
211 if (!wrapper.IsEmpty()) {
212 setHiddenValue(info.GetIsolate(), info.Holder(), "initializedByEventConstructorReadonlyNullableTestInterfaceEmptyAttribute", wrapper);
213 v8SetReturnValue(info, wrapper);
217 static void initializedByEventConstructorReadonlyNullableTestInterfaceEmptyAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
219 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
220 TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyNullableTestInterfaceEmptyAttributeAttributeGetter(info);
221 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
224 static void deprecatedInitializedByEventConstructorReadonlyStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
226 TestInterfaceEventConstructor* imp = V8TestInterfaceEventConstructor::toNative(info.Holder());
227 v8SetReturnValueString(info, imp->deprecatedInitializedByEventConstructorReadonlyStringAttribute(), info.GetIsolate());
230 static void deprecatedInitializedByEventConstructorReadonlyStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
232 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
233 UseCounter::countDeprecation(activeExecutionContext(info.GetIsolate()), UseCounter::initializedByEventConstructorReadonlyStringAttribute);
234 TestInterfaceEventConstructorV8Internal::deprecatedInitializedByEventConstructorReadonlyStringAttributeAttributeGetter(info);
235 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
238 static void implementedAsInitializedByEventConstructorReadonlyStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
240 TestInterfaceEventConstructor* imp = V8TestInterfaceEventConstructor::toNative(info.Holder());
241 v8SetReturnValueString(info, imp->implementedAsName(), info.GetIsolate());
244 static void implementedAsInitializedByEventConstructorReadonlyStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
246 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
247 TestInterfaceEventConstructorV8Internal::implementedAsInitializedByEventConstructorReadonlyStringAttributeAttributeGetter(info);
248 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
251 static void deprecatedImplementedAsInitializedByEventConstructorReadonlyStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
253 TestInterfaceEventConstructor* imp = V8TestInterfaceEventConstructor::toNative(info.Holder());
254 v8SetReturnValueString(info, imp->deprecatedImplementedAsName(), info.GetIsolate());
257 static void deprecatedImplementedAsInitializedByEventConstructorReadonlyStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
259 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
260 UseCounter::countDeprecation(activeExecutionContext(info.GetIsolate()), UseCounter::initializedByEventConstructorReadonlyStringAttribute);
261 TestInterfaceEventConstructorV8Internal::deprecatedImplementedAsInitializedByEventConstructorReadonlyStringAttributeAttributeGetter(info);
262 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
265 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
267 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceEventConstructor", info.Holder(), info.GetIsolate());
268 if (info.Length() < 1) {
269 exceptionState.throwTypeError("An event name must be provided.");
270 exceptionState.throwIfNeeded();
274 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, info[0]);
275 v8::Local<v8::Value> initializedByEventConstructorReadonlyAnyAttribute;
276 TestInterfaceEventConstructorInit eventInit;
277 if (info.Length() >= 2) {
278 V8TRYCATCH_VOID(Dictionary, options, Dictionary(info[1], info.GetIsolate()));
279 if (!initializeTestInterfaceEventConstructor(eventInit, options, exceptionState, info)) {
280 exceptionState.throwIfNeeded();
283 options.get("initializedByEventConstructorReadonlyAnyAttribute", initializedByEventConstructorReadonlyAnyAttribute);
284 if (!initializedByEventConstructorReadonlyAnyAttribute.IsEmpty())
285 setHiddenValue(info.GetIsolate(), info.Holder(), "initializedByEventConstructorReadonlyAnyAttribute", initializedByEventConstructorReadonlyAnyAttribute);
287 RefPtr<TestInterfaceEventConstructor> event = TestInterfaceEventConstructor::create(type, eventInit, exceptionState);
288 if (exceptionState.throwIfNeeded())
290 if (DOMWrapperWorld::current(info.GetIsolate())->isIsolatedWorld()) {
291 if (!initializedByEventConstructorReadonlyAnyAttribute.IsEmpty())
292 event->setSerializedInitializedByEventConstructorReadonlyAnyAttribute(SerializedScriptValue::createAndSwallowExceptions(initializedByEventConstructorReadonlyAnyAttribute, info.GetIsolate()));
295 v8::Handle<v8::Object> wrapper = info.Holder();
296 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceEventConstructor>(event.release(), &V8TestInterfaceEventConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent);
297 v8SetReturnValue(info, wrapper);
300 } // namespace TestInterfaceEventConstructorV8Internal
302 static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceEventConstructorAttributes[] = {
303 {"readonlyStringAttribute", TestInterfaceEventConstructorV8Internal::readonlyStringAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
304 {"initializedByEventConstructorReadonlyStringAttribute", TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyStringAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
305 {"initializedByEventConstructorReadonlyAnyAttribute", TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyAnyAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
306 {"initializedByEventConstructorReadonlyBooleanAttribute", TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyBooleanAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
307 {"initializedByEventConstructorReadonlyLongAttribute", TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyLongAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
308 {"initializedByEventConstructorReadonlyUint8ArrayAttribute", TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyUint8ArrayAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
309 {"initializedByEventConstructorReadonlyTestInterfaceEmptyAttribute", TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyTestInterfaceEmptyAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
310 {"initializedByEventConstructorReadonlyTestInterfaceEmptyArrayAttribute", TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyTestInterfaceEmptyArrayAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
311 {"initializedByEventConstructorReadonlyNullableTestInterfaceEmptyAttribute", TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyNullableTestInterfaceEmptyAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
312 {"deprecatedInitializedByEventConstructorReadonlyStringAttribute", TestInterfaceEventConstructorV8Internal::deprecatedInitializedByEventConstructorReadonlyStringAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
313 {"implementedAsInitializedByEventConstructorReadonlyStringAttribute", TestInterfaceEventConstructorV8Internal::implementedAsInitializedByEventConstructorReadonlyStringAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
314 {"deprecatedImplementedAsInitializedByEventConstructorReadonlyStringAttribute", TestInterfaceEventConstructorV8Internal::deprecatedImplementedAsInitializedByEventConstructorReadonlyStringAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
317 bool initializeTestInterfaceEventConstructor(TestInterfaceEventConstructorInit& eventInit, const Dictionary& options, ExceptionState& exceptionState, const v8::FunctionCallbackInfo<v8::Value>& info, const String& forEventName)
319 Dictionary::ConversionContext conversionContext(forEventName.isEmpty() ? String("TestInterfaceEventConstructor") : forEventName, "", exceptionState);
320 if (!initializeEvent(eventInit, options, exceptionState, info, forEventName.isEmpty() ? String("TestInterfaceEventConstructor") : forEventName))
323 if (!options.convert(conversionContext.setConversionType("DOMString", false), "initializedByEventConstructorReadonlyStringAttribute", eventInit.initializedByEventConstructorReadonlyStringAttribute))
325 if (!options.convert(conversionContext.setConversionType("boolean", false), "initializedByEventConstructorReadonlyBooleanAttribute", eventInit.initializedByEventConstructorReadonlyBooleanAttribute))
327 if (!options.convert(conversionContext.setConversionType("long", false), "initializedByEventConstructorReadonlyLongAttribute", eventInit.initializedByEventConstructorReadonlyLongAttribute))
329 if (!options.convert(conversionContext.setConversionType("Uint8Array", false), "initializedByEventConstructorReadonlyUint8ArrayAttribute", eventInit.initializedByEventConstructorReadonlyUint8ArrayAttribute))
331 if (!options.convert(conversionContext.setConversionType("TestInterfaceEmpty", false), "initializedByEventConstructorReadonlyTestInterfaceEmptyAttribute", eventInit.initializedByEventConstructorReadonlyTestInterfaceEmptyAttribute))
333 if (!options.convert(conversionContext.setConversionType("TestInterfaceEmpty[]", false), "initializedByEventConstructorReadonlyTestInterfaceEmptyArrayAttribute", eventInit.initializedByEventConstructorReadonlyTestInterfaceEmptyArrayAttribute))
335 if (!options.convert(conversionContext.setConversionType("TestInterfaceEmpty", true), "initializedByEventConstructorReadonlyNullableTestInterfaceEmptyAttribute", eventInit.initializedByEventConstructorReadonlyNullableTestInterfaceEmptyAttribute))
337 if (options.convert(conversionContext.setConversionType("DOMString", false), "deprecatedInitializedByEventConstructorReadonlyStringAttribute", eventInit.deprecatedInitializedByEventConstructorReadonlyStringAttribute)) {
338 if (options.hasProperty("deprecatedInitializedByEventConstructorReadonlyStringAttribute"))
339 UseCounter::countDeprecation(activeExecutionContext(info.GetIsolate()), UseCounter::initializedByEventConstructorReadonlyStringAttribute);
343 if (!options.convert(conversionContext.setConversionType("DOMString", false), "implementedAsInitializedByEventConstructorReadonlyStringAttribute", eventInit.implementedAsName))
345 if (options.convert(conversionContext.setConversionType("DOMString", false), "deprecatedImplementedAsInitializedByEventConstructorReadonlyStringAttribute", eventInit.deprecatedImplementedAsName)) {
346 if (options.hasProperty("deprecatedImplementedAsInitializedByEventConstructorReadonlyStringAttribute"))
347 UseCounter::countDeprecation(activeExecutionContext(info.GetIsolate()), UseCounter::initializedByEventConstructorReadonlyStringAttribute);
354 void V8TestInterfaceEventConstructor::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
356 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor");
357 if (!info.IsConstructCall()) {
358 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceEventConstructor", "Please use the 'new' operator, this DOM object constructor cannot be called as a function."), info.GetIsolate());
362 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) {
363 v8SetReturnValue(info, info.Holder());
367 TestInterfaceEventConstructorV8Internal::constructor(info);
370 static void configureV8TestInterfaceEventConstructorTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWorldType currentWorldType)
372 functionTemplate->ReadOnlyPrototype();
374 v8::Local<v8::Signature> defaultSignature;
375 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceEventConstructor", V8Event::domTemplate(isolate, currentWorldType), V8TestInterfaceEventConstructor::internalFieldCount,
376 V8TestInterfaceEventConstructorAttributes, WTF_ARRAY_LENGTH(V8TestInterfaceEventConstructorAttributes),
379 isolate, currentWorldType);
380 functionTemplate->SetCallHandler(V8TestInterfaceEventConstructor::constructorCallback);
381 functionTemplate->SetLength(1);
382 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTemplate->InstanceTemplate();
383 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTemplate->PrototypeTemplate();
385 // Custom toString template
386 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::current()->toStringTemplate());
389 v8::Handle<v8::FunctionTemplate> V8TestInterfaceEventConstructor::domTemplate(v8::Isolate* isolate, WrapperWorldType currentWorldType)
391 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
392 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWorldType).find(&wrapperTypeInfo);
393 if (result != data->templateMap(currentWorldType).end())
394 return result->value.newLocal(isolate);
396 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
397 v8::EscapableHandleScope handleScope(isolate);
398 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidConstructorMode);
399 configureV8TestInterfaceEventConstructorTemplate(templ, isolate, currentWorldType);
400 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v8::FunctionTemplate>(isolate, templ));
401 return handleScope.Escape(templ);
404 bool V8TestInterfaceEventConstructor::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate)
406 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeInfo, jsValue)
407 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTypeInfo, jsValue);
410 v8::Handle<v8::Object> V8TestInterfaceEventConstructor::createWrapper(PassRefPtr<TestInterfaceEventConstructor> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
413 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceEventConstructor>(impl.get(), isolate));
414 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
415 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObject(impl.get());
416 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
417 // the same object de-ref functions, though, so use that as the basis of the check.
418 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
421 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
422 if (UNLIKELY(wrapper.IsEmpty()))
425 installPerContextEnabledProperties(wrapper, impl.get(), isolate);
426 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceEventConstructor>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
430 void V8TestInterfaceEventConstructor::derefObject(void* object)
432 fromInternalPointer(object)->deref();
436 v8::Handle<v8::Value> toV8NoInline(TestInterfaceEventConstructor* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
438 return toV8(impl, creationContext, isolate);
441 } // namespace WebCore