Index: lib/io/common.dart |
diff --git a/runtime/bin/common.dart b/lib/io/common.dart |
similarity index 87% |
rename from runtime/bin/common.dart |
rename to lib/io/common.dart |
index 33ce2a5dd9ef2e933205cefb6f3f973506935555..9dba5522b030c0f1548f546fdfd06614dc554db5 100644 |
--- a/runtime/bin/common.dart |
+++ b/lib/io/common.dart |
@@ -55,12 +55,6 @@ class OSError { |
} |
-// 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. |
-bool _isBuiltinList(List buffer) native "Common_IsBuiltinList"; |
- |
- |
// Object for holding a buffer and an offset. |
class _BufferAndOffset { |
_BufferAndOffset(List this.buffer, int this.offset); |
@@ -68,14 +62,13 @@ class _BufferAndOffset { |
int offset; |
} |
- |
// 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. |
_BufferAndOffset _ensureFastAndSerializableBuffer( |
List buffer, int offset, int bytes) { |
- if (buffer is Uint8List || _isBuiltinList(buffer)) { |
+ if (buffer is Uint8List || _BufferUtils._isBuiltinList(buffer)) { |
return new _BufferAndOffset(buffer, offset); |
} |
var newBuffer = new Uint8List(bytes); |
@@ -83,10 +76,18 @@ _BufferAndOffset _ensureFastAndSerializableBuffer( |
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"); |
+ throw new ArgumentError("List element is not an integer at index $j"); |
} |
newBuffer[i] = value; |
j++; |
} |
return new _BufferAndOffset(newBuffer, 0); |
} |
+ |
+ |
+class _BufferUtils { |
+ // 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. |
+ external static bool _isBuiltinList(List buffer); |
Søren Gjesse
2012/10/30 09:28:32
So externals cannot be top level functions?
Mads Ager (google)
2012/10/30 11:12:40
At this point at least they cannot, no. I'll add a
|
+} |