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

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

Issue 2875583002: AccessorConfiguration and AttributeConfiguration no longer need the same fields. (Closed)
Patch Set: whitespace changes Created 3 years, 7 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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 {% elif attribute.has_cross_origin_setter %} 462 {% elif attribute.has_cross_origin_setter %}
463 {{cpp_class_or_partial}}V8Internal::{{attribute.name}}AttributeSetter(v8Value, V8CrossOriginSetterInfo(info.GetIsolate(), info.Holder())); 463 {{cpp_class_or_partial}}V8Internal::{{attribute.name}}AttributeSetter(v8Value, V8CrossOriginSetterInfo(info.GetIsolate(), info.Holder()));
464 {% else %} 464 {% else %}
465 {{cpp_class_or_partial}}V8Internal::{{attribute.name}}AttributeSetter{{world_s uffix}}(v8Value, info); 465 {{cpp_class_or_partial}}V8Internal::{{attribute.name}}AttributeSetter{{world_s uffix}}(v8Value, info);
466 {% endif %} 466 {% endif %}
467 } 467 }
468 {% endmacro %} 468 {% endmacro %}
469 469
470 470
471 {##############################################################################} 471 {##############################################################################}
472 {% macro attribute_configuration(attribute) %} 472 {% macro build_attribute_or_accessor_configuration(attribute, config_type) %}
473 {% from 'utilities.cpp.tmpl' import property_location %} 473 {% from 'utilities.cpp.tmpl' import property_location %}
474 {% if attribute.constructor_type %} 474 {% if attribute.constructor_type %}
475 {% if attribute.needs_constructor_getter_callback %} 475 {% if attribute.needs_constructor_getter_callback %}
476 {% set getter_callback = '%s::%sConstructorGetterCallback' % (v8_class_or_pa rtial, attribute.name) %} 476 {% set getter_callback = '%s::%sConstructorGetterCallback' % (v8_class_or_pa rtial, attribute.name) %}
477 {% else %} 477 {% else %}
478 {% set getter_callback = 'V8%s::NamedConstructorAttributeGetter' % (attribut e.constructor_type) 478 {% set getter_callback = 'V8%s::NamedConstructorAttributeGetter' % (attribut e.constructor_type)
479 if attribute.is_named_constructor else 'V8ConstructorAttributeGetter' %} 479 if attribute.is_named_constructor else 'V8ConstructorAttributeGetter' %}
480 {% endif %} 480 {% endif %}
481 {% set setter_callback = 'nullptr' %} 481 {% set setter_callback = 'nullptr' %}
482 {% else %}{# regular attributes #} 482 {% else %}{# regular attributes #}
483 {% set getter_callback = '%s::%sAttributeGetterCallback' % 483 {% set getter_callback = '%s::%sAttributeGetterCallback' %
484 (v8_class_or_partial, attribute.name) %} 484 (v8_class_or_partial, attribute.name) %}
485 {% set setter_callback = '%s::%sAttributeSetterCallback' % 485 {% set setter_callback = '%s::%sAttributeSetterCallback' %
486 (v8_class_or_partial, attribute.name) 486 (v8_class_or_partial, attribute.name)
487 if attribute.has_setter else 'nullptr' %} 487 if attribute.has_setter else 'nullptr' %}
488 {% endif %} 488 {% endif %}
489 {% set wrapper_type_info = 489 {% set wrapper_type_info =
490 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' % attribute.constr uctor_type 490 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' % attribute.constr uctor_type
491 if attribute.constructor_type else 'nullptr' %} 491 if attribute.constructor_type else 'nullptr' %}
492 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % 492 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' %
493 ' | '.join(attribute.property_attributes) %} 493 ' | '.join(attribute.property_attributes) %}
494 {% set cached_accessor_callback = 494 {% set cached_property_key =
495 '%s::%sCachedPropertyKey' % (v8_class_or_partial, attribute.name) 495 '%s::%sCachedPropertyKey' % (v8_class_or_partial, attribute.name)
496 if attribute.is_cached_accessor else 496 if attribute.is_cached_accessor else
497 'nullptr' %} 497 'nullptr' %}
498 {% set holder_check = 'V8DOMConfiguration::kDoNotCheckHolder' 498 {% set holder_check = 'V8DOMConfiguration::kDoNotCheckHolder'
499 if attribute.is_lenient_this else 'V8DOMConfiguration::kCheckHolder' %} 499 if attribute.is_lenient_this else 'V8DOMConfiguration::kCheckHolder' %}
500 {% if attribute.is_per_world_bindings %} 500 {% if attribute.is_per_world_bindings %}
501 {% set getter_callback_for_main_world = '%sForMainWorld' % getter_callback %} 501 {% set getter_callback_for_main_world = '%sForMainWorld' % getter_callback %}
502 {% set setter_callback_for_main_world = 502 {% set setter_callback_for_main_world =
503 '%sForMainWorld' % setter_callback 503 '%sForMainWorld' % setter_callback
504 if attribute.has_setter else 'nullptr' %} 504 if attribute.has_setter else 'nullptr' %}
505 {"{{attribute.name}}", {{getter_callback_for_main_world}}, {{setter_callback_for _main_world}}, {{cached_accessor_callback}}, {{wrapper_type_info}}, {{property_a ttribute}}, {{property_location(attribute)}}, {{holder_check}}, V8DOMConfigurati on::kMainWorld}, 505 {% endif %}
506 {"{{attribute.name}}", {{getter_callback}}, {{setter_callback}}, {{cached_access or_callback}}, {{wrapper_type_info}}, {{property_attribute}}, {{property_locatio n(attribute)}}, {{holder_check}}, V8DOMConfiguration::kNonMainWorlds} 506
507 {%- else %} 507
508 {"{{attribute.name}}", {{getter_callback}}, {{setter_callback}}, {{cached_access or_callback}}, {{wrapper_type_info}}, {{property_attribute}}, {{property_locatio n(attribute)}}, {{holder_check}}, V8DOMConfiguration::kAllWorlds} 508 {% set config_pre = {
509 {%- endif %} 509 "main" : [
510 {%- endmacro %} 510 '"%s"' % attribute.name,
511 getter_callback_for_main_world,
512 setter_callback_for_main_world,
513 ],
514 "non_main" : [
515 '"%s"' % attribute.name,
516 getter_callback,
517 setter_callback,
518 ],
519 } %}
520
521 {% set accessor_only_fields = [] if config_type == 'attribute' else [
522 cached_property_key,
523 ] %}
524
525 {% set config_post = [
526 wrapper_type_info,
527 property_attribute,
528 property_location(attribute),
529 holder_check,
530 ] %}
531
532 {% if attribute.is_per_world_bindings %}
533 {% set main_config_list = config_pre["main"] + accessor_only_fields +
534 config_post + ['V8DOMConfiguration::kMainWorld'] %}
535 {% set non_main_config_list = config_pre["non_main"] + accessor_only_fields +
536 config_post + ['V8DOMConfiguration::kNonMainWorlds'] %}
537 {# Emit for main world then non-main.#}
538 { {{main_config_list | join(', ')}} },
539 { {{non_main_config_list | join(', ')}} }
540 {% else %}
541 {% set all_worlds_config_list = config_pre["non_main"] + accessor_only_fields +
Yuki 2017/05/10 06:58:24 nit: 80 columns
542 config_post + ['V8DOMConfiguration::kAllWorlds'] %}
543 {# Emit only for all worlds #}
544 { {{all_worlds_config_list | join(', ')}} }
545 {% endif %}
546 {% endmacro %}
547
548
549 {##############################################################################}
550 {% macro attribute_configuration(attribute) %}
551 {{build_attribute_or_accessor_configuration(attribute, 'attribute')}}
552 {% endmacro %}
553
554
555 {##############################################################################}
556 {% macro accessor_configuration(attribute) %}
557 {{build_attribute_or_accessor_configuration(attribute, 'accessor')}}
558 {% endmacro %}
559
511 560
512 {##############################################################################} 561 {##############################################################################}
513 {% macro install_conditionally_enabled_attributes_on_prototype() %} 562 {% macro install_conditionally_enabled_attributes_on_prototype() %}
514 {% for attribute in attributes if (attribute.exposed_test or attribute.secure_co ntext_test) and attribute.on_prototype %} 563 {% for attribute in attributes if (attribute.exposed_test or attribute.secure_co ntext_test) and attribute.on_prototype %}
515 {% filter exposed(attribute.exposed_test) %} 564 {% filter exposed(attribute.exposed_test) %}
516 {% filter secure_context(attribute.secure_context_test) %} 565 {% filter secure_context(attribute.secure_context_test) %}
517 {% filter runtime_enabled(attribute.runtime_enabled_feature_name) %} 566 {% filter runtime_enabled(attribute.runtime_enabled_feature_name) %}
518 static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration[] = { 567 static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration[] = {
519 {{attribute_configuration(attribute)}} 568 {{accessor_configuration(attribute)}}
520 }; 569 };
521 for (const auto& accessorConfig : accessorConfiguration) 570 for (const auto& accessorConfig : accessorConfiguration)
522 V8DOMConfiguration::InstallAccessor(isolate, world, v8::Local<v8::Object>(), p rototypeObject, interfaceObject, signature, accessorConfig); 571 V8DOMConfiguration::InstallAccessor(isolate, world, v8::Local<v8::Object>(), p rototypeObject, interfaceObject, signature, accessorConfig);
523 {% endfilter %}{# runtime_enabled #} 572 {% endfilter %}{# runtime_enabled #}
524 {% endfilter %}{# secure_context #} 573 {% endfilter %}{# secure_context #}
525 {% endfilter %}{# exposed #} 574 {% endfilter %}{# exposed #}
526 {% endfor %} 575 {% endfor %}
527 {% endmacro %} 576 {% endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698