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

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: rebased 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 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 {% endfor %} 773 {% endfor %}
774 }; 774 };
775 775
776 {% endif %} 776 {% endif %}
777 {% endblock %} 777 {% endblock %}
778 778
779 779
780 {##############################################################################} 780 {##############################################################################}
781 {% block class_methods %} 781 {% block class_methods %}
782 {# FIXME: rename to install_methods and put into configure_class_template #} 782 {# FIXME: rename to install_methods and put into configure_class_template #}
783 {% if has_method_configuration %} 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 methods if method.do_generate_method_configuration %} 785 {% for method in method_configuration_methods %}
786 {% filter conditional(method.conditional_string) %} 786 {% filter conditional(method.conditional_string) %}
787 {{method_configuration(method)}}, 787 {{method_configuration(method)}},
788 {% endfilter %} 788 {% endfilter %}
789 {% endfor %} 789 {% endfor %}
790 }; 790 };
791 791
792 {% endif %} 792 {% endif %}
793 {% endblock %} 793 {% endblock %}
794 794
795 795
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 ('%sAttributes' % v8_class, 897 ('%sAttributes' % v8_class,
898 'WTF_ARRAY_LENGTH(%sAttributes)' % v8_class) 898 'WTF_ARRAY_LENGTH(%sAttributes)' % v8_class)
899 if has_attribute_configuration else (0, 0) %} 899 if has_attribute_configuration else (0, 0) %}
900 {% set accessors_name, accessors_length = 900 {% set accessors_name, accessors_length =
901 ('%sAccessors' % v8_class, 901 ('%sAccessors' % v8_class,
902 'WTF_ARRAY_LENGTH(%sAccessors)' % v8_class) 902 'WTF_ARRAY_LENGTH(%sAccessors)' % v8_class)
903 if has_accessors else (0, 0) %} 903 if has_accessors else (0, 0) %}
904 {% set methods_name, methods_length = 904 {% set methods_name, methods_length =
905 ('%sMethods' % v8_class, 905 ('%sMethods' % v8_class,
906 'WTF_ARRAY_LENGTH(%sMethods)' % v8_class) 906 'WTF_ARRAY_LENGTH(%sMethods)' % v8_class)
907 if has_method_configuration else (0, 0) %} 907 if method_configuration_methods else (0, 0) %}
908 {{attributes_name}}, {{attributes_length}}, 908 {{attributes_name}}, {{attributes_length}},
909 {{accessors_name}}, {{accessors_length}}, 909 {{accessors_name}}, {{accessors_length}},
910 {{methods_name}}, {{methods_length}}, 910 {{methods_name}}, {{methods_length}},
911 isolate); 911 isolate);
912 {% endfilter %} 912 {% endfilter %}
913 913
914 {% if constructors or has_custom_constructor or has_event_constructor %} 914 {% if constructors or has_custom_constructor or has_event_constructor %}
915 functionTemplate->SetCallHandler({{v8_class}}::constructorCallback); 915 functionTemplate->SetCallHandler({{v8_class}}::constructorCallback);
916 functionTemplate->SetLength({{interface_length}}); 916 functionTemplate->SetLength({{interface_length}});
917 {% endif %} 917 {% endif %}
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 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}}); 978 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 {% endif %} 979 {% endif %}
980 {# End special operations #} 980 {# End special operations #}
981 {% if has_custom_legacy_call_as_function %} 981 {% if has_custom_legacy_call_as_function %}
982 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class}}: :legacyCallCustom); 982 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class}}: :legacyCallCustom);
983 {% endif %} 983 {% endif %}
984 {% if interface_name == 'HTMLAllCollection' %} 984 {% if interface_name == 'HTMLAllCollection' %}
985 {# Needed for legacy support of document.all #} 985 {# Needed for legacy support of document.all #}
986 functionTemplate->InstanceTemplate()->MarkAsUndetectable(); 986 functionTemplate->InstanceTemplate()->MarkAsUndetectable();
987 {% endif %} 987 {% endif %}
988 {% for method in methods if not method.do_not_check_signature %} 988 {% for method in custom_registration_methods %}
989 {# install_custom_signature #} 989 {# install_custom_signature #}
990 {% if not method.overload_index or method.overload_index == 1 %}
991 {# For overloaded methods, only generate one accessor #}
992 {% filter conditional(method.conditional_string) %} 990 {% filter conditional(method.conditional_string) %}
993 {% if method.is_do_not_check_security %} 991 {% if method.is_do_not_check_security %}
994 {% if method.is_per_world_bindings %} 992 {% if method.is_per_world_bindings %}
995 if (DOMWrapperWorld::current(isolate).isMainWorld()) { 993 if (DOMWrapperWorld::current(isolate).isMainWorld()) {
996 {{install_do_not_check_security_signature(method, 'ForMainWorld')}} 994 {{install_do_not_check_security_signature(method, 'ForMainWorld')}}
997 } else { 995 } else {
998 {{install_do_not_check_security_signature(method)}} 996 {{install_do_not_check_security_signature(method)}}
999 } 997 }
1000 {% else %} 998 {% else %}
1001 {{install_do_not_check_security_signature(method)}} 999 {{install_do_not_check_security_signature(method)}}
1002 {% endif %} 1000 {% endif %}
1003 {% else %}{# is_do_not_check_security #} 1001 {% else %}{# is_do_not_check_security #}
1004 {% if method.is_per_world_bindings %} 1002 {% if method.is_per_world_bindings %}
1005 if (DOMWrapperWorld::current(isolate).isMainWorld()) { 1003 if (DOMWrapperWorld::current(isolate).isMainWorld()) {
1006 {% filter runtime_enabled(method.runtime_enabled_function) %} 1004 {% filter runtime_enabled(method.runtime_enabled_function) %}
1007 {{install_custom_signature(method, 'ForMainWorld')}} 1005 {{install_custom_signature(method, 'ForMainWorld')}}
1008 {% endfilter %} 1006 {% endfilter %}
1009 } else { 1007 } else {
1010 {% filter runtime_enabled(method.runtime_enabled_function) %} 1008 {% filter runtime_enabled(method.runtime_enabled_function) %}
1011 {{install_custom_signature(method)}} 1009 {{install_custom_signature(method)}}
1012 {% endfilter %} 1010 {% endfilter %}
1013 } 1011 }
1014 {% else %} 1012 {% else %}
1015 {% filter runtime_enabled(method.runtime_enabled_function) %} 1013 {% filter runtime_enabled(method.runtime_enabled_function) %}
1016 {{install_custom_signature(method)}} 1014 {{install_custom_signature(method)}}
1017 {% endfilter %} 1015 {% endfilter %}
1018 {% endif %} 1016 {% endif %}
1019 {% endif %}{# is_do_not_check_security #} 1017 {% endif %}{# is_do_not_check_security #}
1020 {% endfilter %} 1018 {% endfilter %}
1021 {% endif %}{# install_custom_signature #}
1022 {% endfor %} 1019 {% endfor %}
1023 {% for attribute in attributes if attribute.is_static %} 1020 {% for attribute in attributes if attribute.is_static %}
1024 {% set getter_callback = '%sV8Internal::%sAttributeGetterCallback' % 1021 {% set getter_callback = '%sV8Internal::%sAttributeGetterCallback' %
1025 (cpp_class, attribute.name) %} 1022 (cpp_class, attribute.name) %}
1026 {% filter conditional(attribute.conditional_string) %} 1023 {% filter conditional(attribute.conditional_string) %}
1027 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)); 1024 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));
1028 {% endfilter %} 1025 {% endfilter %}
1029 {% endfor %} 1026 {% endfor %}
1030 {# Special interfaces #} 1027 {# Special interfaces #}
1031 {% if interface_name == 'Window' %} 1028 {% if interface_name == 'Window' %}
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 } 1164 }
1168 {% endfor %} 1165 {% endfor %}
1169 } 1166 }
1170 1167
1171 {% endif %} 1168 {% endif %}
1172 {% endblock %} 1169 {% endblock %}
1173 1170
1174 1171
1175 {##############################################################################} 1172 {##############################################################################}
1176 {% block install_per_context_methods %} 1173 {% block install_per_context_methods %}
1177 {% if has_per_context_enabled_methods %} 1174 {% if per_context_enabled_methods %}
1178 void {{v8_class}}::installPerContextEnabledMethods(v8::Handle<v8::Object> protot ypeTemplate, v8::Isolate* isolate) 1175 void {{v8_class}}::installPerContextEnabledMethods(v8::Handle<v8::Object> protot ypeTemplate, v8::Isolate* isolate)
1179 { 1176 {
1180 {# Define per-context enabled operations #} 1177 {# Define per-context enabled operations #}
1181 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domT emplate(isolate)); 1178 v8::Local<v8::Signature> defaultSignature = v8::Signature::New(isolate, domT emplate(isolate));
1182 1179
1183 ExecutionContext* context = toExecutionContext(prototypeTemplate->CreationCo ntext()); 1180 ExecutionContext* context = toExecutionContext(prototypeTemplate->CreationCo ntext());
1184 {% for method in methods if method.per_context_enabled_function %} 1181 {% for method in per_context_enabled_methods %}
1185 if (context && context->isDocument() && {{method.per_context_enabled_functio n}}(toDocument(context))) 1182 if (context && context->isDocument() && {{method.per_context_enabled_functio n}}(toDocument(context)))
1186 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()); 1183 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());
1187 {% endfor %} 1184 {% endfor %}
1188 } 1185 }
1189 1186
1190 {% endif %} 1187 {% endif %}
1191 {% endblock %} 1188 {% endblock %}
1192 1189
1193 1190
1194 {##############################################################################} 1191 {##############################################################################}
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 {% endif %} 1331 {% endif %}
1335 } 1332 }
1336 1333
1337 template<> 1334 template<>
1338 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) 1335 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate)
1339 { 1336 {
1340 return toV8(impl, creationContext, isolate); 1337 return toV8(impl, creationContext, isolate);
1341 } 1338 }
1342 1339
1343 {% endblock %} 1340 {% endblock %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/interface.h ('k') | Source/bindings/tests/results/V8TestInterface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698