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

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

Issue 2758893002: Slim V8DOMConfiguration structs for attributes and accessors. (Closed)
Patch Set: Created 3 years, 9 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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 if attribute.is_named_constructor else 'v8ConstructorAttributeGetter' %} 468 if attribute.is_named_constructor else 'v8ConstructorAttributeGetter' %}
469 {% endif %} 469 {% endif %}
470 {% set setter_callback = 'nullptr' %} 470 {% set setter_callback = 'nullptr' %}
471 {% else %}{# regular attributes #} 471 {% else %}{# regular attributes #}
472 {% set getter_callback = '%s::%sAttributeGetterCallback' % 472 {% set getter_callback = '%s::%sAttributeGetterCallback' %
473 (v8_class_or_partial, attribute.name) %} 473 (v8_class_or_partial, attribute.name) %}
474 {% set setter_callback = '%s::%sAttributeSetterCallback' % 474 {% set setter_callback = '%s::%sAttributeSetterCallback' %
475 (v8_class_or_partial, attribute.name) 475 (v8_class_or_partial, attribute.name)
476 if attribute.has_setter else 'nullptr' %} 476 if attribute.has_setter else 'nullptr' %}
477 {% endif %} 477 {% endif %}
478 {% set getter_callback_for_main_world =
479 '%sForMainWorld' % getter_callback
480 if attribute.is_per_world_bindings else 'nullptr' %}
481 {% set setter_callback_for_main_world =
482 '%sForMainWorld' % setter_callback
483 if attribute.is_per_world_bindings and attribute.has_setter else 'nullptr ' %}
484 {% set wrapper_type_info = 478 {% set wrapper_type_info =
485 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' % attribute.constr uctor_type 479 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' % attribute.constr uctor_type
486 if attribute.constructor_type else 'nullptr' %} 480 if attribute.constructor_type else 'nullptr' %}
487 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % 481 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' %
488 ' | '.join(attribute.property_attributes) %} 482 ' | '.join(attribute.property_attributes) %}
489 {% set cached_accessor_callback = 483 {% set cached_accessor_callback =
490 '%s::%sCachedAccessorCallback' % (v8_class_or_partial, attribute.name) 484 '%s::%sCachedAccessorCallback' % (v8_class_or_partial, attribute.name)
491 if attribute.is_cached_accessor else 485 if attribute.is_cached_accessor else
492 'nullptr' %} 486 'nullptr' %}
493 {% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder' 487 {% set holder_check = 'V8DOMConfiguration::DoNotCheckHolder'
494 if attribute.is_lenient_this else 'V8DOMConfiguration::CheckHolder' %} 488 if attribute.is_lenient_this else 'V8DOMConfiguration::CheckHolder' %}
495 {% set attribute_configuration_list = [ 489 {% if attribute.is_per_world_bindings %}
496 '"%s"' % attribute.name, 490 {% set getter_callback_for_main_world = '%sForMainWorld' % getter_callback %}
497 getter_callback, 491 {% set setter_callback_for_main_world =
498 setter_callback, 492 '%sForMainWorld' % setter_callback
499 getter_callback_for_main_world, 493 if attribute.has_setter else 'nullptr' %}
500 setter_callback_for_main_world, 494 {"{{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::MainWorld},
501 cached_accessor_callback, 495 {"{{attribute.name}}", {{getter_callback}}, {{setter_callback}}, {{cached_access or_callback}}, {{wrapper_type_info}}, {{property_attribute}}, {{property_locatio n(attribute)}}, {{holder_check}}, V8DOMConfiguration::NonMainWorlds}
502 wrapper_type_info, 496 {%- else %}
503 property_attribute, 497 {"{{attribute.name}}", {{getter_callback}}, {{setter_callback}}, {{cached_access or_callback}}, {{wrapper_type_info}}, {{property_attribute}}, {{property_locatio n(attribute)}}, {{holder_check}}, V8DOMConfiguration::AllWorlds}
504 property_location(attribute), 498 {%- endif %}
505 holder_check,
506 ] %}
507 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}}
508 {%- endmacro %} 499 {%- endmacro %}
509 500
510 {##############################################################################} 501 {##############################################################################}
511 {% macro install_conditionally_enabled_attributes_on_prototype() %} 502 {% macro install_conditionally_enabled_attributes_on_prototype() %}
512 {% for attribute in attributes if (attribute.exposed_test or attribute.secure_co ntext_test) and attribute.on_prototype %} 503 {% for attribute in attributes if (attribute.exposed_test or attribute.secure_co ntext_test) and attribute.on_prototype %}
513 {% filter exposed(attribute.exposed_test) %} 504 {% filter exposed(attribute.exposed_test) %}
514 {% filter secure_context(attribute.secure_context_test) %} 505 {% filter secure_context(attribute.secure_context_test) %}
515 {% filter runtime_enabled(attribute.runtime_enabled_feature_name) %} 506 {% filter runtime_enabled(attribute.runtime_enabled_feature_name) %}
516 const V8DOMConfiguration::AccessorConfiguration accessorConfiguration = {{attrib ute_configuration(attribute)}}; 507 static const V8DOMConfiguration::AccessorConfiguration accessorConfiguration[] = {
517 V8DOMConfiguration::installAccessor(isolate, world, v8::Local<v8::Object>(), pro totypeObject, interfaceObject, signature, accessorConfiguration); 508 {{attribute_configuration(attribute)}}
509 };
510 for (const auto& accessorConfig : accessorConfiguration)
511 V8DOMConfiguration::installAccessor(isolate, world, v8::Local<v8::Object>(), p rototypeObject, interfaceObject, signature, accessorConfig);
518 {% endfilter %}{# runtime_enabled #} 512 {% endfilter %}{# runtime_enabled #}
519 {% endfilter %}{# secure_context #} 513 {% endfilter %}{# secure_context #}
520 {% endfilter %}{# exposed #} 514 {% endfilter %}{# exposed #}
521 {% endfor %} 515 {% endfor %}
522 {% endmacro %} 516 {% endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698