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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 452
453 DART_EXPORT bool Dart_IsWeakPersistentHandle(Dart_Handle object) { 453 DART_EXPORT bool Dart_IsWeakPersistentHandle(Dart_Handle object) {
454 Isolate* isolate = Isolate::Current(); 454 Isolate* isolate = Isolate::Current();
455 CHECK_ISOLATE(isolate); 455 CHECK_ISOLATE(isolate);
456 ApiState* state = isolate->api_state(); 456 ApiState* state = isolate->api_state();
457 ASSERT(state != NULL); 457 ASSERT(state != NULL);
458 return state->IsValidWeakPersistentHandle(object); 458 return state->IsValidWeakPersistentHandle(object);
459 } 459 }
460 460
461 461
462 DART_EXPORT Dart_Handle Dart_NewWeakReferenceSet(Dart_Handle* keys,
463 intptr_t num_keys,
464 Dart_Handle* values,
465 intptr_t num_values) {
466 Isolate* isolate = Isolate::Current();
467 CHECK_ISOLATE(isolate);
468 ApiState* state = isolate->api_state();
469 ASSERT(state != NULL);
470 if (keys == NULL) {
471 return Api::NewError("%s expects argument 'keys' to be non-null.",
472 CURRENT_FUNC);
473 }
474 if (num_keys <= 0) {
475 return Api::NewError(
476 "%s expects argument 'num_keys' to be greater than 0.",
477 CURRENT_FUNC);
478 }
479 if (values == NULL) {
480 return Api::NewError("%s expects argument 'values' to be non-null.",
481 CURRENT_FUNC);
482 }
483 if (num_values <= 0) {
484 return Api::NewError(
485 "%s expects argument 'num_values' to be greater than 0.",
486 CURRENT_FUNC);
487 }
488
489 WeakReference* reference = new WeakReference(keys, num_keys,
490 values, num_values);
491 state->DelayWeakReference(reference);
492 return Api::Success();
493 }
494
462 // --- Initialization and Globals --- 495 // --- Initialization and Globals ---
463 496
464 497
465 DART_EXPORT bool Dart_Initialize(Dart_IsolateCreateCallback create, 498 DART_EXPORT bool Dart_Initialize(Dart_IsolateCreateCallback create,
466 Dart_IsolateInterruptCallback interrupt) { 499 Dart_IsolateInterruptCallback interrupt) {
467 return Dart::InitOnce(create, interrupt); 500 return Dart::InitOnce(create, interrupt);
468 } 501 }
469 502
470 DART_EXPORT bool Dart_SetVMFlags(int argc, const char** argv) { 503 DART_EXPORT bool Dart_SetVMFlags(int argc, const char** argv) {
471 return Flags::ProcessCommandLineFlags(argc, argv); 504 return Flags::ProcessCommandLineFlags(argc, argv);
(...skipping 2240 matching lines...) Expand 10 before | Expand all | Expand 10 after
2712 *buffer = NULL; 2745 *buffer = NULL;
2713 } 2746 }
2714 delete debug_region; 2747 delete debug_region;
2715 } else { 2748 } else {
2716 *buffer = NULL; 2749 *buffer = NULL;
2717 *buffer_size = 0; 2750 *buffer_size = 0;
2718 } 2751 }
2719 } 2752 }
2720 2753
2721 } // namespace dart 2754 } // namespace dart
OLDNEW
« 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