Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(802)

Side by Side Diff: mojo/dart/packages/mojo_services/lib/icu_data/icu_data.mojom.dart

Issue 1449203002: Check in generated Dart bindings and add presubmit script (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 library icu_data_mojom;
6
7 import 'dart:async';
8
9 import 'package:mojo/bindings.dart' as bindings;
10 import 'package:mojo/core.dart' as core;
11
12
13
14 class IcuDataMapParams extends bindings.Struct {
15 static const List<bindings.StructDataHeader> kVersions = const [
16 const bindings.StructDataHeader(16, 0)
17 ];
18 String sha1hash = null;
19
20 IcuDataMapParams() : super(kVersions.last.size);
21
22 static IcuDataMapParams deserialize(bindings.Message message) {
23 var decoder = new bindings.Decoder(message);
24 var result = decode(decoder);
25 if (decoder.excessHandles != null) {
26 decoder.excessHandles.forEach((h) => h.close());
27 }
28 return result;
29 }
30
31 static IcuDataMapParams decode(bindings.Decoder decoder0) {
32 if (decoder0 == null) {
33 return null;
34 }
35 IcuDataMapParams result = new IcuDataMapParams();
36
37 var mainDataHeader = decoder0.decodeStructDataHeader();
38 if (mainDataHeader.version <= kVersions.last.version) {
39 // Scan in reverse order to optimize for more recent versions.
40 for (int i = kVersions.length - 1; i >= 0; --i) {
41 if (mainDataHeader.version >= kVersions[i].version) {
42 if (mainDataHeader.size == kVersions[i].size) {
43 // Found a match.
44 break;
45 }
46 throw new bindings.MojoCodecError(
47 'Header size doesn\'t correspond to known version size.');
48 }
49 }
50 } else if (mainDataHeader.size < kVersions.last.size) {
51 throw new bindings.MojoCodecError(
52 'Message newer than the last known version cannot be shorter than '
53 'required by the last known version.');
54 }
55 if (mainDataHeader.version >= 0) {
56
57 result.sha1hash = decoder0.decodeString(8, false);
58 }
59 return result;
60 }
61
62 void encode(bindings.Encoder encoder) {
63 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last);
64
65 encoder0.encodeString(sha1hash, 8, false);
66 }
67
68 String toString() {
69 return "IcuDataMapParams("
70 "sha1hash: $sha1hash" ")";
71 }
72
73 Map toJson() {
74 Map map = new Map();
75 map["sha1hash"] = sha1hash;
76 return map;
77 }
78 }
79
80
81 class IcuDataMapResponseParams extends bindings.Struct {
82 static const List<bindings.StructDataHeader> kVersions = const [
83 const bindings.StructDataHeader(16, 0)
84 ];
85 core.MojoSharedBuffer icuData = null;
86
87 IcuDataMapResponseParams() : super(kVersions.last.size);
88
89 static IcuDataMapResponseParams deserialize(bindings.Message message) {
90 var decoder = new bindings.Decoder(message);
91 var result = decode(decoder);
92 if (decoder.excessHandles != null) {
93 decoder.excessHandles.forEach((h) => h.close());
94 }
95 return result;
96 }
97
98 static IcuDataMapResponseParams decode(bindings.Decoder decoder0) {
99 if (decoder0 == null) {
100 return null;
101 }
102 IcuDataMapResponseParams result = new IcuDataMapResponseParams();
103
104 var mainDataHeader = decoder0.decodeStructDataHeader();
105 if (mainDataHeader.version <= kVersions.last.version) {
106 // Scan in reverse order to optimize for more recent versions.
107 for (int i = kVersions.length - 1; i >= 0; --i) {
108 if (mainDataHeader.version >= kVersions[i].version) {
109 if (mainDataHeader.size == kVersions[i].size) {
110 // Found a match.
111 break;
112 }
113 throw new bindings.MojoCodecError(
114 'Header size doesn\'t correspond to known version size.');
115 }
116 }
117 } else if (mainDataHeader.size < kVersions.last.size) {
118 throw new bindings.MojoCodecError(
119 'Message newer than the last known version cannot be shorter than '
120 'required by the last known version.');
121 }
122 if (mainDataHeader.version >= 0) {
123
124 result.icuData = decoder0.decodeSharedBufferHandle(8, true);
125 }
126 return result;
127 }
128
129 void encode(bindings.Encoder encoder) {
130 var encoder0 = encoder.getStructEncoderAtOffset(kVersions.last);
131
132 encoder0.encodeSharedBufferHandle(icuData, 8, true);
133 }
134
135 String toString() {
136 return "IcuDataMapResponseParams("
137 "icuData: $icuData" ")";
138 }
139
140 Map toJson() {
141 throw new bindings.MojoCodecError(
142 'Object containing handles cannot be encoded to JSON.');
143 }
144 }
145
146 const int kIcuData_map_name = 0;
147
148 const String IcuDataName =
149 'icu_data::ICUData';
150
151 abstract class IcuData {
152 dynamic map(String sha1hash,[Function responseFactory = null]);
153
154 }
155
156
157 class IcuDataProxyImpl extends bindings.Proxy {
158 IcuDataProxyImpl.fromEndpoint(
159 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
160
161 IcuDataProxyImpl.fromHandle(core.MojoHandle handle) :
162 super.fromHandle(handle);
163
164 IcuDataProxyImpl.unbound() : super.unbound();
165
166 static IcuDataProxyImpl newFromEndpoint(
167 core.MojoMessagePipeEndpoint endpoint) {
168 assert(endpoint.setDescription("For IcuDataProxyImpl"));
169 return new IcuDataProxyImpl.fromEndpoint(endpoint);
170 }
171
172 String get name => IcuDataName;
173
174 void handleResponse(bindings.ServiceMessage message) {
175 switch (message.header.type) {
176 case kIcuData_map_name:
177 var r = IcuDataMapResponseParams.deserialize(
178 message.payload);
179 if (!message.header.hasRequestId) {
180 proxyError("Expected a message with a valid request Id.");
181 return;
182 }
183 Completer c = completerMap[message.header.requestId];
184 if (c == null) {
185 proxyError(
186 "Message had unknown request Id: ${message.header.requestId}");
187 return;
188 }
189 completerMap.remove(message.header.requestId);
190 if (c.isCompleted) {
191 proxyError("Response completer already completed");
192 return;
193 }
194 c.complete(r);
195 break;
196 default:
197 proxyError("Unexpected message type: ${message.header.type}");
198 close(immediate: true);
199 break;
200 }
201 }
202
203 String toString() {
204 var superString = super.toString();
205 return "IcuDataProxyImpl($superString)";
206 }
207 }
208
209
210 class _IcuDataProxyCalls implements IcuData {
211 IcuDataProxyImpl _proxyImpl;
212
213 _IcuDataProxyCalls(this._proxyImpl);
214 dynamic map(String sha1hash,[Function responseFactory = null]) {
215 var params = new IcuDataMapParams();
216 params.sha1hash = sha1hash;
217 return _proxyImpl.sendMessageWithRequestId(
218 params,
219 kIcuData_map_name,
220 -1,
221 bindings.MessageHeader.kMessageExpectsResponse);
222 }
223 }
224
225
226 class IcuDataProxy implements bindings.ProxyBase {
227 final bindings.Proxy impl;
228 IcuData ptr;
229 final String name = IcuDataName;
230
231 IcuDataProxy(IcuDataProxyImpl proxyImpl) :
232 impl = proxyImpl,
233 ptr = new _IcuDataProxyCalls(proxyImpl);
234
235 IcuDataProxy.fromEndpoint(
236 core.MojoMessagePipeEndpoint endpoint) :
237 impl = new IcuDataProxyImpl.fromEndpoint(endpoint) {
238 ptr = new _IcuDataProxyCalls(impl);
239 }
240
241 IcuDataProxy.fromHandle(core.MojoHandle handle) :
242 impl = new IcuDataProxyImpl.fromHandle(handle) {
243 ptr = new _IcuDataProxyCalls(impl);
244 }
245
246 IcuDataProxy.unbound() :
247 impl = new IcuDataProxyImpl.unbound() {
248 ptr = new _IcuDataProxyCalls(impl);
249 }
250
251 factory IcuDataProxy.connectToService(
252 bindings.ServiceConnector s, String url) {
253 IcuDataProxy p = new IcuDataProxy.unbound();
254 s.connectToService(url, p);
255 return p;
256 }
257
258 static IcuDataProxy newFromEndpoint(
259 core.MojoMessagePipeEndpoint endpoint) {
260 assert(endpoint.setDescription("For IcuDataProxy"));
261 return new IcuDataProxy.fromEndpoint(endpoint);
262 }
263
264 Future close({bool immediate: false}) => impl.close(immediate: immediate);
265
266 Future responseOrError(Future f) => impl.responseOrError(f);
267
268 Future get errorFuture => impl.errorFuture;
269
270 int get version => impl.version;
271
272 Future<int> queryVersion() => impl.queryVersion();
273
274 void requireVersion(int requiredVersion) {
275 impl.requireVersion(requiredVersion);
276 }
277
278 String toString() {
279 return "IcuDataProxy($impl)";
280 }
281 }
282
283
284 class IcuDataStub extends bindings.Stub {
285 IcuData _impl = null;
286
287 IcuDataStub.fromEndpoint(
288 core.MojoMessagePipeEndpoint endpoint, [this._impl])
289 : super.fromEndpoint(endpoint);
290
291 IcuDataStub.fromHandle(core.MojoHandle handle, [this._impl])
292 : super.fromHandle(handle);
293
294 IcuDataStub.unbound() : super.unbound();
295
296 static IcuDataStub newFromEndpoint(
297 core.MojoMessagePipeEndpoint endpoint) {
298 assert(endpoint.setDescription("For IcuDataStub"));
299 return new IcuDataStub.fromEndpoint(endpoint);
300 }
301
302 static const String name = IcuDataName;
303
304
305 IcuDataMapResponseParams _IcuDataMapResponseParamsFactory(core.MojoSharedBuffe r icuData) {
306 var result = new IcuDataMapResponseParams();
307 result.icuData = icuData;
308 return result;
309 }
310
311 dynamic handleMessage(bindings.ServiceMessage message) {
312 if (bindings.ControlMessageHandler.isControlMessage(message)) {
313 return bindings.ControlMessageHandler.handleMessage(this,
314 0,
315 message);
316 }
317 assert(_impl != null);
318 switch (message.header.type) {
319 case kIcuData_map_name:
320 var params = IcuDataMapParams.deserialize(
321 message.payload);
322 var response = _impl.map(params.sha1hash,_IcuDataMapResponseParamsFactor y);
323 if (response is Future) {
324 return response.then((response) {
325 if (response != null) {
326 return buildResponseWithId(
327 response,
328 kIcuData_map_name,
329 message.header.requestId,
330 bindings.MessageHeader.kMessageIsResponse);
331 }
332 });
333 } else if (response != null) {
334 return buildResponseWithId(
335 response,
336 kIcuData_map_name,
337 message.header.requestId,
338 bindings.MessageHeader.kMessageIsResponse);
339 }
340 break;
341 default:
342 throw new bindings.MojoCodecError("Unexpected message name");
343 break;
344 }
345 return null;
346 }
347
348 IcuData get impl => _impl;
349 set impl(IcuData d) {
350 assert(_impl == null);
351 _impl = d;
352 }
353
354 String toString() {
355 var superString = super.toString();
356 return "IcuDataStub($superString)";
357 }
358
359 int get version => 0;
360 }
361
362
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698