| 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 30 matching lines...) Expand all Loading... |
| 41 {% if attribute.is_call_with_script_state %} | 41 {% if attribute.is_call_with_script_state %} |
| 42 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); | 42 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); |
| 43 {% endif %} | 43 {% endif %} |
| 44 {% if attribute.is_check_security_for_node or | 44 {% if attribute.is_check_security_for_node or |
| 45 attribute.is_getter_raises_exception %} | 45 attribute.is_getter_raises_exception %} |
| 46 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na
me}}", "{{interface_name}}", holder, info.GetIsolate()); | 46 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na
me}}", "{{interface_name}}", holder, info.GetIsolate()); |
| 47 {% endif %} | 47 {% endif %} |
| 48 {% if attribute.is_nullable and not attribute.has_type_checking_nullable %} | 48 {% if attribute.is_nullable and not attribute.has_type_checking_nullable %} |
| 49 bool isNull = false; | 49 bool isNull = false; |
| 50 {% endif %} | 50 {% endif %} |
| 51 {# FIXME: consider always using a local variable for value #} | 51 {% if attribute.cpp_value_original %} |
| 52 {% if attribute.cached_attribute_validation_method or | 52 {{attribute.cpp_type}} {{attribute.cpp_value}}({{attribute.cpp_value_origina
l}}); |
| 53 attribute.is_getter_raises_exception or | |
| 54 attribute.is_nullable or | |
| 55 attribute.reflect_only or | |
| 56 attribute.idl_type == 'EventHandler' %} | |
| 57 {{attribute.cpp_type}} {{attribute.cpp_value}} = {{attribute.cpp_value_origi
nal}}; | |
| 58 {% endif %} | 53 {% endif %} |
| 59 {# Checks #} | 54 {# Checks #} |
| 60 {% if attribute.is_getter_raises_exception %} | 55 {% if attribute.is_getter_raises_exception %} |
| 61 if (UNLIKELY(exceptionState.throwIfNeeded())) | 56 if (UNLIKELY(exceptionState.throwIfNeeded())) |
| 62 return; | 57 return; |
| 63 {% endif %} | 58 {% endif %} |
| 64 {% if attribute.is_check_security_for_node %} | 59 {% if attribute.is_check_security_for_node %} |
| 65 if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), {{attribute
.cpp_value}}, exceptionState)) { | 60 if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), {{attribute
.cpp_value}}, exceptionState)) { |
| 66 v8SetReturnValueNull(info); | 61 v8SetReturnValueNull(info); |
| 67 exceptionState.throwIfNeeded(); | 62 exceptionState.throwIfNeeded(); |
| 68 return; | 63 return; |
| 69 } | 64 } |
| 70 {% endif %} | 65 {% endif %} |
| 71 {% if attribute.reflect_only %} | 66 {% if attribute.reflect_only %} |
| 72 {{release_only_check(attribute.reflect_only, attribute.reflect_missing, | 67 {{release_only_check(attribute.reflect_only, attribute.reflect_missing, |
| 73 attribute.reflect_invalid, attribute.reflect_empty) | 68 attribute.reflect_invalid, attribute.reflect_empty, |
| 69 attribute.cpp_value) |
| 74 | indent}} | 70 | indent}} |
| 75 {% endif %} | 71 {% endif %} |
| 76 {% if attribute.is_nullable %} | 72 {% if attribute.is_nullable %} |
| 77 {% if attribute.has_type_checking_nullable %} | 73 {% if attribute.has_type_checking_nullable %} |
| 78 if (!{{attribute.cpp_value}}) { | 74 if (!{{attribute.cpp_value}}) { |
| 79 {% else %} | 75 {% else %} |
| 80 if (isNull) { | 76 if (isNull) { |
| 81 {% endif %} | 77 {% endif %} |
| 82 v8SetReturnValueNull(info); | 78 v8SetReturnValueNull(info); |
| 83 return; | 79 return; |
| 84 } | 80 } |
| 85 {% endif %} | 81 {% endif %} |
| 86 {% if attribute.cached_attribute_validation_method %} | 82 {% if attribute.cached_attribute_validation_method %} |
| 87 V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, propertyName, {{att
ribute.cpp_value_to_v8_value}}); | 83 V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, propertyName, {{att
ribute.cpp_value_to_v8_value}}); |
| 88 {% endif %} | 84 {% endif %} |
| 89 {# v8SetReturnValue #} | 85 {# v8SetReturnValue #} |
| 90 {% if attribute.is_keep_alive_for_gc %} | 86 {% if attribute.is_keep_alive_for_gc %} |
| 91 {# FIXME: merge local variable assignment with above #} | 87 if ({{attribute.cpp_value}} && DOMDataStore::setReturnValueFromWrapper{{worl
d_suffix}}<{{attribute.v8_type}}>(info.GetReturnValue(), {{attribute.cpp_value}}
.get())) |
| 92 {{attribute.cpp_type}} result({{attribute.cpp_value}}); | |
| 93 if (result && DOMDataStore::setReturnValueFromWrapper{{world_suffix}}<{{attr
ibute.v8_type}}>(info.GetReturnValue(), result.get())) | |
| 94 return; | 88 return; |
| 95 v8::Handle<v8::Value> wrapper = toV8(result.get(), holder, info.GetIsolate()
); | 89 v8::Handle<v8::Value> wrapper = toV8({{attribute.cpp_value}}.get(), holder,
info.GetIsolate()); |
| 96 if (!wrapper.IsEmpty()) { | 90 if (!wrapper.IsEmpty()) { |
| 97 V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, v8AtomicString(
info.GetIsolate(), "{{attribute.name}}"), wrapper); | 91 V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, v8AtomicString(
info.GetIsolate(), "{{attribute.name}}"), wrapper); |
| 98 {{attribute.v8_set_return_value}}; | 92 {{attribute.v8_set_return_value}}; |
| 99 } | 93 } |
| 100 {% elif world_suffix %} | 94 {% elif world_suffix %} |
| 101 {{attribute.v8_set_return_value_for_main_world}}; | 95 {{attribute.v8_set_return_value_for_main_world}}; |
| 102 {% else %} | 96 {% else %} |
| 103 {{attribute.v8_set_return_value}}; | 97 {{attribute.v8_set_return_value}}; |
| 104 {% endif %} | 98 {% endif %} |
| 105 } | 99 } |
| 106 {% endfilter %} | 100 {% endfilter %} |
| 107 {% endmacro %} | 101 {% endmacro %} |
| 108 | 102 |
| 109 {######################################} | 103 {######################################} |
| 110 {% macro release_only_check(reflect_only_values, reflect_missing, | 104 {% macro release_only_check(reflect_only_values, reflect_missing, |
| 111 reflect_invalid, reflect_empty) %} | 105 reflect_invalid, reflect_empty, cpp_value) %} |
| 112 {# Attribute is limited to only known values: check that the attribute value is | 106 {# Attribute is limited to only known values: check that the attribute value is |
| 113 one of those. If not, set it to the empty string. | 107 one of those. If not, set it to the empty string. |
| 114 http://www.whatwg.org/specs/web-apps/current-work/#limited-to-only-known-valu
es #} | 108 http://www.whatwg.org/specs/web-apps/current-work/#limited-to-only-known-valu
es #} |
| 115 {% if reflect_empty %} | 109 {% if reflect_empty %} |
| 116 if (v8Value.isNull()) { | 110 if ({{cpp_value}}.isNull()) { |
| 117 {% if reflect_missing %} | 111 {% if reflect_missing %} |
| 118 v8Value = "{{reflect_missing}}"; | 112 {{cpp_value}} = "{{reflect_missing}}"; |
| 119 {% else %} | 113 {% else %} |
| 120 ; | 114 ; |
| 121 {% endif %} | 115 {% endif %} |
| 122 } else if (v8Value.isEmpty()) { | 116 } else if ({{cpp_value}}.isEmpty()) { |
| 123 v8Value = "{{reflect_empty}}"; | 117 {{cpp_value}} = "{{reflect_empty}}"; |
| 124 {% else %} | 118 {% else %} |
| 125 if (v8Value.isEmpty()) { | 119 if ({{cpp_value}}.isEmpty()) { |
| 126 {# FIXME: should use [ReflectEmpty] instead; need to change IDL files #} | 120 {# FIXME: should use [ReflectEmpty] instead; need to change IDL files #} |
| 127 {% if reflect_missing %} | 121 {% if reflect_missing %} |
| 128 v8Value = "{{reflect_missing}}"; | 122 {{cpp_value}} = "{{reflect_missing}}"; |
| 129 {% else %} | 123 {% else %} |
| 130 ; | 124 ; |
| 131 {% endif %} | 125 {% endif %} |
| 132 {% endif %} | 126 {% endif %} |
| 133 {% for value in reflect_only_values %} | 127 {% for value in reflect_only_values %} |
| 134 } else if (equalIgnoringCase(v8Value, "{{value}}")) { | 128 } else if (equalIgnoringCase({{cpp_value}}, "{{value}}")) { |
| 135 v8Value = "{{value}}"; | 129 {{cpp_value}} = "{{value}}"; |
| 136 {% endfor %} | 130 {% endfor %} |
| 137 } else { | 131 } else { |
| 138 v8Value = "{{reflect_invalid}}"; | 132 {{cpp_value}} = "{{reflect_invalid}}"; |
| 139 } | 133 } |
| 140 {% endmacro %} | 134 {% endmacro %} |
| 141 | 135 |
| 142 | 136 |
| 143 {##############################################################################} | 137 {##############################################################################} |
| 144 {% macro attribute_getter_callback(attribute, world_suffix) %} | 138 {% macro attribute_getter_callback(attribute, world_suffix) %} |
| 145 {% filter conditional(attribute.conditional_string) %} | 139 {% filter conditional(attribute.conditional_string) %} |
| 146 static void {{attribute.name}}AttributeGetterCallback{{world_suffix}}( | 140 static void {{attribute.name}}AttributeGetterCallback{{world_suffix}}( |
| 147 {%- if attribute.is_expose_js_accessors %} | 141 {%- if attribute.is_expose_js_accessors %} |
| 148 const v8::FunctionCallbackInfo<v8::Value>& info | 142 const v8::FunctionCallbackInfo<v8::Value>& info |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 {% endif %} | 331 {% endif %} |
| 338 {% if attribute.has_custom_setter %} | 332 {% if attribute.has_custom_setter %} |
| 339 {{v8_class}}::{{attribute.name}}AttributeSetterCustom(v8Value, info); | 333 {{v8_class}}::{{attribute.name}}AttributeSetterCustom(v8Value, info); |
| 340 {% else %} | 334 {% else %} |
| 341 {{cpp_class}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffix}}(v
8Value, info); | 335 {{cpp_class}}V8Internal::{{attribute.name}}AttributeSetter{{world_suffix}}(v
8Value, info); |
| 342 {% endif %} | 336 {% endif %} |
| 343 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); | 337 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| 344 } | 338 } |
| 345 {% endfilter %} | 339 {% endfilter %} |
| 346 {% endmacro %} | 340 {% endmacro %} |
| OLD | NEW |