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

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 116473004: Add Dart API method Dart_SetPersistentHandle to enable setting the value of (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 Isolate* isolate = Isolate::Current(); 571 Isolate* isolate = Isolate::Current();
572 DARTSCOPE(isolate); 572 DARTSCOPE(isolate);
573 ApiState* state = isolate->api_state(); 573 ApiState* state = isolate->api_state();
574 ASSERT(state != NULL); 574 ASSERT(state != NULL);
575 const Object& old_ref = Object::Handle(isolate, Api::UnwrapHandle(object)); 575 const Object& old_ref = Object::Handle(isolate, Api::UnwrapHandle(object));
576 PersistentHandle* new_ref = state->persistent_handles().AllocateHandle(); 576 PersistentHandle* new_ref = state->persistent_handles().AllocateHandle();
577 new_ref->set_raw(old_ref); 577 new_ref->set_raw(old_ref);
578 return reinterpret_cast<Dart_PersistentHandle>(new_ref); 578 return reinterpret_cast<Dart_PersistentHandle>(new_ref);
579 } 579 }
580 580
581
582 DART_EXPORT void Dart_SetPersistentHandle(Dart_PersistentHandle obj1,
583 Dart_Handle obj2) {
584 Isolate* isolate = Isolate::Current();
585 DARTSCOPE(isolate);
586 ApiState* state = isolate->api_state();
587 ASSERT(state != NULL);
588 ASSERT(state->IsValidPersistentHandle(obj1));
589 const Object& obj2_ref = Object::Handle(isolate, Api::UnwrapHandle(obj2));
590 PersistentHandle* obj1_ref = Api::UnwrapAsPersistentHandle(obj1);
591 obj1_ref->set_raw(obj2_ref);
592 }
593
594
581 static Dart_WeakPersistentHandle AllocateFinalizableHandle( 595 static Dart_WeakPersistentHandle AllocateFinalizableHandle(
582 Isolate* isolate, 596 Isolate* isolate,
583 FinalizablePersistentHandles* handles, 597 FinalizablePersistentHandles* handles,
584 Dart_Handle object, 598 Dart_Handle object,
585 void* peer, 599 void* peer,
586 Dart_WeakPersistentHandleFinalizer callback) { 600 Dart_WeakPersistentHandleFinalizer callback) {
587 const Object& ref = Object::Handle(isolate, Api::UnwrapHandle(object)); 601 const Object& ref = Object::Handle(isolate, Api::UnwrapHandle(object));
588 FinalizablePersistentHandle* finalizable_ref = handles->AllocateHandle(); 602 FinalizablePersistentHandle* finalizable_ref = handles->AllocateHandle();
589 finalizable_ref->set_raw(ref); 603 finalizable_ref->set_raw(ref);
590 finalizable_ref->set_peer(peer); 604 finalizable_ref->set_peer(peer);
(...skipping 3884 matching lines...) Expand 10 before | Expand all | Expand 10 after
4475 } 4489 }
4476 { 4490 {
4477 NoGCScope no_gc; 4491 NoGCScope no_gc;
4478 RawObject* raw_obj = obj.raw(); 4492 RawObject* raw_obj = obj.raw();
4479 isolate->heap()->SetPeer(raw_obj, peer); 4493 isolate->heap()->SetPeer(raw_obj, peer);
4480 } 4494 }
4481 return Api::Success(); 4495 return Api::Success();
4482 } 4496 }
4483 4497
4484 } // namespace dart 4498 } // 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