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

Side by Side Diff: runtime/lib/byte_array.dart

Issue 9235067: Use ByteArray's native for Socket and File. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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 | Annotate | Revision Log
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 interface ByteArray extends List default _InternalByteArray { 5 interface ByteArray extends List default _InternalByteArray {
6 ByteArray(int length); 6 ByteArray(int length);
7 7
8 int get length(); 8 int get length();
9 9
10 int getInt8(int byteOffset); 10 int getInt8(int byteOffset);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 Iterator iterator() { 56 Iterator iterator() {
57 return new _ByteArrayIterator(this); 57 return new _ByteArrayIterator(this);
58 } 58 }
59 59
60 // Collection interface 60 // Collection interface
61 61
62 int get length() { 62 int get length() {
63 return _length(); 63 return _length();
64 } 64 }
65 65
cshapiro 2012/01/28 02:25:48 This code should be moved downward beneath the Lis
Anders Johnsen 2012/01/30 21:15:28 Done.
66 void setRange(int start, int length, List<int> from, [int startFrom = 0]) {
67 if (length < 0) {
68 throw new IllegalArgumentException("negative length $length");
69 }
70 if (from is ByteArray) {
71 _setRange(from, startFrom, start, length);
72 } else {
73 Arrays.copy(from, startFrom, this, start, length);
74 }
75 }
76
77 List getRange(int start, int length) {
78 if (length == 0) return [];
79 Arrays.rangeCheck(this, start, length);
80 ByteArray list = new ByteArray(length);
81 list._setRange(this, start, 0, length);
82 return list;
83 }
84
85 void _setRange(ByteArray src,
cshapiro 2012/01/28 02:25:48 This should be moved to the very bottom with the o
Anders Johnsen 2012/01/30 21:15:28 Done.
86 int srcStart,
87 int dstStart,
88 int count)
89 native "ByteArray_setRange";
90
66 bool every(bool f(int element)) { 91 bool every(bool f(int element)) {
67 return Collections.every(this, f); 92 return Collections.every(this, f);
68 } 93 }
69 94
70 Collection map(f(int element)) { 95 Collection map(f(int element)) {
71 return Collections.map(this, 96 return Collections.map(this,
72 new GrowableObjectArray.withCapacity(length), 97 new GrowableObjectArray.withCapacity(length),
73 f); 98 f);
74 } 99 }
75 100
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 505
481 void _setFloat32(int byteOffset, double value) 506 void _setFloat32(int byteOffset, double value)
482 native "ExternalByteArray_setFloat32"; 507 native "ExternalByteArray_setFloat32";
483 508
484 double _getFloat64(int byteOffset) 509 double _getFloat64(int byteOffset)
485 native "ExternalByteArray_getFloat64"; 510 native "ExternalByteArray_getFloat64";
486 511
487 void _setFloat64(int byteOffset, double value) 512 void _setFloat64(int byteOffset, double value)
488 native "ExternalByteArray_setFloat64"; 513 native "ExternalByteArray_setFloat64";
489 } 514 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698