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

Side by Side Diff: runtime/bin/common.dart

Issue 11000025: Revert hiding of VM-only coreimpl list implementation types. While I (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 | « runtime/bin/common.cc ('k') | runtime/bin/file_impl.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 * An [OSError] object holds information about an error from the 6 * An [OSError] object holds information about an error from the
7 * operating system. 7 * operating system.
8 */ 8 */
9 class OSError { 9 class OSError {
10 /** Constant used to indicate that no OS error code is available. */
11 static const int noErrorCode = -1; 10 static const int noErrorCode = -1;
12 11
13 /** Creates an OSError object from a message and an errorCode. */
14 const OSError([String this.message = "", int this.errorCode = noErrorCode]); 12 const OSError([String this.message = "", int this.errorCode = noErrorCode]);
15 13
16 /** Converts an OSError object to a string representation. */
17 String toString() { 14 String toString() {
18 StringBuffer sb = new StringBuffer(); 15 StringBuffer sb = new StringBuffer();
19 sb.add("OS Error"); 16 sb.add("OS Error");
20 if (!message.isEmpty()) { 17 if (!message.isEmpty()) {
21 sb.add(": "); 18 sb.add(": ");
22 sb.add(message); 19 sb.add(message);
23 if (errorCode != noErrorCode) { 20 if (errorCode != noErrorCode) {
24 sb.add(", errno = "); 21 sb.add(", errno = ");
25 sb.add(errorCode.toString()); 22 sb.add(errorCode.toString());
26 } 23 }
27 } else if (errorCode != noErrorCode) { 24 } else if (errorCode != noErrorCode) {
28 sb.add(": errno = "); 25 sb.add(": errno = ");
29 sb.add(errorCode.toString()); 26 sb.add(errorCode.toString());
30 } 27 }
31 return sb.toString(); 28 return sb.toString();
32 } 29 }
33 30
34 /** 31 /**
35 * Error message supplied by the operating system. null if no message is 32 * Error message supplied by the operating system. null if no message is
36 * associated with the error. 33 * associated with the error.
37 */ 34 */
38 final String message; 35 final String message;
39 36
40 /** 37 /**
41 * Error code supplied by the operating system. Will have the value 38 * Error code supplied by the operating system. Will have the value
42 * [noErrorCode] if there is no error code associated with the error. 39 * [noErrorCode] if there is no error code associated with the error.
43 */ 40 */
44 final int errorCode; 41 final int errorCode;
45 } 42 }
46
47
48 // Check if a List is a builtin VM List type. Returns true
49 // if the List is a builtin VM List type and false if it is
50 // a user defined List type.
51 //
52 // TODO(5474): At this point it actually return false for
53 // _GrowableObjectArrays because of serialization issues.
54 bool _isBuiltinList(List buffer) native "Common_IsBuiltinList";
55
56
57 // Ensure that the input List can be serialized through a native port.
58 // Only builtin Lists can be serialized through. If user-defined Lists
59 // get here, the contents is copied to a Uint8List. This has the added
60 // benefit that it is faster to access from the C code as well.
61 List _ensureFastAndSerializableBuffer(
62 List buffer, int offset, int bytes) {
63 List outBuffer;
64 int outOffset = offset;
65 if (buffer is Uint8List || _isBuiltinList(buffer)) {
66 outBuffer = buffer;
67 } else {
68 outBuffer = new Uint8List(bytes);
69 outOffset = 0;
70 int j = offset;
71 for (int i = 0; i < bytes; i++) {
72 int value = buffer[j];
73 if (value is! int) {
74 throw new FileIOException(
75 "List element is not an integer at index $j");
76 }
77 outBuffer[i] = value;
78 j++;
79 }
80 }
81 return [outBuffer, outOffset];
82 }
OLDNEW
« no previous file with comments | « runtime/bin/common.cc ('k') | runtime/bin/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698