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

Side by Side Diff: mojo/public/bindings/generators/js_templates/module.js.tmpl

Issue 99623010: Add support for enums within structs and interfaces to mojom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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([ 5 define([
6 "mojo/apps/js/bindings/core", 6 "mojo/apps/js/bindings/core",
7 "mojo/apps/js/bindings/codec", 7 "mojo/apps/js/bindings/codec",
8 ], function(core, codec) { 8 ], function(core, codec) {
9 9
10 {#--- Enums #} 10 {#--- Enums #}
11 {%- from "enum_definition.tmpl" import enum_def -%}
11 {% for enum in enums %} 12 {% for enum in enums %}
12 var {{enum.name}} = { 13 {{ enum_def("var %s"|format(enum.name), enum) }}
13 {%- set next_value = 0 %} 14 {%- endfor %}
14 {%- for field in enum.fields %}
15 {%- if field.value %}
16 {%- set next_value = field.value|int %}
17 {%- endif %}
18 {{field.name}}: {{next_value}},
19 {%- set next_value = next_value + 1 %}
20 {%- endfor %}
21 };
22 {% endfor %}
23 15
24 {#--- Struct definitions #} 16 {#--- Struct definitions #}
25 {%- for struct in structs %} 17 {% for struct in structs %}
26 {% include "struct_definition.tmpl" %} 18 {% include "struct_definition.tmpl" %}
27 {%- endfor %} 19 {%- endfor %}
28 20
29 {#--- Interface definitions #} 21 {#--- Interface definitions #}
30 {%- for interface in interfaces %} 22 {%- for interface in interfaces %}
31 {%- include "interface_definition.tmpl" %} 23 {%- include "interface_definition.tmpl" %}
32 {%- endfor %} 24 {%- endfor %}
33 25
34 var exports = {}; 26 var exports = {};
35 {%- for enum in enums %} 27 {%- for enum in enums %}
36 exports.{{enum.name}} = {{enum.name}}; 28 exports.{{enum.name}} = {{enum.name}};
37 {%- endfor %} 29 {%- endfor %}
38 {%- for struct in structs if struct.exported %} 30 {%- for struct in structs if struct.exported %}
39 exports.{{struct.name}} = {{struct.name}}; 31 exports.{{struct.name}} = {{struct.name}};
40 {%- endfor %} 32 {%- endfor %}
41 {%- for interface in interfaces %} 33 {%- for interface in interfaces %}
42 exports.{{interface.name}}Proxy = {{interface.name}}Proxy; 34 exports.{{interface.name}}Proxy = {{interface.name}}Proxy;
43 exports.{{interface.name}}Stub = {{interface.name}}Stub; 35 exports.{{interface.name}}Stub = {{interface.name}}Stub;
44 {%- endfor %} 36 {%- endfor %}
45 return exports; 37 return exports;
46 }); 38 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698