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

Unified Diff: runtime/lib/byte_array.cc

Issue 9235067: Use ByteArray's native for Socket and File. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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/lib/byte_array.cc
===================================================================
--- runtime/lib/byte_array.cc (revision 3706)
+++ runtime/lib/byte_array.cc (working copy)
@@ -32,7 +32,7 @@
static void RangeCheck(const ByteArray& array, const Smi& index,
Ivan Posva 2012/02/01 01:05:27 Why not just use intptr_t as parameters here?
Anders Johnsen 2012/02/01 02:12:11 We use the Smi object to cast the error (line 37).
Ivan Posva 2012/02/01 20:01:34 Create a new Integer handle when you really need t
Anders Johnsen 2012/02/01 20:20:41 Done.
intptr_t num_bytes) {
- if ((index.Value() < 0) || ((index.Value() + num_bytes) > array.Length())) {
+ if (!Utils::RangeCheck(index.Value(), num_bytes, array.Length())) {
GrowableArray<const Object*> arguments;
arguments.Add(&index);
Exceptions::ThrowByType(Exceptions::kIndexOutOfRange, arguments);
@@ -40,6 +40,23 @@
}
+DEFINE_NATIVE_ENTRY(ByteArray_setRange, 5) {
+ ByteArray& dst = ByteArray::CheckedHandle(arguments->At(0));
+ GET_NATIVE_ARGUMENT(ByteArray, src, arguments->At(1));
+ GET_NATIVE_ARGUMENT(Smi, src_start, arguments->At(2));
+ GET_NATIVE_ARGUMENT(Smi, dst_start, arguments->At(3));
+ GET_NATIVE_ARGUMENT(Smi, count, arguments->At(4));
Ivan Posva 2012/02/01 01:05:27 intptr_t count_value = count.Value(); and friends.
Anders Johnsen 2012/02/01 02:12:11 Emm okay, I'm getting some conflicting comments on
+ if (count.Value() < 0) {
+ GrowableArray<const Object*> args;
+ Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
+ }
+ RangeCheck(src, src_start, count.Value());
+ RangeCheck(dst, dst_start, count.Value());
+ ByteArray::Copy(
+ dst, dst_start.Value(), src, src_start.Value(), count.Value());
+}
+
+
#define GETTER(ArrayT, ObjectT, ValueT) \
GET_NATIVE_ARGUMENT(ArrayT, array, arguments->At(0)); \
GET_NATIVE_ARGUMENT(Smi, index, arguments->At(1)); \

Powered by Google App Engine
This is Rietveld 408576698