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

Side by Side Diff: third_party/WebKit/Source/bindings/templates/interface.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 {% extends 'interface_base.cpp.tmpl' %} 1 {% extends 'interface_base.cpp.tmpl' %}
2 2
3 {##############################################################################} 3 {##############################################################################}
4 {% block indexed_property_getter %} 4 {% block indexed_property_getter %}
5 {% if indexed_property_getter and not indexed_property_getter.is_custom %} 5 {% if indexed_property_getter and not indexed_property_getter.is_custom %}
6 {% set getter = indexed_property_getter %} 6 {% set getter = indexed_property_getter %}
7 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) { 7 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) {
8 {% if getter.is_raises_exception %} 8 {% if getter.is_raises_exception %}
9 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedGetter Context, "{{interface_name}}"); 9 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedGetter Context, "{{interface_name}}");
10 {% endif %} 10 {% endif %}
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 {% else %} 645 {% else %}
646 {{cpp_class}}V8Internal::constructor(info); 646 {{cpp_class}}V8Internal::constructor(info);
647 {% endif %} 647 {% endif %}
648 } 648 }
649 649
650 {% endif %} 650 {% endif %}
651 {% endblock %} 651 {% endblock %}
652 652
653 653
654 {##############################################################################} 654 {##############################################################################}
655 {% macro install_origin_safe_method(method, world_suffix, instance_template, pro totype_template) %} 655 {% macro install_origin_safe_method(method, instance_template, prototype_templat e) %}
656 {% from 'utilities.cpp.tmpl' import property_location %} 656 {% from 'utilities.cpp.tmpl' import property_location %}
657 {# TODO(dcheng): Currently, bindings must create a function object for each 657 {# TODO(dcheng): Currently, bindings must create a function object for each
658 realm as a hack to support the incumbent realm. Clean this up when Blink 658 realm as a hack to support the incumbent realm. Clean this up when Blink
659 properly supports the incumbent realm. #} 659 properly supports the incumbent realm. #}
660 {% set getter_callback = 660 {% set getter_callback =
661 '%s::%sOriginSafeMethodGetterCallback%s' % 661 '%s::%sOriginSafeMethodGetterCallback' %
662 (v8_class_or_partial, method.name, world_suffix) %} 662 (v8_class_or_partial, method.name) %}
663 {% set setter_callback = 663 {% set setter_callback =
664 '%s::%sOriginSafeMethodSetterCallback' % (v8_class_or_partial, cpp_class) 664 '%s::%sOriginSafeMethodSetterCallback' % (v8_class_or_partial, cpp_class)
665 if not method.is_unforgeable else 'nullptr' %} 665 if not method.is_unforgeable else 'nullptr' %}
666 {% set property_attribute =
667 'static_cast<v8::PropertyAttribute>(%s)' %
668 ' | '.join(method.property_attributes or ['v8::None']) %}
669 {% set holder_check = 'V8DOMConfiguration::CheckHolder' %}
670 static const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSaf eAttributeConfiguration[] = {
666 {% if method.is_per_world_bindings %} 671 {% if method.is_per_world_bindings %}
667 {% set getter_callback_for_main_world = '%sForMainWorld' % getter_callback %} 672 {% set getter_callback_for_main_world = '%sForMainWorld' % getter_callback %}
668 {% set setter_callback_for_main_world = '%sForMainWorld' % setter_callback 673 {% set setter_callback_for_main_world = '%sForMainWorld' % setter_callback
669 if not method.is_unforgeable else 'nullptr' %} 674 if not method.is_unforgeable else 'nullptr' %}
675 {"{{method.name}}", {{getter_callback_for_main_world}}, {{setter_callback_fo r_main_world}}, nullptr, &{{v8_class}}::wrapperTypeInfo, {{property_attribute}}, {{property_location(method)}}, {{holder_check}}, V8DOMConfiguration::MainWorld} ,
676 {"{{method.name}}", {{getter_callback}}, {{setter_callback}}, nullptr, &{{v8 _class}}::wrapperTypeInfo, {{property_attribute}}, {{property_location(method)}} , {{holder_check}}, V8DOMConfiguration::NonMainWorlds}}
670 {% else %} 677 {% else %}
671 {% set getter_callback_for_main_world = 'nullptr' %} 678 {"{{method.name}}", {{getter_callback}}, {{setter_callback}}, nullptr, &{{v8 _class}}::wrapperTypeInfo, {{property_attribute}}, {{property_location(method)}} , {{holder_check}}, V8DOMConfiguration::AllWorlds}
672 {% set setter_callback_for_main_world = 'nullptr' %}
673 {% endif %} 679 {% endif %}
674 {% set property_attribute =
675 'static_cast<v8::PropertyAttribute>(%s)' %
676 ' | '.join(method.property_attributes or ['v8::None']) %}
677 {% set holder_check = 'V8DOMConfiguration::CheckHolder' %}
678 const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSafeAttrib uteConfiguration = {
679 "{{method.name}}", {{getter_callback}}, {{setter_callback}}, {{getter_callba ck_for_main_world}}, {{setter_callback_for_main_world}}, nullptr, &{{v8_class}}: :wrapperTypeInfo, {{property_attribute}}, {{property_location(method)}}, {{holde r_check}}
680 }; 680 };
681 V8DOMConfiguration::installAttribute(isolate, world, {{instance_template}}, {{pr ototype_template}}, {{method.name}}OriginSafeAttributeConfiguration); 681 for (const auto& attributeConfig : {{method.name}}OriginSafeAttributeConfigurati on)
682 V8DOMConfiguration::installAttribute(isolate, world, {{instance_template}}, {{ prototype_template}}, attributeConfig);
682 {%- endmacro %} 683 {%- endmacro %}
683 684
684 685
685 {##############################################################################} 686 {##############################################################################}
686 {% macro install_indexed_property_handler(target) %} 687 {% macro install_indexed_property_handler(target) %}
687 {% set indexed_property_getter_callback = 688 {% set indexed_property_getter_callback =
688 '%s::indexedPropertyGetterCallback' % v8_class_or_partial %} 689 '%s::indexedPropertyGetterCallback' % v8_class_or_partial %}
689 {% set indexed_property_setter_callback = 690 {% set indexed_property_setter_callback =
690 '%s::indexedPropertySetterCallback' % v8_class_or_partial 691 '%s::indexedPropertySetterCallback' % v8_class_or_partial
691 if indexed_property_setter or named_property_setter else 'nullptr' %} 692 if indexed_property_setter or named_property_setter else 'nullptr' %}
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 } 923 }
923 924
924 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} 925 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %}
925 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) { 926 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) {
926 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; 927 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method;
927 } 928 }
928 929
929 {% endfor %} 930 {% endfor %}
930 {% endif %} 931 {% endif %}
931 {% endblock %} 932 {% endblock %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698