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 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 DARTSCOPE(isolate); | 2233 DARTSCOPE(isolate); |
2234 if (data == NULL && length != 0) { | 2234 if (data == NULL && length != 0) { |
2235 RETURN_NULL_ERROR(data); | 2235 RETURN_NULL_ERROR(data); |
2236 } | 2236 } |
2237 CHECK_LENGTH(length, ExternalUint8Array::kMaxElements); | 2237 CHECK_LENGTH(length, ExternalUint8Array::kMaxElements); |
2238 return Api::NewHandle( | 2238 return Api::NewHandle( |
2239 isolate, ExternalUint8Array::New(data, length, peer, callback)); | 2239 isolate, ExternalUint8Array::New(data, length, peer, callback)); |
2240 } | 2240 } |
2241 | 2241 |
2242 | 2242 |
| 2243 DART_EXPORT Dart_Handle Dart_NewExternalClampedByteArray( |
| 2244 uint8_t* data, |
| 2245 intptr_t length, |
| 2246 void* peer, |
| 2247 Dart_PeerFinalizer callback) { |
| 2248 Isolate* isolate = Isolate::Current(); |
| 2249 DARTSCOPE(isolate); |
| 2250 if (data == NULL && length != 0) { |
| 2251 RETURN_NULL_ERROR(data); |
| 2252 } |
| 2253 CHECK_LENGTH(length, ExternalUint8ClampedArray::kMaxElements); |
| 2254 return Api::NewHandle( |
| 2255 isolate, ExternalUint8ClampedArray::New(data, length, peer, callback)); |
| 2256 } |
| 2257 |
| 2258 |
2243 DART_EXPORT Dart_Handle Dart_ExternalByteArrayGetData(Dart_Handle object, | 2259 DART_EXPORT Dart_Handle Dart_ExternalByteArrayGetData(Dart_Handle object, |
2244 void** data) { | 2260 void** data) { |
2245 Isolate* isolate = Isolate::Current(); | 2261 Isolate* isolate = Isolate::Current(); |
2246 DARTSCOPE(isolate); | 2262 DARTSCOPE(isolate); |
2247 const ExternalUint8Array& array = | 2263 const ExternalUint8Array& array = |
2248 Api::UnwrapExternalUint8ArrayHandle(isolate, object); | 2264 Api::UnwrapExternalUint8ArrayHandle(isolate, object); |
2249 if (array.IsNull()) { | 2265 if (array.IsNull()) { |
2250 RETURN_TYPE_ERROR(isolate, object, ExternalUint8Array); | 2266 RETURN_TYPE_ERROR(isolate, object, ExternalUint8Array); |
2251 } | 2267 } |
2252 if (data == NULL) { | 2268 if (data == NULL) { |
(...skipping 2250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4503 } | 4519 } |
4504 { | 4520 { |
4505 NoGCScope no_gc; | 4521 NoGCScope no_gc; |
4506 RawObject* raw_obj = obj.raw(); | 4522 RawObject* raw_obj = obj.raw(); |
4507 isolate->heap()->SetPeer(raw_obj, peer); | 4523 isolate->heap()->SetPeer(raw_obj, peer); |
4508 } | 4524 } |
4509 return Api::Success(isolate); | 4525 return Api::Success(isolate); |
4510 } | 4526 } |
4511 | 4527 |
4512 } // namespace dart | 4528 } // namespace dart |
OLD | NEW |