Index: mojo/dart/packages/_mojo_for_test_only/lib/mojo/test/test_included_unions.mojom.dart |
diff --git a/mojo/dart/packages/_mojo_for_test_only/lib/mojo/test/test_included_unions.mojom.dart b/mojo/dart/packages/_mojo_for_test_only/lib/mojo/test/test_included_unions.mojom.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a458991a57b4dfd45c926e195c041fcb1f8d75c5 |
--- /dev/null |
+++ b/mojo/dart/packages/_mojo_for_test_only/lib/mojo/test/test_included_unions.mojom.dart |
@@ -0,0 +1,133 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+library test_included_unions_mojom; |
+ |
+import 'dart:async'; |
+ |
+import 'package:mojo/bindings.dart' as bindings; |
+import 'package:mojo/core.dart' as core; |
+import 'package:mojo/mojo/mojom_types.mojom.dart' as mojom_types; |
+ |
+ |
+ |
+ |
+ |
+enum IncludedUnionTag { |
+ a, |
+ unknown |
+} |
+ |
+class IncludedUnion extends bindings.Union { |
+ static final _tag_to_int = const { |
+ IncludedUnionTag.a: 0, |
+ }; |
+ |
+ static final _int_to_tag = const { |
+ 0: IncludedUnionTag.a, |
+ }; |
+ |
+ var _data; |
+ IncludedUnionTag _tag = IncludedUnionTag.unknown; |
+ |
+ IncludedUnionTag get tag => _tag; |
+ int get a { |
+ if (_tag != IncludedUnionTag.a) { |
+ throw new bindings.UnsetUnionTagError(_tag, IncludedUnionTag.a); |
+ } |
+ return _data; |
+ } |
+ |
+ set a(int value) { |
+ _tag = IncludedUnionTag.a; |
+ _data = value; |
+ } |
+ |
+ static IncludedUnion decode(bindings.Decoder decoder0, int offset) { |
+ int size = decoder0.decodeUint32(offset); |
+ if (size == 0) { |
+ return null; |
+ } |
+ IncludedUnion result = new IncludedUnion(); |
+ |
+ // TODO(azani): Handle unknown union member. An assert breaks validation_unittest. |
+ IncludedUnionTag tag = _int_to_tag[decoder0.decodeUint32(offset + 4)]; |
+ switch (tag) { |
+ case IncludedUnionTag.a: |
+ |
+ result.a = decoder0.decodeInt8(offset + 8); |
+ break; |
+ default: |
+ break; |
+ } |
+ |
+ return result; |
+ } |
+ |
+ void encode(bindings.Encoder encoder0, int offset) { |
+ // TODO(azani): Error when trying to encode an unknown member. |
+ encoder0.encodeUint32(16, offset); |
+ encoder0.encodeUint32(_tag_to_int[_tag], offset + 4); |
+ switch (_tag) { |
+ case IncludedUnionTag.a: |
+ |
+ encoder0.encodeInt8(a, offset + 8); |
+ break; |
+ default: |
+ break; |
+ } |
+ } |
+ |
+ String toString() { |
+ String result = "IncludedUnion("; |
+ switch (_tag) { |
+ case IncludedUnionTag.a: |
+ result += "a"; |
+ break; |
+ default: |
+ result += "unknown"; |
+ } |
+ result += ": $_data)"; |
+ return result; |
+ } |
+} |
+ |
+mojom_types.MojomUnion _test_included_unions_IncludedUnion__() { |
+ return new mojom_types.MojomUnion() |
+ ..declData = (new mojom_types.DeclarationData()..shortName = 'IncludedUnion') |
+ ..fields = <mojom_types.UnionField>[ |
+ new mojom_types.UnionField() |
+ ..declData = (new mojom_types.DeclarationData()..shortName = 'A') |
+ ..type = (new mojom_types.Type()..simpleType = mojom_types.SimpleType.INT8) |
+ ..tag = 0, |
+ ]; |
+} |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+var _MojomDesc__ = _initDescriptions(); |
+ |
+Map<String, mojom_types.UserDefinedType> _initDescriptions() { |
+ var map = new Map<String, mojom_types.UserDefinedType>(); |
+ |
+ map["_test_included_unions_IncludedUnion__"] = |
+ new mojom_types.UserDefinedType() |
+ ..unionType = _test_included_unions_IncludedUnion__(); |
+ |
+ |
+ |
+ |
+ return map; |
+} |
+ |
+Map<String, mojom_types.UserDefinedType> getAllMojomTypeDefinitions() { |
+ return _MojomDesc__; |
+} |
+ |
+ |