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

Unified Diff: runtime/bin/common.dart

Issue 10990055: Hide VM-only coreimpl List implementation types. These should not be (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: x64 as well, sigh. 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 side-by-side diff with in-line comments
Download patch
Index: runtime/bin/common.dart
diff --git a/runtime/bin/common.dart b/runtime/bin/common.dart
index 614171c440ca40d1d0f69543879b6ba15b57ef28..fafd02ac7176a737be8968235e65c15a770bbc8b 100644
--- a/runtime/bin/common.dart
+++ b/runtime/bin/common.dart
@@ -7,10 +7,13 @@
* operating system.
*/
class OSError {
+ /** Constant used to indicate that no OS error code is available. */
static const int noErrorCode = -1;
+ /** Creates an OSError object from a message and an errorCode. */
const OSError([String this.message = "", int this.errorCode = noErrorCode]);
+ /** Converts an OSError object to a string representation. */
String toString() {
StringBuffer sb = new StringBuffer();
sb.add("OS Error");
@@ -40,3 +43,40 @@ class OSError {
*/
final int errorCode;
}
+
+
+// Check if a List is a builtin VM List type. Returns true
+// if the List is a builtin VM List type and false if it is
+// a user defined List type.
+//
+// TODO(5474): At this point it actually return false for
+// _GrowableObjectArrays because of serialization issues.
+bool _isBuiltinList(List buffer) native "Common_IsBuiltinList";
+
+
+// Ensure that the input List can be serialized through a native port.
+// Only builtin Lists can be serialized through. If user-defined Lists
+// get here, the contents is copied to a Uint8List. This has the added
+// benefit that it is faster to access from the C code as well.
+List _ensureFastAndSerializableBuffer(
+ List buffer, int offset, int bytes) {
+ List outBuffer;
+ int outOffset = offset;
+ if (buffer is Uint8List || _isBuiltinList(buffer)) {
+ outBuffer = buffer;
+ } else {
+ outBuffer = new Uint8List(bytes);
+ outOffset = 0;
+ int j = offset;
+ for (int i = 0; i < bytes; i++) {
+ int value = buffer[j];
+ if (value is! int) {
+ throw new FileIOException(
+ "List element is not an integer at index $j");
+ }
+ outBuffer[i] = value;
+ j++;
+ }
+ }
+ return [outBuffer, outOffset];
+}
« runtime/bin/common.cc ('K') | « 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