Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 {% filter format_blink_cpp_source_code %} | |
|
bashi
2017/04/28 06:39:05
Sorry forgot to mention that we need to add legacy
tkent
2017/04/28 09:22:01
Done.
| |
| 2 | |
| 3 {% include 'copyright_block.txt' %} | |
| 4 #include "{{v8_class}}.h" | |
| 5 | |
| 6 {% for filename in cpp_includes %} | |
| 7 #include "{{filename}}" | |
| 8 {% endfor %} | |
| 9 | |
| 10 namespace blink { | |
| 11 | |
| 12 // Suppress warning: global constructors, because struct WrapperTypeInfo is | |
| 13 // trivial and does not depend on another global objects. | |
| 14 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) | |
| 15 #pragma clang diagnostic push | |
| 16 #pragma clang diagnostic ignored "-Wglobal-constructors" | |
| 17 #endif | |
| 18 const WrapperTypeInfo {{v8_class}}::wrapperTypeInfo = { | |
| 19 gin::kEmbedderBlink, | |
| 20 {{v8_class}}::DomTemplate, | |
| 21 nullptr, | |
| 22 nullptr, | |
| 23 nullptr, | |
| 24 "{{interface_name}}", | |
| 25 nullptr, | |
| 26 WrapperTypeInfo::kWrapperTypeNoPrototype, | |
| 27 WrapperTypeInfo::kObjectClassId, | |
| 28 WrapperTypeInfo::kNotInheritFromActiveScriptWrappable, | |
| 29 WrapperTypeInfo::kDependent | |
| 30 }; | |
| 31 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) | |
| 32 #pragma clang diagnostic pop | |
| 33 #endif | |
| 34 | |
| 35 void {{v8_class}}::TypeErrorConstructorCallback( | |
| 36 const v8::FunctionCallbackInfo<v8::Value>& info) { | |
| 37 V8ThrowException::ThrowTypeError(info.GetIsolate(), | |
| 38 "Illegal constructor: {{interface_name}}"); | |
| 39 } | |
| 40 | |
| 41 {% from 'constants.cpp.tmpl' import install_constants with context %} | |
| 42 static void Install{{v8_class}}Template( | |
| 43 v8::Isolate* isolate, | |
| 44 const DOMWrapperWorld& world, | |
| 45 v8::Local<v8::FunctionTemplate> interfaceTemplate) { | |
| 46 // Legacy callback interface must not have a prototype object. | |
| 47 interfaceTemplate->RemovePrototype(); | |
| 48 | |
| 49 // Initialize the interface object's template. | |
| 50 V8DOMConfiguration::InitializeDOMInterfaceTemplate(isolate, interfaceTemplate, | |
| 51 {{v8_class}}::wrapperTypeInfo.interface_name, v8::Local<v8::FunctionTempla te>(), | |
| 52 kV8DefaultWrapperInternalFieldCount); | |
| 53 interfaceTemplate->SetCallHandler({{v8_class}}::TypeErrorConstructorCallback); | |
| 54 interfaceTemplate->SetLength(0); | |
| 55 | |
| 56 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late); | |
| 57 ALLOW_UNUSED_LOCAL(signature); | |
| 58 v8::Local<v8::ObjectTemplate> instanceTemplate = interfaceTemplate->InstanceTe mplate(); | |
| 59 ALLOW_UNUSED_LOCAL(instanceTemplate); | |
| 60 v8::Local<v8::ObjectTemplate> prototypeTemplate = interfaceTemplate->Prototype Template(); | |
| 61 ALLOW_UNUSED_LOCAL(prototypeTemplate); | |
| 62 | |
| 63 // Register DOM constants. | |
| 64 {{install_constants() | indent(2)}} | |
| 65 } | |
| 66 | |
| 67 v8::Local<v8::FunctionTemplate> {{v8_class}}::DomTemplate(v8::Isolate* isolate, | |
| 68 const DOMWrapperWorld& world) { | |
| 69 return V8DOMConfiguration::DomClassTemplate( | |
| 70 isolate, | |
| 71 world, | |
| 72 const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), | |
| 73 Install{{v8_class}}Template); | |
| 74 } | |
| 75 | |
| 76 } // namespace blink | |
| 77 | |
| 78 {% endfilter %}{# format_blink_cpp_source_code #} | |
| OLD | NEW |