OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 library test_included_unions_mojom; | 5 library test_included_unions_mojom; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; |
8 | 9 |
9 import 'package:mojo/bindings.dart' as bindings; | 10 import 'package:mojo/bindings.dart' as bindings; |
10 import 'package:mojo/core.dart' as core; | 11 import 'package:mojo/core.dart' as core; |
| 12 import 'package:mojo/mojo/bindings/types/mojom_types.mojom.dart' as mojom_types; |
11 | 13 |
12 | 14 |
13 | 15 |
| 16 |
14 | 17 |
15 enum IncludedUnionTag { | 18 enum IncludedUnionTag { |
16 a, | 19 a, |
17 unknown | 20 unknown |
18 } | 21 } |
19 | 22 |
20 class IncludedUnion extends bindings.Union { | 23 class IncludedUnion extends bindings.Union { |
21 static final _tag_to_int = const { | 24 static final _tag_to_int = const { |
22 IncludedUnionTag.a: 0, | 25 IncludedUnionTag.a: 0, |
23 }; | 26 }; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 result += "a"; | 87 result += "a"; |
85 break; | 88 break; |
86 default: | 89 default: |
87 result += "unknown"; | 90 result += "unknown"; |
88 } | 91 } |
89 result += ": $_data)"; | 92 result += ": $_data)"; |
90 return result; | 93 return result; |
91 } | 94 } |
92 } | 95 } |
93 | 96 |
| 97 mojom_types.MojomUnion _testIncludedUnionsIncludedUnion() { |
| 98 return new mojom_types.MojomUnion() |
| 99 ..declData = (new mojom_types.DeclarationData() |
| 100 ..shortName = 'IncludedUnion' |
| 101 ..fullIdentifier = 'mojo.test.IncludedUnion') |
| 102 ..fields = <mojom_types.UnionField>[ |
| 103 new mojom_types.UnionField() |
| 104 ..declData = (new mojom_types.DeclarationData() |
| 105 ..shortName = 'A') |
| 106 ..type = (new mojom_types.Type() |
| 107 ..simpleType = mojom_types.SimpleType.int8) |
| 108 ..tag = 0,]; |
| 109 } |
| 110 |
| 111 |
| 112 Map<String, mojom_types.UserDefinedType> _initDescriptions() { |
| 113 var map = new HashMap<String, mojom_types.UserDefinedType>(); |
| 114 map["test_included_unions_IncludedUnion__"] = |
| 115 new mojom_types.UserDefinedType() |
| 116 ..unionType = _testIncludedUnionsIncludedUnion(); |
| 117 return map; |
| 118 } |
| 119 |
| 120 var _mojomDesc; |
| 121 Map<String, mojom_types.UserDefinedType> getAllMojomTypeDefinitions() { |
| 122 if (_mojomDesc == null) { |
| 123 _mojomDesc = _initDescriptions(); |
| 124 } |
| 125 return _mojomDesc; |
| 126 } |
| 127 |
OLD | NEW |