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

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

Issue 953953003: Introduce dartanalyze into our build. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: mojob integration Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « mojo/public/dart/rules.gni ('k') | mojo/public/dart/src/data_pipe.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of bindings; 5 part of bindings;
6 6
7 int align(int size) => size + (kAlignment - (size % kAlignment)) % kAlignment; 7 int align(int size) => size + (kAlignment - (size % kAlignment)) % kAlignment;
8 8
9 const int kAlignment = 8; 9 const int kAlignment = 8;
10 const int kSerializedHandleSize = 4; 10 const int kSerializedHandleSize = 4;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 encodedValue |= (1 << bit); 125 encodedValue |= (1 << bit);
126 _buffer.buffer.setUint8(_base + offset, encodedValue); 126 _buffer.buffer.setUint8(_base + offset, encodedValue);
127 } 127 }
128 } 128 }
129 129
130 void encodeInt8(int value, int offset) => 130 void encodeInt8(int value, int offset) =>
131 _buffer.buffer.setInt8(_base + offset, value); 131 _buffer.buffer.setInt8(_base + offset, value);
132 132
133 void encodeUint8(int value, int offset) { 133 void encodeUint8(int value, int offset) {
134 if (value < 0) { 134 if (value < 0) {
135 throw new MojoCodecError('$kErrorUnsigned: $val'); 135 throw new MojoCodecError('$kErrorUnsigned: $value');
136 } 136 }
137 _buffer.buffer.setUint8(_base + offset, value); 137 _buffer.buffer.setUint8(_base + offset, value);
138 } 138 }
139 139
140 void encodeInt16(int value, int offset) => 140 void encodeInt16(int value, int offset) =>
141 _buffer.buffer.setInt16(_base + offset, value, Endianness.LITTLE_ENDIAN); 141 _buffer.buffer.setInt16(_base + offset, value, Endianness.LITTLE_ENDIAN);
142 142
143 void encodeUint16(int value, int offset) { 143 void encodeUint16(int value, int offset) {
144 if (value < 0) { 144 if (value < 0) {
145 throw new MojoCodecError('$kErrorUnsigned: $val'); 145 throw new MojoCodecError('$kErrorUnsigned: $value');
146 } 146 }
147 _buffer.buffer.setUint16(_base + offset, value, Endianness.LITTLE_ENDIAN); 147 _buffer.buffer.setUint16(_base + offset, value, Endianness.LITTLE_ENDIAN);
148 } 148 }
149 149
150 void encodeInt32(int value, int offset) => 150 void encodeInt32(int value, int offset) =>
151 _buffer.buffer.setInt32(_base + offset, value, Endianness.LITTLE_ENDIAN); 151 _buffer.buffer.setInt32(_base + offset, value, Endianness.LITTLE_ENDIAN);
152 152
153 void encodeUint32(int value, int offset) { 153 void encodeUint32(int value, int offset) {
154 if (value < 0) { 154 if (value < 0) {
155 throw new MojoCodecError('$kErrorUnsigned: $val'); 155 throw new MojoCodecError('$kErrorUnsigned: $value');
156 } 156 }
157 _buffer.buffer.setUint32(_base + offset, value, Endianness.LITTLE_ENDIAN); 157 _buffer.buffer.setUint32(_base + offset, value, Endianness.LITTLE_ENDIAN);
158 } 158 }
159 159
160 void encodeInt64(int value, int offset) => 160 void encodeInt64(int value, int offset) =>
161 _buffer.buffer.setInt64(_base + offset, value, Endianness.LITTLE_ENDIAN); 161 _buffer.buffer.setInt64(_base + offset, value, Endianness.LITTLE_ENDIAN);
162 162
163 void encodeUint64(int value, int offset) { 163 void encodeUint64(int value, int offset) {
164 if (value < 0) { 164 if (value < 0) {
165 throw new MojoCodecError('$kErrorUnsigned: $val'); 165 throw new MojoCodecError('$kErrorUnsigned: $value');
166 } 166 }
167 _buffer.buffer.setUint64(_base + offset, value, Endianness.LITTLE_ENDIAN); 167 _buffer.buffer.setUint64(_base + offset, value, Endianness.LITTLE_ENDIAN);
168 } 168 }
169 169
170 void encodeFloat(double value, int offset) => 170 void encodeFloat(double value, int offset) =>
171 _buffer.buffer.setFloat32(_base + offset, value, Endianness.LITTLE_ENDIAN); 171 _buffer.buffer.setFloat32(_base + offset, value, Endianness.LITTLE_ENDIAN);
172 172
173 void encodeDouble(double value, int offset) => 173 void encodeDouble(double value, int offset) =>
174 _buffer.buffer.setFloat64(_base + offset, value, Endianness.LITTLE_ENDIAN); 174 _buffer.buffer.setFloat64(_base + offset, value, Endianness.LITTLE_ENDIAN);
175 175
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 476
477 void appendUint32Array(List<int> value) => 477 void appendUint32Array(List<int> value) =>
478 appendBytes(new Uint8List.view(new Uint32List.fromList(value).buffer)); 478 appendBytes(new Uint8List.view(new Uint32List.fromList(value).buffer));
479 479
480 void appendInt64Array(List<int> value) => 480 void appendInt64Array(List<int> value) =>
481 appendBytes(new Uint8List.view(new Int64List.fromList(value).buffer)); 481 appendBytes(new Uint8List.view(new Int64List.fromList(value).buffer));
482 482
483 void appendUint64Array(List<int> value) => 483 void appendUint64Array(List<int> value) =>
484 appendBytes(new Uint8List.view(new Uint64List.fromList(value).buffer)); 484 appendBytes(new Uint8List.view(new Uint64List.fromList(value).buffer));
485 485
486 void appendFloatArray(List<int> value) => 486 void appendFloatArray(List<double> value) =>
487 appendBytes(new Uint8List.view(new Float32List.fromList(value).buffer)); 487 appendBytes(new Uint8List.view(new Float32List.fromList(value).buffer));
488 488
489 void appendDoubleArray(List<int> value) => 489 void appendDoubleArray(List<double> value) =>
490 appendBytes(new Uint8List.view(new Float64List.fromList(value).buffer)); 490 appendBytes(new Uint8List.view(new Float64List.fromList(value).buffer));
491 491
492 Encoder encoderForMap(int offset) { 492 Encoder encoderForMap(int offset) {
493 encodePointerToNextUnclaimed(offset); 493 encodePointerToNextUnclaimed(offset);
494 return getStructEncoderAtOffset(kMapStructHeader); 494 return getStructEncoderAtOffset(kMapStructHeader);
495 } 495 }
496 } 496 }
497 497
498 498
499 class _Validator { 499 class _Validator {
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 throw new MojoCodecError( 862 throw new MojoCodecError(
863 'Incorrect header for map. The size is incorrect.'); 863 'Incorrect header for map. The size is incorrect.');
864 } 864 }
865 if (header.version != kMapStructHeader.version) { 865 if (header.version != kMapStructHeader.version) {
866 throw new MojoCodecError( 866 throw new MojoCodecError(
867 'Incorrect header for map. The version is incorrect.'); 867 'Incorrect header for map. The version is incorrect.');
868 } 868 }
869 return header; 869 return header;
870 } 870 }
871 } 871 }
OLDNEW
« no previous file with comments | « mojo/public/dart/rules.gni ('k') | mojo/public/dart/src/data_pipe.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698