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..0ea24a9393892a3ca68e6ff2e1d9b8224cb7d6e9 |
| --- /dev/null |
| +++ b/Source/bindings/templates/attributes.cpp |
| @@ -0,0 +1,40 @@ |
| +{% macro attribute_getter(attribute) %} |
| +static void {{attribute.name}}AttributeGetter(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.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); |
| + } |
| +{% else %} |
| + {{attribute.return_v8_value_statement | indent}} |
| +{% endif %} |
| + return; |
| +} |
| +{% endmacro %} |
| + |
| + |
| +{##############################################################################} |
| +{% macro attribute_getter_callback(attribute) %} |
| +static void {{attribute.name}}AttributeGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) |
| +{ |
| + TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| + {{cpp_class_name}}V8Internal::{{attribute.name}}AttributeGetter(name, info); |
| + TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| +} |
| +{% endmacro %} |
| + |
| + |
| +{##############################################################################} |
| +{% macro class_attributes() %} |
|
haraken
2013/08/26 09:33:40
Where is install_attributes() or something like th
Nils Barth (inactive)
2013/08/27 02:59:27
V8DOMConfiguration::installAttributes is only call
|
| +static const V8DOMConfiguration::AttributeConfiguration {{v8_class_name}}Attributes[] = { |
| +{% for attribute in attributes %} |
| + {"{{attribute.name}}", {{cpp_class_name}}V8Internal::{{attribute.name}}AttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, |
| +{% endfor %} |
| +}; |
| +{% endmacro %} |