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

Side by Side Diff: mojo/public/tools/bindings/generators/dart_templates/enum_definition.tmpl

Issue 1433183002: Generate Mojom Types for Dart (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Simplify identifier_store for Go and Dart Created 5 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
OLDNEW
1 {%- macro enum_def(enum) -%} 1 {% import "mojom_type_macros.tmpl" as mojom_type_macros %}
2
3 {%- macro enum_def(enum, typepkg, package) -%}
2 class {{enum|name}} extends bindings.MojoEnum { 4 class {{enum|name}} extends bindings.MojoEnum {
3 {%- for field in enum.fields %} 5 {%- for field in enum.fields %}
4 static const {{field.name}} = const {{enum|name}}._({{field.resolved_value}}); 6 static const {{field.name}} = const {{enum|name}}._({{field.resolved_value}});
5 {%- endfor %} 7 {%- endfor %}
6 8
7 const {{enum|name}}._(int v) : super(v); 9 const {{enum|name}}._(int v) : super(v);
8 10
9 static const Map<String, {{enum|name}}> valuesMap = const { 11 static const Map<String, {{enum|name}}> valuesMap = const {
10 {%- for field in enum.fields %} 12 {%- for field in enum.fields %}
11 "{{field.name}}": {{field.name}}, 13 "{{field.name}}": {{field.name}},
(...skipping 27 matching lines...) Expand all
39 } 41 }
40 return result; 42 return result;
41 } 43 }
42 44
43 String toString() { 45 String toString() {
44 switch(this) { 46 switch(this) {
45 {%- for field in enum.fields %} 47 {%- for field in enum.fields %}
46 case {{field.name}}: 48 case {{field.name}}:
47 return '{{enum|name}}.{{field.name}}'; 49 return '{{enum|name}}.{{field.name}}';
48 {%- endfor %} 50 {%- endfor %}
51 default:
52 return null;
49 } 53 }
50 } 54 }
51 55
52 int toJson() => value; 56 int toJson() => value;
53 } 57 }
58
59 {{ mojom_type_macros.writeMojomTypeDef(enum, typepkg, package) }}
60
54 {%- endmacro %} 61 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698