Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(927)

Unified Diff: runtime/lib/mirrors.cc

Issue 15772005: - Add different types for persistent and weak persistent handles (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/lib/typed_data.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/mirrors.cc
===================================================================
--- runtime/lib/mirrors.cc (revision 23307)
+++ runtime/lib/mirrors.cc (working copy)
@@ -88,10 +88,11 @@
}
-static void FreeVMReference(Dart_Handle weak_ref, void* data) {
- Dart_Handle perm_handle = reinterpret_cast<Dart_Handle>(data);
+static void FreeVMReference(Dart_WeakPersistentHandle weak_ref, void* data) {
+ Dart_PersistentHandle perm_handle =
+ reinterpret_cast<Dart_PersistentHandle>(data);
Dart_DeletePersistentHandle(perm_handle);
- Dart_DeletePersistentHandle(weak_ref);
+ Dart_DeleteWeakPersistentHandle(weak_ref);
}
@@ -108,10 +109,8 @@
}
// Allocate a persistent handle.
- Dart_Handle perm_handle = Dart_NewPersistentHandle(handle);
- if (Dart_IsError(perm_handle)) {
- return perm_handle;
- }
+ Dart_PersistentHandle perm_handle = Dart_NewPersistentHandle(handle);
+ ASSERT(perm_handle != NULL);
// Store the persistent handle in the VMReference.
intptr_t perm_handle_value = reinterpret_cast<intptr_t>(perm_handle);
@@ -126,12 +125,9 @@
// the VMReference is collected, so we can release the persistent
// handle.
void* perm_handle_data = reinterpret_cast<void*>(perm_handle);
- Dart_Handle weak_ref =
+ Dart_WeakPersistentHandle weak_ref =
Dart_NewWeakPersistentHandle(vm_ref, perm_handle_data, FreeVMReference);
- if (Dart_IsError(weak_ref)) {
- Dart_DeletePersistentHandle(perm_handle);
- return weak_ref;
- }
+ ASSERT(weak_ref != NULL);
// Success.
return vm_ref;
@@ -146,9 +142,13 @@
if (Dart_IsError(result)) {
return result;
}
- Dart_Handle perm_handle = reinterpret_cast<Dart_Handle>(perm_handle_value);
- ASSERT(!Dart_IsError(perm_handle));
- return perm_handle;
+ Dart_PersistentHandle perm_handle =
+ reinterpret_cast<Dart_PersistentHandle>(perm_handle_value);
+ ASSERT(perm_handle != NULL);
+ Dart_Handle handle = Dart_HandleFromPersistent(perm_handle);
+ ASSERT(handle != NULL);
+ ASSERT(!Dart_IsError(handle));
+ return handle;
}
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/lib/typed_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698