Chromium Code Reviews| 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 "lib/stacktrace.h" | 10 #include "lib/stacktrace.h" |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 527 | 527 |
| 528 Dart_Handle Api::AcquiredError(Isolate* isolate) { | 528 Dart_Handle Api::AcquiredError(Isolate* isolate) { |
| 529 ASSERT(isolate != NULL); | 529 ASSERT(isolate != NULL); |
| 530 ApiState* state = isolate->api_state(); | 530 ApiState* state = isolate->api_state(); |
| 531 ASSERT(state != NULL); | 531 ASSERT(state != NULL); |
| 532 PersistentHandle* acquired_error_handle = state->AcquiredError(); | 532 PersistentHandle* acquired_error_handle = state->AcquiredError(); |
| 533 return reinterpret_cast<Dart_Handle>(acquired_error_handle); | 533 return reinterpret_cast<Dart_Handle>(acquired_error_handle); |
| 534 } | 534 } |
| 535 | 535 |
| 536 | 536 |
| 537 bool Api::IsValid(Dart_Handle handle) { | |
| 538 Isolate* isolate = Isolate::Current(); | |
| 539 CHECK_ISOLATE(isolate); | |
| 540 | |
| 541 // Check against all of the handles in the current isolate as well as the | |
| 542 // read-only handles. | |
| 543 return isolate->thread_registry()->IsValidHandle(handle) || | |
| 544 isolate->api_state()->IsValidPersistentHandle( | |
| 545 reinterpret_cast<Dart_PersistentHandle>(handle)) || | |
| 546 isolate->api_state()->IsValidWeakPersistentHandle( | |
| 547 reinterpret_cast<Dart_WeakPersistentHandle>(handle)) || | |
| 548 Dart::IsReadOnlyApiHandle(handle) || | |
| 549 Dart::IsReadOnlyHandle(reinterpret_cast<uword>(handle)); | |
| 550 } | |
| 551 | |
| 552 | |
| 537 ApiLocalScope* Api::TopScope(Thread* thread) { | 553 ApiLocalScope* Api::TopScope(Thread* thread) { |
| 538 ASSERT(thread != NULL); | 554 ASSERT(thread != NULL); |
| 539 ApiLocalScope* scope = thread->api_top_scope(); | 555 ApiLocalScope* scope = thread->api_top_scope(); |
| 540 ASSERT(scope != NULL); | 556 ASSERT(scope != NULL); |
| 541 return scope; | 557 return scope; |
| 542 } | 558 } |
| 543 | 559 |
| 544 | 560 |
| 545 void Api::InitOnce() { | 561 void Api::InitOnce() { |
| 546 ASSERT(api_native_key_ == kUnsetThreadLocalKey); | 562 ASSERT(api_native_key_ == kUnsetThreadLocalKey); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 752 Dart_WeakPersistentHandle object = handle->apiHandle(); | 768 Dart_WeakPersistentHandle object = handle->apiHandle(); |
| 753 (*callback)(isolate->init_callback_data(), object, peer); | 769 (*callback)(isolate->init_callback_data(), object, peer); |
| 754 ApiState* state = isolate->api_state(); | 770 ApiState* state = isolate->api_state(); |
| 755 ASSERT(state != NULL); | 771 ASSERT(state != NULL); |
| 756 state->weak_persistent_handles().FreeHandle(handle); | 772 state->weak_persistent_handles().FreeHandle(handle); |
| 757 } | 773 } |
| 758 | 774 |
| 759 | 775 |
| 760 // --- Handles --- | 776 // --- Handles --- |
| 761 | 777 |
| 778 DART_EXPORT bool Dart_IsValid(Dart_Handle handle) { | |
| 779 return Api::IsValid(handle); | |
| 780 } | |
|
siva
2017/01/20 17:40:03
Not needed as you have dropped it from the API.
bkonyi
2017/01/20 23:07:11
Done.
| |
| 781 | |
| 782 | |
| 762 DART_EXPORT bool Dart_IsError(Dart_Handle handle) { | 783 DART_EXPORT bool Dart_IsError(Dart_Handle handle) { |
| 763 return Api::IsError(handle); | 784 return Api::IsError(handle); |
| 764 } | 785 } |
| 765 | 786 |
| 766 | 787 |
| 767 DART_EXPORT bool Dart_IsApiError(Dart_Handle object) { | 788 DART_EXPORT bool Dart_IsApiError(Dart_Handle object) { |
| 768 return Api::ClassId(object) == kApiErrorCid; | 789 return Api::ClassId(object) == kApiErrorCid; |
| 769 } | 790 } |
| 770 | 791 |
| 771 | 792 |
| (...skipping 6019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6791 } | 6812 } |
| 6792 | 6813 |
| 6793 | 6814 |
| 6794 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { | 6815 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { |
| 6795 #ifndef PRODUCT | 6816 #ifndef PRODUCT |
| 6796 Profiler::DumpStackTrace(context); | 6817 Profiler::DumpStackTrace(context); |
| 6797 #endif | 6818 #endif |
| 6798 } | 6819 } |
| 6799 | 6820 |
| 6800 } // namespace dart | 6821 } // namespace dart |
| OLD | NEW |