Chromium Code Reviews| Index: runtime/vm/dart_api_impl.cc |
| =================================================================== |
| --- runtime/vm/dart_api_impl.cc (revision 3621) |
| +++ 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()) { |
|
cshapiro
2012/01/27 23:00:04
Two questions. Why is this ahead of array and why
Anders Johnsen
2012/01/27 23:42:39
Adding the native operations for getting/setting d
|
| + 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()) { |
| + ByteArray::Copy(native_array, byte_array, offset, length); |
| + return Api::Success(); |
| + } |
| + return Api::NewError("Invalid length passed in to access array elements"); |
|
cshapiro
2012/01/27 23:00:04
list elements, right? I think the list interface
Anders Johnsen
2012/01/27 23:42:39
Done.
|
| + } |
| 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()) { |
| + ByteArray::Copy(byte_array, offset, native_array, length); |
| + return Api::Success(); |
| + } |
| + return Api::NewError("Invalid length passed in to access array elements"); |
| + } |
| if (obj.IsArray()) { |
| if (obj.IsImmutableArray()) { |
| return Api::NewError("Cannot modify immutable array"); |