| Index: runtime/vm/dart_api_impl.cc
|
| diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
|
| index 70cf4a6b864c3af7a42c6360623388a170fed091..e262cb1f138718e6bc48555ddd9462e5d58fc877 100644
|
| --- a/runtime/vm/dart_api_impl.cc
|
| +++ b/runtime/vm/dart_api_impl.cc
|
| @@ -1721,6 +1721,178 @@ DART_EXPORT Dart_Handle Dart_ExternalByteArrayGetPeer(Dart_Handle object,
|
| }
|
|
|
|
|
| +template<typename T>
|
| +Dart_Handle ByteArrayGetAt(T* value, Dart_Handle array, intptr_t offset) {
|
| + const ByteArray& array_obj = Api::UnwrapByteArrayHandle(array);
|
| + if (array_obj.IsNull()) {
|
| + RETURN_TYPE_ERROR(array, ByteArray);
|
| + }
|
| + intptr_t length = sizeof(T);
|
| + if (!Utils::RangeCheck(offset, length, array_obj.Length())) {
|
| + return Api::NewError("Invalid index passed in to get byte array element");
|
| + }
|
| + uint8_t* dst = reinterpret_cast<uint8_t*>(value);
|
| + ByteArray::Copy(dst, array_obj, offset, length);
|
| + return Api::Success();
|
| +}
|
| +
|
| +
|
| +template<typename T>
|
| +Dart_Handle ByteArraySetAt(Dart_Handle array, intptr_t offset, T value) {
|
| + const ByteArray& array_obj = Api::UnwrapByteArrayHandle(array);
|
| + if (array_obj.IsNull()) {
|
| + RETURN_TYPE_ERROR(array, ByteArray);
|
| + }
|
| + intptr_t length = sizeof(T);
|
| + if (!Utils::RangeCheck(offset, length, array_obj.Length())) {
|
| + return Api::NewError("Invalid index passed in to get byte array element");
|
| + }
|
| + const uint8_t* src = reinterpret_cast<uint8_t*>(&value);
|
| + ByteArray::Copy(array_obj, offset, src, length);
|
| + return Api::Success();
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArrayGetInt8At(Dart_Handle array,
|
| + intptr_t offset,
|
| + int8_t* value) {
|
| + return ByteArrayGetAt(value, array, offset);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArraySetInt8At(Dart_Handle array,
|
| + intptr_t offset,
|
| + int8_t value) {
|
| + return ByteArraySetAt(array, offset, value);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArrayGetUint8At(Dart_Handle array,
|
| + intptr_t offset,
|
| + uint8_t* value) {
|
| + return ByteArrayGetAt(value, array, offset);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArraySetUint8At(Dart_Handle array,
|
| + intptr_t offset,
|
| + uint8_t value) {
|
| + return ByteArraySetAt(array, offset, value);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArrayGetInt16At(Dart_Handle array,
|
| + intptr_t offset,
|
| + int16_t* value) {
|
| + return ByteArrayGetAt(value, array, offset);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArraySetInt16At(Dart_Handle array,
|
| + intptr_t offset,
|
| + int16_t value) {
|
| + return ByteArraySetAt(array, offset, value);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArrayGetUint16At(Dart_Handle array,
|
| + intptr_t offset,
|
| + uint16_t* value) {
|
| + return ByteArrayGetAt(value, array, offset);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArraySetUint16At(Dart_Handle array,
|
| + intptr_t offset,
|
| + uint16_t value) {
|
| + return ByteArraySetAt(array, offset, value);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArrayGetInt32At(Dart_Handle array,
|
| + intptr_t offset,
|
| + int32_t* value) {
|
| + return ByteArrayGetAt(value, array, offset);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArraySetInt32At(Dart_Handle array,
|
| + intptr_t offset,
|
| + int32_t value) {
|
| + return ByteArraySetAt(array, offset, value);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArrayGetUint32At(Dart_Handle array,
|
| + intptr_t offset,
|
| + uint32_t* value) {
|
| + return ByteArrayGetAt(value, array, offset);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArraySetUint32At(Dart_Handle array,
|
| + intptr_t offset,
|
| + uint32_t value) {
|
| + return ByteArraySetAt(array, offset, value);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArrayGetInt64At(Dart_Handle array,
|
| + intptr_t offset,
|
| + int64_t* value) {
|
| + return ByteArrayGetAt(value, array, offset);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArraySetInt64At(Dart_Handle array,
|
| + intptr_t offset,
|
| + int64_t value) {
|
| + return ByteArraySetAt(array, offset, value);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArrayGetUint64At(Dart_Handle array,
|
| + intptr_t offset,
|
| + uint64_t* value) {
|
| + return ByteArrayGetAt(value, array, offset);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArraySetUint64At(Dart_Handle array,
|
| + intptr_t offset,
|
| + uint64_t value) {
|
| + return ByteArraySetAt(array, offset, value);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArrayGetFloat32At(Dart_Handle array,
|
| + intptr_t offset,
|
| + float* value) {
|
| + return ByteArrayGetAt(value, array, offset);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArraySetFloat32At(Dart_Handle array,
|
| + intptr_t offset,
|
| + float value) {
|
| + return ByteArraySetAt(array, offset, value);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArrayGetFloat64At(Dart_Handle array,
|
| + intptr_t offset,
|
| + double* value) {
|
| + return ByteArrayGetAt(value, array, offset);
|
| +}
|
| +
|
| +
|
| +DART_EXPORT Dart_Handle Dart_ByteArraySetFloat64At(Dart_Handle array,
|
| + intptr_t offset,
|
| + double value) {
|
| + return ByteArraySetAt(array, offset, value);
|
| +}
|
| +
|
| +
|
| // --- Closures ---
|
|
|
|
|
|
|