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

Side by Side Diff: sdk/lib/typed_data/dart2js/typed_data_dart2js.dart

Issue 23464052: Uint8ClampedList no longer inherits from Uint8List (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | « no previous file | sdk/lib/typed_data/typed_data.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 * Specialized integers and floating point numbers, 6 * Specialized integers and floating point numbers,
7 * with SIMD support and efficient lists. 7 * with SIMD support and efficient lists.
8 */ 8 */
9 library dart.typed_data; 9 library dart.typed_data;
10 10
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 556
557 static Uint32List _create2(arg1, arg2) => 557 static Uint32List _create2(arg1, arg2) =>
558 JS('Uint32List', 'new Uint32Array(#, #)', arg1, arg2).._setCachedLength(); 558 JS('Uint32List', 'new Uint32Array(#, #)', arg1, arg2).._setCachedLength();
559 559
560 static Uint32List _create3(arg1, arg2, arg3) => 560 static Uint32List _create3(arg1, arg2, arg3) =>
561 JS('Uint32List', 'new Uint32Array(#, #, #)', arg1, arg2, arg3) 561 JS('Uint32List', 'new Uint32Array(#, #, #)', arg1, arg2, arg3)
562 .._setCachedLength(); 562 .._setCachedLength();
563 } 563 }
564 564
565 565
566 class Uint8ClampedList extends Uint8List 566 class Uint8ClampedList extends TypedData with ListMixin<int>,
567 FixedLengthListMixin<int> implements JavaScriptIndexingBehavior, List<int>
567 native "Uint8ClampedArray,CanvasPixelArray" { 568 native "Uint8ClampedArray,CanvasPixelArray" {
568 factory Uint8ClampedList(int length) => _create1(length); 569 factory Uint8ClampedList(int length) => _create1(length);
569 570
570 factory Uint8ClampedList.fromList(List<num> list) => 571 factory Uint8ClampedList.fromList(List<num> list) =>
571 _create1(_ensureNativeList(list)); 572 _create1(_ensureNativeList(list));
572 573
573 factory Uint8ClampedList.view(ByteBuffer buffer, 574 factory Uint8ClampedList.view(ByteBuffer buffer,
574 [int byteOffset = 0, int length]) => 575 [int byteOffset = 0, int length]) =>
575 length == null 576 length == null
576 ? _create2(buffer, byteOffset) 577 ? _create2(buffer, byteOffset)
577 : _create3(buffer, byteOffset, length); 578 : _create3(buffer, byteOffset, length);
578 579
579 static const int BYTES_PER_ELEMENT = 1; 580 static const int BYTES_PER_ELEMENT = 1;
580 581
581 // Use implementation from Uint8List 582 int get length => JS("int", '#(#)', fetchLength, this);
582 // final int length;
583 583
584 int operator[](int index) { 584 int operator[](int index) {
585 _checkIndex(index, length); 585 _checkIndex(index, length);
586 return JS("int", "#[#]", this, index); 586 return JS("int", "#[#]", this, index);
587 } 587 }
588 588
589 void operator[]=(int index, int value) { 589 void operator[]=(int index, int value) {
590 _checkIndex(index, length); 590 _checkIndex(index, length);
591 JS("void", "#[#] = #", this, index, value); 591 JS("void", "#[#] = #", this, index, value);
592 } 592 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 653
654 static Uint8List _create2(arg1, arg2) => 654 static Uint8List _create2(arg1, arg2) =>
655 JS('Uint8List', 'new Uint8Array(#, #)', arg1, arg2).._setCachedLength(); 655 JS('Uint8List', 'new Uint8Array(#, #)', arg1, arg2).._setCachedLength();
656 656
657 static Uint8List _create3(arg1, arg2, arg3) => 657 static Uint8List _create3(arg1, arg2, arg3) =>
658 JS('Uint8List', 'new Uint8Array(#, #, #)', arg1, arg2, arg3) 658 JS('Uint8List', 'new Uint8Array(#, #, #)', arg1, arg2, arg3)
659 .._setCachedLength(); 659 .._setCachedLength();
660 } 660 }
661 661
662 662
663 class _Uint8ListSubclass extends Uint8List native "Uint8Array_bogus_subclass" {
664 // The Typed Array specification states that Uint8ClampedArray is _not_
665 // a subclass of Uint8Array and is a subclass of ArrayBufferView.
666 // However, some browsers have implemented Uint8ClampedArray as a subclass of
667 // Uint8Array. Dart follows the specification but in order for dart2js to
668 // generate correct code it needs to know that there might be a subclass of
669 // Uint8Array. See: https://codereview.chromium.org/23093027/
670
671 // Factory constructor is unused but needed since a default
672 // (generative) constructor can't be generated for a class
673 // extending a class with no generative constructor.
674 factory _Uint8ListSubclass() => null;
675 }
676
677
663 class Int64List extends TypedData implements JavaScriptIndexingBehavior, List<in t> { 678 class Int64List extends TypedData implements JavaScriptIndexingBehavior, List<in t> {
664 factory Int64List(int length) { 679 factory Int64List(int length) {
665 throw new UnsupportedError("Int64List not supported by dart2js."); 680 throw new UnsupportedError("Int64List not supported by dart2js.");
666 } 681 }
667 682
668 factory Int64List.fromList(List<int> list) { 683 factory Int64List.fromList(List<int> list) {
669 throw new UnsupportedError("Int64List not supported by dart2js."); 684 throw new UnsupportedError("Int64List not supported by dart2js.");
670 } 685 }
671 686
672 factory Int64List.view(ByteBuffer buffer, [int byteOffset, int length]) { 687 factory Int64List.view(ByteBuffer buffer, [int byteOffset, int length]) {
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 rView[3] = _w; 1610 rView[3] = _w;
1596 return r; 1611 return r;
1597 } 1612 }
1598 1613
1599 /// Returns a bit-wise copy of [this] as a [Float32x4]. 1614 /// Returns a bit-wise copy of [this] as a [Float32x4].
1600 Float32x4 toFloat32x4() { 1615 Float32x4 toFloat32x4() {
1601 var view = new Float32List.view(_storage.buffer); 1616 var view = new Float32List.view(_storage.buffer);
1602 return new Float32x4(view[0], view[1], view[2], view[3]); 1617 return new Float32x4(view[0], view[1], view[2], view[3]);
1603 } 1618 }
1604 } 1619 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/typed_data/typed_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698