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

Side by Side Diff: mojo/dart/packages/_mojo_for_test_only/lib/imported/sample_import.mojom.dart

Issue 1539673003: Generate Mojom Types in Dart (Take 2) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Move and Standardize Mojom Type Functions Created 4 years, 10 months 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
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 sample_import_mojom; 5 library sample_import_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;
11 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;
12 class Shape extends bindings.MojoEnum { 14 class Shape extends bindings.MojoEnum {
13 static const Shape rectangle = const Shape._(1); 15 static const Shape rectangle = const Shape._(1);
14 static const Shape circle = const Shape._(2); 16 static const Shape circle = const Shape._(2);
15 static const Shape triangle = const Shape._(3); 17 static const Shape triangle = const Shape._(3);
16 static const Shape last = const Shape._(3); 18 static const Shape last = const Shape._(3);
17 19
18 const Shape._(int v) : super(v); 20 const Shape._(int v) : super(v);
19 21
20 static const Map<String, Shape> valuesMap = const { 22 static const Map<String, Shape> valuesMap = const {
21 "rectangle": rectangle, 23 "rectangle": rectangle,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 String toString() { 62 String toString() {
61 switch(this) { 63 switch(this) {
62 case rectangle: 64 case rectangle:
63 return 'Shape.rectangle'; 65 return 'Shape.rectangle';
64 case circle: 66 case circle:
65 return 'Shape.circle'; 67 return 'Shape.circle';
66 case triangle: 68 case triangle:
67 return 'Shape.triangle'; 69 return 'Shape.triangle';
68 case last: 70 case last:
69 return 'Shape.last'; 71 return 'Shape.last';
72 default:
73 return null;
70 } 74 }
71 } 75 }
72 76
73 int toJson() => mojoEnumValue; 77 int toJson() => mojoEnumValue;
74 } 78 }
75 79
80 mojom_types.MojomEnum _sampleImportShape() {
81 return new mojom_types.MojomEnum()
82 ..declData = (new mojom_types.DeclarationData()
83 ..shortName = 'Shape'
84 ..fullIdentifier = 'imported.Shape')
85 ..values = <mojom_types.EnumValue>[
86 new mojom_types.EnumValue()
87 ..declData = (new mojom_types.DeclarationData()
88 ..shortName = 'Rectangle')
89 ..enumTypeKey = 'sample_import_Shape__'
90 ..intValue = 1,
91 new mojom_types.EnumValue()
92 ..declData = (new mojom_types.DeclarationData()
93 ..shortName = 'Circle')
94 ..enumTypeKey = 'sample_import_Shape__'
95 ..intValue = 2,
96 new mojom_types.EnumValue()
97 ..declData = (new mojom_types.DeclarationData()
98 ..shortName = 'Triangle')
99 ..enumTypeKey = 'sample_import_Shape__'
100 ..intValue = 3,
101 new mojom_types.EnumValue()
102 ..declData = (new mojom_types.DeclarationData()
103 ..shortName = 'Last')
104 ..enumTypeKey = 'sample_import_Shape__'
105 ..intValue = 3,];
106 }
zra 2016/01/27 18:15:11 Missing newline.
alexfandrianto 2016/01/28 03:45:12 Done.
76 class AnotherShape extends bindings.MojoEnum { 107 class AnotherShape extends bindings.MojoEnum {
77 static const AnotherShape rectangle = const AnotherShape._(10); 108 static const AnotherShape rectangle = const AnotherShape._(10);
78 static const AnotherShape circle = const AnotherShape._(11); 109 static const AnotherShape circle = const AnotherShape._(11);
79 static const AnotherShape triangle = const AnotherShape._(12); 110 static const AnotherShape triangle = const AnotherShape._(12);
80 111
81 const AnotherShape._(int v) : super(v); 112 const AnotherShape._(int v) : super(v);
82 113
83 static const Map<String, AnotherShape> valuesMap = const { 114 static const Map<String, AnotherShape> valuesMap = const {
84 "rectangle": rectangle, 115 "rectangle": rectangle,
85 "circle": circle, 116 "circle": circle,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 } 148 }
118 149
119 String toString() { 150 String toString() {
120 switch(this) { 151 switch(this) {
121 case rectangle: 152 case rectangle:
122 return 'AnotherShape.rectangle'; 153 return 'AnotherShape.rectangle';
123 case circle: 154 case circle:
124 return 'AnotherShape.circle'; 155 return 'AnotherShape.circle';
125 case triangle: 156 case triangle:
126 return 'AnotherShape.triangle'; 157 return 'AnotherShape.triangle';
158 default:
159 return null;
127 } 160 }
128 } 161 }
129 162
130 int toJson() => mojoEnumValue; 163 int toJson() => mojoEnumValue;
131 } 164 }
132 165
166 mojom_types.MojomEnum _sampleImportAnotherShape() {
167 return new mojom_types.MojomEnum()
168 ..declData = (new mojom_types.DeclarationData()
169 ..shortName = 'AnotherShape'
170 ..fullIdentifier = 'imported.AnotherShape')
171 ..values = <mojom_types.EnumValue>[
172 new mojom_types.EnumValue()
173 ..declData = (new mojom_types.DeclarationData()
174 ..shortName = 'Rectangle')
175 ..enumTypeKey = 'sample_import_AnotherShape__'
176 ..intValue = 10,
177 new mojom_types.EnumValue()
178 ..declData = (new mojom_types.DeclarationData()
179 ..shortName = 'Circle')
180 ..enumTypeKey = 'sample_import_AnotherShape__'
181 ..intValue = 11,
182 new mojom_types.EnumValue()
183 ..declData = (new mojom_types.DeclarationData()
184 ..shortName = 'Triangle')
185 ..enumTypeKey = 'sample_import_AnotherShape__'
186 ..intValue = 12,];
187 }
133 class YetAnotherShape extends bindings.MojoEnum { 188 class YetAnotherShape extends bindings.MojoEnum {
134 static const YetAnotherShape rectangle = const YetAnotherShape._(20); 189 static const YetAnotherShape rectangle = const YetAnotherShape._(20);
135 static const YetAnotherShape circle = const YetAnotherShape._(21); 190 static const YetAnotherShape circle = const YetAnotherShape._(21);
136 static const YetAnotherShape triangle = const YetAnotherShape._(22); 191 static const YetAnotherShape triangle = const YetAnotherShape._(22);
137 192
138 const YetAnotherShape._(int v) : super(v); 193 const YetAnotherShape._(int v) : super(v);
139 194
140 static const Map<String, YetAnotherShape> valuesMap = const { 195 static const Map<String, YetAnotherShape> valuesMap = const {
141 "rectangle": rectangle, 196 "rectangle": rectangle,
142 "circle": circle, 197 "circle": circle,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 } 229 }
175 230
176 String toString() { 231 String toString() {
177 switch(this) { 232 switch(this) {
178 case rectangle: 233 case rectangle:
179 return 'YetAnotherShape.rectangle'; 234 return 'YetAnotherShape.rectangle';
180 case circle: 235 case circle:
181 return 'YetAnotherShape.circle'; 236 return 'YetAnotherShape.circle';
182 case triangle: 237 case triangle:
183 return 'YetAnotherShape.triangle'; 238 return 'YetAnotherShape.triangle';
239 default:
240 return null;
184 } 241 }
185 } 242 }
186 243
187 int toJson() => mojoEnumValue; 244 int toJson() => mojoEnumValue;
188 } 245 }
189 246
247 mojom_types.MojomEnum _sampleImportYetAnotherShape() {
248 return new mojom_types.MojomEnum()
249 ..declData = (new mojom_types.DeclarationData()
250 ..shortName = 'YetAnotherShape'
251 ..fullIdentifier = 'imported.YetAnotherShape')
252 ..values = <mojom_types.EnumValue>[
253 new mojom_types.EnumValue()
254 ..declData = (new mojom_types.DeclarationData()
255 ..shortName = 'Rectangle')
256 ..enumTypeKey = 'sample_import_YetAnotherShape__'
257 ..intValue = 20,
258 new mojom_types.EnumValue()
259 ..declData = (new mojom_types.DeclarationData()
260 ..shortName = 'Circle')
261 ..enumTypeKey = 'sample_import_YetAnotherShape__'
262 ..intValue = 21,
263 new mojom_types.EnumValue()
264 ..declData = (new mojom_types.DeclarationData()
265 ..shortName = 'Triangle')
266 ..enumTypeKey = 'sample_import_YetAnotherShape__'
267 ..intValue = 22,];
268 }
269
190 270
191 271
192 class Point extends bindings.Struct { 272 class Point extends bindings.Struct {
193 static const List<bindings.StructDataHeader> kVersions = const [ 273 static const List<bindings.StructDataHeader> kVersions = const [
194 const bindings.StructDataHeader(16, 0) 274 const bindings.StructDataHeader(16, 0)
195 ]; 275 ];
196 int x = 0; 276 int x = 0;
197 int y = 0; 277 int y = 0;
198 278
199 Point() : super(kVersions.last.size); 279 Point() : super(kVersions.last.size);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 } 337 }
258 338
259 Map toJson() { 339 Map toJson() {
260 Map map = new Map(); 340 Map map = new Map();
261 map["x"] = x; 341 map["x"] = x;
262 map["y"] = y; 342 map["y"] = y;
263 return map; 343 return map;
264 } 344 }
265 } 345 }
266 346
347 mojom_types.MojomStruct _sampleImportPoint() {
348 return new mojom_types.MojomStruct()
349 ..declData = (new mojom_types.DeclarationData()
350 ..shortName = 'Point'
351 ..fullIdentifier = 'imported.Point')
352 ..fields = <mojom_types.StructField>[
353 new mojom_types.StructField()
354 ..declData = (new mojom_types.DeclarationData()
355 ..shortName = 'X')
356 ..type = (new mojom_types.Type()
357 ..simpleType = mojom_types.SimpleType.int32),
358 new mojom_types.StructField()
359 ..declData = (new mojom_types.DeclarationData()
360 ..shortName = 'Y')
361 ..type = (new mojom_types.Type()
362 ..simpleType = mojom_types.SimpleType.int32),];
363 }
364
267 365
268 class _ImportedInterfaceDoSomethingParams extends bindings.Struct { 366 class _ImportedInterfaceDoSomethingParams extends bindings.Struct {
269 static const List<bindings.StructDataHeader> kVersions = const [ 367 static const List<bindings.StructDataHeader> kVersions = const [
270 const bindings.StructDataHeader(8, 0) 368 const bindings.StructDataHeader(8, 0)
271 ]; 369 ];
272 370
273 _ImportedInterfaceDoSomethingParams() : super(kVersions.last.size); 371 _ImportedInterfaceDoSomethingParams() : super(kVersions.last.size);
274 372
275 static _ImportedInterfaceDoSomethingParams deserialize(bindings.Message messag e) { 373 static _ImportedInterfaceDoSomethingParams deserialize(bindings.Message messag e) {
276 var decoder = new bindings.Decoder(message); 374 var decoder = new bindings.Decoder(message);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 String toString() { 413 String toString() {
316 return "_ImportedInterfaceDoSomethingParams("")"; 414 return "_ImportedInterfaceDoSomethingParams("")";
317 } 415 }
318 416
319 Map toJson() { 417 Map toJson() {
320 Map map = new Map(); 418 Map map = new Map();
321 return map; 419 return map;
322 } 420 }
323 } 421 }
324 422
423 mojom_types.MojomStruct _sampleImportImportedInterfaceDoSomethingParams() {
424 return new mojom_types.MojomStruct()
425 ..declData = (new mojom_types.DeclarationData()
426 ..shortName = 'ImportedInterfaceDoSomethingParams'
427 ..fullIdentifier = 'imported.ImportedInterface_DoSomething_Params')
428 ..fields = <mojom_types.StructField>[];
429 }
430
431
325 const int _ImportedInterface_doSomethingName = 0; 432 const int _ImportedInterface_doSomethingName = 0;
326 433
434 mojom_types.MojomInterface _sampleImportImportedInterface() {
435 return new mojom_types.MojomInterface()
436 ..declData = (new mojom_types.DeclarationData()
437 ..shortName = 'ImportedInterface'
438 ..fullIdentifier = 'imported.ImportedInterface')
439 ..interfaceName = 'ImportedInterface'
440 ..methods = <int, mojom_types.MojomMethod>{
441 _ImportedInterface_doSomethingName: new mojom_types.MojomMethod()
442 ..declData = (new mojom_types.DeclarationData()
443 ..shortName = 'DoSomething')
444 ..ordinal = _ImportedInterface_doSomethingName
445 ..parameters = _sampleImportImportedInterfaceDoSomethingParams(),
446 };
447 }
448
449 class _ImportedInterfaceServiceDescription implements service_describer.ServiceD escription {
450 dynamic getTopLevelInterface([Function responseFactory = null]) =>
451 _sampleImportImportedInterface();
452
453 dynamic getTypeDefinition(String typeKey, [Function responseFactory = null]) = >
454 getAllMojomTypeDefinitions()[typeKey];
455
456 dynamic getAllTypeDefinitions([Function responseFactory = null]) =>
457 getAllMojomTypeDefinitions();
458 }
459
327 abstract class ImportedInterface { 460 abstract class ImportedInterface {
328 static const String serviceName = null; 461 static const String serviceName = null;
329 void doSomething(); 462 void doSomething();
330 } 463 }
331 464
332 465
333 class _ImportedInterfaceProxyImpl extends bindings.Proxy { 466 class _ImportedInterfaceProxyImpl extends bindings.Proxy {
334 _ImportedInterfaceProxyImpl.fromEndpoint( 467 _ImportedInterfaceProxyImpl.fromEndpoint(
335 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); 468 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint);
336 469
337 _ImportedInterfaceProxyImpl.fromHandle(core.MojoHandle handle) : 470 _ImportedInterfaceProxyImpl.fromHandle(core.MojoHandle handle) :
338 super.fromHandle(handle); 471 super.fromHandle(handle);
339 472
340 _ImportedInterfaceProxyImpl.unbound() : super.unbound(); 473 _ImportedInterfaceProxyImpl.unbound() : super.unbound();
341 474
342 static _ImportedInterfaceProxyImpl newFromEndpoint( 475 static _ImportedInterfaceProxyImpl newFromEndpoint(
343 core.MojoMessagePipeEndpoint endpoint) { 476 core.MojoMessagePipeEndpoint endpoint) {
344 assert(endpoint.setDescription("For _ImportedInterfaceProxyImpl")); 477 assert(endpoint.setDescription("For _ImportedInterfaceProxyImpl"));
345 return new _ImportedInterfaceProxyImpl.fromEndpoint(endpoint); 478 return new _ImportedInterfaceProxyImpl.fromEndpoint(endpoint);
346 } 479 }
347 480
481 service_describer.ServiceDescription get serviceDescription =>
482 new _ImportedInterfaceServiceDescription();
483
348 void handleResponse(bindings.ServiceMessage message) { 484 void handleResponse(bindings.ServiceMessage message) {
349 switch (message.header.type) { 485 switch (message.header.type) {
350 default: 486 default:
351 proxyError("Unexpected message type: ${message.header.type}"); 487 proxyError("Unexpected message type: ${message.header.type}");
352 close(immediate: true); 488 close(immediate: true);
353 break; 489 break;
354 } 490 }
355 } 491 }
356 492
357 String toString() { 493 String toString() {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 assert(_impl == null); 616 assert(_impl == null);
481 _impl = d; 617 _impl = d;
482 } 618 }
483 619
484 String toString() { 620 String toString() {
485 var superString = super.toString(); 621 var superString = super.toString();
486 return "ImportedInterfaceStub($superString)"; 622 return "ImportedInterfaceStub($superString)";
487 } 623 }
488 624
489 int get version => 0; 625 int get version => 0;
626
627 service_describer.ServiceDescription get serviceDescription =>
628 new _ImportedInterfaceServiceDescription();
490 } 629 }
491 630
492 631
632
633
634
635
636
637 Map<String, mojom_types.UserDefinedType> _initDescriptions() {
638 var map = new HashMap<String, mojom_types.UserDefinedType>();
639 map["sample_import_Shape__"] =
640 new mojom_types.UserDefinedType()
641 ..enumType = _sampleImportShape();
642 map["sample_import_AnotherShape__"] =
643 new mojom_types.UserDefinedType()
644 ..enumType = _sampleImportAnotherShape();
645 map["sample_import_YetAnotherShape__"] =
646 new mojom_types.UserDefinedType()
647 ..enumType = _sampleImportYetAnotherShape();
648 map["sample_import_Point__"] =
649 new mojom_types.UserDefinedType()
650 ..structType = _sampleImportPoint();
651 map["sample_import_ImportedInterface_DoSomething_Params__"] =
652 new mojom_types.UserDefinedType()
653 ..structType = _sampleImportImportedInterfaceDoSomethingParams();
654 map["sample_import_ImportedInterface__"] =
655 new mojom_types.UserDefinedType()
656 ..interfaceType = _sampleImportImportedInterface();
657
658 return map;
659 }
660
661 var _mojomDesc;
662 Map<String, mojom_types.UserDefinedType> getAllMojomTypeDefinitions() {
663 if (_mojomDesc == null) {
664 _mojomDesc = _initDescriptions();
665 }
666 return _mojomDesc;
667 }
668
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698