| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 return; | 44 return; |
| 45 {% endif %} | 45 {% endif %} |
| 46 {# Local variables #} | 46 {# Local variables #} |
| 47 {% if attribute.is_call_with_execution_context %} | 47 {% if attribute.is_call_with_execution_context %} |
| 48 ExecutionContext* scriptContext = currentExecutionContext(info.GetIsolate())
; | 48 ExecutionContext* scriptContext = currentExecutionContext(info.GetIsolate())
; |
| 49 {% endif %} | 49 {% endif %} |
| 50 {% if attribute.is_check_security_for_node or | 50 {% if attribute.is_check_security_for_node or |
| 51 attribute.is_getter_raises_exception %} | 51 attribute.is_getter_raises_exception %} |
| 52 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na
me}}", "{{interface_name}}", holder, info.GetIsolate()); | 52 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na
me}}", "{{interface_name}}", holder, info.GetIsolate()); |
| 53 {% endif %} | 53 {% endif %} |
| 54 {% if attribute.is_nullable %} | 54 {% if attribute.is_nullable and not attribute.has_strict_type_checking %} |
| 55 bool isNull = false; | 55 bool isNull = false; |
| 56 {% endif %} | 56 {% endif %} |
| 57 {# FIXME: consider always using a local variable for value #} | 57 {# FIXME: consider always using a local variable for value #} |
| 58 {% if attribute.cached_attribute_validation_method or | 58 {% if attribute.cached_attribute_validation_method or |
| 59 attribute.is_getter_raises_exception or | 59 attribute.is_getter_raises_exception or |
| 60 attribute.is_nullable or | 60 attribute.is_nullable or |
| 61 attribute.reflect_only or | 61 attribute.reflect_only or |
| 62 attribute.idl_type == 'EventHandler' %} | 62 attribute.idl_type == 'EventHandler' %} |
| 63 {{attribute.cpp_type}} {{attribute.cpp_value}} = {{attribute.cpp_value_origi
nal}}; | 63 {{attribute.cpp_type}} {{attribute.cpp_value}} = {{attribute.cpp_value_origi
nal}}; |
| 64 {% endif %} | 64 {% endif %} |
| 65 {# Checks #} | 65 {# Checks #} |
| 66 {% if attribute.is_getter_raises_exception %} | 66 {% if attribute.is_getter_raises_exception %} |
| 67 if (UNLIKELY(exceptionState.throwIfNeeded())) | 67 if (UNLIKELY(exceptionState.throwIfNeeded())) |
| 68 return; | 68 return; |
| 69 {% endif %} | 69 {% endif %} |
| 70 {% if attribute.is_check_security_for_node %} | 70 {% if attribute.is_check_security_for_node %} |
| 71 {# FIXME: use a local variable to not call getter twice #} | 71 {# FIXME: use a local variable to not call getter twice #} |
| 72 if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), {{attribute
.cpp_value}}, exceptionState)) { | 72 if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), {{attribute
.cpp_value}}, exceptionState)) { |
| 73 v8SetReturnValueNull(info); | 73 v8SetReturnValueNull(info); |
| 74 exceptionState.throwIfNeeded(); | 74 exceptionState.throwIfNeeded(); |
| 75 return; | 75 return; |
| 76 } | 76 } |
| 77 {% endif %} | 77 {% endif %} |
| 78 {% if attribute.reflect_only %} | 78 {% if attribute.reflect_only %} |
| 79 {{release_only_check(attribute.reflect_only, attribute.reflect_missing, | 79 {{release_only_check(attribute.reflect_only, attribute.reflect_missing, |
| 80 attribute.reflect_invalid, attribute.reflect_empty) | 80 attribute.reflect_invalid, attribute.reflect_empty) |
| 81 | indent}} | 81 | indent}} |
| 82 {% endif %} | 82 {% endif %} |
| 83 {% if attribute.is_nullable %} | 83 {% if attribute.is_nullable %} |
| 84 {% if attribute.has_strict_type_checking %} |
| 85 if (!{{attribute.cpp_value}}) { |
| 86 {% else %} |
| 84 if (isNull) { | 87 if (isNull) { |
| 88 {% endif %} |
| 85 v8SetReturnValueNull(info); | 89 v8SetReturnValueNull(info); |
| 86 return; | 90 return; |
| 87 } | 91 } |
| 88 {% endif %} | 92 {% endif %} |
| 89 {% if attribute.cached_attribute_validation_method %} | 93 {% if attribute.cached_attribute_validation_method %} |
| 90 V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, propertyName, {{att
ribute.cpp_value}}.v8Value()); | 94 V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, propertyName, {{att
ribute.cpp_value}}.v8Value()); |
| 91 {% endif %} | 95 {% endif %} |
| 92 {# v8SetReturnValue #} | 96 {# v8SetReturnValue #} |
| 93 {% if attribute.is_keep_alive_for_gc %} | 97 {% if attribute.is_keep_alive_for_gc %} |
| 94 {# FIXME: merge local variable assignment with above #} | 98 {# FIXME: merge local variable assignment with above #} |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 {% if not attribute.is_static %} | 217 {% if not attribute.is_static %} |
| 214 v8::Handle<v8::Object> holder = info.Holder(); | 218 v8::Handle<v8::Object> holder = info.Holder(); |
| 215 {% endif %} | 219 {% endif %} |
| 216 {% if attribute.has_setter_exception_state %} | 220 {% if attribute.has_setter_exception_state %} |
| 217 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na
me}}", "{{interface_name}}", holder, info.GetIsolate()); | 221 ExceptionState exceptionState(ExceptionState::SetterContext, "{{attribute.na
me}}", "{{interface_name}}", holder, info.GetIsolate()); |
| 218 {% endif %} | 222 {% endif %} |
| 219 {# Type checking #} | 223 {# Type checking #} |
| 220 {% if attribute.has_strict_type_checking %} | 224 {% if attribute.has_strict_type_checking %} |
| 221 {# Type checking for interface types (if interface not implemented, throw | 225 {# Type checking for interface types (if interface not implemented, throw |
| 222 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} | 226 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} |
| 223 if (!isUndefinedOrNull(v8Value) && !V8{{attribute.idl_type}}::hasInstance(v8
Value, info.GetIsolate())) { | 227 if ({% if attribute.is_nullable %}!isUndefinedOrNull(v8Value) && {% endif %}
!V8{{attribute.idl_type}}::hasInstance(v8Value, info.GetIsolate())) { |
| 224 exceptionState.throwTypeError("The provided value is not of type '{{attr
ibute.idl_type}}'."); | 228 exceptionState.throwTypeError("The provided value is not of type '{{attr
ibute.idl_type}}'."); |
| 225 exceptionState.throwIfNeeded(); | 229 exceptionState.throwIfNeeded(); |
| 226 return; | 230 return; |
| 227 } | 231 } |
| 228 {% endif %} | 232 {% endif %} |
| 229 {# impl #} | 233 {# impl #} |
| 230 {% if attribute.put_forwards %} | 234 {% if attribute.put_forwards %} |
| 231 {{cpp_class}}* proxyImpl = {{v8_class}}::toNative(holder); | 235 {{cpp_class}}* proxyImpl = {{v8_class}}::toNative(holder); |
| 232 {{attribute.ref_ptr}}<{{attribute.idl_type}}> impl = WTF::getPtr(proxyImpl->
{{attribute.name}}()); | 236 {{attribute.ref_ptr}}<{{attribute.idl_type}}> impl = WTF::getPtr(proxyImpl->
{{attribute.name}}()); |
| 233 if (!impl) | 237 if (!impl) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 {% endif %} | 315 {% endif %} |
| 312 {% if attribute.has_custom_setter %} | 316 {% if attribute.has_custom_setter %} |
| 313 {{v8_class}}::{{attribute.name}}AttributeSetterCustom(v8Value, info); | 317 {{v8_class}}::{{attribute.name}}AttributeSetterCustom(v8Value, info); |
| 314 {% else %} | 318 {% else %} |
| 315 {{cpp_class}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffix}}(v
8Value, info); | 319 {{cpp_class}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffix}}(v
8Value, info); |
| 316 {% endif %} | 320 {% endif %} |
| 317 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 321 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 318 } | 322 } |
| 319 {% endfilter %} | 323 {% endfilter %} |
| 320 {% endmacro %} | 324 {% endmacro %} |
| OLD | NEW |