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

Side by Side Diff: tools/dom/templates/html/dart2js/impl_ArrayBuffer.darttemplate

Issue 12929005: dart:typeddata for dart2js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revert status change Created 7 years, 9 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) 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 part of $LIBRARYNAME; 5 part of $LIBRARYNAME;
6 6
7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { 7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
8 $!MEMBERS 8 $!MEMBERS
9 @DomName('ArrayBuffer.slice') 9 @DomName('ArrayBuffer.slice')
10 ArrayBuffer slice(int begin, [int end]) { 10 ByteBuffer slice(int begin, [int end]) {
11 // IE10 supports ArrayBuffers but does not have the slice method. 11 // IE10 supports ArrayBuffers but does not have the slice method.
12 if (JS('bool', '!!#.slice', this)) { 12 if (JS('bool', '!!#.slice', this)) {
13 if (?end) { 13 if (?end) {
14 return JS('ArrayBuffer', '#.slice(#, #)', this, begin, end); 14 return JS('ByteBuffer', '#.slice(#, #)', this, begin, end);
15 } 15 }
16 return JS('ArrayBuffer', '#.slice(#)', this, begin); 16 return JS('ByteBuffer', '#.slice(#)', this, begin);
17 } else { 17 } else {
18 var start = begin; 18 var start = begin;
19 // Negative values go from end. 19 // Negative values go from end.
20 if (start < 0) { 20 if (start < 0) {
21 start = this.byteLength + start; 21 start = this.byteLength + start;
22 } 22 }
23 var finish = ?end ? min(end, byteLength) : byteLength; 23 var finish = ?end ? min(end, byteLength) : byteLength;
24 if (finish < 0) { 24 if (finish < 0) {
25 finish = this.byteLength + finish; 25 finish = this.byteLength + finish;
26 } 26 }
27 var length = max(finish - start, 0); 27 var length = max(finish - start, 0);
28 28
29 var clone = new Int8Array(length); 29 var clone = new Int8List(length);
30 var source = new Int8Array.fromBuffer(this, start); 30 var source = new Int8List.fromBuffer(this, start);
31 for (var i = 0; i < length; ++i) { 31 for (var i = 0; i < length; ++i) {
32 clone[i] = source[i]; 32 clone[i] = source[i];
33 } 33 }
34 return clone.buffer; 34 return clone.buffer;
35 } 35 }
36 } 36 }
37 } 37 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698