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

Unified Diff: third_party/mojo/src/mojo/public/tools/bindings/generators/dart_templates/struct_definition.tmpl

Issue 1157843002: Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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: third_party/mojo/src/mojo/public/tools/bindings/generators/dart_templates/struct_definition.tmpl
diff --git a/third_party/mojo/src/mojo/public/tools/bindings/generators/dart_templates/struct_definition.tmpl b/third_party/mojo/src/mojo/public/tools/bindings/generators/dart_templates/struct_definition.tmpl
index 9f62100bebda95806010abaf8ae95366d2e5c779..226a060036679ff85ca13e142d7b6068bb2c222a 100644
--- a/third_party/mojo/src/mojo/public/tools/bindings/generators/dart_templates/struct_definition.tmpl
+++ b/third_party/mojo/src/mojo/public/tools/bindings/generators/dart_templates/struct_definition.tmpl
@@ -33,9 +33,12 @@ encoder{{level}}.{{kind|encode_method(variable, offset, bit)}};
{%- macro decode(variable, kind, offset, bit, level=0) %}
-{%- if kind|is_struct_kind or kind|is_pointer_array_kind or kind|is_map_kind %}
+{%- if kind|is_struct_kind or
+ kind|is_union_kind or
+ kind|is_pointer_array_kind or
+ kind|is_map_kind %}
var decoder{{level+1}} = decoder{{level}}.decodePointer({{offset}}, {{kind|is_nullable_kind|dart_true_false}});
-{%- if kind|is_struct_kind %}
+{%- if kind|is_struct_kind or kind|is_union_kind %}
{{variable}} = {{kind|dart_type}}.decode(decoder{{level+1}});
{%- else %}{# kind|is_pointer_array_kind or is_map_kind #}
{%- if kind|is_nullable_kind %}
@@ -117,9 +120,12 @@ class {{struct|name}} extends bindings.Struct {
// Scan in reverse order to optimize for more recent versions.
for (int i = kVersions.length - 1; i >= 0; --i) {
if (mainDataHeader.version >= kVersions[i].version) {
- if (mainDataHeader.size != kVersions[i].size)
- throw new bindings.MojoCodecError(
- 'Header doesn\'t correspond to any known version.');
+ if (mainDataHeader.size == kVersions[i].size) {
+ // Found a match.
+ break;
+ }
+ throw new bindings.MojoCodecError(
+ 'Header size doesn\'t correspond to known version size.');
}
}
} else if (mainDataHeader.size < kVersions.last.size) {

Powered by Google App Engine
This is Rietveld 408576698