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

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

Issue 704503002: IDL: Union type support for attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@union-arraybuffer
Patch Set: Created 6 years, 1 month 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
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 if ({{attribute.cpp_value}} && DOMDataStore::setReturnValueFromWrapper{{worl d_suffix}}<V8{{attribute.idl_type}}>(info.GetReturnValue(), {{attribute.cpp_valu e}}.get())) 88 if ({{attribute.cpp_value}} && DOMDataStore::setReturnValueFromWrapper{{worl d_suffix}}<V8{{attribute.idl_type}}>(info.GetReturnValue(), {{attribute.cpp_valu e}}.get()))
89 return; 89 return;
90 v8::Handle<v8::Value> wrapper = toV8({{attribute.cpp_value}}.get(), holder, info.GetIsolate()); 90 v8::Handle<v8::Value> wrapper = toV8({{attribute.cpp_value}}.get(), holder, info.GetIsolate());
91 if (!wrapper.IsEmpty()) { 91 if (!wrapper.IsEmpty()) {
92 V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, v8AtomicString( info.GetIsolate(), "{{attribute.name}}"), wrapper); 92 V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, v8AtomicString( info.GetIsolate(), "{{attribute.name}}"), wrapper);
93 {{attribute.v8_set_return_value}}; 93 {{attribute.v8_set_return_value}};
94 } 94 }
95 {% elif world_suffix %} 95 {% elif world_suffix %}
96 {{attribute.v8_set_return_value_for_main_world}}; 96 {{attribute.v8_set_return_value_for_main_world}};
97 {% else %} 97 {% else %}
98 {% if attribute.is_union_type %}
99 {{attribute.cpp_type}} result;
100 {{attribute.cpp_value}};
101 {% endif %}
98 {{attribute.v8_set_return_value}}; 102 {{attribute.v8_set_return_value}};
99 {% endif %} 103 {% endif %}
100 } 104 }
101 {% endfilter %} 105 {% endfilter %}
102 {% endmacro %} 106 {% endmacro %}
103 107
104 {######################################} 108 {######################################}
105 {% macro release_only_check(reflect_only_values, reflect_missing, 109 {% macro release_only_check(reflect_only_values, reflect_missing,
106 reflect_invalid, reflect_empty, cpp_value) %} 110 reflect_invalid, reflect_empty, cpp_value) %}
107 {# Attribute is limited to only known values: check that the attribute value is 111 {# Attribute is limited to only known values: check that the attribute value is
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 {# Type checking #} 220 {# Type checking #}
217 {% if attribute.has_type_checking_interface %} 221 {% if attribute.has_type_checking_interface %}
218 {# Type checking for interface types (if interface not implemented, throw 222 {# Type checking for interface types (if interface not implemented, throw
219 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} 223 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #}
220 if ({% if attribute.is_nullable %}!isUndefinedOrNull(v8Value) && {% endif %} !V8{{attribute.idl_type}}::hasInstance(v8Value, info.GetIsolate())) { 224 if ({% if attribute.is_nullable %}!isUndefinedOrNull(v8Value) && {% endif %} !V8{{attribute.idl_type}}::hasInstance(v8Value, info.GetIsolate())) {
221 exceptionState.throwTypeError("The provided value is not of type '{{attr ibute.idl_type}}'."); 225 exceptionState.throwTypeError("The provided value is not of type '{{attr ibute.idl_type}}'.");
222 exceptionState.throwIfNeeded(); 226 exceptionState.throwIfNeeded();
223 return; 227 return;
224 } 228 }
225 {% endif %} 229 {% endif %}
230 {% if attribute.is_union_type %}
231 {{attribute.cpp_type}} cppValue;
232 {% endif %}
226 {# impl #} 233 {# impl #}
227 {% if attribute.put_forwards %} 234 {% if attribute.put_forwards %}
228 {{cpp_class}}* proxyImpl = {{v8_class}}::toImpl(holder); 235 {{cpp_class}}* proxyImpl = {{v8_class}}::toImpl(holder);
229 {{attribute.cpp_type}} impl = WTF::getPtr(proxyImpl->{{attribute.name}}()); 236 {{attribute.cpp_type}} impl = WTF::getPtr(proxyImpl->{{attribute.name}}());
230 if (!impl) 237 if (!impl)
231 return; 238 return;
232 {% elif not attribute.is_static %} 239 {% elif not attribute.is_static %}
233 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); 240 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder);
234 {% endif %} 241 {% endif %}
235 {% if attribute.idl_type == 'EventHandler' and interface_name == 'Window' %} 242 {% if attribute.idl_type == 'EventHandler' and interface_name == 'Window' %}
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 access_control, 434 access_control,
428 property_attribute, 435 property_attribute,
429 only_exposed_to_private_script, 436 only_exposed_to_private_script,
430 ] %} 437 ] %}
431 {% if not attribute.is_expose_js_accessors %} 438 {% if not attribute.is_expose_js_accessors %}
432 {% set attribute_configuration_list = attribute_configuration_list 439 {% set attribute_configuration_list = attribute_configuration_list
433 + [on_prototype] %} 440 + [on_prototype] %}
434 {% endif %} 441 {% endif %}
435 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 442 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
436 {%- endmacro %} 443 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698