OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file has been auto-generated by code_generator_v8.py. | 5 // This file has been auto-generated by code_generator_v8.py. |
6 // DO NOT MODIFY! | 6 // DO NOT MODIFY! |
7 | 7 |
8 // This file has been generated from the Jinja2 template in | 8 // This file has been generated from the Jinja2 template in |
9 // third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl | 9 // third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl |
10 | 10 |
11 // clang-format off | 11 // clang-format off |
12 #include "V8TestInterfaceNamedConstructor.h" | 12 #include "V8TestInterfaceNamedConstructor.h" |
13 | 13 |
14 #include "bindings/core/v8/ExceptionState.h" | 14 #include "bindings/core/v8/ExceptionState.h" |
15 #include "bindings/core/v8/IDLTypes.h" | 15 #include "bindings/core/v8/IDLTypes.h" |
16 #include "bindings/core/v8/NativeValueTraitsImpl.h" | 16 #include "bindings/core/v8/NativeValueTraitsImpl.h" |
17 #include "bindings/core/v8/V8DOMConfiguration.h" | 17 #include "bindings/core/v8/V8DOMConfiguration.h" |
18 #include "bindings/core/v8/V8ObjectConstructor.h" | 18 #include "bindings/core/v8/V8ObjectConstructor.h" |
| 19 #include "bindings/core/v8/V8PrivateProperty.h" |
19 #include "core/dom/Document.h" | 20 #include "core/dom/Document.h" |
20 #include "core/frame/LocalDOMWindow.h" | 21 #include "core/frame/LocalDOMWindow.h" |
21 #include "wtf/GetPtr.h" | 22 #include "wtf/GetPtr.h" |
22 #include "wtf/RefPtr.h" | 23 #include "wtf/RefPtr.h" |
23 | 24 |
24 namespace blink { | 25 namespace blink { |
25 | 26 |
26 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv
ial | 27 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv
ial |
27 // and does not depend on another global objects. | 28 // and does not depend on another global objects. |
28 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) | 29 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) |
(...skipping 27 matching lines...) Expand all Loading... |
56 | 57 |
57 } // namespace TestInterfaceNamedConstructorV8Internal | 58 } // namespace TestInterfaceNamedConstructorV8Internal |
58 | 59 |
59 // Suppress warning: global constructors, because AttributeConfiguration is triv
ial | 60 // Suppress warning: global constructors, because AttributeConfiguration is triv
ial |
60 // and does not depend on another global objects. | 61 // and does not depend on another global objects. |
61 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) | 62 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) |
62 #pragma clang diagnostic push | 63 #pragma clang diagnostic push |
63 #pragma clang diagnostic ignored "-Wglobal-constructors" | 64 #pragma clang diagnostic ignored "-Wglobal-constructors" |
64 #endif | 65 #endif |
65 const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceNamedConstructor
LazyDataAttributes[] = { | 66 const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceNamedConstructor
LazyDataAttributes[] = { |
66 {"testNamedConstructorConstructorAttribute", v8ConstructorAttributeGetter, n
ullptr, nullptr, nullptr, nullptr, const_cast<WrapperTypeInfo*>(&V8TestNamedCons
tructor::wrapperTypeInfo), static_cast<v8::PropertyAttribute>(v8::DontEnum), V8D
OMConfiguration::OnInstance, V8DOMConfiguration::CheckHolder}, | 67 {"testNamedConstructorConstructorAttribute", V8TestNamedConstructor::NamedCo
nstructorAttributeGetter, nullptr, nullptr, nullptr, nullptr, const_cast<Wrapper
TypeInfo*>(&V8TestNamedConstructor::wrapperTypeInfo), static_cast<v8::PropertyAt
tribute>(v8::DontEnum), V8DOMConfiguration::OnInstance, V8DOMConfiguration::Chec
kHolder}, |
67 }; | 68 }; |
68 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) | 69 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) |
69 #pragma clang diagnostic pop | 70 #pragma clang diagnostic pop |
70 #endif | 71 #endif |
71 | 72 |
72 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv
ial | 73 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv
ial |
73 // and does not depend on another global objects. | 74 // and does not depend on another global objects. |
74 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) | 75 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) |
75 #pragma clang diagnostic push | 76 #pragma clang diagnostic push |
76 #pragma clang diagnostic ignored "-Wglobal-constructors" | 77 #pragma clang diagnostic ignored "-Wglobal-constructors" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 v8::Local<v8::FunctionTemplate> V8TestInterfaceNamedConstructorConstructor::domT
emplate(v8::Isolate* isolate, const DOMWrapperWorld& world) { | 162 v8::Local<v8::FunctionTemplate> V8TestInterfaceNamedConstructorConstructor::domT
emplate(v8::Isolate* isolate, const DOMWrapperWorld& world) { |
162 static int domTemplateKey; // This address is used for a key to look up the do
m template. | 163 static int domTemplateKey; // This address is used for a key to look up the do
m template. |
163 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 164 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
164 v8::Local<v8::FunctionTemplate> result = data->findInterfaceTemplate(world, &d
omTemplateKey); | 165 v8::Local<v8::FunctionTemplate> result = data->findInterfaceTemplate(world, &d
omTemplateKey); |
165 if (!result.IsEmpty()) | 166 if (!result.IsEmpty()) |
166 return result; | 167 return result; |
167 | 168 |
168 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceNamedConstructorCon
structorCallback); | 169 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceNamedConstructorCon
structorCallback); |
169 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); | 170 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); |
170 instanceTemplate->SetInternalFieldCount(V8TestInterfaceNamedConstructor::inter
nalFieldCount); | 171 instanceTemplate->SetInternalFieldCount(V8TestInterfaceNamedConstructor::inter
nalFieldCount); |
171 result->SetClassName(v8AtomicString(isolate, "TestInterfaceNamedConstructor"))
; | 172 result->SetClassName(v8AtomicString(isolate, "Audio")); |
172 result->Inherit(V8TestInterfaceNamedConstructor::domTemplate(isolate, world)); | 173 result->Inherit(V8TestInterfaceNamedConstructor::domTemplate(isolate, world)); |
173 data->setInterfaceTemplate(world, &domTemplateKey, result); | 174 data->setInterfaceTemplate(world, &domTemplateKey, result); |
174 return result; | 175 return result; |
175 } | 176 } |
176 | 177 |
| 178 void V8TestInterfaceNamedConstructorConstructor::NamedConstructorAttributeGetter
( |
| 179 v8::Local<v8::Name> propertyName, |
| 180 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 181 v8::Local<v8::Context> creationContext = info.Holder()->CreationContext(); |
| 182 V8PerContextData* perContextData = V8PerContextData::from(creationContext); |
| 183 if (!perContextData) { |
| 184 // TODO(yukishiino): Return a valid named constructor even after the context
is detached |
| 185 return; |
| 186 } |
| 187 |
| 188 v8::Local<v8::Function> namedConstructor = perContextData->constructorForType(
&V8TestInterfaceNamedConstructorConstructor::wrapperTypeInfo); |
| 189 |
| 190 // Set the prototype of named constructors to the regular constructor. |
| 191 auto privateProperty = V8PrivateProperty::getNamedConstructorInitialized(info.
GetIsolate()); |
| 192 v8::Local<v8::Context> currentContext = info.GetIsolate()->GetCurrentContext()
; |
| 193 v8::Local<v8::Value> privateValue = privateProperty.get(currentContext, namedC
onstructor); |
| 194 |
| 195 if (privateValue.IsEmpty()) { |
| 196 v8::Local<v8::Function> interface = perContextData->constructorForType(&V8Te
stInterfaceNamedConstructor::wrapperTypeInfo); |
| 197 v8::Local<v8::Value> interfacePrototype = interface->Get(currentContext, v8A
tomicString(info.GetIsolate(), "prototype")).ToLocalChecked(); |
| 198 bool result = namedConstructor->Set(currentContext, v8AtomicString(info.GetI
solate(), "prototype"), interfacePrototype).ToChecked(); |
| 199 if (!result) |
| 200 return; |
| 201 privateProperty.set(currentContext, namedConstructor, v8::True(info.GetIsola
te())); |
| 202 } |
| 203 |
| 204 v8SetReturnValue(info, namedConstructor); |
| 205 } |
| 206 |
177 static void installV8TestInterfaceNamedConstructorTemplate(v8::Isolate* isolate,
const DOMWrapperWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate
) { | 207 static void installV8TestInterfaceNamedConstructorTemplate(v8::Isolate* isolate,
const DOMWrapperWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate
) { |
178 // Initialize the interface object's template. | 208 // Initialize the interface object's template. |
179 V8DOMConfiguration::initializeDOMInterfaceTemplate(isolate, interfaceTemplate,
V8TestInterfaceNamedConstructor::wrapperTypeInfo.interfaceName, v8::Local<v8::F
unctionTemplate>(), V8TestInterfaceNamedConstructor::internalFieldCount); | 209 V8DOMConfiguration::initializeDOMInterfaceTemplate(isolate, interfaceTemplate,
V8TestInterfaceNamedConstructor::wrapperTypeInfo.interfaceName, v8::Local<v8::F
unctionTemplate>(), V8TestInterfaceNamedConstructor::internalFieldCount); |
180 | 210 |
181 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp
late); | 211 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp
late); |
182 ALLOW_UNUSED_LOCAL(signature); | 212 ALLOW_UNUSED_LOCAL(signature); |
183 v8::Local<v8::ObjectTemplate> instanceTemplate = interfaceTemplate->InstanceTe
mplate(); | 213 v8::Local<v8::ObjectTemplate> instanceTemplate = interfaceTemplate->InstanceTe
mplate(); |
184 ALLOW_UNUSED_LOCAL(instanceTemplate); | 214 ALLOW_UNUSED_LOCAL(instanceTemplate); |
185 v8::Local<v8::ObjectTemplate> prototypeTemplate = interfaceTemplate->Prototype
Template(); | 215 v8::Local<v8::ObjectTemplate> prototypeTemplate = interfaceTemplate->Prototype
Template(); |
186 ALLOW_UNUSED_LOCAL(prototypeTemplate); | 216 ALLOW_UNUSED_LOCAL(prototypeTemplate); |
(...skipping 16 matching lines...) Expand all Loading... |
203 | 233 |
204 TestInterfaceNamedConstructor* V8TestInterfaceNamedConstructor::toImplWithTypeCh
eck(v8::Isolate* isolate, v8::Local<v8::Value> value) { | 234 TestInterfaceNamedConstructor* V8TestInterfaceNamedConstructor::toImplWithTypeCh
eck(v8::Isolate* isolate, v8::Local<v8::Value> value) { |
205 return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value)
) : nullptr; | 235 return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value)
) : nullptr; |
206 } | 236 } |
207 | 237 |
208 TestInterfaceNamedConstructor* NativeValueTraits<TestInterfaceNamedConstructor>:
:nativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& e
xceptionState) { | 238 TestInterfaceNamedConstructor* NativeValueTraits<TestInterfaceNamedConstructor>:
:nativeValue(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& e
xceptionState) { |
209 return V8TestInterfaceNamedConstructor::toImplWithTypeCheck(isolate, value); | 239 return V8TestInterfaceNamedConstructor::toImplWithTypeCheck(isolate, value); |
210 } | 240 } |
211 | 241 |
212 } // namespace blink | 242 } // namespace blink |
OLD | NEW |