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