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 echo_mojom; | 5 library echo_mojom; |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:typed_data'; |
8 import 'package:mojo/bindings.dart' as bindings; | 9 import 'package:mojo/bindings.dart' as bindings; |
9 import 'package:mojo/core.dart' as core; | 10 import 'package:mojo/core.dart' as core; |
10 import 'package:mojo/mojo/bindings/types/mojom_types.mojom.dart' as mojom_types; | 11 import 'package:mojo/mojo/bindings/types/mojom_types.mojom.dart' as mojom_types; |
11 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; | 12 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; |
12 | 13 |
13 | 14 |
14 | 15 |
15 class _EchoEchoStringParams extends bindings.Struct { | 16 class _EchoEchoStringParams extends bindings.Struct { |
16 static const List<bindings.StructDataHeader> kVersions = const [ | 17 static const List<bindings.StructDataHeader> kVersions = const [ |
17 const bindings.StructDataHeader(16, 0) | 18 const bindings.StructDataHeader(16, 0) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 "value: $value" ")"; | 77 "value: $value" ")"; |
77 } | 78 } |
78 | 79 |
79 Map toJson() { | 80 Map toJson() { |
80 Map map = new Map(); | 81 Map map = new Map(); |
81 map["value"] = value; | 82 map["value"] = value; |
82 return map; | 83 return map; |
83 } | 84 } |
84 } | 85 } |
85 | 86 |
86 mojom_types.MojomStruct _echoEchoEchoStringParams() { | |
87 return new mojom_types.MojomStruct() | |
88 ..declData = (new mojom_types.DeclarationData() | |
89 ..shortName = 'EchoEchoStringParams' | |
90 ..fullIdentifier = 'mojo.examples.Echo_EchoString_Params') | |
91 ..fields = <mojom_types.StructField>[ | |
92 new mojom_types.StructField() | |
93 ..declData = (new mojom_types.DeclarationData() | |
94 ..shortName = 'Value') | |
95 ..type = (new mojom_types.Type() | |
96 ..stringType = (new mojom_types.StringType() | |
97 ..nullable = true | |
98 )),]; | |
99 } | |
100 | |
101 | 87 |
102 class EchoEchoStringResponseParams extends bindings.Struct { | 88 class EchoEchoStringResponseParams extends bindings.Struct { |
103 static const List<bindings.StructDataHeader> kVersions = const [ | 89 static const List<bindings.StructDataHeader> kVersions = const [ |
104 const bindings.StructDataHeader(16, 0) | 90 const bindings.StructDataHeader(16, 0) |
105 ]; | 91 ]; |
106 String value = null; | 92 String value = null; |
107 | 93 |
108 EchoEchoStringResponseParams() : super(kVersions.last.size); | 94 EchoEchoStringResponseParams() : super(kVersions.last.size); |
109 | 95 |
110 static EchoEchoStringResponseParams deserialize(bindings.Message message) { | 96 static EchoEchoStringResponseParams deserialize(bindings.Message message) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 "value: $value" ")"; | 149 "value: $value" ")"; |
164 } | 150 } |
165 | 151 |
166 Map toJson() { | 152 Map toJson() { |
167 Map map = new Map(); | 153 Map map = new Map(); |
168 map["value"] = value; | 154 map["value"] = value; |
169 return map; | 155 return map; |
170 } | 156 } |
171 } | 157 } |
172 | 158 |
173 mojom_types.MojomStruct _echoEchoEchoStringResponseParams() { | |
174 return new mojom_types.MojomStruct() | |
175 ..declData = (new mojom_types.DeclarationData() | |
176 ..shortName = 'EchoEchoStringResponseParams' | |
177 ..fullIdentifier = 'mojo.examples.Echo_EchoString_ResponseParams') | |
178 ..fields = <mojom_types.StructField>[ | |
179 new mojom_types.StructField() | |
180 ..declData = (new mojom_types.DeclarationData() | |
181 ..shortName = 'Value') | |
182 ..type = (new mojom_types.Type() | |
183 ..stringType = (new mojom_types.StringType() | |
184 ..nullable = true | |
185 )),]; | |
186 } | |
187 | |
188 | |
189 const int _Echo_echoStringName = 0; | 159 const int _Echo_echoStringName = 0; |
190 | 160 |
191 mojom_types.MojomInterface _echoEcho() { | |
192 return new mojom_types.MojomInterface() | |
193 ..declData = (new mojom_types.DeclarationData() | |
194 ..shortName = 'Echo' | |
195 ..fullIdentifier = 'mojo.examples.Echo') | |
196 ..serviceName_ = 'Echo' | |
197 ..methods = <int, mojom_types.MojomMethod>{ | |
198 _Echo_echoStringName: new mojom_types.MojomMethod() | |
199 ..declData = (new mojom_types.DeclarationData() | |
200 ..shortName = 'EchoString') | |
201 ..ordinal = _Echo_echoStringName | |
202 ..responseParams = _echoEchoEchoStringResponseParams() | |
203 ..parameters = _echoEchoEchoStringParams(), | |
204 }; | |
205 } | |
206 | |
207 class _EchoServiceDescription implements service_describer.ServiceDescription { | 161 class _EchoServiceDescription implements service_describer.ServiceDescription { |
208 dynamic getTopLevelInterface([Function responseFactory]) => | 162 dynamic getTopLevelInterface([Function responseFactory]){ |
209 responseFactory(_echoEcho()); | 163 var interfaceTypeKey = getRuntimeTypeInfo().servicesByName["mojo::examples::
Echo"].topLevelInterface; |
| 164 var userDefinedType = getAllMojomTypeDefinitions()[interfaceTypeKey]; |
| 165 return responseFactory(userDefinedType.interfaceType); |
| 166 } |
210 | 167 |
211 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => | 168 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => |
212 responseFactory(getAllMojomTypeDefinitions()[typeKey]); | 169 responseFactory(getAllMojomTypeDefinitions()[typeKey]); |
213 | 170 |
214 dynamic getAllTypeDefinitions([Function responseFactory]) => | 171 dynamic getAllTypeDefinitions([Function responseFactory]) => |
215 responseFactory(getAllMojomTypeDefinitions()); | 172 responseFactory(getAllMojomTypeDefinitions()); |
216 } | 173 } |
217 | 174 |
218 abstract class Echo { | 175 abstract class Echo { |
219 static const String serviceName = "mojo::examples::Echo"; | 176 static const String serviceName = "mojo::examples::Echo"; |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 static service_describer.ServiceDescription _cachedServiceDescription; | 385 static service_describer.ServiceDescription _cachedServiceDescription; |
429 static service_describer.ServiceDescription get serviceDescription { | 386 static service_describer.ServiceDescription get serviceDescription { |
430 if (_cachedServiceDescription == null) { | 387 if (_cachedServiceDescription == null) { |
431 _cachedServiceDescription = new _EchoServiceDescription(); | 388 _cachedServiceDescription = new _EchoServiceDescription(); |
432 } | 389 } |
433 return _cachedServiceDescription; | 390 return _cachedServiceDescription; |
434 } | 391 } |
435 } | 392 } |
436 | 393 |
437 | 394 |
438 Map<String, mojom_types.UserDefinedType> _initDescriptions() { | 395 mojom_types.RuntimeTypeInfo getRuntimeTypeInfo() => _runtimeTypeInfo ?? |
439 var map = new HashMap<String, mojom_types.UserDefinedType>(); | 396 _initRuntimeTypeInfo(); |
440 map["echo_Echo_EchoString_Params__"] = | 397 |
441 new mojom_types.UserDefinedType() | 398 Map<String, mojom_types.UserDefinedType> getAllMojomTypeDefinitions() { |
442 ..structType = _echoEchoEchoStringParams(); | 399 return getRuntimeTypeInfo().typeMap; |
443 map["echo_Echo_EchoString_ResponseParams__"] = | |
444 new mojom_types.UserDefinedType() | |
445 ..structType = _echoEchoEchoStringResponseParams(); | |
446 map["echo_Echo__"] = | |
447 new mojom_types.UserDefinedType() | |
448 ..interfaceType = _echoEcho(); | |
449 return map; | |
450 } | 400 } |
451 | 401 |
452 var _mojomDesc; | 402 var _runtimeTypeInfo; |
453 Map<String, mojom_types.UserDefinedType> getAllMojomTypeDefinitions() { | 403 mojom_types.RuntimeTypeInfo _initRuntimeTypeInfo() { |
454 if (_mojomDesc == null) { | 404 // serializedRuntimeTypeInfo contains the bytes of the Mojo serialization of |
455 _mojomDesc = _initDescriptions(); | 405 // a mojom_types.RuntimeTypeInfo struct describing the Mojom types in this |
456 } | 406 // file. |
457 return _mojomDesc; | 407 var serializedRuntimeTypeInfo = new Uint8List.fromList(const [24,0,0,0,0,0,0,0
,16,0,0,0,0,0,0,0,216,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,56,0,0,0,0
,0,0,0,16,0,0,0,1,0,0,0,8,0,0,0,0,0,0,0,28,0,0,0,20,0,0,0,109,111,106,111,58,58,
101,120,97,109,112,108,101,115,58,58,69,99,104,111,0,0,0,0,16,0,0,0,1,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,48,0,0,0,0,0,0,0,35,0,0,0,27,0,0,0
,84,89,80,69,95,75,69,89,58,109,111,106,111,46,101,120,97,109,112,108,101,115,46
,69,99,104,111,0,0,0,0,0,16,0,0,0,1,0,0,0,8,0,0,0,0,0,0,0,35,0,0,0,27,0,0,0,84,8
9,80,69,95,75,69,89,58,109,111,106,111,46,101,120,97,109,112,108,101,115,46,69,9
9,104,111,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,35,0,0,0,27,0,0,0,84,89,80,69,95,75,69,89,58,109,111,106
,111,46,101,120,97,109,112,108,101,115,46,69,99,104,111,0,0,0,0,0,24,0,0,0,1,0,0
,0,16,0,0,0,3,0,0,0,8,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,72,1,0,0,0
,0,0,0,96,1,0,0,0,0,0,0,72,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,255,255,255,25
5,152,0,0,0,0,0,0,0,160,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,176,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,1,0,0,0,8,0,0,0,0,0,0,0,32,0,0,0,0,0,0,
0,24,0,0,0,0,0,0,0,16,0,0,0,7,0,0,0,32,0,0,0,0,0,0,0,19,0,0,0,11,0,0,0,83,101,11
4,118,105,99,101,78,97,109,101,0,0,0,0,0,28,0,0,0,20,0,0,0,109,111,106,111,58,58
,101,120,97,109,112,108,101,115,58,58,69,99,104,111,0,0,0,0,12,0,0,0,4,0,0,0,69,
99,104,111,0,0,0,0,26,0,0,0,18,0,0,0,109,111,106,111,46,101,120,97,109,112,108,1
01,115,46,69,99,104,111,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,10
,0,0,0,57,0,0,0,49,0,0,0,47,104,111,109,101,47,114,117,100,111,109,105,110,101,1
14,47,109,111,106,111,47,115,114,99,47,101,120,97,109,112,108,101,115,47,101,99,
104,111,47,101,99,104,111,46,109,111,106,111,109,0,0,0,0,0,0,0,28,0,0,0,20,0,0,0
,109,111,106,111,58,58,101,120,97,109,112,108,101,115,58,58,69,99,104,111,0,0,0,
0,24,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,12,0,0,0,1,0,0,0,0,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,208,0,0
,0,0,0,0,0,176,2,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,0,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,4
8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,0,0,0,10,0,0,0,69,99,104,111,
83,116,114,105,110,103,0,0,0,0,0,0,24,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,9,0,0,0,2,0
,0,0,57,0,0,0,49,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,101,120,97,109,112,108,101,115,47,101,99,10
4,111,47,101,99,104,111,46,109,111,106,111,109,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0, |
| 408 24,0,0,0,0,0,0,0,208,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,0,0,0,0,0,0,0,0,255,255,255,255,0,0
,0,0,56,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,26,0,0,0,18,0,0,0,69,99,10
4,111,83,116,114,105,110,103,45,114,101,113,117,101,115,116,0,0,0,0,0,0,24,0,0,0
,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,57,0,0,0,49,0,0,0,47,104,111,109,101,4
7,114,117,100,111,109,105,110,101,114,47,109,111,106,111,47,115,114,99,47,101,12
0,97,109,112,108,101,115,47,101,99,104,111,47,101,99,104,111,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,56,0,0,0,0,0,0,0,48,0,0,0,0,0
,0,0,16,0,0,0,1,0,0,0,208,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
,0,0,0,0,0,13,0,0,0,5,0,0,0,118,97,108,117,101,0,0,0,24,0,0,0,0,0,0,0,16,0,0,0,0
,0,0,0,9,0,0,0,21,0,0,0,57,0,0,0,49,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,101,120,97,109,112,108,1
01,115,47,101,99,104,111,47,101,99,104,111,46,109,111,106,111,109,0,0,0,0,0,0,0,
16,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,24,0,0,0,0,0,0,0,208,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,0,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,56,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,27,0,0,0,19,0,0,0,69,99,104,111,83,116,114,105,110,103,4
5,114,101,115,112,111,110,115,101,0,0,0,0,0,24,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,57,0,0,0,49,0,0,0,47,104,111,109,101,47,114,117,100,111,109,105,11
0,101,114,47,109,111,106,111,47,115,114,99,47,101,120,97,109,112,108,101,115,47,
101,99,104,111,47,101,99,104,111,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,56,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,16,0,0,0,1,0,0,0,208,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,255,255,25
5,255,0,0,0,0,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,5,0,0,0,
118,97,108,117,101,0,0,0,24,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,9,0,0,0,40,0,0,0,57,0
,0,0,49,0,0,0,47,104,111,109,101,47,114,117,100,111,109,105,110,101,114,47,109,1
11,106,111,47,115,114,99,47,101,120,97,109,112,108,101,115,47,101,99,104,111,47,
101,99,104,111,46,109,111,106,111,109,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,1,0,0,0,0,0
,0,0]); |
| 409 |
| 410 // Deserialize RuntimeTypeInfo |
| 411 var bdata = new ByteData.view(serializedRuntimeTypeInfo.buffer); |
| 412 var message = new bindings.Message(bdata, null, serializedRuntimeTypeInfo.leng
th, 0); |
| 413 _runtimeTypeInfo = mojom_types.RuntimeTypeInfo.deserialize(message); |
| 414 return _runtimeTypeInfo; |
458 } | 415 } |
459 | |
OLD | NEW |