| 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..756ff4d93267e875089a8e2de67947c75738f232
|
| --- /dev/null
|
| +++ b/Source/bindings/templates/attributes.cpp
|
| @@ -0,0 +1,45 @@
|
| +{% macro attribute_getter(attribute) %}
|
| +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.cpp_type}} result = imp->{{attribute.cpp_method_name}}();
|
| + v8::Handle<v8::Value> wrapper = result.get() ? v8::Handle<v8::Value>(DOMDataStore::getWrapper<{{attribute.v8_type}}>(result.get(), info.GetIsolate())) : v8Undefined();
|
| + if (wrapper.IsEmpty()) {
|
| + wrapper = toV8(result.get(), info.Holder(), info.GetIsolate());
|
| + if (!wrapper.IsEmpty())
|
| + V8HiddenPropertyName::setNamedHiddenReference(info.Holder(), "{{attribute.name}}", wrapper);
|
| + }
|
| + v8SetReturnValue(info, wrapper);
|
| + return;
|
| +{% else %}
|
| + {{attribute.return_js_value_statement | indent}}
|
| + return;
|
| +{% endif %}
|
| +}
|
| +
|
| +{% endmacro %}
|
| +
|
| +
|
| +{##############################################################################}
|
| +{% macro attribute_getter_callback(attribute) %}
|
| +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 %}
|
| +
|
| +
|
| +{##############################################################################}
|
| +{# FIXME: instead pass a list of normal_attributes #}
|
| +{% macro batched_attribute() %}
|
| +static const V8DOMConfiguration::BatchedAttribute {{v8_class_name}}Attrs[] = {
|
| +{% for attribute in attributes %}
|
| + // Attribute '{{attribute.name}}'
|
| + {"{{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 %}
|
| +};
|
| +{% endmacro %}
|
|
|