Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Unified Diff: Source/bindings/templates/attributes.cpp

Issue 351403003: IDL: Merge duplicating local variable assignment in attribute_getter (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Further v8Value -> cppValue renaming Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/scripts/v8_attributes.py ('k') | Source/bindings/tests/results/V8TestInterface.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/templates/attributes.cpp
diff --git a/Source/bindings/templates/attributes.cpp b/Source/bindings/templates/attributes.cpp
index e715340a77e8e8a3826a432bfe22e2026154c7dc..3bff81c74ef70a0ea81c69c38fff6f557c3e6050 100644
--- a/Source/bindings/templates/attributes.cpp
+++ b/Source/bindings/templates/attributes.cpp
@@ -48,13 +48,8 @@ const v8::PropertyCallbackInfo<v8::Value>& info
{% if attribute.is_nullable and not attribute.has_type_checking_nullable %}
bool isNull = false;
{% endif %}
- {# FIXME: consider always using a local variable for value #}
- {% if attribute.cached_attribute_validation_method or
- attribute.is_getter_raises_exception or
- attribute.is_nullable or
- attribute.reflect_only or
- attribute.idl_type == 'EventHandler' %}
- {{attribute.cpp_type}} {{attribute.cpp_value}} = {{attribute.cpp_value_original}};
+ {% if attribute.cpp_value_original %}
+ {{attribute.cpp_type}} {{attribute.cpp_value}}({{attribute.cpp_value_original}});
{% endif %}
{# Checks #}
{% if attribute.is_getter_raises_exception %}
@@ -70,7 +65,8 @@ const v8::PropertyCallbackInfo<v8::Value>& info
{% endif %}
{% if attribute.reflect_only %}
{{release_only_check(attribute.reflect_only, attribute.reflect_missing,
- attribute.reflect_invalid, attribute.reflect_empty)
+ attribute.reflect_invalid, attribute.reflect_empty,
+ attribute.cpp_value)
| indent}}
{% endif %}
{% if attribute.is_nullable %}
@@ -88,11 +84,9 @@ const v8::PropertyCallbackInfo<v8::Value>& info
{% endif %}
{# v8SetReturnValue #}
{% if attribute.is_keep_alive_for_gc %}
- {# FIXME: merge local variable assignment with above #}
- {{attribute.cpp_type}} result({{attribute.cpp_value}});
- if (result && DOMDataStore::setReturnValueFromWrapper{{world_suffix}}<{{attribute.v8_type}}>(info.GetReturnValue(), result.get()))
+ if ({{attribute.cpp_value}} && DOMDataStore::setReturnValueFromWrapper{{world_suffix}}<{{attribute.v8_type}}>(info.GetReturnValue(), {{attribute.cpp_value}}.get()))
return;
- v8::Handle<v8::Value> wrapper = toV8(result.get(), holder, info.GetIsolate());
+ v8::Handle<v8::Value> wrapper = toV8({{attribute.cpp_value}}.get(), holder, info.GetIsolate());
if (!wrapper.IsEmpty()) {
V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, v8AtomicString(info.GetIsolate(), "{{attribute.name}}"), wrapper);
{{attribute.v8_set_return_value}};
@@ -108,34 +102,34 @@ const v8::PropertyCallbackInfo<v8::Value>& info
{######################################}
{% macro release_only_check(reflect_only_values, reflect_missing,
- reflect_invalid, reflect_empty) %}
+ reflect_invalid, reflect_empty, cpp_value) %}
{# Attribute is limited to only known values: check that the attribute value is
one of those. If not, set it to the empty string.
http://www.whatwg.org/specs/web-apps/current-work/#limited-to-only-known-values #}
{% if reflect_empty %}
-if (v8Value.isNull()) {
+if ({{cpp_value}}.isNull()) {
{% if reflect_missing %}
- v8Value = "{{reflect_missing}}";
+ {{cpp_value}} = "{{reflect_missing}}";
{% else %}
;
{% endif %}
-} else if (v8Value.isEmpty()) {
- v8Value = "{{reflect_empty}}";
+} else if ({{cpp_value}}.isEmpty()) {
+ {{cpp_value}} = "{{reflect_empty}}";
{% else %}
-if (v8Value.isEmpty()) {
+if ({{cpp_value}}.isEmpty()) {
{# FIXME: should use [ReflectEmpty] instead; need to change IDL files #}
{% if reflect_missing %}
- v8Value = "{{reflect_missing}}";
+ {{cpp_value}} = "{{reflect_missing}}";
{% else %}
;
{% endif %}
{% endif %}
{% for value in reflect_only_values %}
-} else if (equalIgnoringCase(v8Value, "{{value}}")) {
- v8Value = "{{value}}";
+} else if (equalIgnoringCase({{cpp_value}}, "{{value}}")) {
+ {{cpp_value}} = "{{value}}";
{% endfor %}
} else {
- v8Value = "{{reflect_invalid}}";
+ {{cpp_value}} = "{{reflect_invalid}}";
}
{% endmacro %}
« no previous file with comments | « Source/bindings/scripts/v8_attributes.py ('k') | Source/bindings/tests/results/V8TestInterface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698