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

Side by Side Diff: Source/bindings/templates/interface.cpp

Issue 328663003: IDL: restructure logic handling registration of methods (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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 {% 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 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 {% endfor %} 774 {% endfor %}
775 }; 775 };
776 776
777 {% endif %} 777 {% endif %}
778 {% endblock %} 778 {% endblock %}
779 779
780 780
781 {##############################################################################} 781 {##############################################################################}
782 {% block class_methods %} 782 {% block class_methods %}
783 {# FIXME: rename to install_methods and put into configure_class_template #} 783 {# FIXME: rename to install_methods and put into configure_class_template #}
784 {% if has_method_configuration %} 784 {% if method_configuration_methods %}
785 static const V8DOMConfiguration::MethodConfiguration {{v8_class}}Methods[] = { 785 static const V8DOMConfiguration::MethodConfiguration {{v8_class}}Methods[] = {
786 {% for method in methods if method.do_generate_method_configuration %} 786 {% for method in method_configuration_methods %}
787 {% filter conditional(method.conditional_string) %} 787 {% filter conditional(method.conditional_string) %}
788 {{method_configuration(method)}}, 788 {{method_configuration(method)}},
789 {% endfilter %} 789 {% endfilter %}
790 {% endfor %} 790 {% endfor %}
791 }; 791 };
792 792
793 {% endif %} 793 {% endif %}
794 {% endblock %} 794 {% endblock %}
795 795
796 796
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 ('%sAttributes' % v8_class, 898 ('%sAttributes' % v8_class,
899 'WTF_ARRAY_LENGTH(%sAttributes)' % v8_class) 899 'WTF_ARRAY_LENGTH(%sAttributes)' % v8_class)
900 if has_attribute_configuration else (0, 0) %} 900 if has_attribute_configuration else (0, 0) %}
901 {% set accessors_name, accessors_length = 901 {% set accessors_name, accessors_length =
902 ('%sAccessors' % v8_class, 902 ('%sAccessors' % v8_class,
903 'WTF_ARRAY_LENGTH(%sAccessors)' % v8_class) 903 'WTF_ARRAY_LENGTH(%sAccessors)' % v8_class)
904 if has_accessors else (0, 0) %} 904 if has_accessors else (0, 0) %}
905 {% set methods_name, methods_length = 905 {% set methods_name, methods_length =
906 ('%sMethods' % v8_class, 906 ('%sMethods' % v8_class,
907 'WTF_ARRAY_LENGTH(%sMethods)' % v8_class) 907 'WTF_ARRAY_LENGTH(%sMethods)' % v8_class)
908 if has_method_configuration else (0, 0) %} 908 if method_configuration_methods else (0, 0) %}
909 {{attributes_name}}, {{attributes_length}}, 909 {{attributes_name}}, {{attributes_length}},
910 {{accessors_name}}, {{accessors_length}}, 910 {{accessors_name}}, {{accessors_length}},
911 {{methods_name}}, {{methods_length}}, 911 {{methods_name}}, {{methods_length}},
912 isolate); 912 isolate);
913 {% endfilter %} 913 {% endfilter %}
914 914
915 {% if constructors or has_custom_constructor or has_event_constructor %} 915 {% if constructors or has_custom_constructor or has_event_constructor %}
916 functionTemplate->SetCallHandler({{v8_class}}::constructorCallback); 916 functionTemplate->SetCallHandler({{v8_class}}::constructorCallback);
917 functionTemplate->SetLength({{interface_length}}); 917 functionTemplate->SetLength({{interface_length}});
918 {% endif %} 918 {% endif %}
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 functionTemplate->{{set_on_template}}()->SetNamedPropertyHandler({{named_pro perty_getter_callback}}, {{named_property_setter_callback}}, {{named_property_qu ery_callback}}, {{named_property_deleter_callback}}, {{named_property_enumerator _callback}}); 979 functionTemplate->{{set_on_template}}()->SetNamedPropertyHandler({{named_pro perty_getter_callback}}, {{named_property_setter_callback}}, {{named_property_qu ery_callback}}, {{named_property_deleter_callback}}, {{named_property_enumerator _callback}});
980 {% endif %} 980 {% endif %}
981 {# End special operations #} 981 {# End special operations #}
982 {% if has_custom_legacy_call_as_function %} 982 {% if has_custom_legacy_call_as_function %}
983 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class}}: :legacyCallCustom); 983 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class}}: :legacyCallCustom);
984 {% endif %} 984 {% endif %}
985 {% if interface_name == 'HTMLAllCollection' %} 985 {% if interface_name == 'HTMLAllCollection' %}
986 {# Needed for legacy support of document.all #} 986 {# Needed for legacy support of document.all #}
987 functionTemplate->InstanceTemplate()->MarkAsUndetectable(); 987 functionTemplate->InstanceTemplate()->MarkAsUndetectable();
988 {% endif %} 988 {% endif %}
989 {% for method in methods if not method.do_not_check_signature %} 989 {% for method in custom_registration_methods %}
990 {# install_custom_signature #} 990 {# install_custom_signature #}
991 {% if not method.overload_index or method.overload_index == 1 %}
992 {# For overloaded methods, only generate one accessor #}
993 {% filter conditional(method.conditional_string) %} 991 {% filter conditional(method.conditional_string) %}
994 {% if method.is_do_not_check_security %} 992 {% if method.is_do_not_check_security %}
995 {% if method.is_per_world_bindings %} 993 {% if method.is_per_world_bindings %}
996 if (DOMWrapperWorld::current(isolate).isMainWorld()) { 994 if (DOMWrapperWorld::current(isolate).isMainWorld()) {
997 {{install_do_not_check_security_signature(method, 'ForMainWorld')}} 995 {{install_do_not_check_security_signature(method, 'ForMainWorld')}}
998 } else { 996 } else {
999 {{install_do_not_check_security_signature(method)}} 997 {{install_do_not_check_security_signature(method)}}
1000 } 998 }
1001 {% else %} 999 {% else %}
1002 {{install_do_not_check_security_signature(method)}} 1000 {{install_do_not_check_security_signature(method)}}
1003 {% endif %} 1001 {% endif %}
1004 {% else %}{# is_do_not_check_security #} 1002 {% else %}{# is_do_not_check_security #}
1005 {% if method.is_per_world_bindings %} 1003 {% if method.is_per_world_bindings %}
1006 if (DOMWrapperWorld::current(isolate).isMainWorld()) { 1004 if (DOMWrapperWorld::current(isolate).isMainWorld()) {
1007 {% filter runtime_enabled(method.runtime_enabled_function) %} 1005 {% filter runtime_enabled(method.runtime_enabled_function) %}
1008 {{install_custom_signature(method, 'ForMainWorld')}} 1006 {{install_custom_signature(method, 'ForMainWorld')}}
1009 {% endfilter %} 1007 {% endfilter %}
1010 } else { 1008 } else {
1011 {% filter runtime_enabled(method.runtime_enabled_function) %} 1009 {% filter runtime_enabled(method.runtime_enabled_function) %}
1012 {{install_custom_signature(method)}} 1010 {{install_custom_signature(method)}}
1013 {% endfilter %} 1011 {% endfilter %}
1014 } 1012 }
1015 {% else %} 1013 {% else %}
1016 {% filter runtime_enabled(method.runtime_enabled_function) %} 1014 {% filter runtime_enabled(method.runtime_enabled_function) %}
1017 {{install_custom_signature(method)}} 1015 {{install_custom_signature(method)}}
1018 {% endfilter %} 1016 {% endfilter %}
1019 {% endif %} 1017 {% endif %}
1020 {% endif %}{# is_do_not_check_security #} 1018 {% endif %}{# is_do_not_check_security #}
1021 {% endfilter %} 1019 {% endfilter %}
1022 {% endif %}{# install_custom_signature #}
1023 {% endfor %} 1020 {% endfor %}
1024 {% for attribute in attributes if attribute.is_static %} 1021 {% for attribute in attributes if attribute.is_static %}
1025 {% set getter_callback = '%sV8Internal::%sAttributeGetterCallback' % 1022 {% set getter_callback = '%sV8Internal::%sAttributeGetterCallback' %
1026 (cpp_class, attribute.name) %} 1023 (cpp_class, attribute.name) %}
1027 {% filter conditional(attribute.conditional_string) %} 1024 {% filter conditional(attribute.conditional_string) %}
1028 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "{{attribute .name}}"), {{getter_callback}}, {{attribute.setter_callback}}, v8::External::New (isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::Acces sorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); 1025 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "{{attribute .name}}"), {{getter_callback}}, {{attribute.setter_callback}}, v8::External::New (isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::Acces sorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT));
1029 {% endfilter %} 1026 {% endfilter %}
1030 {% endfor %} 1027 {% endfor %}
1031 {# Special interfaces #} 1028 {# Special interfaces #}
1032 {% if interface_name == 'Window' %} 1029 {% if interface_name == 'Window' %}
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 } 1165 }
1169 {% endfor %} 1166 {% endfor %}
1170 } 1167 }
1171 1168
1172 {% endif %} 1169 {% endif %}
1173 {% endblock %} 1170 {% endblock %}
1174 1171
1175 1172
1176 {##############################################################################} 1173 {##############################################################################}
1177 {% block install_per_context_methods %} 1174 {% block install_per_context_methods %}
1178 {% if has_per_context_enabled_methods %} 1175 {% if per_context_enabled_methods %}
1179 void {{v8_class}}::installPerContextEnabledMethods(v8::Handle<v8::Object> protot ypeTemplate, v8::Isolate* isolate) 1176 void {{v8_class}}::installPerContextEnabledMethods(v8::Handle<v8::Object> protot ypeTemplate, v8::Isolate* isolate)
1180 { 1177 {
1181 {# Define per-context enabled operations #} 1178 {# Define per-context enabled operations #}
1182 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domT emplate(isolate)); 1179 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domT emplate(isolate));
1183 1180
1184 ExecutionContext* context = toExecutionContext(prototypeTemplate->CreationCo ntext()); 1181 ExecutionContext* context = toExecutionContext(prototypeTemplate->CreationCo ntext());
1185 {% for method in methods if method.per_context_enabled_function %} 1182 {% for method in per_context_enabled_methods %}
1186 if (context && context->isDocument() && {{method.per_context_enabled_functio n}}(toDocument(context))) 1183 if (context && context->isDocument() && {{method.per_context_enabled_functio n}}(toDocument(context)))
1187 prototypeTemplate->Set(v8AtomicString(isolate, "{{method.name}}"), v8::F unctionTemplate::New(isolate, {{cpp_class}}V8Internal::{{method.name}}MethodCall back, v8Undefined(), defaultSignature, {{method.number_of_required_arguments}})- >GetFunction()); 1184 prototypeTemplate->Set(v8AtomicString(isolate, "{{method.name}}"), v8::F unctionTemplate::New(isolate, {{cpp_class}}V8Internal::{{method.name}}MethodCall back, v8Undefined(), defaultSignature, {{method.number_of_required_arguments}})- >GetFunction());
1188 {% endfor %} 1185 {% endfor %}
1189 } 1186 }
1190 1187
1191 {% endif %} 1188 {% endif %}
1192 {% endblock %} 1189 {% endblock %}
1193 1190
1194 1191
1195 {##############################################################################} 1192 {##############################################################################}
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 {% endif %} 1332 {% endif %}
1336 } 1333 }
1337 1334
1338 template<> 1335 template<>
1339 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) 1336 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate)
1340 { 1337 {
1341 return toV8(impl, creationContext, isolate); 1338 return toV8(impl, creationContext, isolate);
1342 } 1339 }
1343 1340
1344 {% endblock %} 1341 {% endblock %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698