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

Unified Diff: mojo/public/tools/bindings/generators/dart_templates/union_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, 1 month 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/union_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/dart_templates/union_definition.tmpl b/mojo/public/tools/bindings/generators/dart_templates/union_definition.tmpl
index 511201eb30da382ae42d4f2506a3ab71108972fa..e0d67e9a4df8bd3cb225ec6fe839fdd20f73cc11 100644
--- a/mojo/public/tools/bindings/generators/dart_templates/union_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/dart_templates/union_definition.tmpl
@@ -1,8 +1,9 @@
{#--- Begin #}
{%- import "encoding_macros.tmpl" as encoding_macros %}
+{% import "mojom_type_macros.tmpl" as mojom_type_macros %}
-{%- macro enum_def(union) %}
+{%- macro enum_def(union, typepkg, package) %}
enum {{union|name}}Tag {
{%- for field in union.fields %}
{{field|tag_name}},
@@ -51,7 +52,7 @@ class {{union|name}} extends bindings.Union {
}
{{union|name}} result = new {{union|name}}();
- // TODO(azani): Handle unknown union member.
+ // TODO(azani): Handle unknown union member. An assert breaks validation_unittest.
{{union|name}}Tag tag = _int_to_tag[decoder0.decodeUint32(offset + 4)];
switch (tag) {
{%- for field in union.fields %}
@@ -64,6 +65,8 @@ class {{union|name}} extends bindings.Union {
{%- endif %}
break;
{%- endfor %}
+ default:
zra 2015/11/24 17:34:44 If this is an error or unreachable, that should be
alexfandrianto 2015/12/18 01:53:19 Someone else fixed this.
+ break;
}
return result;
@@ -83,6 +86,8 @@ class {{union|name}} extends bindings.Union {
{%- endif %}
break;
{%- endfor %}
+ default:
zra 2015/11/24 17:34:44 ditto.
alexfandrianto 2015/12/18 01:53:19 Done.
+ break;
}
}
@@ -104,7 +109,9 @@ class {{union|name}} extends bindings.Union {
{%- endmacro %}
-{%- macro union_def(union) %}
+{%- macro union_def(union, typepkg, package) %}
{{enum_def(union)}}
{{wrapper_def(union)}}
+
+{{ mojom_type_macros.writeMojomTypeDef(union, typepkg, package) }}
{%- endmacro %}

Powered by Google App Engine
This is Rietveld 408576698