Chromium Code Reviews| Index: runtime/vm/dart_api_impl.cc |
| =================================================================== |
| --- runtime/vm/dart_api_impl.cc (revision 3698) |
| +++ runtime/vm/dart_api_impl.cc (working copy) |
| @@ -1359,6 +1359,12 @@ |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(list)); |
| + if (obj.IsByteArray()) { |
| + ByteArray& byte_array = ByteArray::Handle(); |
| + byte_array ^= obj.raw(); |
| + *len = byte_array.Length(); |
| + return Api::Success(); |
| + } |
| if (obj.IsArray()) { |
| Array& array_obj = Array::Handle(); |
| array_obj ^= obj.raw(); |
| @@ -1564,6 +1570,15 @@ |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(list)); |
| + if (obj.IsByteArray()) { |
| + ByteArray& byte_array = ByteArray::Handle(); |
| + byte_array ^= obj.raw(); |
| + if ((offset + length) <= byte_array.Length()) { |
|
cshapiro
2012/01/31 03:04:29
This looks like another opportunity for integer ov
Anders Johnsen
2012/01/31 03:34:56
Done.
|
| + ByteArray::Copy(native_array, byte_array, offset, length); |
| + return Api::Success(); |
| + } |
| + return Api::NewError("Invalid length passed in to access list elements"); |
| + } |
| if (obj.IsArray()) { |
| Array& array_obj = Array::Handle(); |
| array_obj ^= obj.raw(); |
| @@ -1627,6 +1642,15 @@ |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| const Object& obj = Object::Handle(Api::UnwrapHandle(list)); |
| + if (obj.IsByteArray()) { |
| + ByteArray& byte_array = ByteArray::Handle(); |
| + byte_array ^= obj.raw(); |
| + if ((offset + length) <= byte_array.Length()) { |
|
cshapiro
2012/01/31 03:04:29
Ditto.
Anders Johnsen
2012/01/31 03:34:56
Done.
|
| + ByteArray::Copy(byte_array, offset, native_array, length); |
| + return Api::Success(); |
| + } |
| + return Api::NewError("Invalid length passed in to set list elements"); |
| + } |
| if (obj.IsArray()) { |
| if (obj.IsImmutableArray()) { |
| return Api::NewError("Cannot modify immutable array"); |