OLD | NEW |
1 // WARNING: DO NOT EDIT. This file was generated by a program. | 1 // WARNING: DO NOT EDIT. This file was generated by a program. |
2 // See $MOJO_SDK/tools/bindings/mojom_bindings_generator.py. | 2 // See $MOJO_SDK/tools/bindings/mojom_bindings_generator.py. |
3 | 3 |
4 library echo_mojom; | 4 library echo_mojom; |
5 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:collection'; | 6 import 'dart:collection'; |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:typed_data'; | 9 import 'dart:typed_data'; |
10 import 'package:mojo/bindings.dart' as bindings; | 10 import 'package:mojo/bindings.dart' as bindings; |
11 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; | 12 import 'package:mojo/mojo/bindings/types/mojom_types.mojom.dart' as mojom_types; |
13 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; | 13 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; |
14 | 14 |
15 | 15 |
16 | 16 |
17 class _EchoEchoStringParams extends bindings.Struct { | 17 class _EchoEchoStringParams extends bindings.Struct { |
18 static const List<bindings.StructDataHeader> kVersions = const [ | 18 static const List<bindings.StructDataHeader> kVersions = const [ |
19 const bindings.StructDataHeader(16, 0) | 19 const bindings.StructDataHeader(16, 0) |
20 ]; | 20 ]; |
21 String value = null; | 21 String value = null; |
22 | 22 |
23 _EchoEchoStringParams() : super(kVersions.last.size); | 23 _EchoEchoStringParams() : super(kVersions.last.size); |
24 | 24 |
| 25 _EchoEchoStringParams.init( |
| 26 String this.value |
| 27 ) : super(kVersions.last.size); |
| 28 |
25 static _EchoEchoStringParams deserialize(bindings.Message message) { | 29 static _EchoEchoStringParams deserialize(bindings.Message message) { |
26 var decoder = new bindings.Decoder(message); | 30 var decoder = new bindings.Decoder(message); |
27 var result = decode(decoder); | 31 var result = decode(decoder); |
28 if (decoder.excessHandles != null) { | 32 if (decoder.excessHandles != null) { |
29 decoder.excessHandles.forEach((h) => h.close()); | 33 decoder.excessHandles.forEach((h) => h.close()); |
30 } | 34 } |
31 return result; | 35 return result; |
32 } | 36 } |
33 | 37 |
34 static _EchoEchoStringParams decode(bindings.Decoder decoder0) { | 38 static _EchoEchoStringParams decode(bindings.Decoder decoder0) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 91 |
88 | 92 |
89 class EchoEchoStringResponseParams extends bindings.Struct { | 93 class EchoEchoStringResponseParams extends bindings.Struct { |
90 static const List<bindings.StructDataHeader> kVersions = const [ | 94 static const List<bindings.StructDataHeader> kVersions = const [ |
91 const bindings.StructDataHeader(16, 0) | 95 const bindings.StructDataHeader(16, 0) |
92 ]; | 96 ]; |
93 String value = null; | 97 String value = null; |
94 | 98 |
95 EchoEchoStringResponseParams() : super(kVersions.last.size); | 99 EchoEchoStringResponseParams() : super(kVersions.last.size); |
96 | 100 |
| 101 EchoEchoStringResponseParams.init( |
| 102 String this.value |
| 103 ) : super(kVersions.last.size); |
| 104 |
97 static EchoEchoStringResponseParams deserialize(bindings.Message message) { | 105 static EchoEchoStringResponseParams deserialize(bindings.Message message) { |
98 var decoder = new bindings.Decoder(message); | 106 var decoder = new bindings.Decoder(message); |
99 var result = decode(decoder); | 107 var result = decode(decoder); |
100 if (decoder.excessHandles != null) { | 108 if (decoder.excessHandles != null) { |
101 decoder.excessHandles.forEach((h) => h.close()); | 109 decoder.excessHandles.forEach((h) => h.close()); |
102 } | 110 } |
103 return result; | 111 return result; |
104 } | 112 } |
105 | 113 |
106 static EchoEchoStringResponseParams decode(bindings.Decoder decoder0) { | 114 static EchoEchoStringResponseParams decode(bindings.Decoder decoder0) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 Map toJson() { | 161 Map toJson() { |
154 Map map = new Map(); | 162 Map map = new Map(); |
155 map["value"] = value; | 163 map["value"] = value; |
156 return map; | 164 return map; |
157 } | 165 } |
158 } | 166 } |
159 | 167 |
160 const int _echoMethodEchoStringName = 0; | 168 const int _echoMethodEchoStringName = 0; |
161 | 169 |
162 class _EchoServiceDescription implements service_describer.ServiceDescription { | 170 class _EchoServiceDescription implements service_describer.ServiceDescription { |
163 dynamic getTopLevelInterface([Function responseFactory]){ | 171 void getTopLevelInterface(Function responder){ |
164 var interfaceTypeKey = getRuntimeTypeInfo().services["mojo::examples::Echo"]
; | 172 var interfaceTypeKey = getRuntimeTypeInfo().services["mojo::examples::Echo"]
; |
165 var userDefinedType = getAllMojomTypeDefinitions()[interfaceTypeKey]; | 173 var userDefinedType = getAllMojomTypeDefinitions()[interfaceTypeKey]; |
166 return responseFactory(userDefinedType.interfaceType); | 174 responder(userDefinedType.interfaceType); |
167 } | 175 } |
168 | 176 |
169 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => | 177 void getTypeDefinition(String typeKey, Function responder) { |
170 responseFactory(getAllMojomTypeDefinitions()[typeKey]); | 178 responder(getAllMojomTypeDefinitions()[typeKey]); |
| 179 } |
171 | 180 |
172 dynamic getAllTypeDefinitions([Function responseFactory]) => | 181 void getAllTypeDefinitions(Function responder) { |
173 responseFactory(getAllMojomTypeDefinitions()); | 182 responder(getAllMojomTypeDefinitions()); |
| 183 } |
174 } | 184 } |
175 | 185 |
176 abstract class Echo { | 186 abstract class Echo { |
177 static const String serviceName = "mojo::examples::Echo"; | 187 static const String serviceName = "mojo::examples::Echo"; |
178 | 188 |
179 static service_describer.ServiceDescription _cachedServiceDescription; | 189 static service_describer.ServiceDescription _cachedServiceDescription; |
180 static service_describer.ServiceDescription get serviceDescription { | 190 static service_describer.ServiceDescription get serviceDescription { |
181 if (_cachedServiceDescription == null) { | 191 if (_cachedServiceDescription == null) { |
182 _cachedServiceDescription = new _EchoServiceDescription(); | 192 _cachedServiceDescription = new _EchoServiceDescription(); |
183 } | 193 } |
184 return _cachedServiceDescription; | 194 return _cachedServiceDescription; |
185 } | 195 } |
186 | 196 |
187 static EchoProxy connectToService( | 197 static EchoProxy connectToService( |
188 bindings.ServiceConnector s, String url, [String serviceName]) { | 198 bindings.ServiceConnector s, String url, [String serviceName]) { |
189 EchoProxy p = new EchoProxy.unbound(); | 199 EchoProxy p = new EchoProxy.unbound(); |
190 String name = serviceName ?? Echo.serviceName; | 200 String name = serviceName ?? Echo.serviceName; |
191 if ((name == null) || name.isEmpty) { | 201 if ((name == null) || name.isEmpty) { |
192 throw new core.MojoApiError( | 202 throw new core.MojoApiError( |
193 "If an interface has no ServiceName, then one must be provided."); | 203 "If an interface has no ServiceName, then one must be provided."); |
194 } | 204 } |
195 s.connectToService(url, p, name); | 205 s.connectToService(url, p, name); |
196 return p; | 206 return p; |
197 } | 207 } |
198 dynamic echoString(String value,[Function responseFactory = null]); | 208 void echoString(String value,void callback(String value)); |
199 } | 209 } |
200 | 210 |
201 abstract class EchoInterface | 211 abstract class EchoInterface |
202 implements bindings.MojoInterface<Echo>, | 212 implements bindings.MojoInterface<Echo>, |
203 Echo { | 213 Echo { |
204 factory EchoInterface([Echo impl]) => | 214 factory EchoInterface([Echo impl]) => |
205 new EchoStub.unbound(impl); | 215 new EchoStub.unbound(impl); |
206 | 216 |
207 factory EchoInterface.fromEndpoint( | 217 factory EchoInterface.fromEndpoint( |
208 core.MojoMessagePipeEndpoint endpoint, | 218 core.MojoMessagePipeEndpoint endpoint, |
(...skipping 29 matching lines...) Expand all Loading... |
238 | 248 |
239 void handleResponse(bindings.ServiceMessage message) { | 249 void handleResponse(bindings.ServiceMessage message) { |
240 switch (message.header.type) { | 250 switch (message.header.type) { |
241 case _echoMethodEchoStringName: | 251 case _echoMethodEchoStringName: |
242 var r = EchoEchoStringResponseParams.deserialize( | 252 var r = EchoEchoStringResponseParams.deserialize( |
243 message.payload); | 253 message.payload); |
244 if (!message.header.hasRequestId) { | 254 if (!message.header.hasRequestId) { |
245 proxyError("Expected a message with a valid request Id."); | 255 proxyError("Expected a message with a valid request Id."); |
246 return; | 256 return; |
247 } | 257 } |
248 Completer c = completerMap[message.header.requestId]; | 258 Function callback = callbackMap[message.header.requestId]; |
249 if (c == null) { | 259 if (callback == null) { |
250 proxyError( | 260 proxyError( |
251 "Message had unknown request Id: ${message.header.requestId}"); | 261 "Message had unknown request Id: ${message.header.requestId}"); |
252 return; | 262 return; |
253 } | 263 } |
254 completerMap.remove(message.header.requestId); | 264 callbackMap.remove(message.header.requestId); |
255 if (c.isCompleted) { | 265 callback(r.value ); |
256 proxyError("Response completer already completed"); | |
257 return; | |
258 } | |
259 c.complete(r); | |
260 break; | 266 break; |
261 default: | 267 default: |
262 proxyError("Unexpected message type: ${message.header.type}"); | 268 proxyError("Unexpected message type: ${message.header.type}"); |
263 close(immediate: true); | 269 close(immediate: true); |
264 break; | 270 break; |
265 } | 271 } |
266 } | 272 } |
267 | 273 |
268 @override | 274 @override |
269 String toString() { | 275 String toString() { |
(...skipping 24 matching lines...) Expand all Loading... |
294 return newMockedProxy; | 300 return newMockedProxy; |
295 } | 301 } |
296 | 302 |
297 static EchoProxy newFromEndpoint( | 303 static EchoProxy newFromEndpoint( |
298 core.MojoMessagePipeEndpoint endpoint) { | 304 core.MojoMessagePipeEndpoint endpoint) { |
299 assert(endpoint.setDescription("For EchoProxy")); | 305 assert(endpoint.setDescription("For EchoProxy")); |
300 return new EchoProxy.fromEndpoint(endpoint); | 306 return new EchoProxy.fromEndpoint(endpoint); |
301 } | 307 } |
302 | 308 |
303 | 309 |
304 dynamic echoString(String value,[Function responseFactory = null]) { | 310 void echoString(String value,void callback(String value)) { |
305 if (impl != null) { | 311 if (impl != null) { |
306 return new Future(() => impl.echoString(value,_EchoStubControl._echoEchoSt
ringResponseParamsFactory)); | 312 impl.echoString(value,callback); |
| 313 return; |
307 } | 314 } |
308 var params = new _EchoEchoStringParams(); | 315 var params = new _EchoEchoStringParams(); |
309 params.value = value; | 316 params.value = value; |
310 return ctrl.sendMessageWithRequestId( | 317 ctrl.sendMessageWithRequestId( |
311 params, | 318 params, |
312 _echoMethodEchoStringName, | 319 _echoMethodEchoStringName, |
313 -1, | 320 -1, |
314 bindings.MessageHeader.kMessageExpectsResponse); | 321 bindings.MessageHeader.kMessageExpectsResponse, |
| 322 callback); |
315 } | 323 } |
316 } | 324 } |
317 | 325 |
318 class _EchoStubControl | 326 class _EchoStubControl |
319 extends bindings.StubMessageHandler | 327 extends bindings.StubMessageHandler |
320 implements bindings.StubControl<Echo> { | 328 implements bindings.StubControl<Echo> { |
321 Echo _impl; | 329 Echo _impl; |
322 | 330 |
323 _EchoStubControl.fromEndpoint( | 331 _EchoStubControl.fromEndpoint( |
324 core.MojoMessagePipeEndpoint endpoint, [Echo impl]) | 332 core.MojoMessagePipeEndpoint endpoint, [Echo impl]) |
325 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 333 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
326 _impl = impl; | 334 _impl = impl; |
327 } | 335 } |
328 | 336 |
329 _EchoStubControl.fromHandle( | 337 _EchoStubControl.fromHandle( |
330 core.MojoHandle handle, [Echo impl]) | 338 core.MojoHandle handle, [Echo impl]) |
331 : super.fromHandle(handle, autoBegin: impl != null) { | 339 : super.fromHandle(handle, autoBegin: impl != null) { |
332 _impl = impl; | 340 _impl = impl; |
333 } | 341 } |
334 | 342 |
335 _EchoStubControl.unbound([this._impl]) : super.unbound(); | 343 _EchoStubControl.unbound([this._impl]) : super.unbound(); |
336 | 344 |
337 String get serviceName => Echo.serviceName; | 345 String get serviceName => Echo.serviceName; |
338 | 346 |
339 | 347 |
340 static EchoEchoStringResponseParams _echoEchoStringResponseParamsFactory(Strin
g value) { | 348 Function _echoEchoStringResponseParamsResponder( |
341 var result = new EchoEchoStringResponseParams(); | 349 int requestId) { |
342 result.value = value; | 350 return (String value) { |
343 return result; | 351 var result = new EchoEchoStringResponseParams(); |
| 352 result.value = value; |
| 353 sendResponse(buildResponseWithId( |
| 354 result, |
| 355 _echoMethodEchoStringName, |
| 356 requestId, |
| 357 bindings.MessageHeader.kMessageIsResponse)); |
| 358 }; |
344 } | 359 } |
345 | 360 |
346 dynamic handleMessage(bindings.ServiceMessage message) { | 361 void handleMessage(bindings.ServiceMessage message) { |
347 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 362 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
348 return bindings.ControlMessageHandler.handleMessage(this, | 363 bindings.ControlMessageHandler.handleMessage( |
349 0, | 364 this, 0, message); |
350 message); | 365 return; |
351 } | 366 } |
352 if (_impl == null) { | 367 if (_impl == null) { |
353 throw new core.MojoApiError("$this has no implementation set"); | 368 throw new core.MojoApiError("$this has no implementation set"); |
354 } | 369 } |
355 switch (message.header.type) { | 370 switch (message.header.type) { |
356 case _echoMethodEchoStringName: | 371 case _echoMethodEchoStringName: |
357 var params = _EchoEchoStringParams.deserialize( | 372 var params = _EchoEchoStringParams.deserialize( |
358 message.payload); | 373 message.payload); |
359 var response = _impl.echoString(params.value,_echoEchoStringResponsePara
msFactory); | 374 _impl.echoString(params.value, _echoEchoStringResponseParamsResponder(me
ssage.header.requestId)); |
360 if (response is Future) { | |
361 return response.then((response) { | |
362 if (response != null) { | |
363 return buildResponseWithId( | |
364 response, | |
365 _echoMethodEchoStringName, | |
366 message.header.requestId, | |
367 bindings.MessageHeader.kMessageIsResponse); | |
368 } | |
369 }); | |
370 } else if (response != null) { | |
371 return buildResponseWithId( | |
372 response, | |
373 _echoMethodEchoStringName, | |
374 message.header.requestId, | |
375 bindings.MessageHeader.kMessageIsResponse); | |
376 } | |
377 break; | 375 break; |
378 default: | 376 default: |
379 throw new bindings.MojoCodecError("Unexpected message name"); | 377 throw new bindings.MojoCodecError("Unexpected message name"); |
380 break; | 378 break; |
381 } | 379 } |
382 return null; | |
383 } | 380 } |
384 | 381 |
385 Echo get impl => _impl; | 382 Echo get impl => _impl; |
386 set impl(Echo d) { | 383 set impl(Echo d) { |
387 if (d == null) { | 384 if (d == null) { |
388 throw new core.MojoApiError("$this: Cannot set a null implementation"); | 385 throw new core.MojoApiError("$this: Cannot set a null implementation"); |
389 } | 386 } |
390 if (isBound && (_impl == null)) { | 387 if (isBound && (_impl == null)) { |
391 beginHandlingEvents(); | 388 beginHandlingEvents(); |
392 } | 389 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 core.MojoHandle handle, [Echo impl]) | 423 core.MojoHandle handle, [Echo impl]) |
427 : super(new _EchoStubControl.fromHandle(handle, impl)); | 424 : super(new _EchoStubControl.fromHandle(handle, impl)); |
428 | 425 |
429 static EchoStub newFromEndpoint( | 426 static EchoStub newFromEndpoint( |
430 core.MojoMessagePipeEndpoint endpoint) { | 427 core.MojoMessagePipeEndpoint endpoint) { |
431 assert(endpoint.setDescription("For EchoStub")); | 428 assert(endpoint.setDescription("For EchoStub")); |
432 return new EchoStub.fromEndpoint(endpoint); | 429 return new EchoStub.fromEndpoint(endpoint); |
433 } | 430 } |
434 | 431 |
435 | 432 |
436 dynamic echoString(String value,[Function responseFactory = null]) { | 433 void echoString(String value,void callback(String value)) { |
437 return impl.echoString(value,responseFactory); | 434 return impl.echoString(value,callback); |
438 } | 435 } |
439 } | 436 } |
440 | 437 |
441 | 438 |
442 mojom_types.RuntimeTypeInfo getRuntimeTypeInfo() => _runtimeTypeInfo ?? | 439 mojom_types.RuntimeTypeInfo getRuntimeTypeInfo() => _runtimeTypeInfo ?? |
443 _initRuntimeTypeInfo(); | 440 _initRuntimeTypeInfo(); |
444 | 441 |
445 Map<String, mojom_types.UserDefinedType> getAllMojomTypeDefinitions() { | 442 Map<String, mojom_types.UserDefinedType> getAllMojomTypeDefinitions() { |
446 return getRuntimeTypeInfo().typeMap; | 443 return getRuntimeTypeInfo().typeMap; |
447 } | 444 } |
448 | 445 |
449 var _runtimeTypeInfo; | 446 var _runtimeTypeInfo; |
450 mojom_types.RuntimeTypeInfo _initRuntimeTypeInfo() { | 447 mojom_types.RuntimeTypeInfo _initRuntimeTypeInfo() { |
451 // serializedRuntimeTypeInfo contains the bytes of the Mojo serialization of | 448 // serializedRuntimeTypeInfo contains the bytes of the Mojo serialization of |
452 // a mojom_types.RuntimeTypeInfo struct describing the Mojom types in this | 449 // a mojom_types.RuntimeTypeInfo struct describing the Mojom types in this |
453 // file. The string contains the base64 encoding of the gzip-compressed bytes. | 450 // file. The string contains the base64 encoding of the gzip-compressed bytes. |
454 var serializedRuntimeTypeInfo = "H4sIAAAJbogC/5JggAABKN0BpdHFLZD4jEDMAeXLALEIE
OfmZ+VbWaVWJOYW5KQWW1m5JmfkY1OvDMTSQBwSGeAa7+0aaQXSqAfTpwfThmG/Aw77STGPEaqfGUm/B
pRWgNIejBA6AUozoNkPC4cZUHoBlP4PBRsYsAN0dytgCWd2JHFhIOYG4uDUorLM5FS/xNxUosKbB4hZg
BjGlwJiIah6LMGCEc6cQMwFxJZAbAjE+hn5uan6RaUp+bmZealF+iBz9IuLkvVhZumnAs0CE3oguVwi0
wW6vTA+DzSccIUbenydgNFM2OMLBgzQ+KC4wiYOA0LQcAC5N7ikKDMvHXt4gdQwUSG80NMD3F+MxPsHB
Cxw+AeWDhD+0S1KLSxNLS7B7i8YoNRf6PHngKM8ucBAHCA2XjVw6OcFYlYgLkvMKU3FEZ+iVPI3A1JaR
g8HCSQ3MSKpp3U6kIaWLSjpoLggP684dTQdoKUDjQFMB4AAAAD//1YHjLGYBwAA"; | 451 var serializedRuntimeTypeInfo = "H4sIAAAJbogC/5JggAABKN0BpdHFLZD4jEDMAeXLALEIE
OfmZ+VbWaVWJOYW5KQWW1m5JmfkY1OvDMTSQBwSGeAa7+0aaQXSqAfTpwfThmG/Aw77STGPEaqfGUm/B
pRWgNIBjBA6A0ozoNkPC4cZUHoBlP4PBRsYsAN0dytgCWd2JHFhIOYG4uDUorLM5FS/xNxUosKbB4hZg
BjGlwJiIah6LMGCEc6cQMwF0g/EtkCsX1pcpJ+Tn5yYo5+en5+ek6qfkZ+bql9VlKgPMtJIv7goWR9mr
n4q0FwwoQeSzCXCvej2w/g80PDCFX7o8XYBSj9gwh5vMGCAxgfFGTZxGBCChQfQvcElRZl56djDDaSGi
Yrhhp4+YP67wUi8v0DAAoe/YOkC4S/dotTC0tTiEuz+gwFq+Q89Ph1wlDM3GIgDxMazBg79vEDMCsRli
TmlqTjiV5TK/mdASuPo4SGB5DZGJPW0ThfS0LIHJV0UF+TnFaeOpgsc6UJjEKQLQAAAAP//GmHdL8gHA
AA="; |
455 | 452 |
456 // Deserialize RuntimeTypeInfo | 453 // Deserialize RuntimeTypeInfo |
457 var bytes = BASE64.decode(serializedRuntimeTypeInfo); | 454 var bytes = BASE64.decode(serializedRuntimeTypeInfo); |
458 var unzippedBytes = new ZLibDecoder().convert(bytes); | 455 var unzippedBytes = new ZLibDecoder().convert(bytes); |
459 var bdata = new ByteData.view(unzippedBytes.buffer); | 456 var bdata = new ByteData.view(unzippedBytes.buffer); |
460 var message = new bindings.Message(bdata, null, unzippedBytes.length, 0); | 457 var message = new bindings.Message(bdata, null, unzippedBytes.length, 0); |
461 _runtimeTypeInfo = mojom_types.RuntimeTypeInfo.deserialize(message); | 458 _runtimeTypeInfo = mojom_types.RuntimeTypeInfo.deserialize(message); |
462 return _runtimeTypeInfo; | 459 return _runtimeTypeInfo; |
463 } | 460 } |
OLD | NEW |