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 #include "include/dart_api.h" | 5 #include "include/dart_api.h" |
6 | 6 |
7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "vm/object_store.h" | 21 #include "vm/object_store.h" |
22 #include "vm/port.h" | 22 #include "vm/port.h" |
23 #include "vm/resolver.h" | 23 #include "vm/resolver.h" |
24 #include "vm/snapshot.h" | 24 #include "vm/snapshot.h" |
25 #include "vm/stack_frame.h" | 25 #include "vm/stack_frame.h" |
26 #include "vm/timer.h" | 26 #include "vm/timer.h" |
27 #include "vm/verifier.h" | 27 #include "vm/verifier.h" |
28 | 28 |
29 namespace dart { | 29 namespace dart { |
30 | 30 |
| 31 ThreadLocalKey Api::api_native_key_ = Thread::kUnsetThreadLocalKey; |
| 32 |
31 const char* CanonicalFunction(const char* func) { | 33 const char* CanonicalFunction(const char* func) { |
32 if (strncmp(func, "dart::", 6) == 0) { | 34 if (strncmp(func, "dart::", 6) == 0) { |
33 return func + 6; | 35 return func + 6; |
34 } else { | 36 } else { |
35 return func; | 37 return func; |
36 } | 38 } |
37 } | 39 } |
38 | 40 |
39 #define RETURN_TYPE_ERROR(dart_handle, Type) \ | 41 #define RETURN_TYPE_ERROR(dart_handle, Type) \ |
40 do { \ | 42 do { \ |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 Isolate* isolate = Isolate::Current(); | 232 Isolate* isolate = Isolate::Current(); |
231 ASSERT(isolate != NULL); | 233 ASSERT(isolate != NULL); |
232 ApiState* state = isolate->api_state(); | 234 ApiState* state = isolate->api_state(); |
233 ASSERT(state != NULL); | 235 ASSERT(state != NULL); |
234 ApiLocalScope* scope = state->top_scope(); | 236 ApiLocalScope* scope = state->top_scope(); |
235 ASSERT(scope != NULL); | 237 ASSERT(scope != NULL); |
236 return scope->zone().Reallocate(ptr, old_size, new_size); | 238 return scope->zone().Reallocate(ptr, old_size, new_size); |
237 } | 239 } |
238 | 240 |
239 | 241 |
| 242 void Api::InitOnce() { |
| 243 ASSERT(api_native_key_ == Thread::kUnsetThreadLocalKey); |
| 244 api_native_key_ = Thread::CreateThreadLocal(); |
| 245 ASSERT(api_native_key_ != Thread::kUnsetThreadLocalKey); |
| 246 } |
| 247 |
| 248 |
240 // --- Handles --- | 249 // --- Handles --- |
241 | 250 |
242 | 251 |
243 DART_EXPORT bool Dart_IsError(Dart_Handle handle) { | 252 DART_EXPORT bool Dart_IsError(Dart_Handle handle) { |
244 DARTSCOPE(Isolate::Current()); | 253 DARTSCOPE(Isolate::Current()); |
245 const Object& obj = Object::Handle(Api::UnwrapHandle(handle)); | 254 const Object& obj = Object::Handle(Api::UnwrapHandle(handle)); |
246 return obj.IsError(); | 255 return obj.IsError(); |
247 } | 256 } |
248 | 257 |
249 | 258 |
(...skipping 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2430 } else { | 2439 } else { |
2431 *buffer = NULL; | 2440 *buffer = NULL; |
2432 } | 2441 } |
2433 delete debug_region; | 2442 delete debug_region; |
2434 } else { | 2443 } else { |
2435 *buffer = NULL; | 2444 *buffer = NULL; |
2436 *buffer_size = 0; | 2445 *buffer_size = 0; |
2437 } | 2446 } |
2438 } | 2447 } |
2439 | 2448 |
2440 | |
2441 } // namespace dart | 2449 } // namespace dart |
OLD | NEW |