OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "include/dart_api.h" | 5 #include "include/dart_api.h" |
6 | 6 |
7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
(...skipping 1932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1943 return Api::NewError("Invalid length passed in to access array elements"); \ | 1943 return Api::NewError("Invalid length passed in to access array elements"); \ |
1944 | 1944 |
1945 | 1945 |
1946 DART_EXPORT Dart_Handle Dart_ListGetAsBytes(Dart_Handle list, | 1946 DART_EXPORT Dart_Handle Dart_ListGetAsBytes(Dart_Handle list, |
1947 intptr_t offset, | 1947 intptr_t offset, |
1948 uint8_t* native_array, | 1948 uint8_t* native_array, |
1949 intptr_t length) { | 1949 intptr_t length) { |
1950 Isolate* isolate = Isolate::Current(); | 1950 Isolate* isolate = Isolate::Current(); |
1951 DARTSCOPE(isolate); | 1951 DARTSCOPE(isolate); |
1952 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(list)); | 1952 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(list)); |
1953 if (obj.IsUint8Array() || obj.IsExternalUint8Array()) { | 1953 if (obj.IsUint8Array() || obj.IsExternalUint8Array() || |
| 1954 obj.IsInt8Array() || obj.IsExternalInt8Array()) { |
1954 const ByteArray& byte_array = ByteArray::Cast(obj); | 1955 const ByteArray& byte_array = ByteArray::Cast(obj); |
1955 if (Utils::RangeCheck(offset, length, byte_array.Length())) { | 1956 if (Utils::RangeCheck(offset, length, byte_array.Length())) { |
1956 ByteArray::Copy(native_array, byte_array, offset, length); | 1957 ByteArray::Copy(native_array, byte_array, offset, length); |
1957 return Api::Success(isolate); | 1958 return Api::Success(isolate); |
1958 } | 1959 } |
1959 return Api::NewError("Invalid length passed in to access list elements"); | 1960 return Api::NewError("Invalid length passed in to access list elements"); |
1960 } else if (obj.IsArray()) { | 1961 } else if (obj.IsArray()) { |
1961 GET_LIST_ELEMENT_AS_BYTES(isolate, | 1962 GET_LIST_ELEMENT_AS_BYTES(isolate, |
1962 Array, | 1963 Array, |
1963 obj, | 1964 obj, |
(...skipping 2480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4444 } | 4445 } |
4445 { | 4446 { |
4446 NoGCScope no_gc; | 4447 NoGCScope no_gc; |
4447 RawObject* raw_obj = obj.raw(); | 4448 RawObject* raw_obj = obj.raw(); |
4448 isolate->heap()->SetPeer(raw_obj, peer); | 4449 isolate->heap()->SetPeer(raw_obj, peer); |
4449 } | 4450 } |
4450 return Api::Success(isolate); | 4451 return Api::Success(isolate); |
4451 } | 4452 } |
4452 | 4453 |
4453 } // namespace dart | 4454 } // namespace dart |
OLD | NEW |