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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 9531001: Implement weak references sets and provide an embedding API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: minor changes to prepare for review Created 8 years, 10 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
Index: runtime/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 8d48d15f04c0572a080f3a83ce534b65dc27eda1..1b179e8ae715cf183f2992895d556efaf3930cfd 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -459,6 +459,39 @@ DART_EXPORT bool Dart_IsWeakPersistentHandle(Dart_Handle object) {
}
+DART_EXPORT Dart_Handle Dart_NewWeakReferenceSet(Dart_Handle* keys,
+ intptr_t num_keys,
+ Dart_Handle* values,
+ intptr_t num_values) {
+ Isolate* isolate = Isolate::Current();
+ CHECK_ISOLATE(isolate);
+ ApiState* state = isolate->api_state();
+ ASSERT(state != NULL);
+ if (keys == NULL) {
+ return Api::NewError("%s expects argument 'keys' to be non-null.",
+ CURRENT_FUNC);
+ }
+ if (num_keys <= 0) {
+ return Api::NewError(
+ "%s expects argument 'num_keys' to be greater than 0.",
+ CURRENT_FUNC);
+ }
+ if (values == NULL) {
+ return Api::NewError("%s expects argument 'values' to be non-null.",
+ CURRENT_FUNC);
+ }
+ if (num_values <= 0) {
+ return Api::NewError(
+ "%s expects argument 'num_values' to be greater than 0.",
+ CURRENT_FUNC);
+ }
+
+ WeakReference* reference = new WeakReference(keys, num_keys,
+ values, num_values);
+ state->DelayWeakReference(reference);
+ return Api::Success();
+}
+
// --- Initialization and Globals ---

Powered by Google App Engine
This is Rietveld 408576698