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

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

Issue 2875583002: AccessorConfiguration and AttributeConfiguration no longer need the same fields. (Closed)
Patch Set: 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 {% filter format_blink_cpp_source_code %} 1 {% filter format_blink_cpp_source_code %}
2 2
3 {% include 'copyright_block.txt' %} 3 {% include 'copyright_block.txt' %}
4 #include "{{v8_class_or_partial}}.h" 4 #include "{{v8_class_or_partial}}.h"
5 5
6 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %} 6 {% for filename in cpp_includes if filename != '%s.h' % cpp_class_or_partial %}
7 #include "{{filename}}" 7 #include "{{filename}}"
8 {% endfor %} 8 {% endfor %}
9 9
10 namespace blink { 10 namespace blink {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 {% if not is_array_buffer_or_view %} 70 {% if not is_array_buffer_or_view %}
71 namespace {{cpp_class_or_partial}}V8Internal { 71 namespace {{cpp_class_or_partial}}V8Internal {
72 {% if has_partial_interface %} 72 {% if has_partial_interface %}
73 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} 73 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %}
74 static void (*{{method.name}}MethodForPartialInterface)(const v8::FunctionCallba ckInfo<v8::Value>&) = 0; 74 static void (*{{method.name}}MethodForPartialInterface)(const v8::FunctionCallba ckInfo<v8::Value>&) = 0;
75 {% endfor %} 75 {% endfor %}
76 {% endif %} 76 {% endif %}
77 77
78 {##############################################################################} 78 {##############################################################################}
79 {# Attributes #} 79 {# Attributes #}
80 {% from 'attributes.cpp.tmpl' import attribute_getter, attribute_setter with con text %} 80 {% from 'attributes.cpp.tmpl' import attribute_getter,
81 attribute_setter,
82 with context %}
81 {% for attribute in attributes %} 83 {% for attribute in attributes %}
82 {% for world_suffix in attribute.world_suffixes %} 84 {% for world_suffix in attribute.world_suffixes %}
83 {% if not attribute.has_custom_getter and not attribute.constructor_type %} 85 {% if not attribute.has_custom_getter and not attribute.constructor_type %}
84 {{attribute_getter(attribute, world_suffix)}} 86 {{attribute_getter(attribute, world_suffix)}}
85 {% endif %} 87 {% endif %}
86 {% if attribute.has_setter and not attribute.has_custom_setter %} 88 {% if attribute.has_setter and not attribute.has_custom_setter %}
87 {{attribute_setter(attribute, world_suffix)}} 89 {{attribute_setter(attribute, world_suffix)}}
88 {% endif %} 90 {% endif %}
89 {% endfor %} 91 {% endfor %}
90 {% endfor %} 92 {% endfor %}
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 {% endfor %} 364 {% endfor %}
363 }; 365 };
364 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) 366 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
365 #pragma clang diagnostic pop 367 #pragma clang diagnostic pop
366 #endif 368 #endif
367 369
368 {% endif %} 370 {% endif %}
369 {% endblock %} 371 {% endblock %}
370 {##############################################################################} 372 {##############################################################################}
371 {% block install_accessors %} 373 {% block install_accessors %}
372 {% from 'attributes.cpp.tmpl' import attribute_configuration with context %} 374 {% from 'attributes.cpp.tmpl' import accessor_configuration with context %}
373 {% if accessors %} 375 {% if accessors %}
374 static const V8DOMConfiguration::AccessorConfiguration {{v8_class}}Accessors[] = { 376 static const V8DOMConfiguration::AccessorConfiguration {{v8_class}}Accessors[] = {
375 {% for accessor in accessors %} 377 {% for accessor in accessors %}
376 {{attribute_configuration(accessor) | indent(4)}}, 378 {{accessor_configuration(accessor) | indent(4)}},
377 {% endfor %} 379 {% endfor %}
378 }; 380 };
379 381
380 {% endif %} 382 {% endif %}
381 {% endblock %} 383 {% endblock %}
382 {##############################################################################} 384 {##############################################################################}
383 {% block install_methods %} 385 {% block install_methods %}
384 {% from 'methods.cpp.tmpl' import method_configuration with context %} 386 {% from 'methods.cpp.tmpl' import method_configuration with context %}
385 {% if methods | has_method_configuration(is_partial) %} 387 {% if methods | has_method_configuration(is_partial) %}
386 static const V8DOMConfiguration::MethodConfiguration {{v8_class}}Methods[] = { 388 static const V8DOMConfiguration::MethodConfiguration {{v8_class}}Methods[] = {
387 {% for method in methods | has_method_configuration(is_partial) %} 389 {% for method in methods | has_method_configuration(is_partial) %}
388 {{method_configuration(method) | indent(4)}}, 390 {{method_configuration(method) | indent(4)}},
389 {% endfor %} 391 {% endfor %}
390 }; 392 };
391 393
392 {% endif %} 394 {% endif %}
393 {% endblock %} 395 {% endblock %}
394 {% endif %}{# not is_array_buffer_or_view #} 396 {% endif %}{# not is_array_buffer_or_view #}
395 {##############################################################################} 397 {##############################################################################}
396 {% block named_constructor %}{% endblock %} 398 {% block named_constructor %}{% endblock %}
397 {% block constructor_callback %}{% endblock %} 399 {% block constructor_callback %}{% endblock %}
398 {##############################################################################} 400 {##############################################################################}
399 {% block install_dom_template %} 401 {% block install_dom_template %}
400 {% if not is_array_buffer_or_view %} 402 {% if not is_array_buffer_or_view %}
401 {% from 'methods.cpp.tmpl' import install_custom_signature with context %} 403 {% from 'methods.cpp.tmpl' import install_custom_signature with context %}
402 {% from 'attributes.cpp.tmpl' import attribute_configuration with context %} 404 {% from 'attributes.cpp.tmpl' import accessor_configuration,
405 attribute_configuration,
406 with context %}
403 {% from 'constants.cpp.tmpl' import install_constants with context %} 407 {% from 'constants.cpp.tmpl' import install_constants with context %}
404 {% from 'methods.cpp.tmpl' import method_configuration with context %} 408 {% from 'methods.cpp.tmpl' import method_configuration with context %}
405 {% if has_partial_interface or is_partial %} 409 {% if has_partial_interface or is_partial %}
406 void {{v8_class_or_partial}}::install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) { 410 void {{v8_class_or_partial}}::install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) {
407 {% else %} 411 {% else %}
408 static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo rld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) { 412 static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo rld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) {
409 {% endif %} 413 {% endif %}
410 // Initialize the interface object's template. 414 // Initialize the interface object's template.
411 {% if is_partial %} 415 {% if is_partial %}
412 {{v8_class}}::install{{v8_class}}Template(isolate, world, interfaceTemplate); 416 {{v8_class}}::install{{v8_class}}Template(isolate, world, interfaceTemplate);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 {% filter runtime_enabled(feature_name) %} 485 {% filter runtime_enabled(feature_name) %}
482 {% for attribute in attribute_list | unique_by('name') | sort %} 486 {% for attribute in attribute_list | unique_by('name') | sort %}
483 {% if attribute.is_data_type_property %} 487 {% if attribute.is_data_type_property %}
484 static const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.n ame}}Configuration[] = { 488 static const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.n ame}}Configuration[] = {
485 {{attribute_configuration(attribute) | indent(2)}} 489 {{attribute_configuration(attribute) | indent(2)}}
486 }; 490 };
487 for (const auto& attributeConfig : attribute{{attribute.name}}Configuration) 491 for (const auto& attributeConfig : attribute{{attribute.name}}Configuration)
488 V8DOMConfiguration::InstallAttribute(isolate, world, instanceTemplate, proto typeTemplate, attributeConfig); 492 V8DOMConfiguration::InstallAttribute(isolate, world, instanceTemplate, proto typeTemplate, attributeConfig);
489 {% else %} 493 {% else %}
490 static const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.nam e}}Configuration[] = { 494 static const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.nam e}}Configuration[] = {
491 {{attribute_configuration(attribute) | indent(2)}} 495 {{accessor_configuration(attribute) | indent(2)}}
492 }; 496 };
493 for (const auto& accessorConfig : accessor{{attribute.name}}Configuration) 497 for (const auto& accessorConfig : accessor{{attribute.name}}Configuration)
494 V8DOMConfiguration::InstallAccessor(isolate, world, instanceTemplate, protot ypeTemplate, interfaceTemplate, signature, accessorConfig); 498 V8DOMConfiguration::InstallAccessor(isolate, world, instanceTemplate, protot ypeTemplate, interfaceTemplate, signature, accessorConfig);
495 {% endif %} 499 {% endif %}
496 {% endfor %} 500 {% endfor %}
497 {% endfilter %} 501 {% endfilter %}
498 {% endfor %} 502 {% endfor %}
499 503
500 {% if (indexed_property_getter or named_property_getter) and not is_partial %} 504 {% if (indexed_property_getter or named_property_getter) and not is_partial %}
501 // Indexed properties 505 // Indexed properties
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 {% endfilter %} 613 {% endfilter %}
610 {% endfor %} 614 {% endfor %}
611 {% endif %} 615 {% endif %}
612 } 616 }
613 617
614 {% endif %}{# not is_array_buffer_or_view #} 618 {% endif %}{# not is_array_buffer_or_view #}
615 {% endblock %} 619 {% endblock %}
616 {##############################################################################} 620 {##############################################################################}
617 {% block install_runtime_enabled %} 621 {% block install_runtime_enabled %}
618 {% if needs_runtime_enabled_installer %} 622 {% if needs_runtime_enabled_installer %}
619 {% from 'attributes.cpp.tmpl' import attribute_configuration with context %} 623 {% from 'attributes.cpp.tmpl' import accessor_configuration,
624 attribute_configuration,
625 with context %}
620 {% from 'methods.cpp.tmpl' import install_custom_signature with context %} 626 {% from 'methods.cpp.tmpl' import install_custom_signature with context %}
621 void {{v8_class_or_partial}}::installRuntimeEnabledFeatures(v8::Isolate* isolate , const DOMWrapperWorld& world, v8::Local<v8::Object> instance, v8::Local<v8::Ob ject> prototype, v8::Local<v8::Function> interface) { 627 void {{v8_class_or_partial}}::installRuntimeEnabledFeatures(v8::Isolate* isolate , const DOMWrapperWorld& world, v8::Local<v8::Object> instance, v8::Local<v8::Ob ject> prototype, v8::Local<v8::Function> interface) {
622 {% if runtime_enabled_feature_name %} 628 {% if runtime_enabled_feature_name %}
623 #error "We don't expect a runtime enabled interface {{v8_class_or_partial}} to h ave installRuntimeEnabledFeatures()." 629 #error "We don't expect a runtime enabled interface {{v8_class_or_partial}} to h ave installRuntimeEnabledFeatures()."
624 {% endif %} 630 {% endif %}
625 631
626 {% if is_partial %} 632 {% if is_partial %}
627 {{v8_class}}::installRuntimeEnabledFeatures(isolate, world, instance, prototyp e, interface); 633 {{v8_class}}::installRuntimeEnabledFeatures(isolate, world, instance, prototyp e, interface);
628 {% endif %} 634 {% endif %}
629 635
630 v8::Local<v8::FunctionTemplate> interfaceTemplate = {{v8_class}}::wrapperTypeI nfo.domTemplate(isolate, world); 636 v8::Local<v8::FunctionTemplate> interfaceTemplate = {{v8_class}}::wrapperTypeI nfo.domTemplate(isolate, world);
631 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late); 637 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late);
632 ALLOW_UNUSED_LOCAL(signature); 638 ALLOW_UNUSED_LOCAL(signature);
633 639
634 {# TODO(peria): Generate code to install constants. It depends on runtime_enab led_feaure of this interface. #} 640 {# TODO(peria): Generate code to install constants. It depends on runtime_enab led_feaure of this interface. #}
635 641
636 {% for feature_name, attrs in runtime_enabled_attributes | groupby('runtime_en abled_feature_name') %} 642 {% for feature_name, attrs in runtime_enabled_attributes | groupby('runtime_en abled_feature_name') %}
637 {% filter runtime_enabled(feature_name) %} 643 {% filter runtime_enabled(feature_name) %}
638 {% for attribute in attrs | unique_by('name') | sort %} 644 {% for attribute in attrs | unique_by('name') | sort %}
639 {% if attribute.is_data_type_property %} 645 {% if attribute.is_data_type_property %}
640 static const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.n ame}}Configuration[] = { 646 static const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.n ame}}Configuration[] = {
641 {{attribute_configuration(attribute) | indent(2)}} 647 {{attribute_configuration(attribute) | indent(2)}}
642 }; 648 };
643 for (const auto& attributeConfig : attribute{{attribute.name}}Configuration) 649 for (const auto& attributeConfig : attribute{{attribute.name}}Configuration)
644 V8DOMConfiguration::InstallAttribute(isolate, world, instance, prototype, at tributeConfig); 650 V8DOMConfiguration::InstallAttribute(isolate, world, instance, prototype, at tributeConfig);
645 {% else %} 651 {% else %}
646 static const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.nam e}}Configuration[] = { 652 static const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.nam e}}Configuration[] = {
647 {{attribute_configuration(attribute) | indent(2)}} 653 {{accessor_configuration(attribute) | indent(2)}}
648 }; 654 };
649 for (const auto& accessorConfig : accessor{{attribute.name}}Configuration) 655 for (const auto& accessorConfig : accessor{{attribute.name}}Configuration)
650 V8DOMConfiguration::InstallAccessor(isolate, world, instance, prototype, int erface, signature, accessorConfig); 656 V8DOMConfiguration::InstallAccessor(isolate, world, instance, prototype, int erface, signature, accessorConfig);
651 {% endif %} 657 {% endif %}
652 {% endfor %} 658 {% endfor %}
653 {% endfilter %} 659 {% endfilter %}
654 {% endfor %} 660 {% endfor %}
655 661
656 {% if iterator_method and iterator_method.runtime_enabled_feature_name %} 662 {% if iterator_method and iterator_method.runtime_enabled_feature_name %}
657 {% filter exposed(iterator_method.exposed_test) %} 663 {% filter exposed(iterator_method.exposed_test) %}
(...skipping 21 matching lines...) Expand all
679 {% endif %} 685 {% endif %}
680 {% endfilter %} 686 {% endfilter %}
681 {% endfor %} 687 {% endfor %}
682 {% endif %} 688 {% endif %}
683 } 689 }
684 690
685 {% endif %}{# needs_runtime_enabled_installer #} 691 {% endif %}{# needs_runtime_enabled_installer #}
686 {% endblock %} 692 {% endblock %}
687 {##############################################################################} 693 {##############################################################################}
688 {% block origin_trials %} 694 {% block origin_trials %}
689 {% from 'attributes.cpp.tmpl' import attribute_configuration with context %} 695 {% from 'attributes.cpp.tmpl' import accessor_configuration,
696 attribute_configuration,
697 with context %}
690 {% from 'constants.cpp.tmpl' import constant_configuration with context %} 698 {% from 'constants.cpp.tmpl' import constant_configuration with context %}
691 {% from 'methods.cpp.tmpl' import method_configuration with context %} 699 {% from 'methods.cpp.tmpl' import method_configuration with context %}
692 {% for feature in origin_trial_features %} 700 {% for feature in origin_trial_features %}
693 void {{v8_class_or_partial}}::install{{feature.name}}(v8::Isolate* isolate, cons t DOMWrapperWorld& world, v8::Local<v8::Object> instance, v8::Local<v8::Object> prototype, v8::Local<v8::Function> interface) { 701 void {{v8_class_or_partial}}::install{{feature.name}}(v8::Isolate* isolate, cons t DOMWrapperWorld& world, v8::Local<v8::Object> instance, v8::Local<v8::Object> prototype, v8::Local<v8::Function> interface) {
694 {% if feature.attributes or feature.methods %} 702 {% if feature.attributes or feature.methods %}
695 v8::Local<v8::FunctionTemplate> interfaceTemplate = {{v8_class}}::wrapperTypeI nfo.domTemplate(isolate, world); 703 v8::Local<v8::FunctionTemplate> interfaceTemplate = {{v8_class}}::wrapperTypeI nfo.domTemplate(isolate, world);
696 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late); 704 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late);
697 ALLOW_UNUSED_LOCAL(signature); 705 ALLOW_UNUSED_LOCAL(signature);
698 {% endif %} 706 {% endif %}
699 {# Origin-Trial-enabled attributes #} 707 {# Origin-Trial-enabled attributes #}
700 {% for attribute in feature.attributes %} 708 {% for attribute in feature.attributes %}
701 {% if attribute.is_data_type_property %} 709 {% if attribute.is_data_type_property %}
702 static const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.n ame}}Configuration[] = { 710 static const V8DOMConfiguration::AttributeConfiguration attribute{{attribute.n ame}}Configuration[] = {
703 {{attribute_configuration(attribute) | indent(2)}} 711 {{attribute_configuration(attribute) | indent(2)}}
704 }; 712 };
705 for (const auto& attributeConfig : attribute{{attribute.name}}Configuration) 713 for (const auto& attributeConfig : attribute{{attribute.name}}Configuration)
706 V8DOMConfiguration::InstallAttribute(isolate, world, instance, prototype, at tributeConfig); 714 V8DOMConfiguration::InstallAttribute(isolate, world, instance, prototype, at tributeConfig);
707 {% else %} 715 {% else %}
708 static const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.nam e}}Configuration[] = { 716 static const V8DOMConfiguration::AccessorConfiguration accessor{{attribute.nam e}}Configuration[] = {
709 {{attribute_configuration(attribute) | indent(2)}} 717 {{accessor_configuration(attribute) | indent(2)}}
haraken 2017/05/10 04:21:13 Not related to this CL, 'accessor', 'attribute' an
peria 2017/05/10 05:20:50 We have to decide the naming rule about this confu
710 }; 718 };
711 for (const auto& accessorConfig : accessor{{attribute.name}}Configuration) 719 for (const auto& accessorConfig : accessor{{attribute.name}}Configuration)
712 V8DOMConfiguration::InstallAccessor(isolate, world, instance, prototype, int erface, signature, accessorConfig); 720 V8DOMConfiguration::InstallAccessor(isolate, world, instance, prototype, int erface, signature, accessorConfig);
713 {% endif %} 721 {% endif %}
714 {% endfor %} 722 {% endfor %}
715 {# Origin-Trial-enabled constants #} 723 {# Origin-Trial-enabled constants #}
716 {% for constant in feature.constants %} 724 {% for constant in feature.constants %}
717 {% set constant_name = constant.name.title().replace('_', '') %} 725 {% set constant_name = constant.name.title().replace('_', '') %}
718 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Confi guration = {{constant_configuration(constant)}}; 726 const V8DOMConfiguration::ConstantConfiguration constant{{constant_name}}Confi guration = {{constant_configuration(constant)}};
719 V8DOMConfiguration::InstallConstant(isolate, interface, prototype, constant{{c onstant_name}}Configuration); 727 V8DOMConfiguration::InstallConstant(isolate, interface, prototype, constant{{c onstant_name}}Configuration);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 {% endif %} 799 {% endif %}
792 } 800 }
793 {% endif %} 801 {% endif %}
794 802
795 {% endblock %} 803 {% endblock %}
796 {##############################################################################} 804 {##############################################################################}
797 {% block partial_interface %}{% endblock %} 805 {% block partial_interface %}{% endblock %}
798 } // namespace blink 806 } // namespace blink
799 807
800 {% endfilter %}{# format_blink_cpp_source_code #} 808 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698