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 sample_import2_mojom; | 5 library sample_import2_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 | |
11 import 'package:_mojo_for_test_only/imported/sample_import.mojom.dart' as sample _import_mojom; | 14 import 'package:_mojo_for_test_only/imported/sample_import.mojom.dart' as sample _import_mojom; |
12 | |
zra
2016/01/27 18:15:11
Please leave this newline.
alexfandrianto
2016/01/28 03:45:12
I think I figured that one out. It was enums who d
| |
13 class Color extends bindings.MojoEnum { | 15 class Color extends bindings.MojoEnum { |
14 static const Color red = const Color._(0); | 16 static const Color red = const Color._(0); |
15 static const Color black = const Color._(1); | 17 static const Color black = const Color._(1); |
16 | 18 |
17 const Color._(int v) : super(v); | 19 const Color._(int v) : super(v); |
18 | 20 |
19 static const Map<String, Color> valuesMap = const { | 21 static const Map<String, Color> valuesMap = const { |
20 "red": red, | 22 "red": red, |
21 "black": black, | 23 "black": black, |
22 }; | 24 }; |
(...skipping 24 matching lines...) Expand all Loading... | |
47 } | 49 } |
48 return result; | 50 return result; |
49 } | 51 } |
50 | 52 |
51 String toString() { | 53 String toString() { |
52 switch(this) { | 54 switch(this) { |
53 case red: | 55 case red: |
54 return 'Color.red'; | 56 return 'Color.red'; |
55 case black: | 57 case black: |
56 return 'Color.black'; | 58 return 'Color.black'; |
59 default: | |
60 return null; | |
57 } | 61 } |
58 } | 62 } |
59 | 63 |
60 int toJson() => mojoEnumValue; | 64 int toJson() => mojoEnumValue; |
61 } | 65 } |
62 | 66 |
67 mojom_types.MojomEnum _sampleImport2Color() { | |
68 return new mojom_types.MojomEnum() | |
69 ..declData = (new mojom_types.DeclarationData() | |
70 ..shortName = 'Color' | |
71 ..fullIdentifier = 'imported.Color') | |
72 ..values = <mojom_types.EnumValue>[ | |
73 new mojom_types.EnumValue() | |
74 ..declData = (new mojom_types.DeclarationData() | |
75 ..shortName = 'Red') | |
76 ..enumTypeKey = 'sample_import2_Color__' | |
77 ..intValue = 0, | |
78 new mojom_types.EnumValue() | |
79 ..declData = (new mojom_types.DeclarationData() | |
80 ..shortName = 'Black') | |
81 ..enumTypeKey = 'sample_import2_Color__' | |
82 ..intValue = 1,]; | |
83 } | |
84 | |
63 | 85 |
64 | 86 |
65 class Size extends bindings.Struct { | 87 class Size extends bindings.Struct { |
66 static const List<bindings.StructDataHeader> kVersions = const [ | 88 static const List<bindings.StructDataHeader> kVersions = const [ |
67 const bindings.StructDataHeader(16, 0) | 89 const bindings.StructDataHeader(16, 0) |
68 ]; | 90 ]; |
69 int width = 0; | 91 int width = 0; |
70 int height = 0; | 92 int height = 0; |
71 | 93 |
72 Size() : super(kVersions.last.size); | 94 Size() : super(kVersions.last.size); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 } | 152 } |
131 | 153 |
132 Map toJson() { | 154 Map toJson() { |
133 Map map = new Map(); | 155 Map map = new Map(); |
134 map["width"] = width; | 156 map["width"] = width; |
135 map["height"] = height; | 157 map["height"] = height; |
136 return map; | 158 return map; |
137 } | 159 } |
138 } | 160 } |
139 | 161 |
162 mojom_types.MojomStruct _sampleImport2Size() { | |
163 return new mojom_types.MojomStruct() | |
164 ..declData = (new mojom_types.DeclarationData() | |
165 ..shortName = 'Size' | |
166 ..fullIdentifier = 'imported.Size') | |
167 ..fields = <mojom_types.StructField>[ | |
168 new mojom_types.StructField() | |
169 ..declData = (new mojom_types.DeclarationData() | |
170 ..shortName = 'Width') | |
171 ..type = (new mojom_types.Type() | |
172 ..simpleType = mojom_types.SimpleType.int32), | |
173 new mojom_types.StructField() | |
174 ..declData = (new mojom_types.DeclarationData() | |
175 ..shortName = 'Height') | |
176 ..type = (new mojom_types.Type() | |
177 ..simpleType = mojom_types.SimpleType.int32),]; | |
178 } | |
179 | |
140 | 180 |
141 class Thing extends bindings.Struct { | 181 class Thing extends bindings.Struct { |
142 static const List<bindings.StructDataHeader> kVersions = const [ | 182 static const List<bindings.StructDataHeader> kVersions = const [ |
143 const bindings.StructDataHeader(32, 0) | 183 const bindings.StructDataHeader(32, 0) |
144 ]; | 184 ]; |
145 sample_import_mojom.Shape shape = new sample_import_mojom.Shape(1); | 185 sample_import_mojom.Shape shape = new sample_import_mojom.Shape(1); |
146 Color color = new Color(1); | 186 Color color = new Color(1); |
147 sample_import_mojom.Point location = null; | 187 sample_import_mojom.Point location = null; |
148 Size size = null; | 188 Size size = null; |
149 | 189 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 Map toJson() { | 274 Map toJson() { |
235 Map map = new Map(); | 275 Map map = new Map(); |
236 map["shape"] = shape; | 276 map["shape"] = shape; |
237 map["color"] = color; | 277 map["color"] = color; |
238 map["location"] = location; | 278 map["location"] = location; |
239 map["size"] = size; | 279 map["size"] = size; |
240 return map; | 280 return map; |
241 } | 281 } |
242 } | 282 } |
243 | 283 |
284 mojom_types.MojomStruct _sampleImport2Thing() { | |
285 return new mojom_types.MojomStruct() | |
286 ..declData = (new mojom_types.DeclarationData() | |
287 ..shortName = 'Thing' | |
288 ..fullIdentifier = 'imported.Thing') | |
289 ..fields = <mojom_types.StructField>[ | |
290 new mojom_types.StructField() | |
291 ..declData = (new mojom_types.DeclarationData() | |
292 ..shortName = 'Shape') | |
293 ..type = (new mojom_types.Type() | |
294 ..typeReference = (new mojom_types.TypeReference() | |
295 | |
296 ..identifier = 'sample_import_Shape__' | |
297 ..typeKey = 'sample_import_Shape__' | |
298 )), | |
299 new mojom_types.StructField() | |
300 ..declData = (new mojom_types.DeclarationData() | |
301 ..shortName = 'Color') | |
302 ..type = (new mojom_types.Type() | |
303 ..typeReference = (new mojom_types.TypeReference() | |
304 | |
305 ..identifier = 'sample_import2_Color__' | |
306 ..typeKey = 'sample_import2_Color__' | |
307 )), | |
308 new mojom_types.StructField() | |
309 ..declData = (new mojom_types.DeclarationData() | |
310 ..shortName = 'Location') | |
311 ..type = (new mojom_types.Type() | |
312 ..typeReference = (new mojom_types.TypeReference() | |
313 | |
314 ..identifier = 'sample_import_Point__' | |
315 ..typeKey = 'sample_import_Point__' | |
316 )), | |
317 new mojom_types.StructField() | |
318 ..declData = (new mojom_types.DeclarationData() | |
319 ..shortName = 'Size') | |
320 ..type = (new mojom_types.Type() | |
321 ..typeReference = (new mojom_types.TypeReference() | |
322 | |
323 ..identifier = 'sample_import2_Size__' | |
324 ..typeKey = 'sample_import2_Size__' | |
325 )),]; | |
326 } | |
244 | 327 |
328 | |
329 | |
330 | |
331 | |
332 | |
333 | |
334 | |
335 Map<String, mojom_types.UserDefinedType> _initDescriptions() { | |
336 var map = new HashMap<String, mojom_types.UserDefinedType>(); | |
337 map["sample_import2_Color__"] = | |
zra
2016/01/27 18:15:11
indentation
alexfandrianto
2016/01/28 03:45:12
I think it looks better now.
| |
338 new mojom_types.UserDefinedType() | |
339 ..enumType = _sampleImport2Color(); | |
340 map["sample_import2_Size__"] = | |
341 new mojom_types.UserDefinedType() | |
342 ..structType = _sampleImport2Size(); | |
343 map["sample_import2_Thing__"] = | |
344 new mojom_types.UserDefinedType() | |
345 ..structType = _sampleImport2Thing(); | |
346 sample_import_mojom.getAllMojomTypeDefinitions().forEach((String s, mojom_types. UserDefinedType udt) { | |
347 map[s] = udt; | |
348 }); | |
349 | |
350 return map; | |
351 } | |
352 | |
353 var _mojomDesc; | |
354 Map<String, mojom_types.UserDefinedType> getAllMojomTypeDefinitions() { | |
355 if (_mojomDesc == null) { | |
356 _mojomDesc = _initDescriptions(); | |
357 } | |
358 return _mojomDesc; | |
359 } | |
360 | |
OLD | NEW |