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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 define("{{module.path}}", [ 5 define("{{module.path}}", [
6 "mojo/public/js/bindings/core", 6 "mojo/public/js/bindings/core",
7 "mojo/public/js/bindings/codec", 7 "mojo/public/js/bindings/codec",
8 {%- for import in imports %} 8 {%- for import in imports %}
9 "{{import.module.path}}", 9 "{{import.module.path}}",
10 {%- endfor %} 10 {%- endfor %}
11 ], function(core, codec 11 ], function(core, codec
12 {%- for import in imports -%} 12 {%- for import in imports -%}
13 , {{import.unique_name}} 13 , {{import.unique_name}}
14 {%- endfor -%} 14 {%- endfor -%}
15 ) { 15 ) {
16 16
17 {#--- Constants #}
18 {% for constant in module.constants %}
19 var {{constant.name}} = {{constant.value|expression_to_text(module)}};
20 {%- endfor %}
21
17 {#--- Enums #} 22 {#--- Enums #}
18 {% from "enum_definition.tmpl" import enum_def -%} 23 {%- from "enum_definition.tmpl" import enum_def %}
19 {% for enum in enums %} 24 {%- for enum in enums %}
20 var {{ enum_def(enum.name, enum, module) }} 25 var {{ enum_def(enum.name, enum, module) }}
21 {%- endfor %} 26 {%- endfor %}
22 27
23 {#--- Struct definitions #} 28 {#--- Struct definitions #}
24 {% for struct in structs %} 29 {% for struct in structs %}
25 {%- include "struct_definition.tmpl" %} 30 {%- include "struct_definition.tmpl" %}
26 {%- endfor %} 31 {%- endfor %}
27 32
28 {#--- Interface definitions #} 33 {#--- Interface definitions #}
29 {%- for interface in interfaces %} 34 {%- for interface in interfaces %}
30 {%- include "interface_definition.tmpl" %} 35 {%- include "interface_definition.tmpl" %}
31 {%- endfor %} 36 {%- endfor %}
32 37
33 var exports = {}; 38 var exports = {};
39 {% for constant in module.constants %}
40 exports.{{constant.name}} = {{constant.name}};
41 {%- endfor %}
34 {%- for enum in enums %} 42 {%- for enum in enums %}
35 exports.{{enum.name}} = {{enum.name}}; 43 exports.{{enum.name}} = {{enum.name}};
36 {%- endfor %} 44 {%- endfor %}
37 {%- for struct in structs if struct.exported %} 45 {%- for struct in structs if struct.exported %}
38 exports.{{struct.name}} = {{struct.name}}; 46 exports.{{struct.name}} = {{struct.name}};
39 {%- endfor %} 47 {%- endfor %}
40 {%- for interface in interfaces %} 48 {%- for interface in interfaces %}
41 exports.{{interface.name}}Proxy = {{interface.name}}Proxy; 49 exports.{{interface.name}}Proxy = {{interface.name}}Proxy;
42 exports.{{interface.name}}Stub = {{interface.name}}Stub; 50 exports.{{interface.name}}Stub = {{interface.name}}Stub;
43 {%- endfor %} 51 {%- endfor %}
44 return exports; 52 return exports;
45 }); 53 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698