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

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

Issue 23068032: Add constants and primitive type readonly attributes to Python IDL compiler (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix spacing 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
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..791dd47eebd7c9dfee438eb96d4a6fbe957080a4
--- /dev/null
+++ b/Source/bindings/templates/constants.cpp
@@ -0,0 +1,57 @@
+{# FIXME: remove all the conditional_string blocks once test removed #}
+{# FIXME: should use reflected_name instead of name #}
+{% macro class_constants() %}
haraken 2013/08/26 09:33:40 I think you can remove class_constants() and move
Nils Barth (inactive) 2013/08/27 02:59:27 Got it; it's just a variable used in the installCo
+static const V8DOMConfiguration::ConstantConfiguration {{v8_class_name}}Constants[] = {
+{% 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 %}
+{# FIXME
+{{cpp_class_name}}Enum{{constant.name_reflect}}IsWrongUseDoNotCheckConstants
+=>
+TheValueOf{{cpp_class_name}}::{{constant.name_reflect}}Doesn'tMatchWithImplementation
+#}
+COMPILE_ASSERT({{constant.value}} == {{cpp_class_name}}::{{constant.reflected_name}}, {{cpp_class_name}}Enum{{constant.reflected_name}}IsWrongUseDoNotCheckConstants);
+{% if constant.conditional_string %}
+#endif // {{constant.conditional_string}}
+{% endif %}
+{% endfor %}
+{% endif %}{# not do_not_check_constants #}
+{% endmacro %}
+
+
+{##############################################################################}
+{% macro constant_configuration(constant) %}
haraken 2013/08/26 09:33:40 constant_configuration => install_runtime_enabled_
Nils Barth (inactive) 2013/08/27 02:59:27 Actually merged into install_constants!
+{% if constant.enabled_at_runtime %}
+{% if constant.conditional_string %}
+#if {{constant.conditional_string}}
+{% endif %}
+ if ({{constant.enable_function}}()) {
+ static const V8DOMConfiguration::ConstantConfiguration constantConfiguration = {"{{constant.name}}", static_cast<signed int>({{constant.value}})};
+ V8DOMConfiguration::installConstants(desc, proto, &constantConfiguration, 1, isolate);
+ }
+{% if constant.conditional_string %}
+#endif // {{constant.conditional_string}}
+{%- endif %}
+{% endif %}
+{% endmacro %}
+
+
+{##############################################################################}
+{% macro install_constants() %}
+V8DOMConfiguration::installConstants(desc, proto, {{v8_class_name}}Constants, WTF_ARRAY_LENGTH({{v8_class_name}}Constants), isolate);
+{%- endmacro %}

Powered by Google App Engine
This is Rietveld 408576698