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

Unified Diff: third_party/mojo/src/mojo/public/dart/lib/src/codec.dart

Issue 1179733005: Update mojo sdk to rev bdbb0c7e396fc4044a8b194058d7a7e529715286 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update CommandBufferImpl (Binding::OnConnectionError is no more) Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: third_party/mojo/src/mojo/public/dart/lib/src/codec.dart
diff --git a/third_party/mojo/src/mojo/public/dart/lib/src/codec.dart b/third_party/mojo/src/mojo/public/dart/lib/src/codec.dart
index 07bad358bbff0ad229c4f4a464f3b970cbd5dafd..4f3e72376c7727efd481e67ecdecbb8d51312391 100644
--- a/third_party/mojo/src/mojo/public/dart/lib/src/codec.dart
+++ b/third_party/mojo/src/mojo/public/dart/lib/src/codec.dart
@@ -10,6 +10,7 @@ const int kAlignment = 8;
const int kSerializedHandleSize = 4;
const int kSerializedInterfaceSize = 8; // 4-byte handle + 4-byte version
const int kPointerSize = 8;
+const int kUnionSize = 16;
const StructDataHeader kMapStructHeader = const StructDataHeader(24, 0);
const int kUnspecifiedArrayLength = -1;
const int kNothingNullable = 0;
@@ -270,9 +271,32 @@ class Encoder {
value.encode(this);
}
+ void encodeUnion(Union value, int offset, bool nullable) {
+ if (value == null) {
+ if (!nullable) {
+ throw new MojoCodecError(
+ 'Trying to encode a non-nullable null union.');
+ }
+ encodeUint64(0, offset);
+ encodeUint64(0, offset + 8);
+ return;
+ }
+ value.encode(this, offset);
+ }
+
+ void encodeNestedUnion(Union value, int offset, bool nullable) {
+ _buffer.claimMemory(align(kUnionSize));
+ encodePointerToNextUnclaimed(offset);
+ var encoder = new Encoder._fromBuffer(_buffer);
+ encoder.encodeUnion(value, 0, nullable);
+ }
+
Encoder encodePointerArray(int length, int offset, int expectedLength) =>
encoderForArray(kPointerSize, length, offset, expectedLength);
+ Encoder encodeUnionArray(int length, int offset, int expectedLength) =>
+ encoderForArray(kUnionSize, length, offset, expectedLength);
+
Encoder encoderForArray(
int elementSize, int length, int offset, int expectedLength) {
if ((expectedLength != kUnspecifiedArrayLength) &&
@@ -714,6 +738,9 @@ class Decoder {
ArrayDataHeader decodeDataHeaderForPointerArray(int expectedLength) =>
decodeDataHeaderForArray(kPointerSize, expectedLength);
+ ArrayDataHeader decodeDataHeaderForUnionArray(int expectedLength) =>
+ decodeDataHeaderForArray(kUnionSize, expectedLength);
+
List decodeArray(Function arrayViewer, int elementSize, int offset,
int nullability, int expectedLength) {
Decoder d = decodePointer(offset, isArrayNullable(nullability));
« no previous file with comments | « third_party/mojo/src/mojo/public/dart/lib/bindings.dart ('k') | third_party/mojo/src/mojo/public/dart/lib/src/union.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698