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

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

Issue 148083004: IDL compiler: anonymous indexed property getters (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 6 years, 11 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 {% 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 '{0}V8Internal::{0}ConstructorGetter'.format(interface_name) %} 10 '{0}V8Internal::{0}ConstructorGetter'.format(interface_name) %}
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 { 91 {
92 {{cpp_class}}* imp = {{v8_class}}::toNative(host); 92 {{cpp_class}}* imp = {{v8_class}}::toNative(host);
93 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe curityError); 93 return BindingSecurity::shouldAllowAccessToFrame(imp->frame(), DoNotReportSe curityError);
94 } 94 }
95 95
96 {% endif %} 96 {% endif %}
97 {% endblock %} 97 {% endblock %}
98 98
99 99
100 {##############################################################################} 100 {##############################################################################}
101 {% block anonymous_indexed_property_getter_and_callback %}
102 {% if anonymous_indexed_property_getter %}
103 {% set getter = anonymous_indexed_property_getter %}
104 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info)
105 {
106 {{cpp_class}}* collection = {{v8_class}}::toNative(info.Holder());
107 {{getter.cpp_type}} element = collection->{{getter.name}}(index);
108 if ({{getter.is_null_expression}})
109 return;
110 {{getter.v8_set_return_value}};
111 }
112
113 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCall backInfo<v8::Value>& info)
114 {
115 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty");
116 {{cpp_class}}V8Internal::indexedPropertyGetter(index, info);
117 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
118 }
119
120 {% endif %}
121 {% endblock %}
122
123
124 {##############################################################################}
101 {% block origin_safe_method_setter %} 125 {% block origin_safe_method_setter %}
102 {% if has_origin_safe_method_setter %} 126 {% if has_origin_safe_method_setter %}
103 static void {{cpp_class}}OriginSafeMethodSetter(v8::Local<v8::String> name, v8:: Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 127 static void {{cpp_class}}OriginSafeMethodSetter(v8::Local<v8::String> name, v8:: Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
104 { 128 {
105 {# FIXME: don't call GetIsolate 3 times #} 129 {# FIXME: don't call GetIsolate 3 times #}
106 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain({{ v8_class}}::domTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); 130 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain({{ v8_class}}::domTemplate(info.GetIsolate(), worldType(info.GetIsolate())));
107 if (holder.IsEmpty()) 131 if (holder.IsEmpty())
108 return; 132 return;
109 {{cpp_class}}* imp = {{v8_class}}::toNative(holder); 133 {{cpp_class}}* imp = {{v8_class}}::toNative(holder);
110 v8::String::Utf8Value attributeName(name); 134 v8::String::Utf8Value attributeName(name);
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 if ({{attribute.runtime_enabled_function}}()) { 481 if ({{attribute.runtime_enabled_function}}()) {
458 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\ 482 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu ration =\
459 {{attribute_configuration(attribute)}}; 483 {{attribute_configuration(attribute)}};
460 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate , attributeConfiguration, isolate, currentWorldType); 484 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate , attributeConfiguration, isolate, currentWorldType);
461 } 485 }
462 {% endfilter %} 486 {% endfilter %}
463 {% endfor %} 487 {% endfor %}
464 {% if constants %} 488 {% if constants %}
465 {{install_constants() | indent}} 489 {{install_constants() | indent}}
466 {% endif %} 490 {% endif %}
491 {% if anonymous_indexed_property_getter %}
492 functionTemplate->InstanceTemplate()->SetIndexedPropertyHandler({{cpp_class} }V8Internal::indexedPropertyGetterCallback, 0, 0, 0, indexedPropertyEnumerator<{ {cpp_class}}>);
493 {% endif %}
467 {% if has_custom_legacy_call_as_function %} 494 {% if has_custom_legacy_call_as_function %}
468 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class}}: :legacyCallCustom); 495 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class}}: :legacyCallCustom);
469 {% endif %} 496 {% endif %}
470 {% if interface_name == 'HTMLAllCollection' %} 497 {% if interface_name == 'HTMLAllCollection' %}
471 {# Needed for legacy support of document.all #} 498 {# Needed for legacy support of document.all #}
472 functionTemplate->InstanceTemplate()->MarkAsUndetectable(); 499 functionTemplate->InstanceTemplate()->MarkAsUndetectable();
473 {% endif %} 500 {% endif %}
474 {% for method in methods if not method.do_not_check_signature %} 501 {% for method in methods if not method.do_not_check_signature %}
475 {# install_custom_signature #} 502 {# install_custom_signature #}
476 {% if not method.overload_index or method.overload_index == 1 %} 503 {% if not method.overload_index or method.overload_index == 1 %}
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 fromInternalPointer(object)->deref(); 785 fromInternalPointer(object)->deref();
759 } 786 }
760 787
761 template<> 788 template<>
762 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) 789 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate)
763 { 790 {
764 return toV8(impl, creationContext, isolate); 791 return toV8(impl, creationContext, isolate);
765 } 792 }
766 793
767 {% endblock %} 794 {% endblock %}
OLDNEW
« no previous file with comments | « Source/bindings/scripts/unstable/v8_methods.py ('k') | Source/bindings/templates/interface_base.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698