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

Unified Diff: mojo/public/tools/bindings/generators/js_templates/module.js.tmpl

Issue 268363003: Mojo: Add support for constants to the IDL compiler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: JS export constants Created 6 years, 7 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: mojo/public/tools/bindings/generators/js_templates/module.js.tmpl
diff --git a/mojo/public/tools/bindings/generators/js_templates/module.js.tmpl b/mojo/public/tools/bindings/generators/js_templates/module.js.tmpl
index 9b3046825c1d13e1efd24068d3a9e7fb74866087..aaa3ed557f7520e4111dd7a6b52f6df5ecf2fe6b 100644
--- a/mojo/public/tools/bindings/generators/js_templates/module.js.tmpl
+++ b/mojo/public/tools/bindings/generators/js_templates/module.js.tmpl
@@ -14,9 +14,14 @@ define("{{module.path}}", [
{%- endfor -%}
) {
+{#--- Constants #}
+{% for constant in module.constants %}
+ var {{constant.name}} = {{constant.value|expression_to_text(module)}};
+{%- endfor %}
+
{#--- Enums #}
-{% from "enum_definition.tmpl" import enum_def -%}
-{% for enum in enums %}
+{%- from "enum_definition.tmpl" import enum_def %}
+{%- for enum in enums %}
var {{ enum_def(enum.name, enum, module) }}
{%- endfor %}
@@ -31,6 +36,9 @@ define("{{module.path}}", [
{%- endfor %}
var exports = {};
+{% for constant in module.constants %}
+ exports.{{constant.name}} = {{constant.name}};
+{%- endfor %}
{%- for enum in enums %}
exports.{{enum.name}} = {{enum.name}};
{%- endfor %}

Powered by Google App Engine
This is Rietveld 408576698