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" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 if (!raw->IsHeapObject()) { | 187 if (!raw->IsHeapObject()) { |
188 return kSmiCid; | 188 return kSmiCid; |
189 } | 189 } |
190 return raw->GetClassId(); | 190 return raw->GetClassId(); |
191 } | 191 } |
192 | 192 |
193 // Generates a handle used to designate an error return. | 193 // Generates a handle used to designate an error return. |
194 static Dart_Handle NewError(const char* format, ...) PRINTF_ATTRIBUTE(1, 2); | 194 static Dart_Handle NewError(const char* format, ...) PRINTF_ATTRIBUTE(1, 2); |
195 | 195 |
196 // Gets a handle to Null. | 196 // Gets a handle to Null. |
197 static Dart_Handle Null(); | 197 static Dart_Handle Null() { |
| 198 return null_handle_; |
| 199 } |
198 | 200 |
199 // Gets a handle to True. | 201 // Gets a handle to True. |
200 static Dart_Handle True(); | 202 static Dart_Handle True() { |
| 203 return true_handle_; |
| 204 } |
201 | 205 |
202 // Gets a handle to False | 206 // Gets a handle to False. |
203 static Dart_Handle False(); | 207 static Dart_Handle False() { |
| 208 return false_handle_; |
| 209 } |
| 210 |
| 211 // Gets a handle to EmptyString. |
| 212 static Dart_Handle EmptyString() { |
| 213 return empty_string_handle_; |
| 214 } |
204 | 215 |
205 // Retrieves the top ApiLocalScope. | 216 // Retrieves the top ApiLocalScope. |
206 static ApiLocalScope* TopScope(Isolate* isolate); | 217 static ApiLocalScope* TopScope(Isolate* isolate); |
207 | 218 |
208 // Performs one-time initialization needed by the API. | 219 // Performs one-time initialization needed by the API. |
209 static void InitOnce(); | 220 static void InitOnce(); |
210 | 221 |
211 // Allocates handles for objects in the VM isolate. | 222 // Allocates handles for objects in the VM isolate. |
212 static void InitHandles(); | 223 static void InitHandles(); |
213 | 224 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 269 |
259 private: | 270 private: |
260 static Dart_Handle InitNewHandle(Isolate* isolate, RawObject* raw); | 271 static Dart_Handle InitNewHandle(Isolate* isolate, RawObject* raw); |
261 | 272 |
262 // Thread local key used by the API. Currently holds the current | 273 // Thread local key used by the API. Currently holds the current |
263 // ApiNativeScope if any. | 274 // ApiNativeScope if any. |
264 static ThreadLocalKey api_native_key_; | 275 static ThreadLocalKey api_native_key_; |
265 static Dart_Handle true_handle_; | 276 static Dart_Handle true_handle_; |
266 static Dart_Handle false_handle_; | 277 static Dart_Handle false_handle_; |
267 static Dart_Handle null_handle_; | 278 static Dart_Handle null_handle_; |
| 279 static Dart_Handle empty_string_handle_; |
268 | 280 |
269 friend class ApiNativeScope; | 281 friend class ApiNativeScope; |
270 }; | 282 }; |
271 | 283 |
272 class IsolateSaver { | 284 class IsolateSaver { |
273 public: | 285 public: |
274 explicit IsolateSaver(Isolate* current_isolate) | 286 explicit IsolateSaver(Isolate* current_isolate) |
275 : saved_isolate_(current_isolate) { | 287 : saved_isolate_(current_isolate) { |
276 } | 288 } |
277 ~IsolateSaver() { | 289 ~IsolateSaver() { |
(...skipping 17 matching lines...) Expand all Loading... |
295 if (isolate->no_callback_scope_depth() != 0) { \ | 307 if (isolate->no_callback_scope_depth() != 0) { \ |
296 return reinterpret_cast<Dart_Handle>(Api::AcquiredError(isolate)); \ | 308 return reinterpret_cast<Dart_Handle>(Api::AcquiredError(isolate)); \ |
297 } \ | 309 } \ |
298 | 310 |
299 #define ASSERT_CALLBACK_STATE(isolate) \ | 311 #define ASSERT_CALLBACK_STATE(isolate) \ |
300 ASSERT(isolate->no_callback_scope_depth() == 0) | 312 ASSERT(isolate->no_callback_scope_depth() == 0) |
301 | 313 |
302 } // namespace dart. | 314 } // namespace dart. |
303 | 315 |
304 #endif // VM_DART_API_IMPL_H_ | 316 #endif // VM_DART_API_IMPL_H_ |
OLD | NEW |