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 import 'dart:collection'; | 6 import 'dart:collection'; |
7 import 'dart:typed_data'; | |
7 import 'package:mojo/bindings.dart' as bindings; | 8 import 'package:mojo/bindings.dart' as bindings; |
8 import 'package:mojo/mojo/bindings/types/mojom_types.mojom.dart' as mojom_types; | 9 import 'package:mojo/mojo/bindings/types/mojom_types.mojom.dart' as mojom_types; |
9 | 10 |
10 | 11 |
11 | 12 |
12 | 13 |
13 | 14 |
14 enum IncludedUnionTag { | 15 enum IncludedUnionTag { |
15 a, | 16 a, |
16 unknown | 17 unknown |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 result += "a"; | 83 result += "a"; |
83 break; | 84 break; |
84 default: | 85 default: |
85 result += "unknown"; | 86 result += "unknown"; |
86 } | 87 } |
87 result += ": $_data)"; | 88 result += ": $_data)"; |
88 return result; | 89 return result; |
89 } | 90 } |
90 } | 91 } |
91 | 92 |
92 mojom_types.MojomUnion _testIncludedUnionsIncludedUnion() { | 93 mojom_types.RuntimeTypeInfo getRuntimeTypeInfo() => _runtimeTypeInfo ?? |
93 return new mojom_types.MojomUnion() | 94 _initRuntimeTypeInfo(); |
94 ..declData = (new mojom_types.DeclarationData() | 95 |
95 ..shortName = 'IncludedUnion' | 96 Map<String, mojom_types.UserDefinedType> getAllMojomTypeDefinitions() { |
96 ..fullIdentifier = 'mojo.test.IncludedUnion') | 97 return getRuntimeTypeInfo().typeMap; |
97 ..fields = <mojom_types.UnionField>[ | |
98 new mojom_types.UnionField() | |
99 ..declData = (new mojom_types.DeclarationData() | |
100 ..shortName = 'A') | |
101 ..type = (new mojom_types.Type() | |
102 ..simpleType = mojom_types.SimpleType.int8) | |
103 ..tag = 0,]; | |
104 } | 98 } |
105 | 99 |
100 var _runtimeTypeInfo; | |
101 mojom_types.RuntimeTypeInfo _initRuntimeTypeInfo() { | |
102 // serializedRuntimeTypeInfo contains the bytes of the Mojo serialization of | |
103 // a mojom_types.RuntimeTypeInfo struct describing the Mojom types in this | |
104 // file. | |
105 var serializedRuntimeTypeInfo = new Uint8List.fromList(const [24,0,0,0,0,0,0,0 ,16,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,16,0,0,0,0, 0,0,0,8,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,64,0,0,0 ,0,0,0,0,16,0,0,0,1,0,0,0,8,0,0,0,0,0,0,0,40,0,0,0,32,0,0,0,84,89,80,69,95,75,69 ,89,58,109,111,106,111,46,116,101,115,116,46,73,110,99,108,117,100,101,100,85,11 0,105,111,110,24,0,0,0,1,0,0,0,16,0,0,0,2,0,0,0,8,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0 ,16,0,0,0,0,0,0,0,8,1,0,0,0,0,0,0,72,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,2 55,255,255,48,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,80,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,21,0,0,0,13,0,0,0,73,110,99,108,117,100,10 1,100,85,110,105,111,110,0,0,0,31,0,0,0,23,0,0,0,109,111,106,111,46,116,101,115, 116,46,73,110,99,108,117,100,101,100,85,110,105,111,110,0,24,0,0,0,0,0,0,0,16,0, 0,0,0,0,0,0,7,0,0,0,6,0,0,0,97,0,0,0,89,0,0,0,47,104,111,109,101,47,114,117,100, 111,109,105,110,101,114,47,109,111,106,111,47,115,114,99,47,109,111,106,111,47,1 12,117,98,108,105,99,47,105,110,116,101,114,102,97,99,101,115,47,98,105,110,100, 105,110,103,115,47,116,101,115,116,115,47,116,101,115,116,95,105,110,99,108,117, 100,101,100,95,117,110,105,111,110,115,46,109,111,106,111,109,0,0,0,0,0,0,0,16,0 ,0,0,1,0,0,0,8,0,0,0,0,0,0,0,40,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0, 3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,72,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255 ,255,255,48,0,0,0,0,0,0,0,56,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,48,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0,0,1,0,0,0,97,0,0,0,0,0,0,0,8,0,0,0,0,0 ,0,0,24,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,8,0,0,0,7,0,0,0,97,0,0,0,89,0,0,0,47,104, 111,109,101,47,114,117,100,111,109,105,110,101,114,47,109,111,106,111,47,115,114 ,99,47,109,111,106,111,47,112,117,98,108,105,99,47,105,110,116,101,114,102,97,99 ,101,115,47,98,105,110,100,105,110,103,115,47,116,101,115,116,115,47,116,101,115 ,116,95,105,110,99,108,117,100,101,100,95,117,110,105,111,110,115,46,109,111,106 ,111,109,0,0,0,0,0,0,0]); | |
106 | 106 |
107 Map<String, mojom_types.UserDefinedType> _initDescriptions() { | 107 // Deserialize RuntimeTypeInfo |
108 var map = new HashMap<String, mojom_types.UserDefinedType>(); | 108 var bdata = new ByteData.view(serializedRuntimeTypeInfo.buffer); |
109 map["test_included_unions_IncludedUnion__"] = | 109 var message = new bindings.Message(bdata, null, serializedRuntimeTypeInfo.leng th, 0); |
110 new mojom_types.UserDefinedType() | 110 _runtimeTypeInfo = mojom_types.RuntimeTypeInfo.deserialize(message); |
111 ..unionType = _testIncludedUnionsIncludedUnion(); | 111 return _runtimeTypeInfo; |
112 return map; | |
113 } | 112 } |
114 | |
115 var _mojomDesc; | |
116 Map<String, mojom_types.UserDefinedType> getAllMojomTypeDefinitions() { | |
117 if (_mojomDesc == null) { | |
118 _mojomDesc = _initDescriptions(); | |
119 } | |
120 return _mojomDesc; | |
121 } | |
122 | |
OLD | NEW |