Chromium Code Reviews| Index: Source/bindings/templates/interface.cpp |
| diff --git a/Source/bindings/templates/interface.cpp b/Source/bindings/templates/interface.cpp |
| index ba5a3baa9e1922b61bfcbc50c5a9b534f23ff625..a10301424c3a07e76bcfdda4a25129542a99ef80 100644 |
| --- a/Source/bindings/templates/interface.cpp |
| +++ b/Source/bindings/templates/interface.cpp |
| @@ -18,6 +18,8 @@ |
| Boston, MA 02111-1307, USA. |
| */ |
| +{% from 'attributes.cpp' import attribute_getter, attribute_getter_callback, batched_attribute with context %} |
| +{% from 'constants.cpp' import class_consts, const_data, batch_configure_constants with context %} |
| #include "config.h" |
| {% if conditional_string %} |
| #if {{conditional_string}} |
| @@ -25,7 +27,7 @@ |
| #include "{{v8_class_name}}.h" |
| {% for filename in cpp_includes %} |
| -#include "{{ filename }}" |
| +#include "{{filename}}" |
| {% endfor %} |
| namespace WebCore { |
| @@ -57,40 +59,16 @@ namespace {{cpp_class_name}}V8Internal { |
| template <typename T> void V8_USE(T) { } |
| {% for attribute in attributes %} |
| -static void {{attribute.name}}AttrGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) |
| -{ |
| - {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder()); |
| - {{attribute.cpp_type}} result = imp->{{attribute.cpp_method_name}}(); |
| - if (result.get() && DOMDataStore::setReturnValueFromWrapper<{{attribute.v8_type}}>(info.GetReturnValue(), result.get())) |
| - return; |
| - v8::Handle<v8::Value> wrapper = toV8(result.get(), info.Holder(), info.GetIsolate()); |
| - if (!wrapper.IsEmpty()) { |
| - V8HiddenPropertyName::setNamedHiddenReference(info.Holder(), "{{attribute.name}}", wrapper); |
| - v8SetReturnValue(info, wrapper); |
| - } |
| -} |
| - |
| -static void {{attribute.name}}AttrGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) |
| -{ |
| - TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| - {{cpp_class_name}}V8Internal::{{attribute.name}}AttrGetter(name, info); |
| - TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| -} |
| - |
| -{% endfor %} |
| - |
| +{{attribute_getter(attribute) -}} |
|
haraken
2013/08/22 07:31:33
What is the '-' ?
Nils Barth (inactive)
2013/08/22 09:08:13
For whitespace control; see above.
One annoyance w
|
| +{{attribute_getter_callback(attribute)}}{% endfor %} |
| } // namespace {{cpp_class_name}}V8Internal |
| {% if attributes %} |
| -static const V8DOMConfiguration::BatchedAttribute {{v8_class_name}}Attributes[] = { |
| -{% for attribute in attributes %} |
| - {"{{attribute.name}}", {{cpp_class_name}}V8Internal::{{attribute.name}}AttrGetterCallback, 0, 0, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, |
| -{% endfor %} |
| -}; |
| - |
| +{{batched_attribute()}} |
| +{% endif %} |
| +{% if constants %} |
| +{{class_consts()}} |
| {% endif %} |
| - |
| - |
| static v8::Handle<v8::FunctionTemplate> Configure{{v8_class_name}}Template(v8::Handle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWorldType) |
| { |
| desc->ReadOnlyPrototype(); |
| @@ -100,6 +78,16 @@ static v8::Handle<v8::FunctionTemplate> Configure{{v8_class_name}}Template(v8::H |
| {{attribute_templates}}, {{number_of_attributes}}, |
| 0, 0, isolate, currentWorldType); |
| UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. |
| +{% if constants %} |
| + v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); |
| + v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); |
| + UNUSED_PARAM(instance); // In some cases, it will not be used. |
| + UNUSED_PARAM(proto); // In some cases, it will not be used. |
| +{% endif %} |
| +{% for constant in constants %}{{const_data(constant)}}{% endfor %} |
| +{% if constants %} |
| + {{batch_configure_constants()}} |
| +{% endif %} |
| // Custom toString template |
| desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate()); |
| @@ -133,6 +121,7 @@ bool {{v8_class_name}}::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::I |
| || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorld); |
| } |
| + |
|
haraken
2013/08/22 07:31:33
Nit: Unnecessary empty line.
Nils Barth (inactive)
2013/08/22 09:08:13
(Perl.)
|
| v8::Handle<v8::Object> {{v8_class_name}}::createWrapper(PassRefPtr<{{cpp_class_name}}> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
| { |
| ASSERT(impl.get()); |
| @@ -144,22 +133,21 @@ v8::Handle<v8::Object> {{v8_class_name}}::createWrapper(PassRefPtr<{{cpp_class_n |
| RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == info.derefObjectFunction); |
| } |
| + |
|
haraken
2013/08/22 07:31:33
Ditto.
Nils Barth (inactive)
2013/08/22 09:08:13
(Perl.)
|
| v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &info, toInternalPointer(impl.get()), isolate); |
| if (UNLIKELY(wrapper.IsEmpty())) |
| return wrapper; |
| - |
| installPerContextProperties(wrapper, impl.get(), isolate); |
| V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &info, wrapper, isolate, WrapperConfiguration::Independent); |
| return wrapper; |
| } |
| - |
|
haraken
2013/08/22 07:31:33
Nit: This empty line would be needed.
Nils Barth (inactive)
2013/08/22 09:08:13
(Perl.)
|
| void {{v8_class_name}}::derefObject(void* object) |
| { |
| fromInternalPointer(object)->deref(); |
| } |
| } // namespace WebCore |
| - |
| {% if conditional_string %} |
| + |
| #endif // {{conditional_string}} |
| {% endif %} |