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

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: address review comments 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
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index dd5f1434e10ea2f7cc3612f28483fecb33ecbad0..e1ba5575550b2815af5f5c499050364032e08516 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 ---
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698