| Index: runtime/vm/dart_api_impl.cc
|
| ===================================================================
|
| --- runtime/vm/dart_api_impl.cc (revision 36670)
|
| +++ runtime/vm/dart_api_impl.cc (working copy)
|
| @@ -2686,12 +2686,11 @@
|
| } \
|
| return Api::NewError("Invalid length passed in to access array elements"); \
|
|
|
| -
|
| -static Dart_Handle CopyBytes(const TypedData& array,
|
| +template<typename T>
|
| +static Dart_Handle CopyBytes(const T& array,
|
| intptr_t offset,
|
| uint8_t* native_array,
|
| intptr_t length) {
|
| - ASSERT(array.IsTypedData());
|
| ASSERT(array.ElementSizeInBytes() == 1);
|
| NoGCScope no_gc;
|
| memmove(native_array,
|
| @@ -2718,6 +2717,16 @@
|
| return CopyBytes(array, offset, native_array, length);
|
| }
|
| }
|
| + if (obj.IsExternalTypedData()) {
|
| + const ExternalTypedData& external_array = ExternalTypedData::Cast(obj);
|
| + if (external_array.ElementSizeInBytes() == 1) {
|
| + if (!Utils::RangeCheck(offset, length, external_array.Length())) {
|
| + return Api::NewError(
|
| + "Invalid length passed in to access list elements");
|
| + }
|
| + return CopyBytes(external_array, offset, native_array, length);
|
| + }
|
| + }
|
| if (RawObject::IsTypedDataViewClassId(obj.GetClassId())) {
|
| const Instance& view = Instance::Cast(obj);
|
| if (TypedDataView::ElementSizeInBytes(view) == 1) {
|
|
|