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

Side by Side Diff: sdk/lib/io/common.dart

Issue 1974043002: Revert "Fix remaining strong-mode warnings and errors in dart:io." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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 | « sdk/lib/io/bytes_builder.dart ('k') | sdk/lib/io/crypto.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.io; 5 part of dart.io;
6 6
7 // Constants used when working with native ports. 7 // Constants used when working with native ports.
8 // These must match the constants in runtime/bin/dartutils.h class CObject. 8 // These must match the constants in runtime/bin/dartutils.h class CObject.
9 const int _SUCCESS_RESPONSE = 0; 9 const int _SUCCESS_RESPONSE = 0;
10 const int _ILLEGAL_ARGUMENT_RESPONSE = 1; 10 const int _ILLEGAL_ARGUMENT_RESPONSE = 1;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 sb..write(": errno = ") 83 sb..write(": errno = ")
84 ..write(errorCode.toString()); 84 ..write(errorCode.toString());
85 } 85 }
86 return sb.toString(); 86 return sb.toString();
87 } 87 }
88 } 88 }
89 89
90 90
91 // Object for holding a buffer and an offset. 91 // Object for holding a buffer and an offset.
92 class _BufferAndStart { 92 class _BufferAndStart {
93 List<int> buffer; 93 List buffer;
94 int start; 94 int start;
95 _BufferAndStart(this.buffer, this.start); 95 _BufferAndStart(this.buffer, this.start);
96 } 96 }
97 97
98 // Ensure that the input List can be serialized through a native port. 98 // Ensure that the input List can be serialized through a native port.
99 // Only Int8List and Uint8List Lists are serialized directly. 99 // Only Int8List and Uint8List Lists are serialized directly.
100 // All other lists are first copied into a Uint8List. This has the added 100 // All other lists are first copied into a Uint8List. This has the added
101 // benefit that it is faster to access from the C code as well. 101 // benefit that it is faster to access from the C code as well.
102 _BufferAndStart _ensureFastAndSerializableByteData( 102 _BufferAndStart _ensureFastAndSerializableByteData(
103 List<int> buffer, int start, int end) { 103 List buffer, int start, int end) {
104 if (buffer is Uint8List || buffer is Int8List) { 104 if (buffer is Uint8List || buffer is Int8List) {
105 return new _BufferAndStart(buffer, start); 105 return new _BufferAndStart(buffer, start);
106 } 106 }
107 int length = end - start; 107 int length = end - start;
108 var newBuffer = new Uint8List(length); 108 var newBuffer = new Uint8List(length);
109 int j = start; 109 int j = start;
110 for (int i = 0; i < length; i++) { 110 for (int i = 0; i < length; i++) {
111 int value = buffer[j]; 111 int value = buffer[j];
112 if (value is! int) { 112 if (value is! int) {
113 throw new ArgumentError("List element is not an integer at index $j"); 113 throw new ArgumentError("List element is not an integer at index $j");
114 } 114 }
115 newBuffer[i] = value; 115 newBuffer[i] = value;
116 j++; 116 j++;
117 } 117 }
118 return new _BufferAndStart(newBuffer, 0); 118 return new _BufferAndStart(newBuffer, 0);
119 } 119 }
120 120
121 121
122 class _IOCrypto { 122 class _IOCrypto {
123 external static Uint8List getRandomBytes(int count); 123 external static Uint8List getRandomBytes(int count);
124 } 124 }
OLDNEW
« no previous file with comments | « sdk/lib/io/bytes_builder.dart ('k') | sdk/lib/io/crypto.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698