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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: Source/bindings/templates/interface.cpp
diff --git a/Source/bindings/templates/interface.cpp b/Source/bindings/templates/interface.cpp
index 4d3a7140fce0eea58d8447ae1dc87eaaf8d6b5d1..9c41e59942394cf0c31a758abc84fa296e6847f4 100644
--- a/Source/bindings/templates/interface.cpp
+++ b/Source/bindings/templates/interface.cpp
@@ -98,6 +98,31 @@ bool namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::Value> key, v8
{##############################################################################}
+{% block anonymous_indexed_property_getter_and_callback %}
+{% if anonymous_indexed_property_getter %}
+{% set getter = anonymous_indexed_property_getter %}
+static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
+{
+ ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
haraken 2014/01/27 06:35:32 You can remove this. It's guaranteed that info.Hol
Nils Barth (inactive) 2014/01/27 06:59:35 Got it, posted CL: Remove unnecessary maybeDOMWrap
+ {{cpp_class}}* collection = {{v8_class}}::toNative(info.Holder());
+ {{getter.cpp_type}} element = collection->{{getter.name}}(index);
+ if ({{getter.is_null_expression}})
+ return;
+ {{getter.v8_set_return_value}};
+}
+
+static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty");
+ {{cpp_class}}V8Internal::indexedPropertyGetter(index, info);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
+}
+
+{% endif %}
+{% endblock %}
+
+
+{##############################################################################}
{% block origin_safe_method_setter %}
{% if has_origin_safe_method_setter %}
static void {{cpp_class}}OriginSafeMethodSetter(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
@@ -464,6 +489,9 @@ static void configure{{v8_class}}Template(v8::Handle<v8::FunctionTemplate> funct
{% if constants %}
{{install_constants() | indent}}
{% endif %}
+ {% if anonymous_indexed_property_getter %}
+ functionTemplate->InstanceTemplate()->SetIndexedPropertyHandler({{cpp_class}}V8Internal::indexedPropertyGetterCallback, 0, 0, 0, indexedPropertyEnumerator<{{cpp_class}}>);
+ {% endif %}
{% if has_custom_legacy_call_as_function %}
functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler({{v8_class}}::legacyCallCustom);
{% endif %}

Powered by Google App Engine
This is Rietveld 408576698