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

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

Issue 946973005: IDL: Drop value conversion (V8 -> C++) macros from generated code (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: address comments Created 5 years, 10 months 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
« no previous file with comments | « Source/bindings/scripts/v8_union.py ('k') | Source/bindings/templates/conversions.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 {% from 'conversions.cpp' import v8_value_to_local_cpp_value %}
2
3
1 {##############################################################################} 4 {##############################################################################}
2 {% macro attribute_getter(attribute, world_suffix) %} 5 {% macro attribute_getter(attribute, world_suffix) %}
3 {% filter conditional(attribute.conditional_string) %} 6 {% filter conditional(attribute.conditional_string) %}
4 static void {{attribute.name}}AttributeGetter{{world_suffix}}( 7 static void {{attribute.name}}AttributeGetter{{world_suffix}}(
5 {%- if attribute.is_expose_js_accessors %} 8 {%- if attribute.is_expose_js_accessors %}
6 const v8::FunctionCallbackInfo<v8::Value>& info 9 const v8::FunctionCallbackInfo<v8::Value>& info
7 {%- else %} 10 {%- else %}
8 const v8::PropertyCallbackInfo<v8::Value>& info 11 const v8::PropertyCallbackInfo<v8::Value>& info
9 {%- endif %}) 12 {%- endif %})
10 { 13 {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 and is_node and not attribute.is_implemented_in_private_script %} 213 and is_node and not attribute.is_implemented_in_private_script %}
211 {% set cpp_class, v8_class = 'Element', 'V8Element' %} 214 {% set cpp_class, v8_class = 'Element', 'V8Element' %}
212 {% endif %} 215 {% endif %}
213 {# Local variables #} 216 {# Local variables #}
214 {% if not attribute.is_static %} 217 {% if not attribute.is_static %}
215 v8::Local<v8::Object> holder = info.Holder(); 218 v8::Local<v8::Object> holder = info.Holder();
216 {% endif %} 219 {% endif %}
217 {% if attribute.has_setter_exception_state %} 220 {% if attribute.has_setter_exception_state %}
218 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());
219 {% endif %} 222 {% endif %}
220 {% if attribute.use_output_parameter_for_result %}
221 {{attribute.cpp_type}} cppValue;
222 {% endif %}
223 {# impl #} 223 {# impl #}
224 {% if attribute.put_forwards %} 224 {% if attribute.put_forwards %}
225 {{cpp_class}}* proxyImpl = {{v8_class}}::toImpl(holder); 225 {{cpp_class}}* proxyImpl = {{v8_class}}::toImpl(holder);
226 {{attribute.cpp_type}} impl = WTF::getPtr(proxyImpl->{{attribute.name}}()); 226 {{attribute.cpp_type}} impl = WTF::getPtr(proxyImpl->{{attribute.name}}());
227 if (!impl) 227 if (!impl)
228 return; 228 return;
229 {% elif not attribute.is_static %} 229 {% elif not attribute.is_static %}
230 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder); 230 {{cpp_class}}* impl = {{v8_class}}::toImpl(holder);
231 {% endif %} 231 {% endif %}
232 {% if attribute.idl_type == 'EventHandler' and interface_name == 'Window' %} 232 {% if attribute.idl_type == 'EventHandler' and interface_name == 'Window' %}
233 if (!impl->document()) 233 if (!impl->document())
234 return; 234 return;
235 {% endif %} 235 {% endif %}
236 {# Convert JS value to C++ value #} 236 {# Convert JS value to C++ value #}
237 {% if attribute.idl_type != 'EventHandler' %} 237 {% if attribute.idl_type != 'EventHandler' %}
238 {{attribute.v8_value_to_local_cpp_value}}; 238 {{v8_value_to_local_cpp_value(attribute) | indent}}
239 {% elif not is_node %}{# EventHandler hack #} 239 {% elif not is_node %}{# EventHandler hack #}
240 moveEventListenerToNewWrapper(info.GetIsolate(), holder, {{attribute.event_h andler_getter_expression}}, v8Value, {{v8_class}}::eventListenerCacheIndex); 240 moveEventListenerToNewWrapper(info.GetIsolate(), holder, {{attribute.event_h andler_getter_expression}}, v8Value, {{v8_class}}::eventListenerCacheIndex);
241 {% endif %} 241 {% endif %}
242 {# Type checking, possibly throw a TypeError, per: 242 {# Type checking, possibly throw a TypeError, per:
243 http://www.w3.org/TR/WebIDL/#es-type-mapping #} 243 http://www.w3.org/TR/WebIDL/#es-type-mapping #}
244 {% if attribute.has_type_checking_interface %} 244 {% if attribute.has_type_checking_interface %}
245 {# Type checking for interface types (if interface not implemented, throw 245 {# Type checking for interface types (if interface not implemented, throw
246 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} 246 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #}
247 if (!cppValue{% if attribute.is_nullable %} && !isUndefinedOrNull(v8Value){% endif %}) { 247 if (!cppValue{% if attribute.is_nullable %} && !isUndefinedOrNull(v8Value){% endif %}) {
248 exceptionState.throwTypeError("The provided value is not of type '{{attr ibute.idl_type}}'."); 248 exceptionState.throwTypeError("The provided value is not of type '{{attr ibute.idl_type}}'.");
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 if (!scriptState->executionContext()) 342 if (!scriptState->executionContext())
343 return false; 343 return false;
344 344
345 ScriptState::Scope scope(scriptState); 345 ScriptState::Scope scope(scriptState);
346 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate()); 346 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate());
347 347
348 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() ); 348 ExceptionState exceptionState(ExceptionState::GetterContext, "{{attribute.na me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate() );
349 v8::Local<v8::Value> v8Value = PrivateScriptRunner::runDOMAttributeGetter(sc riptState, scriptStateInUserScript, "{{cpp_class}}", "{{attribute.name}}", holde r); 349 v8::Local<v8::Value> v8Value = PrivateScriptRunner::runDOMAttributeGetter(sc riptState, scriptStateInUserScript, "{{cpp_class}}", "{{attribute.name}}", holde r);
350 if (v8Value.IsEmpty()) 350 if (v8Value.IsEmpty())
351 return false; 351 return false;
352 {{attribute.private_script_v8_value_to_local_cpp_value}}; 352 {{v8_value_to_local_cpp_value(attribute.private_script_v8_value_to_local_cpp _value) | indent}}
353 RELEASE_ASSERT(!exceptionState.hadException()); 353 RELEASE_ASSERT(!exceptionState.hadException());
354 *result = cppValue; 354 *result = cppValue;
355 return true; 355 return true;
356 } 356 }
357 {% endmacro %} 357 {% endmacro %}
358 358
359 359
360 {% macro attribute_setter_implemented_in_private_script(attribute) %} 360 {% macro attribute_setter_implemented_in_private_script(attribute) %}
361 bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeSetter(LocalFrame* frame, {{cpp_class}}* holderImpl, {{attribute.argument_cpp_type}} cppValue) 361 bool {{v8_class}}::PrivateScript::{{attribute.name}}AttributeSetter(LocalFrame* frame, {{cpp_class}}* holderImpl, {{attribute.argument_cpp_type}} cppValue)
362 { 362 {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 access_control, 423 access_control,
424 property_attribute, 424 property_attribute,
425 only_exposed_to_private_script, 425 only_exposed_to_private_script,
426 ] %} 426 ] %}
427 {% if not attribute.is_expose_js_accessors %} 427 {% if not attribute.is_expose_js_accessors %}
428 {% set attribute_configuration_list = attribute_configuration_list 428 {% set attribute_configuration_list = attribute_configuration_list
429 + [on_prototype] %} 429 + [on_prototype] %}
430 {% endif %} 430 {% endif %}
431 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 431 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
432 {%- endmacro %} 432 {%- endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_union.py ('k') | Source/bindings/templates/conversions.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698