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

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

Issue 10919146: Get rid of a lot of () for getters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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
« no previous file with comments | « pkg/unittest/html_enhanced_config.dart ('k') | runtime/lib/date_patch.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 /** 5 /**
6 * A random-access sequence of bytes that also provides random access to 6 * A random-access sequence of bytes that also provides random access to
7 * the fixed-width integers and floating point numbers represented by 7 * the fixed-width integers and floating point numbers represented by
8 * those bytes. Byte arrays may be used to pack and unpack data from 8 * those bytes. Byte arrays may be used to pack and unpack data from
9 * external sources (such as networks or files systems), and to process 9 * external sources (such as networks or files systems), and to process
10 * large quantities of numerical data more efficiently than would be possible 10 * large quantities of numerical data more efficiently than would be possible
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 } 826 }
827 827
828 bool some(bool f(element)) { 828 bool some(bool f(element)) {
829 return Collections.some(this, f); 829 return Collections.some(this, f);
830 } 830 }
831 831
832 bool isEmpty() { 832 bool isEmpty() {
833 return this.length === 0; 833 return this.length === 0;
834 } 834 }
835 835
836 int get length() { 836 int get length {
837 return _length(); 837 return _length();
838 } 838 }
839 839
840 // Methods implementing the List interface. 840 // Methods implementing the List interface.
841 841
842 set length(newLength) { 842 set length(newLength) {
843 throw const UnsupportedOperationException( 843 throw const UnsupportedOperationException(
844 "Cannot resize a non-extendable array"); 844 "Cannot resize a non-extendable array");
845 } 845 }
846 846
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after
2305 } 2305 }
2306 2306
2307 bool some(bool f(element)) { 2307 bool some(bool f(element)) {
2308 return Collections.some(this, f);; 2308 return Collections.some(this, f);;
2309 } 2309 }
2310 2310
2311 bool isEmpty() { 2311 bool isEmpty() {
2312 return this.length === 0; 2312 return this.length === 0;
2313 } 2313 }
2314 2314
2315 abstract int get length(); 2315 abstract int get length;
2316 2316
2317 // Methods implementing the List interface. 2317 // Methods implementing the List interface.
2318 2318
2319 set length(newLength) { 2319 set length(newLength) {
2320 throw const UnsupportedOperationException( 2320 throw const UnsupportedOperationException(
2321 "Cannot resize a non-extendable array"); 2321 "Cannot resize a non-extendable array");
2322 } 2322 }
2323 2323
2324 void add(value) { 2324 void add(value) {
2325 throw const UnsupportedOperationException( 2325 throw const UnsupportedOperationException(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2378 class _Int8ArrayView extends _ByteArrayViewBase implements Int8List { 2378 class _Int8ArrayView extends _ByteArrayViewBase implements Int8List {
2379 _Int8ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2379 _Int8ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
2380 : _array = array, 2380 : _array = array,
2381 _offset = _requireInteger(offsetInBytes), 2381 _offset = _requireInteger(offsetInBytes),
2382 _length = _requireIntegerOrNull( 2382 _length = _requireIntegerOrNull(
2383 length, 2383 length,
2384 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 2384 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
2385 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); 2385 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2386 } 2386 }
2387 2387
2388 get length() { 2388 get length {
2389 return _length; 2389 return _length;
2390 } 2390 }
2391 2391
2392 int operator[](int index) { 2392 int operator[](int index) {
2393 if (index < 0 || index >= _length) { 2393 if (index < 0 || index >= _length) {
2394 String message = "$index must be in the range [0..$_length)"; 2394 String message = "$index must be in the range [0..$_length)";
2395 throw new IndexOutOfRangeException(message); 2395 throw new IndexOutOfRangeException(message);
2396 } 2396 }
2397 return _array.getInt8(_offset + (index * _BYTES_PER_ELEMENT)); 2397 return _array.getInt8(_offset + (index * _BYTES_PER_ELEMENT));
2398 } 2398 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 class _Uint8ArrayView extends _ByteArrayViewBase implements Uint8List { 2450 class _Uint8ArrayView extends _ByteArrayViewBase implements Uint8List {
2451 _Uint8ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2451 _Uint8ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
2452 : _array = array, 2452 : _array = array,
2453 _offset = _requireInteger(offsetInBytes), 2453 _offset = _requireInteger(offsetInBytes),
2454 _length = _requireIntegerOrNull( 2454 _length = _requireIntegerOrNull(
2455 length, 2455 length,
2456 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 2456 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
2457 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); 2457 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2458 } 2458 }
2459 2459
2460 get length() { 2460 get length {
2461 return _length; 2461 return _length;
2462 } 2462 }
2463 2463
2464 int operator[](int index) { 2464 int operator[](int index) {
2465 if (index < 0 || index >= _length) { 2465 if (index < 0 || index >= _length) {
2466 String message = "$index must be in the range [0..$_length)"; 2466 String message = "$index must be in the range [0..$_length)";
2467 throw new IndexOutOfRangeException(message); 2467 throw new IndexOutOfRangeException(message);
2468 } 2468 }
2469 return _array.getUint8(_offset + (index * _BYTES_PER_ELEMENT)); 2469 return _array.getUint8(_offset + (index * _BYTES_PER_ELEMENT));
2470 } 2470 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2522 class _Int16ArrayView extends _ByteArrayViewBase implements Int16List { 2522 class _Int16ArrayView extends _ByteArrayViewBase implements Int16List {
2523 _Int16ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2523 _Int16ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
2524 : _array = array, 2524 : _array = array,
2525 _offset = _requireInteger(offsetInBytes), 2525 _offset = _requireInteger(offsetInBytes),
2526 _length = _requireIntegerOrNull( 2526 _length = _requireIntegerOrNull(
2527 length, 2527 length,
2528 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 2528 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
2529 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); 2529 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2530 } 2530 }
2531 2531
2532 get length() { 2532 get length {
2533 return _length; 2533 return _length;
2534 } 2534 }
2535 2535
2536 int operator[](int index) { 2536 int operator[](int index) {
2537 if (index < 0 || index >= _length) { 2537 if (index < 0 || index >= _length) {
2538 String message = "$index must be in the range [0..$_length)"; 2538 String message = "$index must be in the range [0..$_length)";
2539 throw new IndexOutOfRangeException(message); 2539 throw new IndexOutOfRangeException(message);
2540 } 2540 }
2541 return _array.getInt16(_offset + (index * _BYTES_PER_ELEMENT)); 2541 return _array.getInt16(_offset + (index * _BYTES_PER_ELEMENT));
2542 } 2542 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 class _Uint16ArrayView extends _ByteArrayViewBase implements Uint16List { 2594 class _Uint16ArrayView extends _ByteArrayViewBase implements Uint16List {
2595 _Uint16ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2595 _Uint16ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
2596 : _array = array, 2596 : _array = array,
2597 _offset = _requireInteger(offsetInBytes), 2597 _offset = _requireInteger(offsetInBytes),
2598 _length = _requireIntegerOrNull( 2598 _length = _requireIntegerOrNull(
2599 length, 2599 length,
2600 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 2600 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
2601 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); 2601 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2602 } 2602 }
2603 2603
2604 get length() { 2604 get length {
2605 return _length; 2605 return _length;
2606 } 2606 }
2607 2607
2608 int operator[](int index) { 2608 int operator[](int index) {
2609 if (index < 0 || index >= _length) { 2609 if (index < 0 || index >= _length) {
2610 String message = "$index must be in the range [0..$_length)"; 2610 String message = "$index must be in the range [0..$_length)";
2611 throw new IndexOutOfRangeException(message); 2611 throw new IndexOutOfRangeException(message);
2612 } 2612 }
2613 return _array.getUint16(_offset + (index * _BYTES_PER_ELEMENT)); 2613 return _array.getUint16(_offset + (index * _BYTES_PER_ELEMENT));
2614 } 2614 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2666 class _Int32ArrayView extends _ByteArrayViewBase implements Int32List { 2666 class _Int32ArrayView extends _ByteArrayViewBase implements Int32List {
2667 _Int32ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2667 _Int32ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
2668 : _array = array, 2668 : _array = array,
2669 _offset = _requireInteger(offsetInBytes), 2669 _offset = _requireInteger(offsetInBytes),
2670 _length = _requireIntegerOrNull( 2670 _length = _requireIntegerOrNull(
2671 length, 2671 length,
2672 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 2672 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
2673 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); 2673 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2674 } 2674 }
2675 2675
2676 get length() { 2676 get length {
2677 return _length; 2677 return _length;
2678 } 2678 }
2679 2679
2680 int operator[](int index) { 2680 int operator[](int index) {
2681 if (index < 0 || index >= _length) { 2681 if (index < 0 || index >= _length) {
2682 String message = "$index must be in the range [0..$_length)"; 2682 String message = "$index must be in the range [0..$_length)";
2683 throw new IndexOutOfRangeException(message); 2683 throw new IndexOutOfRangeException(message);
2684 } 2684 }
2685 return _array.getInt32(_offset + (index * _BYTES_PER_ELEMENT)); 2685 return _array.getInt32(_offset + (index * _BYTES_PER_ELEMENT));
2686 } 2686 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2738 class _Uint32ArrayView extends _ByteArrayViewBase implements Uint32List { 2738 class _Uint32ArrayView extends _ByteArrayViewBase implements Uint32List {
2739 _Uint32ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2739 _Uint32ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
2740 : _array = array, 2740 : _array = array,
2741 _offset = _requireInteger(offsetInBytes), 2741 _offset = _requireInteger(offsetInBytes),
2742 _length = _requireIntegerOrNull( 2742 _length = _requireIntegerOrNull(
2743 length, 2743 length,
2744 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 2744 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
2745 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); 2745 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2746 } 2746 }
2747 2747
2748 get length() { 2748 get length {
2749 return _length; 2749 return _length;
2750 } 2750 }
2751 2751
2752 int operator[](int index) { 2752 int operator[](int index) {
2753 if (index < 0 || index >= _length) { 2753 if (index < 0 || index >= _length) {
2754 String message = "$index must be in the range [0..$_length)"; 2754 String message = "$index must be in the range [0..$_length)";
2755 throw new IndexOutOfRangeException(message); 2755 throw new IndexOutOfRangeException(message);
2756 } 2756 }
2757 return _array.getUint32(_offset + (index * _BYTES_PER_ELEMENT)); 2757 return _array.getUint32(_offset + (index * _BYTES_PER_ELEMENT));
2758 } 2758 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2810 class _Int64ArrayView extends _ByteArrayViewBase implements Int64List { 2810 class _Int64ArrayView extends _ByteArrayViewBase implements Int64List {
2811 _Int64ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2811 _Int64ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
2812 : _array = array, 2812 : _array = array,
2813 _offset = _requireInteger(offsetInBytes), 2813 _offset = _requireInteger(offsetInBytes),
2814 _length = _requireIntegerOrNull( 2814 _length = _requireIntegerOrNull(
2815 length, 2815 length,
2816 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 2816 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
2817 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); 2817 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2818 } 2818 }
2819 2819
2820 get length() { 2820 get length {
2821 return _length; 2821 return _length;
2822 } 2822 }
2823 2823
2824 int operator[](int index) { 2824 int operator[](int index) {
2825 if (index < 0 || index >= _length) { 2825 if (index < 0 || index >= _length) {
2826 String message = "$index must be in the range [0..$_length)"; 2826 String message = "$index must be in the range [0..$_length)";
2827 throw new IndexOutOfRangeException(message); 2827 throw new IndexOutOfRangeException(message);
2828 } 2828 }
2829 return _array.getInt64(_offset + (index * _BYTES_PER_ELEMENT)); 2829 return _array.getInt64(_offset + (index * _BYTES_PER_ELEMENT));
2830 } 2830 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2882 class _Uint64ArrayView extends _ByteArrayViewBase implements Uint64List { 2882 class _Uint64ArrayView extends _ByteArrayViewBase implements Uint64List {
2883 _Uint64ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2883 _Uint64ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
2884 : _array = array, 2884 : _array = array,
2885 _offset = _requireInteger(offsetInBytes), 2885 _offset = _requireInteger(offsetInBytes),
2886 _length = _requireIntegerOrNull( 2886 _length = _requireIntegerOrNull(
2887 length, 2887 length,
2888 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 2888 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
2889 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); 2889 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2890 } 2890 }
2891 2891
2892 get length() { 2892 get length {
2893 return _length; 2893 return _length;
2894 } 2894 }
2895 2895
2896 int operator[](int index) { 2896 int operator[](int index) {
2897 if (index < 0 || index >= _length) { 2897 if (index < 0 || index >= _length) {
2898 String message = "$index must be in the range [0..$_length)"; 2898 String message = "$index must be in the range [0..$_length)";
2899 throw new IndexOutOfRangeException(message); 2899 throw new IndexOutOfRangeException(message);
2900 } 2900 }
2901 return _array.getUint64(_offset + (index * _BYTES_PER_ELEMENT)); 2901 return _array.getUint64(_offset + (index * _BYTES_PER_ELEMENT));
2902 } 2902 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2954 class _Float32ArrayView extends _ByteArrayViewBase implements Float32List { 2954 class _Float32ArrayView extends _ByteArrayViewBase implements Float32List {
2955 _Float32ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 2955 _Float32ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
2956 : _array = array, 2956 : _array = array,
2957 _offset = _requireInteger(offsetInBytes), 2957 _offset = _requireInteger(offsetInBytes),
2958 _length = _requireIntegerOrNull( 2958 _length = _requireIntegerOrNull(
2959 length, 2959 length,
2960 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 2960 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
2961 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); 2961 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
2962 } 2962 }
2963 2963
2964 get length() { 2964 get length {
2965 return _length; 2965 return _length;
2966 } 2966 }
2967 2967
2968 double operator[](int index) { 2968 double operator[](int index) {
2969 if (index < 0 || index >= _length) { 2969 if (index < 0 || index >= _length) {
2970 String message = "$index must be in the range [0..$_length)"; 2970 String message = "$index must be in the range [0..$_length)";
2971 throw new IndexOutOfRangeException(message); 2971 throw new IndexOutOfRangeException(message);
2972 } 2972 }
2973 return _array.getFloat32(_offset + (index * _BYTES_PER_ELEMENT)); 2973 return _array.getFloat32(_offset + (index * _BYTES_PER_ELEMENT));
2974 } 2974 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3026 class _Float64ArrayView extends _ByteArrayViewBase implements Float64List { 3026 class _Float64ArrayView extends _ByteArrayViewBase implements Float64List {
3027 _Float64ArrayView(ByteArray array, [int offsetInBytes = 0, int length]) 3027 _Float64ArrayView(ByteArray array, [int offsetInBytes = 0, int length])
3028 : _array = array, 3028 : _array = array,
3029 _offset = _requireInteger(offsetInBytes), 3029 _offset = _requireInteger(offsetInBytes),
3030 _length = _requireIntegerOrNull( 3030 _length = _requireIntegerOrNull(
3031 length, 3031 length,
3032 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) { 3032 ((array.lengthInBytes() - offsetInBytes) ~/ _BYTES_PER_ELEMENT)) {
3033 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT); 3033 _rangeCheck(array.lengthInBytes(), _offset, _length * _BYTES_PER_ELEMENT);
3034 } 3034 }
3035 3035
3036 get length() { 3036 get length {
3037 return _length; 3037 return _length;
3038 } 3038 }
3039 3039
3040 double operator[](int index) { 3040 double operator[](int index) {
3041 if (index < 0 || index >= _length) { 3041 if (index < 0 || index >= _length) {
3042 String message = "$index must be in the range [0..$_length)"; 3042 String message = "$index must be in the range [0..$_length)";
3043 throw new IndexOutOfRangeException(message); 3043 throw new IndexOutOfRangeException(message);
3044 } 3044 }
3045 return _array.getFloat64(_offset + (index * _BYTES_PER_ELEMENT)); 3045 return _array.getFloat64(_offset + (index * _BYTES_PER_ELEMENT));
3046 } 3046 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3086 } 3086 }
3087 _rangeCheck(this.length, start, length); 3087 _rangeCheck(this.length, start, length);
3088 return _array.subByteArray(_offset + start, length); 3088 return _array.subByteArray(_offset + start, length);
3089 } 3089 }
3090 3090
3091 static const int _BYTES_PER_ELEMENT = 8; 3091 static const int _BYTES_PER_ELEMENT = 8;
3092 final ByteArray _array; 3092 final ByteArray _array;
3093 final int _offset; 3093 final int _offset;
3094 final int _length; 3094 final int _length;
3095 } 3095 }
OLDNEW
« no previous file with comments | « pkg/unittest/html_enhanced_config.dart ('k') | runtime/lib/date_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698