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

Side by Side Diff: third_party/WebKit/Source/bindings/templates/attributes.cpp.tmpl

Issue 2647643002: Fix V8 bindings for named constructors to set prototype object correctly (Closed)
Patch Set: Review feedback Created 3 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
OLDNEW
1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t o_local_cpp_value %} 1 {% from 'utilities.cpp.tmpl' import declare_enum_validation_variable, v8_value_t o_local_cpp_value %}
2 2
3 {##############################################################################} 3 {##############################################################################}
4 {% macro attribute_getter(attribute, world_suffix) %} 4 {% macro attribute_getter(attribute, world_suffix) %}
5 static void {{attribute.name}}AttributeGetter{{world_suffix}}( 5 static void {{attribute.name}}AttributeGetter{{world_suffix}}(
6 {%- if attribute.is_data_type_property %} 6 {%- if attribute.is_data_type_property %}
7 const v8::PropertyCallbackInfo<v8::Value>& info 7 const v8::PropertyCallbackInfo<v8::Value>& info
8 {%- else %} 8 {%- else %}
9 const v8::FunctionCallbackInfo<v8::Value>& info 9 const v8::FunctionCallbackInfo<v8::Value>& info
10 {%- endif %}) { 10 {%- endif %}) {
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 } 418 }
419 {% endmacro %} 419 {% endmacro %}
420 420
421 421
422 {##############################################################################} 422 {##############################################################################}
423 {% macro attribute_configuration(attribute) %} 423 {% macro attribute_configuration(attribute) %}
424 {% from 'utilities.cpp.tmpl' import property_location %} 424 {% from 'utilities.cpp.tmpl' import property_location %}
425 {% if attribute.constructor_type %} 425 {% if attribute.constructor_type %}
426 {% set getter_callback = 426 {% set getter_callback =
427 '%sV8Internal::%sConstructorGetterCallback' % (cpp_class_or_partial, attr ibute.name) 427 '%sV8Internal::%sConstructorGetterCallback' % (cpp_class_or_partial, attr ibute.name)
428 if attribute.needs_constructor_getter_callback else 428 if attribute.needs_constructor_getter_callback else
haraken 2017/01/25 03:37:16 Can you clean up the if-else clause? If-else-if-el
sashab 2017/01/25 04:54:15 Changed to actual {% if %} and {% else %} statemen
429 'v8ConstructorAttributeGetter' %} 429 ('V8%s::NamedConstructorAttributeGetter' % (attribute.constructor_type)
430 if attribute.is_named_constructor else
431 'v8ConstructorAttributeGetter') %}
430 {% set setter_callback = '0' %} 432 {% set setter_callback = '0' %}
431 {% else %}{# regular attributes #} 433 {% else %}{# regular attributes #}
432 {% set getter_callback = '%sV8Internal::%sAttributeGetterCallback' % 434 {% set getter_callback = '%sV8Internal::%sAttributeGetterCallback' %
433 (cpp_class_or_partial, attribute.name) %} 435 (cpp_class_or_partial, attribute.name) %}
434 {% set setter_callback = '%sV8Internal::%sAttributeSetterCallback' % 436 {% set setter_callback = '%sV8Internal::%sAttributeSetterCallback' %
435 (cpp_class_or_partial, attribute.name) 437 (cpp_class_or_partial, attribute.name)
436 if attribute.has_setter else '0' %} 438 if attribute.has_setter else '0' %}
437 {% endif %} 439 {% endif %}
438 {% set getter_callback_for_main_world = 440 {% set getter_callback_for_main_world =
439 '%sForMainWorld' % getter_callback 441 '%sForMainWorld' % getter_callback
440 if attribute.is_per_world_bindings else '0' %} 442 if attribute.is_per_world_bindings else '0' %}
441 {% set setter_callback_for_main_world = 443 {% set setter_callback_for_main_world =
442 '%sForMainWorld' % setter_callback 444 '%sForMainWorld' % setter_callback
443 if attribute.is_per_world_bindings and attribute.has_setter else '0' %} 445 if attribute.is_per_world_bindings and attribute.has_setter else '0' %}
444 {% set wrapper_type_info = 446 {% set wrapper_type_info =
445 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' % 447 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' %
446 attribute.constructor_type 448 attribute.constructor_type
447 if attribute.constructor_type else '0' %} 449 if attribute.constructor_type and not attribute.is_named_constructor else '0' %}
haraken 2017/01/25 03:37:16 Is this change needed?
sashab 2017/01/25 04:54:15 Nit suggested by yuki: "Since you no longer need |
448 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % 450 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' %
449 ' | '.join(attribute.property_attributes) %} 451 ' | '.join(attribute.property_attributes) %}
450 {% set cached_accessor_callback = 452 {% set cached_accessor_callback =
451 '%sV8Internal::%sCachedAccessorCallback' % (cpp_class_or_partial, attribu te.name) 453 '%sV8Internal::%sCachedAccessorCallback' % (cpp_class_or_partial, attribu te.name)
452 if attribute.is_cached_accessor else 454 if attribute.is_cached_accessor else
453 'nullptr' %} 455 'nullptr' %}
454 {% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder' 456 {% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder'
455 if attribute.is_lenient_this else 'V8DOMConfiguration::CheckHolder' %} 457 if attribute.is_lenient_this else 'V8DOMConfiguration::CheckHolder' %}
456 {% set attribute_configuration_list = [ 458 {% set attribute_configuration_list = [
457 '"%s"' % attribute.name, 459 '"%s"' % attribute.name,
458 getter_callback, 460 getter_callback,
459 setter_callback, 461 setter_callback,
460 getter_callback_for_main_world, 462 getter_callback_for_main_world,
461 setter_callback_for_main_world, 463 setter_callback_for_main_world,
462 cached_accessor_callback, 464 cached_accessor_callback,
463 wrapper_type_info, 465 wrapper_type_info,
464 property_attribute, 466 property_attribute,
465 property_location(attribute), 467 property_location(attribute),
466 holder_check, 468 holder_check,
467 ] %} 469 ] %}
468 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} 470 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
469 {%- endmacro %} 471 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698