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

Side by Side Diff: Source/bindings/templates/attributes.cpp

Issue 155623004: IDL compiler: [ReflectEmpty] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 {##############################################################################} 1 {##############################################################################}
2 {% macro attribute_getter(attribute, world_suffix) %} 2 {% macro attribute_getter(attribute, world_suffix) %}
3 {% filter conditional(attribute.conditional_string) %} 3 {% filter conditional(attribute.conditional_string) %}
4 static void {{attribute.name}}AttributeGetter{{world_suffix}}( 4 static void {{attribute.name}}AttributeGetter{{world_suffix}}(
5 {%- if attribute.is_expose_js_accessors %} 5 {%- if attribute.is_expose_js_accessors %}
6 const v8::FunctionCallbackInfo<v8::Value>& info 6 const v8::FunctionCallbackInfo<v8::Value>& info
7 {%- else %} 7 {%- else %}
8 const v8::PropertyCallbackInfo<v8::Value>& info 8 const v8::PropertyCallbackInfo<v8::Value>& info
9 {%- endif %}) 9 {%- endif %})
10 { 10 {
(...skipping 17 matching lines...) Expand all
28 v8SetReturnValue(info, jsValue); 28 v8SetReturnValue(info, jsValue);
29 return; 29 return;
30 } 30 }
31 } 31 }
32 {% elif not (attribute.is_static or attribute.is_unforgeable) %} 32 {% elif not (attribute.is_static or attribute.is_unforgeable) %}
33 {{cpp_class}}* imp = {{v8_class}}::toNative(info.Holder()); 33 {{cpp_class}}* imp = {{v8_class}}::toNative(info.Holder());
34 {% endif %} 34 {% endif %}
35 {% if attribute.reflect_only %} 35 {% if attribute.reflect_only %}
36 {{attribute.cpp_type}} {{attribute.cpp_value}} = {{attribute.cpp_value_origi nal}}; 36 {{attribute.cpp_type}} {{attribute.cpp_value}} = {{attribute.cpp_value_origi nal}};
37 {{release_only_check(attribute.reflect_only, attribute.reflect_missing, 37 {{release_only_check(attribute.reflect_only, attribute.reflect_missing,
38 attribute.reflect_invalid) | indent}} 38 attribute.reflect_invalid, attribute.reflect_empty)
39 | indent}}
39 {% endif %} 40 {% endif %}
40 {% if attribute.is_call_with_execution_context %} 41 {% if attribute.is_call_with_execution_context %}
41 ExecutionContext* scriptContext = currentExecutionContext(info.GetIsolate()) ; 42 ExecutionContext* scriptContext = currentExecutionContext(info.GetIsolate()) ;
42 {% endif %} 43 {% endif %}
43 {# Special cases #} 44 {# Special cases #}
44 {% if attribute.is_check_security_for_node or 45 {% if attribute.is_check_security_for_node or
45 attribute.is_getter_raises_exception %} 46 attribute.is_getter_raises_exception %}
46 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); 47 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate());
47 {% endif %} 48 {% endif %}
48 {% if attribute.is_check_security_for_node %} 49 {% if attribute.is_check_security_for_node %}
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 {% else %} 91 {% else %}
91 {{attribute.v8_set_return_value}}; 92 {{attribute.v8_set_return_value}};
92 {% endif %} 93 {% endif %}
93 {% endif %} 94 {% endif %}
94 } 95 }
95 {% endfilter %} 96 {% endfilter %}
96 {% endmacro %} 97 {% endmacro %}
97 98
98 {######################################} 99 {######################################}
99 {% macro release_only_check(reflect_only_values, reflect_missing, 100 {% macro release_only_check(reflect_only_values, reflect_missing,
100 reflect_invalid) %} 101 reflect_invalid, reflect_empty) %}
101 {# Attribute is limited to only known values: check that the attribute value is 102 {# Attribute is limited to only known values: check that the attribute value is
102 one of those. If not, set it to the empty string. 103 one of those. If not, set it to the empty string.
103 http://www.whatwg.org/specs/web-apps/current-work/#limited-to-only-known-valu es #} 104 http://www.whatwg.org/specs/web-apps/current-work/#limited-to-only-known-valu es #}
104 if (resultValue.isEmpty()) { 105 {% if reflect_empty %}
106 if (resultValue.isNull()) {
105 {% if reflect_missing %} 107 {% if reflect_missing %}
106 resultValue = "{{reflect_missing}}"; 108 resultValue = "{{reflect_missing}}";
107 {% else %} 109 {% else %}
108 ; 110 ;
109 {% endif %} 111 {% endif %}
112 } else if (resultValue.isEmpty()) {
113 resultValue = "{{reflect_empty}}";
114 {% else %}
115 if (resultValue.isEmpty()) {
116 {# FIXME: should use [ReflectEmpty] instead; need to change IDL files #}
haraken 2014/02/05 07:13:15 Yeah, we should fix it.
117 {% if reflect_missing %}
118 resultValue = "{{reflect_missing}}";
119 {% else %}
120 ;
haraken 2014/02/05 07:13:15 What's this?
Nils Barth (inactive) 2014/02/05 07:14:39 Perl generates an empty statement if there's no va
121 {% endif %}
122 {% endif %}
110 {% for value in reflect_only_values %} 123 {% for value in reflect_only_values %}
111 } else if (equalIgnoringCase(resultValue, "{{value}}")) { 124 } else if (equalIgnoringCase(resultValue, "{{value}}")) {
112 resultValue = "{{value}}"; 125 resultValue = "{{value}}";
113 {% endfor %} 126 {% endfor %}
114 } else { 127 } else {
115 resultValue = "{{reflect_invalid}}"; 128 resultValue = "{{reflect_invalid}}";
116 } 129 }
117 {% endmacro %} 130 {% endmacro %}
118 131
119 132
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 {% endif %} 268 {% endif %}
256 {% if attribute.has_custom_setter %} 269 {% if attribute.has_custom_setter %}
257 {{v8_class}}::{{attribute.name}}AttributeSetterCustom(jsValue, info); 270 {{v8_class}}::{{attribute.name}}AttributeSetterCustom(jsValue, info);
258 {% else %} 271 {% else %}
259 {{cpp_class}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffix}}(j sValue, info); 272 {{cpp_class}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffix}}(j sValue, info);
260 {% endif %} 273 {% endif %}
261 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 274 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
262 } 275 }
263 {% endfilter %} 276 {% endfilter %}
264 {% endmacro %} 277 {% endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/scripts/unstable/v8_attributes.py ('k') | Source/bindings/tests/idls/TestObjectPython.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698