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

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: Merge with master 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..e41ca99c3cb9323d082efb636691e3b057f5834a 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 %}
+
+{%- 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,15 @@ class {{enum|name}} extends bindings.MojoEnum {
case {{field|name}}:
return '{{enum|name}}.{{field|name}}';
{%- endfor %}
+ default:
+ return null;
}
}
int toJson() => mojoEnumValue;
}
+
+{% if should_gen_mojom_types -%}
+{{ mojom_type_macros.writeMojomTypeDef(enum, typepkg, package) }}
+{%- endif -%}
{%- endmacro %}

Powered by Google App Engine
This is Rietveld 408576698