OLD | NEW |
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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 and is_node and not attribute.is_implemented_in_private_script %} | 210 and is_node and not attribute.is_implemented_in_private_script %} |
211 {% set cpp_class, v8_class = 'Element', 'V8Element' %} | 211 {% set cpp_class, v8_class = 'Element', 'V8Element' %} |
212 {% endif %} | 212 {% endif %} |
213 {# Local variables #} | 213 {# Local variables #} |
214 {% if not attribute.is_static %} | 214 {% if not attribute.is_static %} |
215 v8::Handle<v8::Object> holder = info.Holder(); | 215 v8::Handle<v8::Object> holder = info.Holder(); |
216 {% endif %} | 216 {% endif %} |
217 {% if attribute.has_setter_exception_state %} | 217 {% if attribute.has_setter_exception_state %} |
218 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na
me}}", "{{interface_name}}", holder, info.GetIsolate()); | 218 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na
me}}", "{{interface_name}}", holder, info.GetIsolate()); |
219 {% endif %} | 219 {% endif %} |
220 {# Type checking #} | |
221 {% if attribute.has_type_checking_interface %} | |
222 {# Type checking for interface types (if interface not implemented, throw | |
223 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} | |
224 if ({% if attribute.is_nullable %}!isUndefinedOrNull(v8Value) && {% endif %}
!V8{{attribute.idl_type}}::hasInstance(v8Value, info.GetIsolate())) { | |
225 exceptionState.throwTypeError("The provided value is not of type '{{attr
ibute.idl_type}}'."); | |
226 exceptionState.throwIfNeeded(); | |
227 return; | |
228 } | |
229 {% endif %} | |
230 {% if attribute.use_output_parameter_for_result %} | 220 {% if attribute.use_output_parameter_for_result %} |
231 {{attribute.cpp_type}} cppValue; | 221 {{attribute.cpp_type}} cppValue; |
232 {% endif %} | 222 {% endif %} |
233 {# impl #} | 223 {# impl #} |
234 {% if attribute.put_forwards %} | 224 {% if attribute.put_forwards %} |
235 {{cpp_class}}* proxyImpl = {{v8_class}}::toImpl(holder); | 225 {{cpp_class}}* proxyImpl = {{v8_class}}::toImpl(holder); |
236 {{attribute.cpp_type}} impl = WTF::getPtr(proxyImpl->{{attribute.name}}()); | 226 {{attribute.cpp_type}} impl = WTF::getPtr(proxyImpl->{{attribute.name}}()); |
237 if (!impl) | 227 if (!impl) |
238 return; | 228 return; |
239 {% elif not attribute.is_static %} | 229 {% elif not attribute.is_static %} |
(...skipping 13 matching lines...) Expand all Loading... |
253 http://www.w3.org/TR/WebIDL/#es-type-mapping #} | 243 http://www.w3.org/TR/WebIDL/#es-type-mapping #} |
254 {% if attribute.has_type_checking_unrestricted %} | 244 {% if attribute.has_type_checking_unrestricted %} |
255 {# Non-finite floating point values (NaN, +Infinity or −Infinity), per: | 245 {# Non-finite floating point values (NaN, +Infinity or −Infinity), per: |
256 http://heycam.github.io/webidl/#es-float | 246 http://heycam.github.io/webidl/#es-float |
257 http://heycam.github.io/webidl/#es-double #} | 247 http://heycam.github.io/webidl/#es-double #} |
258 if (!std::isfinite(cppValue)) { | 248 if (!std::isfinite(cppValue)) { |
259 exceptionState.throwTypeError("The provided {{attribute.idl_type}} value
is non-finite."); | 249 exceptionState.throwTypeError("The provided {{attribute.idl_type}} value
is non-finite."); |
260 exceptionState.throwIfNeeded(); | 250 exceptionState.throwIfNeeded(); |
261 return; | 251 return; |
262 } | 252 } |
| 253 {% elif attribute.has_type_checking_interface %} |
| 254 {# Type checking for interface types (if interface not implemented, throw |
| 255 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} |
| 256 if (!cppValue{% if attribute.is_nullable %} && !isUndefinedOrNull(v8Value){%
endif %}) { |
| 257 exceptionState.throwTypeError("The provided value is not of type '{{attr
ibute.idl_type}}'."); |
| 258 exceptionState.throwIfNeeded(); |
| 259 return; |
| 260 } |
263 {% elif attribute.enum_validation_expression %} | 261 {% elif attribute.enum_validation_expression %} |
264 {# Setter ignores invalid enum values: | 262 {# Setter ignores invalid enum values: |
265 http://www.w3.org/TR/WebIDL/#idl-enums #} | 263 http://www.w3.org/TR/WebIDL/#idl-enums #} |
266 String string = cppValue; | 264 String string = cppValue; |
267 if (!({{attribute.enum_validation_expression}})) | 265 if (!({{attribute.enum_validation_expression}})) |
268 return; | 266 return; |
269 {% endif %} | 267 {% endif %} |
270 {# Pre-set context #} | 268 {# Pre-set context #} |
271 {% if attribute.is_custom_element_callbacks or | 269 {% if attribute.is_custom_element_callbacks or |
272 (attribute.is_reflect and | 270 (attribute.is_reflect and |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 access_control, | 432 access_control, |
435 property_attribute, | 433 property_attribute, |
436 only_exposed_to_private_script, | 434 only_exposed_to_private_script, |
437 ] %} | 435 ] %} |
438 {% if not attribute.is_expose_js_accessors %} | 436 {% if not attribute.is_expose_js_accessors %} |
439 {% set attribute_configuration_list = attribute_configuration_list | 437 {% set attribute_configuration_list = attribute_configuration_list |
440 + [on_prototype] %} | 438 + [on_prototype] %} |
441 {% endif %} | 439 {% endif %} |
442 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} | 440 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} |
443 {%- endmacro %} | 441 {%- endmacro %} |
OLD | NEW |