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

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

Issue 1539673003: Generate Mojom Types in Dart (Take 2) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Move and Standardize Mojom Type Functions Created 4 years, 11 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
OLDNEW
1 {%- macro enum_def(enum) %} 1 {% import "mojom_type_macros.tmpl" as mojom_type_macros %}
2
zra 2016/01/27 18:15:12 I wonder if newlines like this one are contributin
alexfandrianto 2016/01/28 03:45:12 This one's probably okay since it's not part of th
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 {{enum|name}} {{field|name}} = const {{enum|name}}._({{field.reso lved_value}}); 6 static const {{enum|name}} {{field|name}} = const {{enum|name}}._({{field.reso lved_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() => mojoEnumValue; 56 int toJson() => mojoEnumValue;
53 } 57 }
58
zra 2016/01/27 18:15:12 Ditto.
alexfandrianto 2016/01/28 03:45:12 This was supposed to be intentional, but it is aff
59 {{ mojom_type_macros.writeMojomTypeDef(enum, typepkg, package) }}
60
zra 2016/01/27 18:15:12 Ditto.
alexfandrianto 2016/01/28 03:45:12 Done.
54 {%- endmacro %} 61 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698