Chromium Code Reviews| Index: Source/bindings/templates/attributes.cpp |
| diff --git a/Source/bindings/templates/attributes.cpp b/Source/bindings/templates/attributes.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0ca2dd621bc4c3fecd0ad1a2f002176ab5470250 |
| --- /dev/null |
| +++ b/Source/bindings/templates/attributes.cpp |
| @@ -0,0 +1,49 @@ |
| +{% macro attribute_getter(attribute) %} |
|
haraken
2013/08/22 07:31:33
attribute_getter => define_attribute_getter
Nils Barth (inactive)
2013/08/22 09:08:13
For functions, I agree that verb names are better,
|
| +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()); |
| +{% if attribute.should_keep_attribute_alive %} |
| + {{attribute_return_keep_property_alive(attribute) | indent}} |
| +{% else %} |
| + {{attribute.return_js_value_statement | indent}} |
| +{% endif %} |
| + return; |
| +} |
| + |
| +{% endmacro %} |
| + |
| + |
| +{##############################################################################} |
| +{% macro attribute_return_keep_property_alive(attribute) %} |
|
haraken
2013/08/22 07:31:33
attribute_return_keep_property_alive => keep_attri
Nils Barth (inactive)
2013/08/22 09:08:13
For these block templates, I'm not sure how to nam
|
| +{{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); |
| +} |
| +{% endmacro %} |
| + |
| + |
| +{##############################################################################} |
| +{% macro attribute_getter_callback(attribute) %} |
|
haraken
2013/08/22 07:31:33
attribute_getter_callback => define_attribute_gett
Nils Barth (inactive)
2013/08/22 09:08:13
(As above, declarative template, not function.)
|
| +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"); |
| +} |
| + |
| +{% endmacro %} |
| + |
| + |
| +{##############################################################################} |
| +{% macro batched_attribute() %} |
|
haraken
2013/08/22 07:31:33
batched_attribute => install_attributes
"Batched"
Nils Barth (inactive)
2013/08/22 09:08:13
I'm naming the macros after what they define (per
haraken
2013/08/22 11:05:28
I'm suggesting naming everything consistently. For
Nils Barth (inactive)
2013/08/23 01:50:05
Got it, will change in Perl first, then update thi
|
| +static const V8DOMConfiguration::BatchedAttribute {{v8_class_name}}Attrs[] = { |
|
haraken
2013/08/22 07:31:33
{{v8_class_name}}Attrs[] => {{v8_class_name}}Attri
Nils Barth (inactive)
2013/08/22 09:08:13
(Perl compatibility.)
|
| +{% for attribute in attributes %} |
| + // Attribute '{{attribute.name}}' |
|
haraken
2013/08/22 07:31:33
You can remove this comment.
Nils Barth (inactive)
2013/08/22 09:08:13
(Perl compatibility.)
|
| + {"{{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 */}, |
|
haraken
2013/08/22 07:31:33
You can remove /*no data*/. It isn't helpful.
Nils Barth (inactive)
2013/08/22 09:08:13
(Perl compatibility.)
|
| +{% endfor %} |
| +}; |
| +{% endmacro %} |