| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #ifndef VM_DART_API_STATE_H_ | 5 #ifndef VM_DART_API_STATE_H_ |
| 6 #define VM_DART_API_STATE_H_ | 6 #define VM_DART_API_STATE_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 | 9 |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 RawObject* raw() const { return raw_; } | 120 RawObject* raw() const { return raw_; } |
| 121 void set_raw(RawObject* raw) { raw_ = raw; } | 121 void set_raw(RawObject* raw) { raw_ = raw; } |
| 122 void set_raw(const LocalHandle& ref) { raw_ = ref.raw(); } | 122 void set_raw(const LocalHandle& ref) { raw_ = ref.raw(); } |
| 123 void set_raw(const Object& object) { raw_ = object.raw(); } | 123 void set_raw(const Object& object) { raw_ = object.raw(); } |
| 124 static intptr_t raw_offset() { return OFFSET_OF(WeakPersistentHandle, raw_); } | 124 static intptr_t raw_offset() { return OFFSET_OF(WeakPersistentHandle, raw_); } |
| 125 void* peer() const { return peer_; } | 125 void* peer() const { return peer_; } |
| 126 void set_peer(void* peer) { peer_ = peer; } | 126 void set_peer(void* peer) { peer_ = peer; } |
| 127 Dart_PeerFinalizer callback() const { return callback_; } | 127 Dart_PeerFinalizer callback() const { return callback_; } |
| 128 void set_callback(Dart_PeerFinalizer callback) { callback_ = callback; } | 128 void set_callback(Dart_PeerFinalizer callback) { callback_ = callback; } |
| 129 | 129 |
| 130 void Finalize() { | 130 static void Finalize(WeakPersistentHandle* handle) { |
| 131 if (callback_ != NULL) { | 131 if (handle->callback() != NULL) { |
| 132 (*callback_)(peer_); | 132 Dart_PeerFinalizer callback = handle->callback(); |
| 133 void* peer = handle->peer(); |
| 134 handle->Clear(); |
| 135 (*callback)(reinterpret_cast<Dart_Handle>(handle), peer); |
| 136 } else { |
| 137 handle->Clear(); |
| 133 } | 138 } |
| 134 Clear(); | |
| 135 } | 139 } |
| 136 | 140 |
| 137 private: | 141 private: |
| 138 friend class WeakPersistentHandles; | 142 friend class WeakPersistentHandles; |
| 139 | 143 |
| 140 WeakPersistentHandle() : raw_(NULL), peer_(NULL), callback_(NULL) { } | 144 WeakPersistentHandle() : raw_(NULL), peer_(NULL), callback_(NULL) { } |
| 141 ~WeakPersistentHandle() { } | 145 ~WeakPersistentHandle() { } |
| 142 | 146 |
| 143 // Overload the callback_ field as a next pointer when adding freed | 147 // Overload the callback_ field as a next pointer when adding freed |
| 144 // handles to the free list. | 148 // handles to the free list. |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 PersistentHandle* null_; | 507 PersistentHandle* null_; |
| 504 PersistentHandle* true_; | 508 PersistentHandle* true_; |
| 505 PersistentHandle* false_; | 509 PersistentHandle* false_; |
| 506 | 510 |
| 507 DISALLOW_COPY_AND_ASSIGN(ApiState); | 511 DISALLOW_COPY_AND_ASSIGN(ApiState); |
| 508 }; | 512 }; |
| 509 | 513 |
| 510 } // namespace dart | 514 } // namespace dart |
| 511 | 515 |
| 512 #endif // VM_DART_API_STATE_H_ | 516 #endif // VM_DART_API_STATE_H_ |
| OLD | NEW |