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 | 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; |
| 13 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; |
11 | 14 |
12 | 15 |
13 | 16 |
14 class _EchoEchoStringParams extends bindings.Struct { | 17 class _EchoEchoStringParams extends bindings.Struct { |
15 static const List<bindings.StructDataHeader> kVersions = const [ | 18 static const List<bindings.StructDataHeader> kVersions = const [ |
16 const bindings.StructDataHeader(16, 0) | 19 const bindings.StructDataHeader(16, 0) |
17 ]; | 20 ]; |
18 String value = null; | 21 String value = null; |
19 | 22 |
20 _EchoEchoStringParams() : super(kVersions.last.size); | 23 _EchoEchoStringParams() : super(kVersions.last.size); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 "value: $value" ")"; | 73 "value: $value" ")"; |
71 } | 74 } |
72 | 75 |
73 Map toJson() { | 76 Map toJson() { |
74 Map map = new Map(); | 77 Map map = new Map(); |
75 map["value"] = value; | 78 map["value"] = value; |
76 return map; | 79 return map; |
77 } | 80 } |
78 } | 81 } |
79 | 82 |
| 83 mojom_types.MojomStruct _echoEchoEchoStringParams() { |
| 84 return new mojom_types.MojomStruct() |
| 85 ..declData = (new mojom_types.DeclarationData() |
| 86 ..shortName = 'EchoEchoStringParams' |
| 87 ..fullIdentifier = 'mojo.examples.Echo_EchoString_Params') |
| 88 ..fields = <mojom_types.StructField>[ |
| 89 new mojom_types.StructField() |
| 90 ..declData = (new mojom_types.DeclarationData() |
| 91 ..shortName = 'Value') |
| 92 ..type = (new mojom_types.Type() |
| 93 ..stringType = (new mojom_types.StringType() |
| 94 ..nullable = true |
| 95 )),]; |
| 96 } |
| 97 |
80 | 98 |
81 class EchoEchoStringResponseParams extends bindings.Struct { | 99 class EchoEchoStringResponseParams extends bindings.Struct { |
82 static const List<bindings.StructDataHeader> kVersions = const [ | 100 static const List<bindings.StructDataHeader> kVersions = const [ |
83 const bindings.StructDataHeader(16, 0) | 101 const bindings.StructDataHeader(16, 0) |
84 ]; | 102 ]; |
85 String value = null; | 103 String value = null; |
86 | 104 |
87 EchoEchoStringResponseParams() : super(kVersions.last.size); | 105 EchoEchoStringResponseParams() : super(kVersions.last.size); |
88 | 106 |
89 static EchoEchoStringResponseParams deserialize(bindings.Message message) { | 107 static EchoEchoStringResponseParams deserialize(bindings.Message message) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 "value: $value" ")"; | 155 "value: $value" ")"; |
138 } | 156 } |
139 | 157 |
140 Map toJson() { | 158 Map toJson() { |
141 Map map = new Map(); | 159 Map map = new Map(); |
142 map["value"] = value; | 160 map["value"] = value; |
143 return map; | 161 return map; |
144 } | 162 } |
145 } | 163 } |
146 | 164 |
| 165 mojom_types.MojomStruct _echoEchoEchoStringResponseParams() { |
| 166 return new mojom_types.MojomStruct() |
| 167 ..declData = (new mojom_types.DeclarationData() |
| 168 ..shortName = 'EchoEchoStringResponseParams' |
| 169 ..fullIdentifier = 'mojo.examples.Echo_EchoString_ResponseParams') |
| 170 ..fields = <mojom_types.StructField>[ |
| 171 new mojom_types.StructField() |
| 172 ..declData = (new mojom_types.DeclarationData() |
| 173 ..shortName = 'Value') |
| 174 ..type = (new mojom_types.Type() |
| 175 ..stringType = (new mojom_types.StringType() |
| 176 ..nullable = true |
| 177 )),]; |
| 178 } |
| 179 |
| 180 |
147 const int _Echo_echoStringName = 0; | 181 const int _Echo_echoStringName = 0; |
148 | 182 |
| 183 mojom_types.MojomInterface _echoEcho() { |
| 184 return new mojom_types.MojomInterface() |
| 185 ..declData = (new mojom_types.DeclarationData() |
| 186 ..shortName = 'Echo' |
| 187 ..fullIdentifier = 'mojo.examples.Echo') |
| 188 ..interfaceName = 'Echo' |
| 189 ..methods = <int, mojom_types.MojomMethod>{ |
| 190 _Echo_echoStringName: new mojom_types.MojomMethod() |
| 191 ..declData = (new mojom_types.DeclarationData() |
| 192 ..shortName = 'EchoString') |
| 193 ..ordinal = _Echo_echoStringName |
| 194 ..responseParams = _echoEchoEchoStringResponseParams() |
| 195 ..parameters = _echoEchoEchoStringParams(), |
| 196 }; |
| 197 } |
| 198 |
| 199 class _EchoServiceDescription implements service_describer.ServiceDescription { |
| 200 dynamic getTopLevelInterface([Function responseFactory]) => |
| 201 _echoEcho(); |
| 202 |
| 203 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => |
| 204 getAllMojomTypeDefinitions()[typeKey]; |
| 205 |
| 206 dynamic getAllTypeDefinitions([Function responseFactory]) => |
| 207 getAllMojomTypeDefinitions(); |
| 208 } |
| 209 |
149 abstract class Echo { | 210 abstract class Echo { |
150 static const String serviceName = "mojo::examples::Echo"; | 211 static const String serviceName = "mojo::examples::Echo"; |
151 dynamic echoString(String value,[Function responseFactory = null]); | 212 dynamic echoString(String value,[Function responseFactory = null]); |
152 } | 213 } |
153 | 214 |
154 | 215 |
155 class _EchoProxyImpl extends bindings.Proxy { | 216 class _EchoProxyImpl extends bindings.Proxy { |
156 _EchoProxyImpl.fromEndpoint( | 217 _EchoProxyImpl.fromEndpoint( |
157 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 218 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
158 | 219 |
159 _EchoProxyImpl.fromHandle(core.MojoHandle handle) : | 220 _EchoProxyImpl.fromHandle(core.MojoHandle handle) : |
160 super.fromHandle(handle); | 221 super.fromHandle(handle); |
161 | 222 |
162 _EchoProxyImpl.unbound() : super.unbound(); | 223 _EchoProxyImpl.unbound() : super.unbound(); |
163 | 224 |
164 static _EchoProxyImpl newFromEndpoint( | 225 static _EchoProxyImpl newFromEndpoint( |
165 core.MojoMessagePipeEndpoint endpoint) { | 226 core.MojoMessagePipeEndpoint endpoint) { |
166 assert(endpoint.setDescription("For _EchoProxyImpl")); | 227 assert(endpoint.setDescription("For _EchoProxyImpl")); |
167 return new _EchoProxyImpl.fromEndpoint(endpoint); | 228 return new _EchoProxyImpl.fromEndpoint(endpoint); |
168 } | 229 } |
169 | 230 |
| 231 service_describer.ServiceDescription get serviceDescription => |
| 232 new _EchoServiceDescription(); |
| 233 |
170 void handleResponse(bindings.ServiceMessage message) { | 234 void handleResponse(bindings.ServiceMessage message) { |
171 switch (message.header.type) { | 235 switch (message.header.type) { |
172 case _Echo_echoStringName: | 236 case _Echo_echoStringName: |
173 var r = EchoEchoStringResponseParams.deserialize( | 237 var r = EchoEchoStringResponseParams.deserialize( |
174 message.payload); | 238 message.payload); |
175 if (!message.header.hasRequestId) { | 239 if (!message.header.hasRequestId) { |
176 proxyError("Expected a message with a valid request Id."); | 240 proxyError("Expected a message with a valid request Id."); |
177 return; | 241 return; |
178 } | 242 } |
179 Completer c = completerMap[message.header.requestId]; | 243 Completer c = completerMap[message.header.requestId]; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 assert(_impl == null); | 409 assert(_impl == null); |
346 _impl = d; | 410 _impl = d; |
347 } | 411 } |
348 | 412 |
349 String toString() { | 413 String toString() { |
350 var superString = super.toString(); | 414 var superString = super.toString(); |
351 return "EchoStub($superString)"; | 415 return "EchoStub($superString)"; |
352 } | 416 } |
353 | 417 |
354 int get version => 0; | 418 int get version => 0; |
| 419 |
| 420 service_describer.ServiceDescription get serviceDescription => |
| 421 new _EchoServiceDescription(); |
355 } | 422 } |
356 | 423 |
357 | 424 |
| 425 Map<String, mojom_types.UserDefinedType> _initDescriptions() { |
| 426 var map = new HashMap<String, mojom_types.UserDefinedType>(); |
| 427 map["echo_Echo_EchoString_Params__"] = |
| 428 new mojom_types.UserDefinedType() |
| 429 ..structType = _echoEchoEchoStringParams(); |
| 430 map["echo_Echo_EchoString_ResponseParams__"] = |
| 431 new mojom_types.UserDefinedType() |
| 432 ..structType = _echoEchoEchoStringResponseParams(); |
| 433 map["echo_Echo__"] = |
| 434 new mojom_types.UserDefinedType() |
| 435 ..interfaceType = _echoEcho(); |
| 436 return map; |
| 437 } |
| 438 |
| 439 var _mojomDesc; |
| 440 Map<String, mojom_types.UserDefinedType> getAllMojomTypeDefinitions() { |
| 441 if (_mojomDesc == null) { |
| 442 _mojomDesc = _initDescriptions(); |
| 443 } |
| 444 return _mojomDesc; |
| 445 } |
| 446 |
OLD | NEW |