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

Side by Side Diff: mojo/public/dart/src/codec.dart

Issue 782693004: Update mojo sdk to rev f6c8ec07c01deebc13178d516225fd12695c3dc2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hack mojo_system_impl gypi for android :| Created 6 years 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 // TODO(zra): Rewrite MojoDecoder and MojoEncoder using Dart idioms, and make
6 // corresponding changes to the bindings generation script.
7
5 part of bindings; 8 part of bindings;
6 9
7 const int kAlignment = 8; 10 const int kAlignment = 8;
8 const int kArrayHeaderSize = 8; 11 const int kArrayHeaderSize = 8;
9 const int kStructHeaderSize = 8; 12 const int kStructHeaderSize = 8;
10 const int kMessageHeaderSize = 16; 13 const int kMessageHeaderSize = 16;
11 const int kMessageWithRequestIDHeaderSize = 24; 14 const int kMessageWithRequestIDHeaderSize = 24;
12 const int kMapStructPayloadSize = 16; 15 const int kMapStructPayloadSize = 16;
13 const int kStructHeaderNumBytesOffset = 0; 16 const int kStructHeaderNumBytesOffset = 0;
14 const int kStructHeaderNumFieldsOffset = 4; 17 const int kStructHeaderNumFieldsOffset = 4;
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 if (num_fields >= 3) { 559 if (num_fields >= 3) {
557 requestID = decoder.readUint64(); 560 requestID = decoder.readUint64();
558 } 561 }
559 decoder.skip(messageHeaderSize - decoder.next); 562 decoder.skip(messageHeaderSize - decoder.next);
560 } 563 }
561 564
562 Object decodeStruct(Object t) => _callDecode(t, decoder); 565 Object decodeStruct(Object t) => _callDecode(t, decoder);
563 } 566 }
564 567
565 568
566 abstract class MojoType<T> {
567 static const int encodedSize = 0;
568 static T decode(MojoDecoder decoder) { return null; }
569 static void encode(MojoEncoder encoder, T val) {}
570 }
571
572
573 class PackedBool {} 569 class PackedBool {}
574 570
575 571
576 class Int8 implements MojoType<int> { 572 class Int8 {
577 static const int encodedSize = 1; 573 static const int encodedSize = 1;
578 static int decode(MojoDecoder decoder) => decoder.readInt8(); 574 static int decode(MojoDecoder decoder) => decoder.readInt8();
579 static void encode(MojoEncoder encoder, int val) { 575 static void encode(MojoEncoder encoder, int val) {
580 encoder.writeInt8(val); 576 encoder.writeInt8(val);
581 } 577 }
582 } 578 }
583 579
584 580
585 class Uint8 implements MojoType<int> { 581 class Uint8 {
586 static const int encodedSize = 1; 582 static const int encodedSize = 1;
587 static int decode(MojoDecoder decoder) => decoder.readUint8(); 583 static int decode(MojoDecoder decoder) => decoder.readUint8();
588 static void encode(MojoEncoder encoder, int val) { 584 static void encode(MojoEncoder encoder, int val) {
589 encoder.writeUint8(val); 585 encoder.writeUint8(val);
590 } 586 }
591 } 587 }
592 588
593 589
594 class Int16 implements MojoType<int> { 590 class Int16 {
595 static const int encodedSize = 2; 591 static const int encodedSize = 2;
596 static int decode(MojoDecoder decoder) => decoder.readInt16(); 592 static int decode(MojoDecoder decoder) => decoder.readInt16();
597 static void encode(MojoEncoder encoder, int val) { 593 static void encode(MojoEncoder encoder, int val) {
598 encoder.writeInt16(val); 594 encoder.writeInt16(val);
599 } 595 }
600 } 596 }
601 597
602 598
603 class Uint16 implements MojoType<int> { 599 class Uint16 {
604 static const int encodedSize = 2; 600 static const int encodedSize = 2;
605 static int decode(MojoDecoder decoder) => decoder.readUint16(); 601 static int decode(MojoDecoder decoder) => decoder.readUint16();
606 static void encode(MojoEncoder encoder, int val) { 602 static void encode(MojoEncoder encoder, int val) {
607 encoder.writeUint16(val); 603 encoder.writeUint16(val);
608 } 604 }
609 } 605 }
610 606
611 607
612 class Int32 implements MojoType<int> { 608 class Int32 {
613 static const int encodedSize = 4; 609 static const int encodedSize = 4;
614 static int decode(MojoDecoder decoder) => decoder.readInt32(); 610 static int decode(MojoDecoder decoder) => decoder.readInt32();
615 static void encode(MojoEncoder encoder, int val) { 611 static void encode(MojoEncoder encoder, int val) {
616 encoder.writeInt32(val); 612 encoder.writeInt32(val);
617 } 613 }
618 } 614 }
619 615
620 616
621 class Uint32 implements MojoType<int> { 617 class Uint32 {
622 static const int encodedSize = 4; 618 static const int encodedSize = 4;
623 static int decode(MojoDecoder decoder) => decoder.readUint32(); 619 static int decode(MojoDecoder decoder) => decoder.readUint32();
624 static void encode(MojoEncoder encoder, int val) { 620 static void encode(MojoEncoder encoder, int val) {
625 encoder.writeUint32(val); 621 encoder.writeUint32(val);
626 } 622 }
627 } 623 }
628 624
629 625
630 class Int64 implements MojoType<int> { 626 class Int64 {
631 static const int encodedSize = 8; 627 static const int encodedSize = 8;
632 static int decode(MojoDecoder decoder) => decoder.readInt64(); 628 static int decode(MojoDecoder decoder) => decoder.readInt64();
633 static void encode(MojoEncoder encoder, int val) { 629 static void encode(MojoEncoder encoder, int val) {
634 encoder.writeInt64(val); 630 encoder.writeInt64(val);
635 } 631 }
636 } 632 }
637 633
638 634
639 class Uint64 implements MojoType<int> { 635 class Uint64 {
640 static const int encodedSize = 8; 636 static const int encodedSize = 8;
641 static int decode(MojoDecoder decoder) => decoder.readUint64(); 637 static int decode(MojoDecoder decoder) => decoder.readUint64();
642 static void encode(MojoEncoder encoder, int val) { 638 static void encode(MojoEncoder encoder, int val) {
643 encoder.writeUint64(val); 639 encoder.writeUint64(val);
644 } 640 }
645 } 641 }
646 642
647 643
648 class MojoString implements MojoType<String> { 644 class MojoString {
649 static const int encodedSize = 8; 645 static const int encodedSize = 8;
650 static String decode(MojoDecoder decoder) => decoder.decodeStringPointer(); 646 static String decode(MojoDecoder decoder) => decoder.decodeStringPointer();
651 static void encode(MojoEncoder encoder, String val) { 647 static void encode(MojoEncoder encoder, String val) {
652 encoder.encodeStringPointer(val); 648 encoder.encodeStringPointer(val);
653 } 649 }
654 } 650 }
655 651
656 652
657 class NullableMojoString implements MojoType<String> { 653 class NullableMojoString {
658 static const int encodedSize = MojoString.encodedSize; 654 static const int encodedSize = MojoString.encodedSize;
659 static var decode = MojoString.decode; 655 static var decode = MojoString.decode;
660 static var encode = MojoString.encode; 656 static var encode = MojoString.encode;
661 } 657 }
662 658
663 659
664 class Float implements MojoType<double> { 660 class Float {
665 static const int encodedSize = 4; 661 static const int encodedSize = 4;
666 static double decode(MojoDecoder decoder) => decoder.readFloat(); 662 static double decode(MojoDecoder decoder) => decoder.readFloat();
667 static void encode(MojoEncoder encoder, double val) { 663 static void encode(MojoEncoder encoder, double val) {
668 encoder.writeFloat(val); 664 encoder.writeFloat(val);
669 } 665 }
670 } 666 }
671 667
672 668
673 class Double implements MojoType<double> { 669 class Double {
674 static const int encodedSize = 8; 670 static const int encodedSize = 8;
675 static double decode(MojoDecoder decoder) => decoder.readDouble(); 671 static double decode(MojoDecoder decoder) => decoder.readDouble();
676 static void encode(MojoEncoder encoder, double val) { 672 static void encode(MojoEncoder encoder, double val) {
677 encoder.writeDouble(val); 673 encoder.writeDouble(val);
678 } 674 }
679 } 675 }
680 676
681 677
682 class PointerTo { 678 class PointerTo {
683 Object val; 679 Object val;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 encoder.encodeArrayPointer(this.val, val); 719 encoder.encodeArrayPointer(this.val, val);
724 } 720 }
725 } 721 }
726 722
727 723
728 class NullableArrayOf extends ArrayOf { 724 class NullableArrayOf extends ArrayOf {
729 NullableArrayOf(Object val, [int length = 0]) : super(val, length); 725 NullableArrayOf(Object val, [int length = 0]) : super(val, length);
730 } 726 }
731 727
732 728
733 class Handle implements MojoType<core.RawMojoHandle> { 729 class Handle {
734 static const int encodedSize = 4; 730 static const int encodedSize = 4;
735 static core.RawMojoHandle decode(MojoDecoder decoder) => decoder.decodeHandle( ); 731 static core.RawMojoHandle decode(MojoDecoder decoder) =>
732 decoder.decodeHandle();
736 static void encode(MojoEncoder encoder, core.RawMojoHandle val) { 733 static void encode(MojoEncoder encoder, core.RawMojoHandle val) {
737 encoder.encodeHandle(val); 734 encoder.encodeHandle(val);
738 } 735 }
739 } 736 }
740 737
741 738
742 class NullableHandle implements MojoType<int> { 739 class NullableHandle {
743 static const int encodedSize = Handle.encodedSize; 740 static const int encodedSize = Handle.encodedSize;
744 static const decode = Handle.decode; 741 static const decode = Handle.decode;
745 static const encode = Handle.encode; 742 static const encode = Handle.encode;
746 } 743 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698