| 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 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 class ApiNativeScope { | 619 class ApiNativeScope { |
| 620 public: | 620 public: |
| 621 ApiNativeScope() { | 621 ApiNativeScope() { |
| 622 // Currently no support for nesting native scopes. | 622 // Currently no support for nesting native scopes. |
| 623 ASSERT(Current() == NULL); | 623 ASSERT(Current() == NULL); |
| 624 Thread::SetThreadLocal(Api::api_native_key_, reinterpret_cast<uword>(this)); | 624 Thread::SetThreadLocal(Api::api_native_key_, reinterpret_cast<uword>(this)); |
| 625 } | 625 } |
| 626 | 626 |
| 627 ~ApiNativeScope() { | 627 ~ApiNativeScope() { |
| 628 ASSERT(Current() == this); | 628 ASSERT(Current() == this); |
| 629 Thread::SetThreadLocal(Api::api_native_key_, NULL); | 629 Thread::SetThreadLocal(Api::api_native_key_, 0); |
| 630 } | 630 } |
| 631 | 631 |
| 632 static inline ApiNativeScope* Current() { | 632 static inline ApiNativeScope* Current() { |
| 633 return reinterpret_cast<ApiNativeScope*>( | 633 return reinterpret_cast<ApiNativeScope*>( |
| 634 Thread::GetThreadLocal(Api::api_native_key_)); | 634 Thread::GetThreadLocal(Api::api_native_key_)); |
| 635 } | 635 } |
| 636 | 636 |
| 637 ApiZone* zone() { return &zone_; } | 637 ApiZone* zone() { return &zone_; } |
| 638 | 638 |
| 639 private: | 639 private: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 655 ApiNativeScope::Current()->zone()->GetBaseZone()) {} | 655 ApiNativeScope::Current()->zone()->GetBaseZone()) {} |
| 656 ApiGrowableArray() | 656 ApiGrowableArray() |
| 657 : BaseGrowableArray<T, ValueObject>( | 657 : BaseGrowableArray<T, ValueObject>( |
| 658 ApiNativeScope::Current()->zone()->GetBaseZone()) {} | 658 ApiNativeScope::Current()->zone()->GetBaseZone()) {} |
| 659 }; | 659 }; |
| 660 | 660 |
| 661 | 661 |
| 662 } // namespace dart | 662 } // namespace dart |
| 663 | 663 |
| 664 #endif // VM_DART_API_STATE_H_ | 664 #endif // VM_DART_API_STATE_H_ |
| OLD | NEW |