Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 {% extends 'interface_base.cpp' %} | 1 {% extends 'interface_base.cpp' %} |
| 2 | 2 |
| 3 | 3 |
| 4 {##############################################################################} | 4 {##############################################################################} |
| 5 {% macro attribute_configuration(attribute) %} | 5 {% macro attribute_configuration(attribute) %} |
| 6 {% set getter_callback = | 6 {% set getter_callback = |
| 7 '%sV8Internal::%sAttributeGetterCallback' % | 7 '%sV8Internal::%sAttributeGetterCallback' % |
| 8 (cpp_class, attribute.name) | 8 (cpp_class, attribute.name) |
| 9 if not attribute.constructor_type else | 9 if not attribute.constructor_type else |
| 10 ('%sV8Internal::%sConstructorGetterCallback' % | 10 ('%sV8Internal::%sConstructorGetterCallback' % |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 if attribute.is_per_world_bindings and | 22 if attribute.is_per_world_bindings and |
| 23 (not attribute.is_read_only or attribute.put_forwards) else '0' %} | 23 (not attribute.is_read_only or attribute.put_forwards) else '0' %} |
| 24 {% set wrapper_type_info = | 24 {% set wrapper_type_info = |
| 25 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' % | 25 'const_cast<WrapperTypeInfo*>(&V8%s::wrapperTypeInfo)' % |
| 26 attribute.constructor_type | 26 attribute.constructor_type |
| 27 if attribute.constructor_type else '0' %} | 27 if attribute.constructor_type else '0' %} |
| 28 {% set access_control = 'static_cast<v8::AccessControl>(%s)' % | 28 {% set access_control = 'static_cast<v8::AccessControl>(%s)' % |
| 29 ' | '.join(attribute.access_control_list) %} | 29 ' | '.join(attribute.access_control_list) %} |
| 30 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % | 30 {% set property_attribute = 'static_cast<v8::PropertyAttribute>(%s)' % |
| 31 ' | '.join(attribute.property_attributes) %} | 31 ' | '.join(attribute.property_attributes) %} |
| 32 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if attribute.only_exposed_to_private_script else 'V8DOMConfiguration::E xposedToAllScripts' %} | |
| 32 {% set on_prototype = '1 /* on prototype */' | 33 {% set on_prototype = '1 /* on prototype */' |
| 33 if interface_name == 'Window' and attribute.idl_type == 'EventHandler' | 34 if interface_name == 'Window' and attribute.idl_type == 'EventHandler' |
| 34 else '0 /* on instance */' %} | 35 else '0 /* on instance */' %} |
| 35 {% set attribute_configuration_list = [ | 36 {% set attribute_configuration_list = [ |
| 36 '"%s"' % attribute.name, | 37 '"%s"' % attribute.name, |
| 37 getter_callback, | 38 getter_callback, |
| 38 setter_callback, | 39 setter_callback, |
| 39 getter_callback_for_main_world, | 40 getter_callback_for_main_world, |
| 40 setter_callback_for_main_world, | 41 setter_callback_for_main_world, |
| 41 wrapper_type_info, | 42 wrapper_type_info, |
| 42 access_control, | 43 access_control, |
| 43 property_attribute, | 44 property_attribute, |
| 45 only_exposed_to_private_script, | |
| 44 ] %} | 46 ] %} |
| 45 {% if not attribute.is_expose_js_accessors %} | 47 {% if not attribute.is_expose_js_accessors %} |
| 46 {% set attribute_configuration_list = attribute_configuration_list | 48 {% set attribute_configuration_list = attribute_configuration_list |
| 47 + [on_prototype] %} | 49 + [on_prototype] %} |
| 48 {% endif %} | 50 {% endif %} |
| 49 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} | 51 {{'{'}}{{attribute_configuration_list | join(', ')}}{{'}'}} |
| 50 {%- endmacro %} | 52 {%- endmacro %} |
| 51 | 53 |
| 52 | 54 |
| 53 {##############################################################################} | 55 {##############################################################################} |
| 54 {% macro method_configuration(method) %} | 56 {% macro method_configuration(method) %} |
| 55 {% set method_callback = | 57 {% set method_callback = |
| 56 '%sV8Internal::%sMethodCallback' % (cpp_class, method.name) %} | 58 '%sV8Internal::%sMethodCallback' % (cpp_class, method.name) %} |
| 57 {% set method_callback_for_main_world = | 59 {% set method_callback_for_main_world = |
| 58 '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class, method.name) | 60 '%sV8Internal::%sMethodCallbackForMainWorld' % (cpp_class, method.name) |
| 59 if method.is_per_world_bindings else '0' %} | 61 if method.is_per_world_bindings else '0' %} |
| 60 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m ethod.length}}} | 62 {% set only_exposed_to_private_script = 'V8DOMConfiguration::OnlyExposedToPrivat eScript' if method.only_exposed_to_private_script else 'V8DOMConfiguration::Expo sedToAllScripts' %} |
| 63 {"{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{m ethod.length}}, {{only_exposed_to_private_script}}} | |
| 61 {%- endmacro %} | 64 {%- endmacro %} |
| 62 | 65 |
| 63 | 66 |
| 64 {##############################################################################} | 67 {##############################################################################} |
| 65 {% block constructor_getter %} | 68 {% block constructor_getter %} |
| 66 {% if has_constructor_attributes %} | 69 {% if has_constructor_attributes %} |
| 67 static void {{cpp_class}}ConstructorGetter(v8::Local<v8::String>, const v8::Prop ertyCallbackInfo<v8::Value>& info) | 70 static void {{cpp_class}}ConstructorGetter(v8::Local<v8::String>, const v8::Prop ertyCallbackInfo<v8::Value>& info) |
| 68 { | 71 { |
| 69 v8::Handle<v8::Value> data = info.Data(); | 72 v8::Handle<v8::Value> data = info.Data(); |
| 70 ASSERT(data->IsExternal()); | 73 ASSERT(data->IsExternal()); |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 721 | 724 |
| 722 {% endif %} | 725 {% endif %} |
| 723 {% endblock %} | 726 {% endblock %} |
| 724 | 727 |
| 725 | 728 |
| 726 {##############################################################################} | 729 {##############################################################################} |
| 727 {% block shadow_attributes %} | 730 {% block shadow_attributes %} |
| 728 {% if interface_name == 'Window' %} | 731 {% if interface_name == 'Window' %} |
| 729 static const V8DOMConfiguration::AttributeConfiguration shadowAttributes[] = { | 732 static const V8DOMConfiguration::AttributeConfiguration shadowAttributes[] = { |
| 730 {% for attribute in attributes if attribute.is_unforgeable %} | 733 {% for attribute in attributes if attribute.is_unforgeable %} |
| 731 {# FIXME: Expose [OnlyExposedToPrivateScript] attributes to window objects o f private scripts #} | 734 {% if not attribute.is_implemented_in_private_script or not attribute.only_e xposed_to_private_script %} |
|
bashi
2014/07/25 07:57:42
nit: We check the same condition four times. We ma
haraken
2014/07/25 08:26:59
Done.
| |
| 732 {% if not attribute.only_exposed_to_private_script %} | |
| 733 {{attribute_configuration(attribute)}}, | 735 {{attribute_configuration(attribute)}}, |
| 734 {% endif %} | 736 {% endif %} |
| 735 {% endfor %} | 737 {% endfor %} |
| 736 }; | 738 }; |
| 737 | 739 |
| 738 {% endif %} | 740 {% endif %} |
| 739 {% endblock %} | 741 {% endblock %} |
| 740 | 742 |
| 741 | 743 |
| 742 {##############################################################################} | 744 {##############################################################################} |
| 743 {% block install_attributes %} | 745 {% block install_attributes %} |
| 744 {% if has_attribute_configuration %} | 746 {% if has_attribute_configuration %} |
| 745 static const V8DOMConfiguration::AttributeConfiguration {{v8_class}}Attributes[] = { | 747 static const V8DOMConfiguration::AttributeConfiguration {{v8_class}}Attributes[] = { |
| 746 {% for attribute in attributes | 748 {% for attribute in attributes |
| 747 if not (attribute.is_expose_js_accessors or | 749 if not (attribute.is_expose_js_accessors or |
| 748 attribute.is_static or | 750 attribute.is_static or |
| 749 attribute.runtime_enabled_function or | 751 attribute.runtime_enabled_function or |
| 750 attribute.per_context_enabled_function or | 752 attribute.per_context_enabled_function or |
| 751 (interface_name == 'Window' and attribute.is_unforgeable)) %} | 753 (interface_name == 'Window' and attribute.is_unforgeable)) %} |
| 752 {# FIXME: Expose [OnlyExposedToPrivateScript] attributes to window objects o f private scripts #} | 754 {% if not attribute.is_implemented_in_private_script or not attribute.only_e xposed_to_private_script %} |
|
bashi
2014/07/25 07:57:42
nit: Can we merge this to the above if?
haraken
2014/07/25 08:26:59
Done.
| |
| 753 {% if not attribute.only_exposed_to_private_script %} | |
| 754 {% filter conditional(attribute.conditional_string) %} | 755 {% filter conditional(attribute.conditional_string) %} |
| 755 {{attribute_configuration(attribute)}}, | 756 {{attribute_configuration(attribute)}}, |
| 756 {% endfilter %} | 757 {% endfilter %} |
| 757 {% endif %} | 758 {% endif %} |
| 758 {% endfor %} | 759 {% endfor %} |
| 759 }; | 760 }; |
| 760 | 761 |
| 761 {% endif %} | 762 {% endif %} |
| 762 {% endblock %} | 763 {% endblock %} |
| 763 | 764 |
| 764 | 765 |
| 765 {##############################################################################} | 766 {##############################################################################} |
| 766 {% block install_accessors %} | 767 {% block install_accessors %} |
| 767 {% if has_accessors %} | 768 {% if has_accessors %} |
| 768 static const V8DOMConfiguration::AccessorConfiguration {{v8_class}}Accessors[] = { | 769 static const V8DOMConfiguration::AccessorConfiguration {{v8_class}}Accessors[] = { |
| 769 {% for attribute in attributes if attribute.is_expose_js_accessors %} | 770 {% for attribute in attributes if attribute.is_expose_js_accessors %} |
| 770 {# FIXME: Expose [OnlyExposedToPrivateScript] attributes to window objects o f private scripts #} | 771 {% if not attribute.is_implemented_in_private_script or not attribute.only_e xposed_to_private_script %} |
| 771 {% if not attribute.only_exposed_to_private_script %} | |
| 772 {{attribute_configuration(attribute)}}, | 772 {{attribute_configuration(attribute)}}, |
| 773 {% endif %} | 773 {% endif %} |
| 774 {% endfor %} | 774 {% endfor %} |
| 775 }; | 775 }; |
| 776 | 776 |
| 777 {% endif %} | 777 {% endif %} |
| 778 {% endblock %} | 778 {% endblock %} |
| 779 | 779 |
| 780 | 780 |
| 781 {##############################################################################} | 781 {##############################################################################} |
| 782 {% block install_methods %} | 782 {% block install_methods %} |
| 783 {% if method_configuration_methods %} | 783 {% if method_configuration_methods %} |
| 784 static const V8DOMConfiguration::MethodConfiguration {{v8_class}}Methods[] = { | 784 static const V8DOMConfiguration::MethodConfiguration {{v8_class}}Methods[] = { |
| 785 {% for method in method_configuration_methods %} | 785 {% for method in method_configuration_methods %} |
| 786 {# FIXME: Expose [OnlyExposedToPrivateScript] methods to window objects of p rivate scripts #} | 786 {% if not method.is_implemented_in_private_script or not method.only_exposed _to_private_script %} |
|
bashi
2014/07/25 07:57:42
nit: We check this condition two times.
haraken
2014/07/25 08:26:59
Done.
| |
| 787 {% if not method.only_exposed_to_private_script %} | |
| 788 {% filter conditional(method.conditional_string) %} | 787 {% filter conditional(method.conditional_string) %} |
| 789 {{method_configuration(method)}}, | 788 {{method_configuration(method)}}, |
| 790 {% endfilter %} | 789 {% endfilter %} |
| 791 {% endif %} | 790 {% endif %} |
| 792 {% endfor %} | 791 {% endfor %} |
| 793 }; | 792 }; |
| 794 | 793 |
| 795 {% endif %} | 794 {% endif %} |
| 796 {% endblock %} | 795 {% endblock %} |
| 797 | 796 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1053 {% set setter_callback_for_main_world = '%sForMainWorld' % setter_callback | 1052 {% set setter_callback_for_main_world = '%sForMainWorld' % setter_callback |
| 1054 if not method.is_read_only else '0' %} | 1053 if not method.is_read_only else '0' %} |
| 1055 {% else %} | 1054 {% else %} |
| 1056 {% set getter_callback_for_main_world = '0' %} | 1055 {% set getter_callback_for_main_world = '0' %} |
| 1057 {% set setter_callback_for_main_world = '0' %} | 1056 {% set setter_callback_for_main_world = '0' %} |
| 1058 {% endif %} | 1057 {% endif %} |
| 1059 {% set property_attribute = | 1058 {% set property_attribute = |
| 1060 'static_cast<v8::PropertyAttribute>(%s)' % | 1059 'static_cast<v8::PropertyAttribute>(%s)' % |
| 1061 ' | '.join(method.property_attributes or ['v8::DontDelete']) %} | 1060 ' | '.join(method.property_attributes or ['v8::DontDelete']) %} |
| 1062 static const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSaf eAttributeConfiguration = { | 1061 static const V8DOMConfiguration::AttributeConfiguration {{method.name}}OriginSaf eAttributeConfiguration = { |
| 1063 "{{method.name}}", {{getter_callback}}, {{setter_callback}}, {{getter_callba ck_for_main_world}}, {{setter_callback_for_main_world}}, &{{v8_class}}::wrapperT ypeInfo, v8::ALL_CAN_READ, {{property_attribute}}, false | 1062 "{{method.name}}", {{getter_callback}}, {{setter_callback}}, {{getter_callba ck_for_main_world}}, {{setter_callback_for_main_world}}, &{{v8_class}}::wrapperT ypeInfo, v8::ALL_CAN_READ, {{property_attribute}}, V8DOMConfiguration::ExposedTo AllScripts, false, |
| 1064 }; | 1063 }; |
| 1065 V8DOMConfiguration::installAttribute({{method.function_template}}, v8::Handle<v8 ::ObjectTemplate>(), {{method.name}}OriginSafeAttributeConfiguration, isolate); | 1064 V8DOMConfiguration::installAttribute({{method.function_template}}, v8::Handle<v8 ::ObjectTemplate>(), {{method.name}}OriginSafeAttributeConfiguration, isolate); |
| 1066 {%- endmacro %} | 1065 {%- endmacro %} |
| 1067 | 1066 |
| 1068 | 1067 |
| 1069 {######################################} | 1068 {######################################} |
| 1070 {% macro install_custom_signature(method) %} | 1069 {% macro install_custom_signature(method) %} |
| 1071 {% set method_callback = '%sV8Internal::%sMethodCallback' % (cpp_class, method.n ame) %} | 1070 {% set method_callback = '%sV8Internal::%sMethodCallback' % (cpp_class, method.n ame) %} |
| 1072 {% set method_callback_for_main_world = '%sForMainWorld' % method_callback | 1071 {% set method_callback_for_main_world = '%sForMainWorld' % method_callback |
| 1073 if method.is_per_world_bindings else '0' %} | 1072 if method.is_per_world_bindings else '0' %} |
| 1074 {% set property_attribute = | 1073 {% set property_attribute = |
| 1075 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut es) | 1074 'static_cast<v8::PropertyAttribute>(%s)' % ' | '.join(method.property_attribut es) |
| 1076 if method.property_attributes else 'v8::None' %} | 1075 if method.property_attributes else 'v8::None' %} |
| 1077 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig uration = { | 1076 static const V8DOMConfiguration::MethodConfiguration {{method.name}}MethodConfig uration = { |
| 1078 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{method.length}} | 1077 "{{method.name}}", {{method_callback}}, {{method_callback_for_main_world}}, {{method.length}}, V8DOMConfiguration::ExposedToAllScripts, |
| 1079 }; | 1078 }; |
| 1080 V8DOMConfiguration::installMethodCustomSignature({{method.function_template}}, { {method.signature}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); | 1079 V8DOMConfiguration::installMethodCustomSignature({{method.function_template}}, { {method.signature}}, {{property_attribute}}, {{method.name}}MethodConfiguration, isolate); |
| 1081 {%- endmacro %} | 1080 {%- endmacro %} |
| 1082 | 1081 |
| 1083 | 1082 |
| 1084 {######################################} | 1083 {######################################} |
| 1085 {% macro install_constants() %} | 1084 {% macro install_constants() %} |
| 1086 {# Normal (always enabled) constants #} | 1085 {# Normal (always enabled) constants #} |
| 1087 static const V8DOMConfiguration::ConstantConfiguration {{v8_class}}Constants[] = { | 1086 static const V8DOMConfiguration::ConstantConfiguration {{v8_class}}Constants[] = { |
| 1088 {% for constant in constants if not constant.runtime_enabled_function %} | 1087 {% for constant in constants if not constant.runtime_enabled_function %} |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1349 {% endif %} | 1348 {% endif %} |
| 1350 } | 1349 } |
| 1351 | 1350 |
| 1352 template<> | 1351 template<> |
| 1353 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) | 1352 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) |
| 1354 { | 1353 { |
| 1355 return toV8(impl, creationContext, isolate); | 1354 return toV8(impl, creationContext, isolate); |
| 1356 } | 1355 } |
| 1357 | 1356 |
| 1358 {% endblock %} | 1357 {% endblock %} |
| OLD | NEW |