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

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

Issue 1193793003: bindings: Makes almost all attributes accessor-type properties. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Synced. Created 5 years, 5 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 | Annotate | Revision Log
OLDNEW
1 {% include 'copyright_block.txt' %} 1 {% include 'copyright_block.txt' %}
2 #include "config.h" 2 #include "config.h"
3 {% filter conditional(conditional_string) %} 3 {% filter conditional(conditional_string) %}
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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 {% block install_attributes %} 220 {% block install_attributes %}
221 {% from 'attributes.cpp' import attribute_configuration with context %} 221 {% from 'attributes.cpp' import attribute_configuration with context %}
222 {% if has_attribute_configuration %} 222 {% if has_attribute_configuration %}
223 // Suppress warning: global constructors, because AttributeConfiguration is triv ial 223 // Suppress warning: global constructors, because AttributeConfiguration is triv ial
224 // and does not depend on another global objects. 224 // and does not depend on another global objects.
225 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) 225 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
226 #pragma clang diagnostic push 226 #pragma clang diagnostic push
227 #pragma clang diagnostic ignored "-Wglobal-constructors" 227 #pragma clang diagnostic ignored "-Wglobal-constructors"
228 #endif 228 #endif
229 static const V8DOMConfiguration::AttributeConfiguration {{v8_class}}Attributes[] = { 229 static const V8DOMConfiguration::AttributeConfiguration {{v8_class}}Attributes[] = {
230 {# [Unforgeable] attributes in Window are defined as shadow_attributes, so
231 excluded here. #}
230 {% for attribute in attributes 232 {% for attribute in attributes
231 if not (attribute.is_expose_js_accessors or 233 if not (attribute.exposed_test or
232 attribute.is_static or 234 attribute.runtime_enabled_function) and
233 attribute.runtime_enabled_function or 235 attribute.is_data_type_property and
234 attribute.exposed_test or 236 attribute.should_be_exposed_to_script and
235 (interface_name == 'Window' and attribute.is_unforgeable)) 237 not (interface_name == 'Window' and attribute.is_unforgeable) %}
236 and attribute.should_be_exposed_to_script %}
237 {% filter conditional(attribute.conditional_string) %} 238 {% filter conditional(attribute.conditional_string) %}
238 {{attribute_configuration(attribute)}}, 239 {{attribute_configuration(attribute)}},
239 {% endfilter %} 240 {% endfilter %}
240 {% endfor %} 241 {% endfor %}
241 }; 242 };
242 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) 243 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
243 #pragma clang diagnostic pop 244 #pragma clang diagnostic pop
244 #endif 245 #endif
245 246
246 {% endif %} 247 {% endif %}
247 {% endblock %} 248 {% endblock %}
248 {##############################################################################} 249 {##############################################################################}
249 {% block install_accessors %} 250 {% block install_accessors %}
250 {% from 'attributes.cpp' import attribute_configuration with context %} 251 {% from 'attributes.cpp' import attribute_configuration with context %}
251 {% if has_accessor_configuration %} 252 {% if has_accessor_configuration %}
252 static const V8DOMConfiguration::AccessorConfiguration {{v8_class}}Accessors[] = { 253 static const V8DOMConfiguration::AccessorConfiguration {{v8_class}}Accessors[] = {
254 {# [Unforgeable] attributes in Window are defined as shadow_attributes, so
255 excluded here. #}
253 {% for attribute in attributes 256 {% for attribute in attributes
254 if (attribute.is_expose_js_accessors and 257 if not (attribute.exposed_test or
255 not (attribute.is_static or 258 attribute.runtime_enabled_function) and
256 attribute.runtime_enabled_function or 259 not attribute.is_data_type_property and
257 attribute.exposed_test) and 260 attribute.should_be_exposed_to_script and
258 attribute.should_be_exposed_to_script) %} 261 not (interface_name == 'Window' and attribute.is_unforgeable) %}
259 {% filter conditional(attribute.conditional_string) %} 262 {% filter conditional(attribute.conditional_string) %}
260 {{attribute_configuration(attribute)}}, 263 {{attribute_configuration(attribute)}},
261 {% endfilter %} 264 {% endfilter %}
262 {% endfor %} 265 {% endfor %}
263 }; 266 };
264 267
265 {% endif %} 268 {% endif %}
266 {% endblock %} 269 {% endblock %}
267 {##############################################################################} 270 {##############################################################################}
268 {% block install_methods %} 271 {% block install_methods %}
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 ALLOW_UNUSED_LOCAL(prototypeTemplate); 349 ALLOW_UNUSED_LOCAL(prototypeTemplate);
347 {% if has_access_check_callbacks %} 350 {% if has_access_check_callbacks %}
348 instanceTemplate->SetAccessCheckCallbacks({{cpp_class}}V8Internal::namedSecu rityCheck, {{cpp_class}}V8Internal::indexedSecurityCheck, v8::External::New(isol ate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperTypeInfo))); 351 instanceTemplate->SetAccessCheckCallbacks({{cpp_class}}V8Internal::namedSecu rityCheck, {{cpp_class}}V8Internal::indexedSecurityCheck, v8::External::New(isol ate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperTypeInfo)));
349 {% endif %} 352 {% endif %}
350 {% for attribute in attributes 353 {% for attribute in attributes
351 if attribute.runtime_enabled_function and 354 if attribute.runtime_enabled_function and
352 not attribute.exposed_test and 355 not attribute.exposed_test and
353 not attribute.is_static %} 356 not attribute.is_static %}
354 {% filter conditional(attribute.conditional_string) %} 357 {% filter conditional(attribute.conditional_string) %}
355 if ({{attribute.runtime_enabled_function}}()) { 358 if ({{attribute.runtime_enabled_function}}()) {
356 {% if attribute.is_expose_js_accessors %} 359 {% if attribute.is_data_type_property %}
357 static const V8DOMConfiguration::AccessorConfiguration accessorConfigura tion =\ 360 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration = \
361 {{attribute_configuration(attribute)}};
362 V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototyp eTemplate, attributeConfiguration);
363 {% else %}
364 static const V8DOMConfiguration::AccessorConfiguration accessorConfigura tion = \
358 {{attribute_configuration(attribute)}}; 365 {{attribute_configuration(attribute)}};
359 V8DOMConfiguration::installAccessor(isolate, instanceTemplate, prototype Template, functionTemplate, defaultSignature, accessorConfiguration); 366 V8DOMConfiguration::installAccessor(isolate, instanceTemplate, prototype Template, functionTemplate, defaultSignature, accessorConfiguration);
360 {% else %}
361 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\
362 {{attribute_configuration(attribute)}};
363 V8DOMConfiguration::installAttribute(isolate, instanceTemplate, prototyp eTemplate, attributeConfiguration);
364 {% endif %} 367 {% endif %}
365 } 368 }
366 {% endfilter %} 369 {% endfilter %}
367 {% endfor %} 370 {% endfor %}
368 {% if constants %} 371 {% if constants %}
369 {{install_constants() | indent}} 372 {{install_constants() | indent}}
370 {% endif %} 373 {% endif %}
371 {# Special operations #} 374 {# Special operations #}
372 {# V8 has access-check callback API and it\'s used on Window instead of 375 {# V8 has access-check callback API and it\'s used on Window instead of
373 deleters or enumerators; see ObjectTemplate::SetAccessCheckCallbacks. 376 deleters or enumerators; see ObjectTemplate::SetAccessCheckCallbacks.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 method.runtime_enabled_function) %} 460 method.runtime_enabled_function) %}
458 {% if method.is_do_not_check_security %} 461 {% if method.is_do_not_check_security %}
459 {{install_do_not_check_security_signature(method) | indent}} 462 {{install_do_not_check_security_signature(method) | indent}}
460 {% else %}{# is_do_not_check_security #} 463 {% else %}{# is_do_not_check_security #}
461 {{install_custom_signature(method) | indent}} 464 {{install_custom_signature(method) | indent}}
462 {% endif %}{# is_do_not_check_security #} 465 {% endif %}{# is_do_not_check_security #}
463 {% endfilter %}{# runtime_enabled() #} 466 {% endfilter %}{# runtime_enabled() #}
464 {% endfilter %}{# exposed() #} 467 {% endfilter %}{# exposed() #}
465 {% endfilter %}{# conditional() #} 468 {% endfilter %}{# conditional() #}
466 {% endfor %} 469 {% endfor %}
467 {% for attribute in attributes if attribute.is_static %}
468 {% set getter_callback = '%sV8Internal::%sAttributeGetterCallback' %
469 (cpp_class, attribute.name) %}
470 {% set setter_callback = '%sV8Internal::%sAttributeSetterCallback' %
471 (cpp_class, attribute.name)
472 if attribute.has_setter else '0' %}
473 {% filter conditional(attribute.conditional_string) %}
474 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "{{attribute .name}}"), {{getter_callback}}, {{setter_callback}}, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Local<v8::AccessorSignatur e>(), static_cast<v8::AccessControl>(v8::DEFAULT));
475 {% endfilter %}
476 {% endfor %}
477 {# Special interfaces #} 470 {# Special interfaces #}
478 {% if not is_partial %} 471 {% if not is_partial %}
479 {% if interface_name == 'Window' %} 472 {% if interface_name == 'Window' %}
480 473
481 prototypeTemplate->SetInternalFieldCount(V8Window::internalFieldCount); 474 prototypeTemplate->SetInternalFieldCount(V8Window::internalFieldCount);
482 functionTemplate->SetHiddenPrototype(true); 475 functionTemplate->SetHiddenPrototype(true);
483 instanceTemplate->SetInternalFieldCount(V8Window::internalFieldCount); 476 instanceTemplate->SetInternalFieldCount(V8Window::internalFieldCount);
484 {% elif interface_name in [ 477 {% elif interface_name in [
485 'HTMLDocument', 'DedicatedWorkerGlobalScope', 'CompositorWorkerGlobal Scope', 478 'HTMLDocument', 'DedicatedWorkerGlobalScope', 'CompositorWorkerGlobal Scope',
486 'SharedWorkerGlobalScope', 'ServiceWorkerGlobalScope'] %} 479 'SharedWorkerGlobalScope', 'ServiceWorkerGlobalScope'] %}
(...skipping 24 matching lines...) Expand all
511 {% endfor %} 504 {% endfor %}
512 {% for attribute in attributes if attribute.is_implemented_in_private_script %} 505 {% for attribute in attributes if attribute.is_implemented_in_private_script %}
513 {{attribute_getter_implemented_in_private_script(attribute)}} 506 {{attribute_getter_implemented_in_private_script(attribute)}}
514 {% if attribute.has_setter %} 507 {% if attribute.has_setter %}
515 {{attribute_setter_implemented_in_private_script(attribute)}} 508 {{attribute_setter_implemented_in_private_script(attribute)}}
516 {% endif %} 509 {% endif %}
517 {% endfor %} 510 {% endfor %}
518 {% block partial_interface %}{% endblock %} 511 {% block partial_interface %}{% endblock %}
519 } // namespace blink 512 } // namespace blink
520 {% endfilter %} 513 {% endfilter %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/interface.h ('k') | Source/bindings/tests/results/core/V8SVGTestInterface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698