OLD | NEW |
1 {% from 'conversions.cpp' import v8_value_to_local_cpp_value %} | 1 {% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l
ocal_cpp_value %} |
2 | 2 |
3 | 3 |
4 {##############################################################################} | 4 {##############################################################################} |
5 {% macro attribute_getter(attribute, world_suffix) %} | 5 {% macro attribute_getter(attribute, world_suffix) %} |
6 {% filter conditional(attribute.conditional_string) %} | 6 {% filter conditional(attribute.conditional_string) %} |
7 static void {{attribute.name}}AttributeGetter{{world_suffix}}( | 7 static void {{attribute.name}}AttributeGetter{{world_suffix}}( |
8 {%- if attribute.is_expose_js_accessors %} | 8 {%- if attribute.is_expose_js_accessors %} |
9 const v8::FunctionCallbackInfo<v8::Value>& info | 9 const v8::FunctionCallbackInfo<v8::Value>& info |
10 {%- else %} | 10 {%- else %} |
11 const v8::PropertyCallbackInfo<v8::Value>& info | 11 const v8::PropertyCallbackInfo<v8::Value>& info |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 {# Type checking, possibly throw a TypeError, per: | 323 {# Type checking, possibly throw a TypeError, per: |
324 http://www.w3.org/TR/WebIDL/#es-type-mapping #} | 324 http://www.w3.org/TR/WebIDL/#es-type-mapping #} |
325 {% if attribute.has_type_checking_interface %} | 325 {% if attribute.has_type_checking_interface %} |
326 {# Type checking for interface types (if interface not implemented, throw | 326 {# Type checking for interface types (if interface not implemented, throw |
327 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} | 327 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} |
328 if (!cppValue{% if attribute.is_nullable %} && !isUndefinedOrNull(v8Value){%
endif %}) { | 328 if (!cppValue{% if attribute.is_nullable %} && !isUndefinedOrNull(v8Value){%
endif %}) { |
329 exceptionState.throwTypeError("The provided value is not of type '{{attr
ibute.idl_type}}'."); | 329 exceptionState.throwTypeError("The provided value is not of type '{{attr
ibute.idl_type}}'."); |
330 exceptionState.throwIfNeeded(); | 330 exceptionState.throwIfNeeded(); |
331 return; | 331 return; |
332 } | 332 } |
333 {% elif attribute.enum_validation_expression %} | 333 {% elif attribute.enum_values %} |
334 {# Setter ignores invalid enum values: | 334 {# Setter ignores invalid enum values: |
335 http://www.w3.org/TR/WebIDL/#idl-enums #} | 335 http://www.w3.org/TR/WebIDL/#idl-enums #} |
336 String string = cppValue; | 336 {% if not attribute.has_setter_exception_state %} |
337 if (!({{attribute.enum_validation_expression}})) { | 337 NonThrowableExceptionState exceptionState; |
338 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes
sage::create(JSMessageSource, WarningMessageLevel, "The provided value '" + stri
ng + "' is not a valid value of type '{{attribute.idl_type}}'.")); | 338 {% endif %} |
| 339 {{declare_enum_validation_variable(attribute.enum_values) | indent}} |
| 340 if (!isValidEnum(cppValue, validValues, WTF_ARRAY_LENGTH(validValues), excep
tionState)) { |
| 341 currentExecutionContext(info.GetIsolate())->addConsoleMessage(ConsoleMes
sage::create(JSMessageSource, WarningMessageLevel, exceptionState.message())); |
339 return; | 342 return; |
340 } | 343 } |
341 {% endif %} | 344 {% endif %} |
342 {# Pre-set context #} | 345 {# Pre-set context #} |
343 {% if attribute.is_custom_element_callbacks or | 346 {% if attribute.is_custom_element_callbacks or |
344 (attribute.is_reflect and | 347 (attribute.is_reflect and |
345 not(attribute.idl_type == 'DOMString' and is_node)) %} | 348 not(attribute.idl_type == 'DOMString' and is_node)) %} |
346 {# Skip on compact node DOMString getters #} | 349 {# Skip on compact node DOMString getters #} |
347 CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; | 350 CustomElementProcessingStack::CallbackDeliveryScope deliveryScope; |
348 {% endif %} | 351 {% endif %} |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 access_control, | 518 access_control, |
516 property_attribute, | 519 property_attribute, |
517 only_exposed_to_private_script, | 520 only_exposed_to_private_script, |
518 ] %} | 521 ] %} |
519 {% if not attribute.is_expose_js_accessors %} | 522 {% if not attribute.is_expose_js_accessors %} |
520 {% set attribute_configuration_list = attribute_configuration_list | 523 {% set attribute_configuration_list = attribute_configuration_list |
521 + [on_prototype] %} | 524 + [on_prototype] %} |
522 {% endif %} | 525 {% endif %} |
523 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} | 526 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} |
524 {%- endmacro %} | 527 {%- endmacro %} |
OLD | NEW |