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

Unified Diff: Source/bindings/templates/attributes.cpp

Issue 17572008: WIP IDL compiler rewrite (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Branch: const + primitive type readonly attributes Created 7 years, 4 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
« no previous file with comments | « Source/bindings/scripts/v8_values.py ('k') | Source/bindings/templates/attributes_wip.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/templates/attributes.cpp
diff --git a/Source/bindings/templates/attributes.cpp b/Source/bindings/templates/attributes.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..756ff4d93267e875089a8e2de67947c75738f232
--- /dev/null
+++ b/Source/bindings/templates/attributes.cpp
@@ -0,0 +1,45 @@
+{% macro attribute_getter(attribute) %}
+static void {{attribute.name}}AttrGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
+{
+ {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder());
+{% if attribute.should_keep_attribute_alive %}
+ {{attribute.cpp_type}} result = imp->{{attribute.cpp_method_name}}();
+ v8::Handle<v8::Value> wrapper = result.get() ? v8::Handle<v8::Value>(DOMDataStore::getWrapper<{{attribute.v8_type}}>(result.get(), info.GetIsolate())) : v8Undefined();
+ if (wrapper.IsEmpty()) {
+ wrapper = toV8(result.get(), info.Holder(), info.GetIsolate());
+ if (!wrapper.IsEmpty())
+ V8HiddenPropertyName::setNamedHiddenReference(info.Holder(), "{{attribute.name}}", wrapper);
+ }
+ v8SetReturnValue(info, wrapper);
+ return;
+{% else %}
+ {{attribute.return_js_value_statement | indent}}
+ return;
+{% endif %}
+}
+
+{% endmacro %}
+
+
+{##############################################################################}
+{% macro attribute_getter_callback(attribute) %}
+static void {{attribute.name}}AttrGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
+{
+ TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
+ {{cpp_class_name}}V8Internal::{{attribute.name}}AttrGetter(name, info);
+ TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
+}
+
+{% endmacro %}
+
+
+{##############################################################################}
+{# FIXME: instead pass a list of normal_attributes #}
+{% macro batched_attribute() %}
+static const V8DOMConfiguration::BatchedAttribute {{v8_class_name}}Attrs[] = {
+{% for attribute in attributes %}
+ // Attribute '{{attribute.name}}'
+ {"{{attribute.name}}", {{cpp_class_name}}V8Internal::{{attribute.name}}AttrGetterCallback, 0, 0, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
+{% endfor %}
+};
+{% endmacro %}
« no previous file with comments | « Source/bindings/scripts/v8_values.py ('k') | Source/bindings/templates/attributes_wip.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698