| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |