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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/tools/bindings/generators/dart_templates/enum_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/dart_templates/enum_definition.tmpl b/mojo/public/tools/bindings/generators/dart_templates/enum_definition.tmpl
index 753892021b4313c80e96f76a5c217d463cbd69f4..6e0f83a93ef121b9348ede96137bc7b08ec64aa2 100644
--- a/mojo/public/tools/bindings/generators/dart_templates/enum_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/dart_templates/enum_definition.tmpl
@@ -1,4 +1,6 @@
-{%- macro enum_def(enum) %}
+{% import "mojom_type_macros.tmpl" as mojom_type_macros %}
+
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
+{%- macro enum_def(enum, typepkg, package) -%}
class {{enum|name}} extends bindings.MojoEnum {
{%- for field in enum.fields %}
static const {{enum|name}} {{field|name}} = const {{enum|name}}._({{field.resolved_value}});
@@ -46,9 +48,14 @@ class {{enum|name}} extends bindings.MojoEnum {
case {{field|name}}:
return '{{enum|name}}.{{field|name}}';
{%- endfor %}
+ default:
+ return null;
}
}
int toJson() => mojoEnumValue;
}
+
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
+{{ mojom_type_macros.writeMojomTypeDef(enum, typepkg, package) }}
+
zra 2016/01/27 18:15:12 Ditto.
alexfandrianto 2016/01/28 03:45:12 Done.
{%- endmacro %}

Powered by Google App Engine
This is Rietveld 408576698