| 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 serialization_test_structs_mojom; | 5 library serialization_test_structs_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; |
| 11 | 13 |
| 12 | 14 |
| 13 | 15 |
| 16 |
| 14 class Struct1 extends bindings.Struct { | 17 class Struct1 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 int i = 0; | 21 int i = 0; |
| 19 | 22 |
| 20 Struct1() : super(kVersions.last.size); | 23 Struct1() : super(kVersions.last.size); |
| 21 | 24 |
| 22 static Struct1 deserialize(bindings.Message message) { | 25 static Struct1 deserialize(bindings.Message message) { |
| 23 var decoder = new bindings.Decoder(message); | 26 var decoder = new bindings.Decoder(message); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 "i: $i" ")"; | 73 "i: $i" ")"; |
| 71 } | 74 } |
| 72 | 75 |
| 73 Map toJson() { | 76 Map toJson() { |
| 74 Map map = new Map(); | 77 Map map = new Map(); |
| 75 map["i"] = i; | 78 map["i"] = i; |
| 76 return map; | 79 return map; |
| 77 } | 80 } |
| 78 } | 81 } |
| 79 | 82 |
| 83 mojom_types.MojomStruct _serializationTestStructsStruct1() { |
| 84 return new mojom_types.MojomStruct() |
| 85 ..declData = (new mojom_types.DeclarationData() |
| 86 ..shortName = 'Struct1' |
| 87 ..fullIdentifier = 'mojo.test.Struct1') |
| 88 ..fields = <mojom_types.StructField>[ |
| 89 new mojom_types.StructField() |
| 90 ..declData = (new mojom_types.DeclarationData() |
| 91 ..shortName = 'I') |
| 92 ..type = (new mojom_types.Type() |
| 93 ..simpleType = mojom_types.SimpleType.uint8),]; |
| 94 } |
| 95 |
| 80 | 96 |
| 81 class Struct2 extends bindings.Struct { | 97 class Struct2 extends bindings.Struct { |
| 82 static const List<bindings.StructDataHeader> kVersions = const [ | 98 static const List<bindings.StructDataHeader> kVersions = const [ |
| 83 const bindings.StructDataHeader(16, 0) | 99 const bindings.StructDataHeader(16, 0) |
| 84 ]; | 100 ]; |
| 85 core.MojoHandle hdl = null; | 101 core.MojoHandle hdl = null; |
| 86 | 102 |
| 87 Struct2() : super(kVersions.last.size); | 103 Struct2() : super(kVersions.last.size); |
| 88 | 104 |
| 89 static Struct2 deserialize(bindings.Message message) { | 105 static Struct2 deserialize(bindings.Message message) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 return "Struct2(" | 152 return "Struct2(" |
| 137 "hdl: $hdl" ")"; | 153 "hdl: $hdl" ")"; |
| 138 } | 154 } |
| 139 | 155 |
| 140 Map toJson() { | 156 Map toJson() { |
| 141 throw new bindings.MojoCodecError( | 157 throw new bindings.MojoCodecError( |
| 142 'Object containing handles cannot be encoded to JSON.'); | 158 'Object containing handles cannot be encoded to JSON.'); |
| 143 } | 159 } |
| 144 } | 160 } |
| 145 | 161 |
| 162 mojom_types.MojomStruct _serializationTestStructsStruct2() { |
| 163 return new mojom_types.MojomStruct() |
| 164 ..declData = (new mojom_types.DeclarationData() |
| 165 ..shortName = 'Struct2' |
| 166 ..fullIdentifier = 'mojo.test.Struct2') |
| 167 ..fields = <mojom_types.StructField>[ |
| 168 new mojom_types.StructField() |
| 169 ..declData = (new mojom_types.DeclarationData() |
| 170 ..shortName = 'Hdl') |
| 171 ..type = (new mojom_types.Type() |
| 172 ..handleType = (new mojom_types.HandleType() |
| 173 ..kind = mojom_types.HandleTypeKind.unspecified)),]; |
| 174 } |
| 175 |
| 146 | 176 |
| 147 class Struct3 extends bindings.Struct { | 177 class Struct3 extends bindings.Struct { |
| 148 static const List<bindings.StructDataHeader> kVersions = const [ | 178 static const List<bindings.StructDataHeader> kVersions = const [ |
| 149 const bindings.StructDataHeader(16, 0) | 179 const bindings.StructDataHeader(16, 0) |
| 150 ]; | 180 ]; |
| 151 Struct1 struct1 = null; | 181 Struct1 struct1 = null; |
| 152 | 182 |
| 153 Struct3() : super(kVersions.last.size); | 183 Struct3() : super(kVersions.last.size); |
| 154 | 184 |
| 155 static Struct3 deserialize(bindings.Message message) { | 185 static Struct3 deserialize(bindings.Message message) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 "struct1: $struct1" ")"; | 234 "struct1: $struct1" ")"; |
| 205 } | 235 } |
| 206 | 236 |
| 207 Map toJson() { | 237 Map toJson() { |
| 208 Map map = new Map(); | 238 Map map = new Map(); |
| 209 map["struct1"] = struct1; | 239 map["struct1"] = struct1; |
| 210 return map; | 240 return map; |
| 211 } | 241 } |
| 212 } | 242 } |
| 213 | 243 |
| 244 mojom_types.MojomStruct _serializationTestStructsStruct3() { |
| 245 return new mojom_types.MojomStruct() |
| 246 ..declData = (new mojom_types.DeclarationData() |
| 247 ..shortName = 'Struct3' |
| 248 ..fullIdentifier = 'mojo.test.Struct3') |
| 249 ..fields = <mojom_types.StructField>[ |
| 250 new mojom_types.StructField() |
| 251 ..declData = (new mojom_types.DeclarationData() |
| 252 ..shortName = 'Struct1') |
| 253 ..type = (new mojom_types.Type() |
| 254 ..typeReference = (new mojom_types.TypeReference() |
| 255 ..identifier = 'serialization_test_structs_Struct1__' |
| 256 ..typeKey = 'serialization_test_structs_Struct1__' |
| 257 )),]; |
| 258 } |
| 259 |
| 214 | 260 |
| 215 class Struct4 extends bindings.Struct { | 261 class Struct4 extends bindings.Struct { |
| 216 static const List<bindings.StructDataHeader> kVersions = const [ | 262 static const List<bindings.StructDataHeader> kVersions = const [ |
| 217 const bindings.StructDataHeader(16, 0) | 263 const bindings.StructDataHeader(16, 0) |
| 218 ]; | 264 ]; |
| 219 List<Struct1> data = null; | 265 List<Struct1> data = null; |
| 220 | 266 |
| 221 Struct4() : super(kVersions.last.size); | 267 Struct4() : super(kVersions.last.size); |
| 222 | 268 |
| 223 static Struct4 deserialize(bindings.Message message) { | 269 static Struct4 deserialize(bindings.Message message) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 "data: $data" ")"; | 334 "data: $data" ")"; |
| 289 } | 335 } |
| 290 | 336 |
| 291 Map toJson() { | 337 Map toJson() { |
| 292 Map map = new Map(); | 338 Map map = new Map(); |
| 293 map["data"] = data; | 339 map["data"] = data; |
| 294 return map; | 340 return map; |
| 295 } | 341 } |
| 296 } | 342 } |
| 297 | 343 |
| 344 mojom_types.MojomStruct _serializationTestStructsStruct4() { |
| 345 return new mojom_types.MojomStruct() |
| 346 ..declData = (new mojom_types.DeclarationData() |
| 347 ..shortName = 'Struct4' |
| 348 ..fullIdentifier = 'mojo.test.Struct4') |
| 349 ..fields = <mojom_types.StructField>[ |
| 350 new mojom_types.StructField() |
| 351 ..declData = (new mojom_types.DeclarationData() |
| 352 ..shortName = 'Data') |
| 353 ..type = (new mojom_types.Type() |
| 354 ..arrayType = (new mojom_types.ArrayType() |
| 355 ..elementType = (new mojom_types.Type() |
| 356 ..typeReference = (new mojom_types.TypeReference() |
| 357 ..identifier = 'serialization_test_structs_Struct1__' |
| 358 ..typeKey = 'serialization_test_structs_Struct1__' |
| 359 )))),]; |
| 360 } |
| 361 |
| 298 | 362 |
| 299 class Struct5 extends bindings.Struct { | 363 class Struct5 extends bindings.Struct { |
| 300 static const List<bindings.StructDataHeader> kVersions = const [ | 364 static const List<bindings.StructDataHeader> kVersions = const [ |
| 301 const bindings.StructDataHeader(16, 0) | 365 const bindings.StructDataHeader(16, 0) |
| 302 ]; | 366 ]; |
| 303 List<Struct1> pair = null; | 367 List<Struct1> pair = null; |
| 304 | 368 |
| 305 Struct5() : super(kVersions.last.size); | 369 Struct5() : super(kVersions.last.size); |
| 306 | 370 |
| 307 static Struct5 deserialize(bindings.Message message) { | 371 static Struct5 deserialize(bindings.Message message) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 "pair: $pair" ")"; | 436 "pair: $pair" ")"; |
| 373 } | 437 } |
| 374 | 438 |
| 375 Map toJson() { | 439 Map toJson() { |
| 376 Map map = new Map(); | 440 Map map = new Map(); |
| 377 map["pair"] = pair; | 441 map["pair"] = pair; |
| 378 return map; | 442 return map; |
| 379 } | 443 } |
| 380 } | 444 } |
| 381 | 445 |
| 446 mojom_types.MojomStruct _serializationTestStructsStruct5() { |
| 447 return new mojom_types.MojomStruct() |
| 448 ..declData = (new mojom_types.DeclarationData() |
| 449 ..shortName = 'Struct5' |
| 450 ..fullIdentifier = 'mojo.test.Struct5') |
| 451 ..fields = <mojom_types.StructField>[ |
| 452 new mojom_types.StructField() |
| 453 ..declData = (new mojom_types.DeclarationData() |
| 454 ..shortName = 'Pair') |
| 455 ..type = (new mojom_types.Type() |
| 456 ..arrayType = (new mojom_types.ArrayType() |
| 457 ..fixedLength = 2 |
| 458 ..elementType = (new mojom_types.Type() |
| 459 ..typeReference = (new mojom_types.TypeReference() |
| 460 ..identifier = 'serialization_test_structs_Struct1__' |
| 461 ..typeKey = 'serialization_test_structs_Struct1__' |
| 462 )))),]; |
| 463 } |
| 464 |
| 382 | 465 |
| 383 class Struct6 extends bindings.Struct { | 466 class Struct6 extends bindings.Struct { |
| 384 static const List<bindings.StructDataHeader> kVersions = const [ | 467 static const List<bindings.StructDataHeader> kVersions = const [ |
| 385 const bindings.StructDataHeader(16, 0) | 468 const bindings.StructDataHeader(16, 0) |
| 386 ]; | 469 ]; |
| 387 String str = null; | 470 String str = null; |
| 388 | 471 |
| 389 Struct6() : super(kVersions.last.size); | 472 Struct6() : super(kVersions.last.size); |
| 390 | 473 |
| 391 static Struct6 deserialize(bindings.Message message) { | 474 static Struct6 deserialize(bindings.Message message) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 "str: $str" ")"; | 522 "str: $str" ")"; |
| 440 } | 523 } |
| 441 | 524 |
| 442 Map toJson() { | 525 Map toJson() { |
| 443 Map map = new Map(); | 526 Map map = new Map(); |
| 444 map["str"] = str; | 527 map["str"] = str; |
| 445 return map; | 528 return map; |
| 446 } | 529 } |
| 447 } | 530 } |
| 448 | 531 |
| 532 mojom_types.MojomStruct _serializationTestStructsStruct6() { |
| 533 return new mojom_types.MojomStruct() |
| 534 ..declData = (new mojom_types.DeclarationData() |
| 535 ..shortName = 'Struct6' |
| 536 ..fullIdentifier = 'mojo.test.Struct6') |
| 537 ..fields = <mojom_types.StructField>[ |
| 538 new mojom_types.StructField() |
| 539 ..declData = (new mojom_types.DeclarationData() |
| 540 ..shortName = 'Str') |
| 541 ..type = (new mojom_types.Type() |
| 542 ..stringType = (new mojom_types.StringType())),]; |
| 543 } |
| 544 |
| 449 | 545 |
| 450 class StructOfNullables extends bindings.Struct { | 546 class StructOfNullables extends bindings.Struct { |
| 451 static const List<bindings.StructDataHeader> kVersions = const [ | 547 static const List<bindings.StructDataHeader> kVersions = const [ |
| 452 const bindings.StructDataHeader(32, 0) | 548 const bindings.StructDataHeader(32, 0) |
| 453 ]; | 549 ]; |
| 454 core.MojoHandle hdl = null; | 550 core.MojoHandle hdl = null; |
| 455 Struct1 struct1 = null; | 551 Struct1 struct1 = null; |
| 456 String str = null; | 552 String str = null; |
| 457 | 553 |
| 458 StructOfNullables() : super(kVersions.last.size); | 554 StructOfNullables() : super(kVersions.last.size); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 "struct1: $struct1" ", " | 618 "struct1: $struct1" ", " |
| 523 "str: $str" ")"; | 619 "str: $str" ")"; |
| 524 } | 620 } |
| 525 | 621 |
| 526 Map toJson() { | 622 Map toJson() { |
| 527 throw new bindings.MojoCodecError( | 623 throw new bindings.MojoCodecError( |
| 528 'Object containing handles cannot be encoded to JSON.'); | 624 'Object containing handles cannot be encoded to JSON.'); |
| 529 } | 625 } |
| 530 } | 626 } |
| 531 | 627 |
| 628 mojom_types.MojomStruct _serializationTestStructsStructOfNullables() { |
| 629 return new mojom_types.MojomStruct() |
| 630 ..declData = (new mojom_types.DeclarationData() |
| 631 ..shortName = 'StructOfNullables' |
| 632 ..fullIdentifier = 'mojo.test.StructOfNullables') |
| 633 ..fields = <mojom_types.StructField>[ |
| 634 new mojom_types.StructField() |
| 635 ..declData = (new mojom_types.DeclarationData() |
| 636 ..shortName = 'Hdl') |
| 637 ..type = (new mojom_types.Type() |
| 638 ..handleType = (new mojom_types.HandleType() |
| 639 ..kind = mojom_types.HandleTypeKind.unspecified |
| 640 ..nullable = true |
| 641 )), |
| 642 new mojom_types.StructField() |
| 643 ..declData = (new mojom_types.DeclarationData() |
| 644 ..shortName = 'Struct1') |
| 645 ..type = (new mojom_types.Type() |
| 646 ..typeReference = (new mojom_types.TypeReference() |
| 647 ..nullable = true |
| 648 |
| 649 ..identifier = 'serialization_test_structs_Struct1__' |
| 650 ..typeKey = 'serialization_test_structs_Struct1__' |
| 651 )), |
| 652 new mojom_types.StructField() |
| 653 ..declData = (new mojom_types.DeclarationData() |
| 654 ..shortName = 'Str') |
| 655 ..type = (new mojom_types.Type() |
| 656 ..stringType = (new mojom_types.StringType() |
| 657 ..nullable = true |
| 658 )),]; |
| 659 } |
| 532 | 660 |
| 661 |
| 662 |
| 663 Map<String, mojom_types.UserDefinedType> _initDescriptions() { |
| 664 var map = new HashMap<String, mojom_types.UserDefinedType>(); |
| 665 map["serialization_test_structs_Struct1__"] = |
| 666 new mojom_types.UserDefinedType() |
| 667 ..structType = _serializationTestStructsStruct1(); |
| 668 map["serialization_test_structs_Struct2__"] = |
| 669 new mojom_types.UserDefinedType() |
| 670 ..structType = _serializationTestStructsStruct2(); |
| 671 map["serialization_test_structs_Struct3__"] = |
| 672 new mojom_types.UserDefinedType() |
| 673 ..structType = _serializationTestStructsStruct3(); |
| 674 map["serialization_test_structs_Struct4__"] = |
| 675 new mojom_types.UserDefinedType() |
| 676 ..structType = _serializationTestStructsStruct4(); |
| 677 map["serialization_test_structs_Struct5__"] = |
| 678 new mojom_types.UserDefinedType() |
| 679 ..structType = _serializationTestStructsStruct5(); |
| 680 map["serialization_test_structs_Struct6__"] = |
| 681 new mojom_types.UserDefinedType() |
| 682 ..structType = _serializationTestStructsStruct6(); |
| 683 map["serialization_test_structs_StructOfNullables__"] = |
| 684 new mojom_types.UserDefinedType() |
| 685 ..structType = _serializationTestStructsStructOfNullables(); |
| 686 return map; |
| 687 } |
| 688 |
| 689 var _mojomDesc; |
| 690 Map<String, mojom_types.UserDefinedType> getAllMojomTypeDefinitions() { |
| 691 if (_mojomDesc == null) { |
| 692 _mojomDesc = _initDescriptions(); |
| 693 } |
| 694 return _mojomDesc; |
| 695 } |
| 696 |
| OLD | NEW |