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 "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 ApiState* state = Isolate::Current()->api_state(); | 364 ApiState* state = Isolate::Current()->api_state(); |
| 365 ASSERT(state->IsValidWeakPersistentHandle(handle) || | 365 ASSERT(state->IsValidWeakPersistentHandle(handle) || |
| 366 state->IsValidPrologueWeakPersistentHandle(handle)); | 366 state->IsValidPrologueWeakPersistentHandle(handle)); |
| 367 #endif | 367 #endif |
| 368 uword addr = reinterpret_cast<uword>(handle); | 368 uword addr = reinterpret_cast<uword>(handle); |
| 369 return reinterpret_cast<FinalizablePersistentHandle*>( | 369 return reinterpret_cast<FinalizablePersistentHandle*>( |
| 370 addr & ~kWeakPersistentTagMask); | 370 addr & ~kWeakPersistentTagMask); |
| 371 } | 371 } |
| 372 | 372 |
| 373 | 373 |
| 374 void FinalizablePersistentHandle::Finalize(Isolate* isolate, | |
| 375 FinalizablePersistentHandle* handle, | |
| 376 bool is_prologue_weak) { | |
| 377 Dart_WeakPersistentHandleFinalizer callback = handle->callback(); | |
| 378 if (callback != NULL) { | |
|
Ivan Posva
2014/03/19 23:08:14
How can the callback be NULL, I thought it was a r
siva
2014/03/20 20:05:32
good point changed that to an assert
ASSERT(callba
| |
| 379 void* peer = handle->peer(); | |
| 380 Dart_WeakPersistentHandle object = is_prologue_weak ? | |
| 381 handle->apiPrologueHandle() : | |
| 382 handle->apiHandle(); | |
| 383 (*callback)(isolate->init_callback_data(), object, peer); | |
| 384 } | |
| 385 ApiState* state = isolate->api_state(); | |
| 386 ASSERT(state != NULL); | |
| 387 if (is_prologue_weak) { | |
| 388 state->prologue_weak_persistent_handles().FreeHandle(handle); | |
| 389 } else { | |
| 390 state->weak_persistent_handles().FreeHandle(handle); | |
| 391 } | |
| 392 } | |
| 393 | |
| 394 | |
| 374 // --- Handles --- | 395 // --- Handles --- |
| 375 | 396 |
| 376 DART_EXPORT bool Dart_IsError(Dart_Handle handle) { | 397 DART_EXPORT bool Dart_IsError(Dart_Handle handle) { |
| 377 TRACE_API_CALL(CURRENT_FUNC); | 398 TRACE_API_CALL(CURRENT_FUNC); |
| 378 return RawObject::IsErrorClassId(Api::ClassId(handle)); | 399 return RawObject::IsErrorClassId(Api::ClassId(handle)); |
| 379 } | 400 } |
| 380 | 401 |
| 381 | 402 |
| 382 DART_EXPORT bool Dart_IsApiError(Dart_Handle object) { | 403 DART_EXPORT bool Dart_IsApiError(Dart_Handle object) { |
| 383 TRACE_API_CALL(CURRENT_FUNC); | 404 TRACE_API_CALL(CURRENT_FUNC); |
| (...skipping 4249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4633 | 4654 |
| 4634 | 4655 |
| 4635 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 4656 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
| 4636 const char* name, | 4657 const char* name, |
| 4637 Dart_ServiceRequestCallback callback, | 4658 Dart_ServiceRequestCallback callback, |
| 4638 void* user_data) { | 4659 void* user_data) { |
| 4639 Service::RegisterRootEmbedderCallback(name, callback, user_data); | 4660 Service::RegisterRootEmbedderCallback(name, callback, user_data); |
| 4640 } | 4661 } |
| 4641 | 4662 |
| 4642 } // namespace dart | 4663 } // namespace dart |
| OLD | NEW |