| 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_IMPL_H_ | 5 #ifndef VM_DART_API_IMPL_H_ |
| 6 #define VM_DART_API_IMPL_H_ | 6 #define VM_DART_API_IMPL_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/native_arguments.h" | 9 #include "vm/native_arguments.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 DECLARE_FLAG(bool, trace_api); |
| 15 |
| 14 class ApiLocalScope; | 16 class ApiLocalScope; |
| 15 class ApiState; | 17 class ApiState; |
| 16 class FinalizablePersistentHandle; | 18 class FinalizablePersistentHandle; |
| 17 class LocalHandle; | 19 class LocalHandle; |
| 18 class PersistentHandle; | 20 class PersistentHandle; |
| 19 | 21 |
| 20 const char* CanonicalFunction(const char* func); | 22 const char* CanonicalFunction(const char* func); |
| 21 | 23 |
| 22 #define CURRENT_FUNC CanonicalFunction(__FUNCTION__) | 24 #define CURRENT_FUNC CanonicalFunction(__FUNCTION__) |
| 23 | 25 |
| 26 #if defined(DEBUG) |
| 27 #define TRACE_API_CALL(name) \ |
| 28 if (FLAG_trace_api) { \ |
| 29 OS::Print("Calling API func: %s\n", name); \ |
| 30 } |
| 31 #else |
| 32 #define TRACE_API_CALL(name) |
| 33 #endif |
| 34 |
| 35 |
| 24 // Checks that the current isolate is not NULL. | 36 // Checks that the current isolate is not NULL. |
| 25 #define CHECK_ISOLATE(isolate) \ | 37 #define CHECK_ISOLATE(isolate) \ |
| 26 do { \ | 38 do { \ |
| 39 TRACE_API_CALL(CURRENT_FUNC); \ |
| 27 if ((isolate) == NULL) { \ | 40 if ((isolate) == NULL) { \ |
| 28 FATAL1("%s expects there to be a current isolate. Did you " \ | 41 FATAL1("%s expects there to be a current isolate. Did you " \ |
| 29 "forget to call Dart_CreateIsolate or Dart_EnterIsolate?", \ | 42 "forget to call Dart_CreateIsolate or Dart_EnterIsolate?", \ |
| 30 CURRENT_FUNC); \ | 43 CURRENT_FUNC); \ |
| 31 } \ | 44 } \ |
| 32 } while (0) | 45 } while (0) |
| 33 | 46 |
| 34 // Checks that the current isolate is NULL. | 47 // Checks that the current isolate is NULL. |
| 35 #define CHECK_NO_ISOLATE(isolate) \ | 48 #define CHECK_NO_ISOLATE(isolate) \ |
| 36 do { \ | 49 do { \ |
| 50 TRACE_API_CALL(CURRENT_FUNC); \ |
| 37 if ((isolate) != NULL) { \ | 51 if ((isolate) != NULL) { \ |
| 38 FATAL1("%s expects there to be no current isolate. Did you " \ | 52 FATAL1("%s expects there to be no current isolate. Did you " \ |
| 39 "forget to call Dart_ExitIsolate?", CURRENT_FUNC); \ | 53 "forget to call Dart_ExitIsolate?", CURRENT_FUNC); \ |
| 40 } \ | 54 } \ |
| 41 } while (0) | 55 } while (0) |
| 42 | 56 |
| 43 // Checks that the current isolate is not NULL and that it has an API scope. | 57 // Checks that the current isolate is not NULL and that it has an API scope. |
| 44 #define CHECK_ISOLATE_SCOPE(isolate) \ | 58 #define CHECK_ISOLATE_SCOPE(isolate) \ |
| 45 do { \ | 59 do { \ |
| 46 Isolate* tmp = (isolate); \ | 60 Isolate* tmp = (isolate); \ |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 if (isolate->no_callback_scope_depth() != 0) { \ | 262 if (isolate->no_callback_scope_depth() != 0) { \ |
| 249 return reinterpret_cast<Dart_Handle>(Api::AcquiredError(isolate)); \ | 263 return reinterpret_cast<Dart_Handle>(Api::AcquiredError(isolate)); \ |
| 250 } \ | 264 } \ |
| 251 | 265 |
| 252 #define ASSERT_CALLBACK_STATE(isolate) \ | 266 #define ASSERT_CALLBACK_STATE(isolate) \ |
| 253 ASSERT(isolate->no_callback_scope_depth() == 0) | 267 ASSERT(isolate->no_callback_scope_depth() == 0) |
| 254 | 268 |
| 255 } // namespace dart. | 269 } // namespace dart. |
| 256 | 270 |
| 257 #endif // VM_DART_API_IMPL_H_ | 271 #endif // VM_DART_API_IMPL_H_ |
| OLD | NEW |