| OLD | NEW |
| 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 #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 "platform/thread.h" | 10 #include "platform/thread.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 void set_raw(const Object& object) { raw_ = object.raw(); } | 128 void set_raw(const Object& object) { raw_ = object.raw(); } |
| 129 static intptr_t raw_offset() { return OFFSET_OF(WeakPersistentHandle, raw_); } | 129 static intptr_t raw_offset() { return OFFSET_OF(WeakPersistentHandle, raw_); } |
| 130 void* peer() const { return peer_; } | 130 void* peer() const { return peer_; } |
| 131 void set_peer(void* peer) { peer_ = peer; } | 131 void set_peer(void* peer) { peer_ = peer; } |
| 132 Dart_WeakPersistentHandleFinalizer callback() const { return callback_; } | 132 Dart_WeakPersistentHandleFinalizer callback() const { return callback_; } |
| 133 void set_callback(Dart_WeakPersistentHandleFinalizer callback) { | 133 void set_callback(Dart_WeakPersistentHandleFinalizer callback) { |
| 134 callback_ = callback; | 134 callback_ = callback; |
| 135 } | 135 } |
| 136 | 136 |
| 137 static void Finalize(WeakPersistentHandle* handle) { | 137 static void Finalize(WeakPersistentHandle* handle) { |
| 138 if (handle->callback() != NULL) { | 138 Dart_WeakPersistentHandleFinalizer callback = handle->callback(); |
| 139 Dart_WeakPersistentHandleFinalizer callback = handle->callback(); | 139 if (callback != NULL) { |
| 140 void* peer = handle->peer(); | 140 void* peer = handle->peer(); |
| 141 handle->Clear(); | 141 handle->Clear(); |
| 142 (*callback)(reinterpret_cast<Dart_Handle>(handle), peer); | 142 (*callback)(reinterpret_cast<Dart_Handle>(handle), peer); |
| 143 } else { | 143 } else { |
| 144 handle->Clear(); | 144 handle->Clear(); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 private: | 148 private: |
| 149 friend class WeakPersistentHandles; | 149 friend class WeakPersistentHandles; |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 ApiNativeScope::Current()->zone()->GetBaseZone()) {} | 558 ApiNativeScope::Current()->zone()->GetBaseZone()) {} |
| 559 ApiGrowableArray() | 559 ApiGrowableArray() |
| 560 : BaseGrowableArray<T, ValueObject>( | 560 : BaseGrowableArray<T, ValueObject>( |
| 561 ApiNativeScope::Current()->zone()->GetBaseZone()) {} | 561 ApiNativeScope::Current()->zone()->GetBaseZone()) {} |
| 562 }; | 562 }; |
| 563 | 563 |
| 564 | 564 |
| 565 } // namespace dart | 565 } // namespace dart |
| 566 | 566 |
| 567 #endif // VM_DART_API_STATE_H_ | 567 #endif // VM_DART_API_STATE_H_ |
| OLD | NEW |