Chromium Code Reviews| Index: runtime/vm/dart_api_impl.cc |
| diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc |
| index b282bf2fd913c338eba9f83747b290160c139391..cad829527cc3a42e53fa99c3521c9d501069f4f9 100644 |
| --- a/runtime/vm/dart_api_impl.cc |
| +++ b/runtime/vm/dart_api_impl.cc |
| @@ -412,13 +412,13 @@ DART_EXPORT Dart_Handle Dart_NewWeakPersistentHandle( |
| DARTSCOPE_NOCHECKS(isolate); |
| ApiState* state = isolate->api_state(); |
| ASSERT(state != NULL); |
| - const Object& old_ref = Object::Handle(Api::UnwrapHandle(object)); |
| - WeakPersistentHandle* new_ref = |
| + const Object& ref = Object::Handle(Api::UnwrapHandle(object)); |
| + WeakPersistentHandle* weak_ref = |
| state->weak_persistent_handles().AllocateHandle(); |
| - new_ref->set_raw(old_ref); |
| - new_ref->set_peer(peer); |
| - new_ref->set_callback(callback); |
| - return reinterpret_cast<Dart_Handle>(new_ref); |
| + weak_ref->set_raw(ref); |
| + weak_ref->set_peer(peer); |
| + weak_ref->set_callback(callback); |
| + return reinterpret_cast<Dart_Handle>(weak_ref); |
| } |
| @@ -1649,6 +1649,37 @@ DART_EXPORT Dart_Handle Dart_NewByteArray(intptr_t length) { |
| } |
| +DART_EXPORT Dart_Handle Dart_NewExternalByteArray(uint8_t* data, |
| + intptr_t length, |
| + void* peer, |
| + Dart_PeerFinalizer callback) { |
| + DARTSCOPE(Isolate::Current()); |
|
siva
2012/02/11 03:00:58
Should we complain with error messages here for
-
cshapiro
2012/02/11 04:11:50
Sure, done. I think it is okay for data to be NUL
|
| + const ExternalByteArray& obj = |
| + ExternalByteArray::Handle(ExternalByteArray::New(data, |
| + length, |
| + peer, |
| + callback)); |
| + return Api::NewLocalHandle(obj); |
| +} |
| + |
| + |
| +DART_EXPORT Dart_Handle Dart_ExternalByteArrayGetPeer(Dart_Handle object, |
| + void** peer) { |
| + DARTSCOPE(Isolate::Current()); |
| + const ExternalByteArray& array = |
| + Api::UnwrapExternalByteArrayHandle(object); |
| + if (array.IsNull()) { |
| + RETURN_TYPE_ERROR(object, ExternalByteArray); |
| + } |
| + if (peer == NULL) { |
| + return Api::NewError("%s expects argument 'peer' to be non-null.", |
| + CURRENT_FUNC); |
| + } |
| + *peer = array.GetPeer(); |
| + return Api::Success(); |
| +} |
| + |
| + |
| // --- Closures --- |