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

Unified Diff: Source/bindings/templates/constants.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/templates/callback_interface.cpp ('k') | Source/bindings/templates/constructors.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/templates/constants.cpp
diff --git a/Source/bindings/templates/constants.cpp b/Source/bindings/templates/constants.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..994b0ba0ef2ca1c0c2662f24edebb0e1104f3d08
--- /dev/null
+++ b/Source/bindings/templates/constants.cpp
@@ -0,0 +1,52 @@
+{# FIXME: remove all the conditional_string blocks once test removed #}
+{# FIXME: should use name_reflect instead of name #}
+{# FIXME: do we need separate value and value_raw? #}
+{% macro class_consts() %}
+static const V8DOMConfiguration::BatchedConstant {{v8_class_name}}Consts[] = {
+{% for constant in constants %}
+{% if not constant.enabled_at_runtime %}
+{% if constant.conditional_string %}
+#if {{constant.conditional_string}}
+{% endif %}
+ {"{{constant.name}}", {{constant.value}}},
+{% if constant.conditional_string %}
+#endif // {{constant.conditional_string}}
+{% endif %}
+{% endif %}{# not constant.enabled_at_runtime #}
+{% endfor %}
+};
+{% if not do_not_check_constants %}
+
+
+{% for constant in constants %}
+{% if constant.conditional_string %}
+#if {{constant.conditional_string}}
+{% endif %}
+COMPILE_ASSERT({{constant.value_raw}} == {{cpp_class_name}}::{{constant.name_reflect}}, {{cpp_class_name}}Enum{{constant.name_reflect}}IsWrongUseDoNotCheckConstants);
+{% if constant.conditional_string %}
+#endif // {{constant.conditional_string}}
+{% endif %}
+{% endfor %}
+{% endif %}{# not do_not_check_constants #}
+{% endmacro %}{# class_consts #}
+
+
+{% macro const_data(constant) %}
+{% if constant.enabled_at_runtime %}
+{% if constant.conditional_string %}
+#if {{constant.conditional_string}}
+{% endif %}
+ if ({{constant.enable_function}}()) {
+ static const V8DOMConfiguration::BatchedConstant constData = {"{{constant.name}}", static_cast<signed int>({{constant.value}})};
+ V8DOMConfiguration::batchConfigureConstants(desc, proto, &constData, 1, isolate);
+ }
+{% if constant.conditional_string %}
+#endif // {{constant.conditional_string}}
+{%- endif %}
+{% endif %}
+{% endmacro %}{# const_data #}
+
+
+{% macro batch_configure_constants() %}
+V8DOMConfiguration::batchConfigureConstants(desc, proto, {{v8_class_name}}Consts, WTF_ARRAY_LENGTH({{v8_class_name}}Consts), isolate);
+{%- endmacro %}
« no previous file with comments | « Source/bindings/templates/callback_interface.cpp ('k') | Source/bindings/templates/constructors.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698