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

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

Issue 2841443005: [Bindings] Create and use V8 context snapshots (Closed)
Patch Set: Support runtime feature on templates Created 3 years, 6 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 {##############################################################################} 414 {##############################################################################}
415 {% block install_dom_template %} 415 {% block install_dom_template %}
416 {% if not is_array_buffer_or_view %} 416 {% if not is_array_buffer_or_view %}
417 {% from 'methods.cpp.tmpl' import install_custom_signature with context %} 417 {% from 'methods.cpp.tmpl' import install_custom_signature with context %}
418 {% from 'attributes.cpp.tmpl' import accessor_configuration, 418 {% from 'attributes.cpp.tmpl' import accessor_configuration,
419 attribute_configuration, 419 attribute_configuration,
420 with context %} 420 with context %}
421 {% from 'constants.cpp.tmpl' import install_constants with context %} 421 {% from 'constants.cpp.tmpl' import install_constants with context %}
422 {% from 'methods.cpp.tmpl' import method_configuration with context %} 422 {% from 'methods.cpp.tmpl' import method_configuration with context %}
423 {% if has_partial_interface or is_partial %} 423 {% if has_partial_interface or is_partial %}
424 void {{v8_class_or_partial}}::install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) { 424 void {{v8_class_or_partial}}::install{{v8_class}}Template(
425 v8::Isolate* isolate,
426 const DOMWrapperWorld& world,
427 v8::Local<v8::FunctionTemplate> interfaceTemplate) {
425 {% else %} 428 {% else %}
426 static void install{{v8_class}}Template(v8::Isolate* isolate, const DOMWrapperWo rld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) { 429 static void install{{v8_class}}Template(
430 v8::Isolate* isolate,
431 const DOMWrapperWorld& world,
432 v8::Local<v8::FunctionTemplate> interfaceTemplate) {
427 {% endif %} 433 {% endif %}
428 // Initialize the interface object's template. 434 // Initialize the interface object's template.
429 {% if is_partial %} 435 {% if is_partial %}
430 {{v8_class}}::install{{v8_class}}Template(isolate, world, interfaceTemplate); 436 {{v8_class}}::install{{v8_class}}Template(isolate, world, interfaceTemplate);
431 {% else %} 437 {% else %}
432 {% set parent_interface_template = 438 {% set parent_interface_template =
433 '%s::domTemplateForNamedPropertiesObject(isolate, world)' % v8_class 439 '%s::domTemplateForNamedPropertiesObject(isolate, world)' % v8_class
434 if has_named_properties_object else 440 if has_named_properties_object else
435 'V8%s::domTemplate(isolate, world)' % parent_interface 441 'V8%s::domTemplate(isolate, world)' % parent_interface
436 if parent_interface else 442 if parent_interface else
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 641
636 {% endif %}{# not is_array_buffer_or_view #} 642 {% endif %}{# not is_array_buffer_or_view #}
637 {% endblock %} 643 {% endblock %}
638 {##############################################################################} 644 {##############################################################################}
639 {% block install_runtime_enabled %} 645 {% block install_runtime_enabled %}
640 {% if needs_runtime_enabled_installer %} 646 {% if needs_runtime_enabled_installer %}
641 {% from 'attributes.cpp.tmpl' import accessor_configuration, 647 {% from 'attributes.cpp.tmpl' import accessor_configuration,
642 attribute_configuration, 648 attribute_configuration,
643 with context %} 649 with context %}
644 {% from 'methods.cpp.tmpl' import install_custom_signature with context %} 650 {% from 'methods.cpp.tmpl' import install_custom_signature with context %}
645 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) { 651 void {{v8_class_or_partial}}::InstallRuntimeEnabledFeatures(
652 v8::Isolate* isolate,
653 const DOMWrapperWorld& world,
654 v8::Local<v8::Object> instance,
655 v8::Local<v8::Object> prototype,
656 v8::Local<v8::Function> interface) {
646 {% if runtime_enabled_feature_name %} 657 {% if runtime_enabled_feature_name %}
647 #error "We don't expect a runtime enabled interface {{v8_class_or_partial}} to h ave installRuntimeEnabledFeatures()." 658 #error "We don't expect a runtime enabled interface {{v8_class_or_partial}} to h ave installRuntimeEnabledFeatures()."
648 {% endif %} 659 {% endif %}
649 660
650 {% if is_partial %} 661 {% if is_partial %}
651 {{v8_class}}::installRuntimeEnabledFeatures(isolate, world, instance, prototyp e, interface); 662 {{v8_class}}::InstallRuntimeEnabledFeatures(isolate, world, instance, prototyp e, interface);
652 {% endif %} 663 {% endif %}
653 664
654 v8::Local<v8::FunctionTemplate> interfaceTemplate = {{v8_class}}::wrapperTypeI nfo.domTemplate(isolate, world); 665 v8::Local<v8::FunctionTemplate> interface_template = {{v8_class}}::wrapperType Info.domTemplate(isolate, world);
655 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp late); 666 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interface_tem plate);
656 ALLOW_UNUSED_LOCAL(signature); 667 ALLOW_UNUSED_LOCAL(signature);
657 668
658 {# TODO(peria): Generate code to install constants. It depends on runtime_enab led_feaure of this interface. #} 669 {# TODO(peria): Generate code to install constants. It depends on runtime_enab led_feaure of this interface. #}
659 670
660 {% for feature_name, attrs in runtime_enabled_attributes | selectattr('is_data _type_property') | groupby('runtime_enabled_feature_name') %} 671 {% for feature_name, attrs in runtime_enabled_attributes | selectattr('is_data _type_property') | groupby('runtime_enabled_feature_name') %}
661 {% filter runtime_enabled(feature_name) %} 672 {% filter runtime_enabled(feature_name) %}
662 static const V8DOMConfiguration::AttributeConfiguration attribute_configuratio ns[] = { 673 static const V8DOMConfiguration::AttributeConfiguration attribute_configuratio ns[] = {
663 {% for attribute in attrs | sort %} 674 {% for attribute in attrs | sort %}
664 {{attribute_configuration(attribute) | indent(6)}}, 675 {{attribute_configuration(attribute) | indent(6)}},
665 {% endfor %} 676 {% endfor %}
(...skipping 10 matching lines...) Expand all
676 {{accessor_configuration(attribute) | indent(6)}}, 687 {{accessor_configuration(attribute) | indent(6)}},
677 {% endfor %} 688 {% endfor %}
678 }; 689 };
679 V8DOMConfiguration::InstallAccessors(isolate, world, instance, prototype, 690 V8DOMConfiguration::InstallAccessors(isolate, world, instance, prototype,
680 interface, signature, accessor_configurations, 691 interface, signature, accessor_configurations,
681 WTF_ARRAY_LENGTH(accessor_configurations)); 692 WTF_ARRAY_LENGTH(accessor_configurations));
682 {% endfilter %} 693 {% endfilter %}
683 {% endfor %} 694 {% endfor %}
684 695
685 {% if iterator_method and iterator_method.runtime_enabled_feature_name %} 696 {% if iterator_method and iterator_method.runtime_enabled_feature_name %}
686 {% filter exposed(iterator_method.exposed_test) %} 697 #error "{{v8_class_or_partial}} should not have runtime enabled iterator (@@iter ator)."
687 {% filter runtime_enabled(iterator_method.runtime_enabled_feature_name) %}
688 // Runtime enabled iterator (@@iterator)
689 #error "{{v8_class_or_partial}} should not have runtime enabled iterators."
690 {% endfilter %}
691 {% endfilter %}
692 {% endif %} 698 {% endif %}
693 699
694 {% if methods | custom_registration(is_partial) %} 700 {% if methods | custom_registration(is_partial) %}
695 {% for method in methods | custom_registration(is_partial) %} 701 {% for method in methods | custom_registration(is_partial) %}
696 {% filter exposed(method.overloads.exposed_test_all 702 {% filter exposed(method.overloads.exposed_test_all
697 if method.overloads else method.exposed_test) %} 703 if method.overloads else method.exposed_test) %}
698 {% set feature_name = (method.overloads.runtime_enabled_all 704 {% set feature_name = (method.overloads.runtime_enabled_all
699 if method.overloads else method.runtime_enabled_feature _name) %} 705 if method.overloads else method.runtime_enabled_feature _name) %}
700 {% if feature_name %} 706 {% if feature_name %}
701 {% filter runtime_enabled(feature_name) %} 707 {% filter runtime_enabled(feature_name) %}
702 {% if method.is_cross_origin %} 708 {% if method.is_cross_origin %}
703 #error "{{v8_class_or_partial}} should not have runtime enabled and cross origin methods." 709 #error "{{v8_class_or_partial}} should not have runtime enabled and cross origin methods."
704 {% else %} 710 {% else %}
705 {{install_custom_signature(method, 'instance', 'prototype', 'interface', 'sign ature') | indent(2)}} 711 {{install_custom_signature(method, 'instance', 'prototype', 'interface', 'sign ature') | indent(2)}}
706 {% endif %} 712 {% endif %}
707 {% endfilter %} 713 {% endfilter %}
708 {% endif %} 714 {% endif %}
709 {% endfilter %} 715 {% endfilter %}
710 {% endfor %} 716 {% endfor %}
711 {% endif %} 717 {% endif %}
712 } 718 }
713 719
720 void {{v8_class_or_partial}}::InstallRuntimeEnabledFeaturesOnTemplate(
Yuki 2017/06/21 09:23:21 Probably we could land this change separately in a
peria 2017/06/23 02:22:05 Yes, of course, will do. It is included in this ch
721 v8::Isolate* isolate,
722 const DOMWrapperWorld& world,
723 v8::Local<v8::FunctionTemplate> interface_template) {
724 {% if runtime_enabled_feature_name %}
725 #error "We don't expect a runtime enabled interface {{v8_class_or_partial}} to h ave InstallRuntimeEnabledFeaturesOnTemplate()."
726 {% endif %}
727
728 {% if is_partial %}
729 {{v8_class}}::InstallRuntimeEnabledFeaturesOnTemplate(isolate, world, interfac e_template);
730 {% endif %}
731
732 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interface_tem plate);
733 ALLOW_UNUSED_LOCAL(signature);
734 v8::Local<v8::ObjectTemplate> instance_template = interface_template->Instance Template();
735 ALLOW_UNUSED_LOCAL(instance_template);
736 v8::Local<v8::ObjectTemplate> prototype_template = interface_template->Prototy peTemplate();
737 ALLOW_UNUSED_LOCAL(prototype_template);
738
739 // Register DOM constants, attributes and operations.
Yuki 2017/06/21 09:23:21 nit: s/DOM/IDL/
peria 2017/06/23 02:22:05 Done.
740 {% for feature_name, constants_list in constants | selectattr('runtime_enabled _feature_name') | groupby('runtime_enabled_feature_name') %}
741 {% filter runtime_enabled(feature_name) %}
742 static const V8DOMConfiguration::ConstantConfiguration constant_configurations = {
743 {% for constant in constants_list %}
744 {{constant_configuration(constant) | indent(6)}},
745 {% endfor %}
746 }
747 V8DOMConfiguration::InstallConstants(
748 isolate, interface_template, prototype_template,
749 constant_configurations, WTF_ARRAY_LENGTH(constant_configurations));
750 {% endfilter %}
751 {% endfor %}
752
753 {% for feature_name, attribute_list in runtime_enabled_attributes | selectattr ('is_data_type_property') | groupby('runtime_enabled_feature_name') %}
754 {% filter runtime_enabled(feature_name) %}
755 static const V8DOMConfiguration::AttributeConfiguration attribute_configuratio ns[] = {
756 {% for attribute in attribute_list | sort %}
757 {{attribute_configuration(attribute) | indent(6)}},
758 {% endfor %}
759 };
760 V8DOMConfiguration::InstallAttributes(
761 isolate, world, instance_template, prototype_template,
762 attribute_configurations, WTF_ARRAY_LENGTH(attribute_configurations));
763 {% endfilter %}
764 {% endfor %}
765
766 {% for feature_name, attribute_list in runtime_enabled_attributes | selectattr ('is_data_type_property', 'equalto', False) | groupby('runtime_enabled_feature_n ame') %}
767 {% filter runtime_enabled(feature_name) %}
768 static const V8DOMConfiguration::AccessorConfiguration accessor_configurations [] = {
769 {% for attribute in attribute_list | sort %}
770 {{accessor_configuration(attribute) | indent(6)}},
771 {% endfor %}
772 };
773 V8DOMConfiguration::InstallAccessors(
774 isolate, world, instance_template, prototype_template, interface_template,
775 signature, accessor_configurations,
776 WTF_ARRAY_LENGTH(accessor_configurations));
777 {% endfilter %}
778 {% endfor %}
779
780 {% if iterator_method and iterator_method.runtime_enabled_feature_name %}
781 {% filter exposed(iterator_method.exposed_test) %}
782 {% filter runtime_enabled(iterator_method.runtime_enabled_feature_name) %}
783 {% set symbol_alias = '"%s"' % iterator_method_alias
784 if iterator_method_alias else 'nullptr' %}
785 // Iterator (@@iterator)
786 static const V8DOMConfiguration::SymbolKeyedMethodConfiguration
787 symbol_keyed_iterator_configuration = {
788 v8::Symbol::GetIterator,
789 {{symbol_alias}},
790 {{v8_class_or_partial}}::iteratorMethodCallback,
791 0,
792 v8::DontEnum,
793 V8DOMConfiguration::kOnPrototype,
794 V8DOMConfiguration::kCheckHolder,
795 V8DOMConfiguration::kDoNotCheckAccess
796 };
797 V8DOMConfiguration::InstallMethod(
798 isolate, world, prototype_template, signature,
799 symbol_keyed_iterator_configuration);
800 {% endfilter %}
801 {% endfilter %}
802 {% endif %}
803
804 {% if methods | custom_registration(is_partial) %}
805 {% for method in methods | custom_registration(is_partial) %}
806 {% filter exposed(method.overloads.exposed_test_all
807 if method.overloads else method.exposed_test) %}
808 {% set feature_name = method.overloads.runtime_enabled_all
809 if method.overloads else method.runtime_enabled_feature_name %}
810 {% if feature_name %}
811 {% filter runtime_enabled(feature_name) %}
812 {% if method.is_cross_origin %}
813 {{install_origin_safe_method(method, 'instance_template', 'prototype_template' ) | indent(2)}}
814 {% else %}
815 {{install_custom_signature(method, 'instance_template', 'prototype_template', 'interface_template', 'signature') | indent(2)}}
816 {% endif %}
817 {% endfilter %}
818 {% endif %}
819 {% endfilter %}
820 {% endfor %}
821 {% endif %}
822 }
823
714 {% endif %}{# needs_runtime_enabled_installer #} 824 {% endif %}{# needs_runtime_enabled_installer #}
715 {% endblock %} 825 {% endblock %}
716 {##############################################################################} 826 {##############################################################################}
717 {% block origin_trials %} 827 {% block origin_trials %}
718 {% from 'attributes.cpp.tmpl' import accessor_configuration, 828 {% from 'attributes.cpp.tmpl' import accessor_configuration,
719 attribute_configuration, 829 attribute_configuration,
720 with context %} 830 with context %}
721 {% from 'constants.cpp.tmpl' import constant_configuration with context %} 831 {% from 'constants.cpp.tmpl' import constant_configuration with context %}
722 {% from 'methods.cpp.tmpl' import method_configuration with context %} 832 {% from 'methods.cpp.tmpl' import method_configuration with context %}
723 {% for feature in optional_features %} 833 {% for feature in optional_features %}
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 {% endif %} 940 {% endif %}
831 } 941 }
832 {% endif %} 942 {% endif %}
833 943
834 {% endblock %} 944 {% endblock %}
835 {##############################################################################} 945 {##############################################################################}
836 {% block partial_interface %}{% endblock %} 946 {% block partial_interface %}{% endblock %}
837 } // namespace blink 947 } // namespace blink
838 948
839 {% endfilter %}{# format_blink_cpp_source_code #} 949 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698