| 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 static void InitOnce(); | 188 static void InitOnce(); |
| 189 | 189 |
| 190 // Allocates handles for objects in the VM isolate. | 190 // Allocates handles for objects in the VM isolate. |
| 191 static void InitHandles(); | 191 static void InitHandles(); |
| 192 | 192 |
| 193 // Helper function to get the peer value of an external string object. | 193 // Helper function to get the peer value of an external string object. |
| 194 static bool ExternalStringGetPeerHelper(Dart_Handle object, void** peer); | 194 static bool ExternalStringGetPeerHelper(Dart_Handle object, void** peer); |
| 195 | 195 |
| 196 // Helper function to set the return value of native functions. | 196 // Helper function to set the return value of native functions. |
| 197 static void SetReturnValue(NativeArguments* args, Dart_Handle retval) { | 197 static void SetReturnValue(NativeArguments* args, Dart_Handle retval) { |
| 198 NoGCScope no_gc_scope; | |
| 199 args->SetReturnUnsafe(UnwrapHandle(retval)); | 198 args->SetReturnUnsafe(UnwrapHandle(retval)); |
| 200 } | 199 } |
| 201 static void SetSmiReturnValue(NativeArguments* args, intptr_t retval) { | 200 static void SetSmiReturnValue(NativeArguments* args, intptr_t retval) { |
| 202 NoGCScope no_gc_scope; | |
| 203 args->SetReturnUnsafe(Smi::New(retval)); | 201 args->SetReturnUnsafe(Smi::New(retval)); |
| 204 } | 202 } |
| 205 static void SetIntegerReturnValue(NativeArguments* args, intptr_t retval) { | 203 static void SetIntegerReturnValue(NativeArguments* args, intptr_t retval) { |
| 206 NoGCScope no_gc_scope; | |
| 207 args->SetReturnUnsafe(Integer::New(retval)); | 204 args->SetReturnUnsafe(Integer::New(retval)); |
| 208 } | 205 } |
| 209 static void SetDoubleReturnValue(NativeArguments* args, double retval) { | 206 static void SetDoubleReturnValue(NativeArguments* args, double retval) { |
| 210 NoGCScope no_gc_scope; | |
| 211 args->SetReturnUnsafe(Double::New(retval)); | 207 args->SetReturnUnsafe(Double::New(retval)); |
| 212 } | 208 } |
| 213 | 209 |
| 214 private: | 210 private: |
| 215 // Thread local key used by the API. Currently holds the current | 211 // Thread local key used by the API. Currently holds the current |
| 216 // ApiNativeScope if any. | 212 // ApiNativeScope if any. |
| 217 static ThreadLocalKey api_native_key_; | 213 static ThreadLocalKey api_native_key_; |
| 218 static Dart_Handle true_handle_; | 214 static Dart_Handle true_handle_; |
| 219 static Dart_Handle false_handle_; | 215 static Dart_Handle false_handle_; |
| 220 static Dart_Handle null_handle_; | 216 static Dart_Handle null_handle_; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 248 if (isolate->no_callback_scope_depth() != 0) { \ | 244 if (isolate->no_callback_scope_depth() != 0) { \ |
| 249 return reinterpret_cast<Dart_Handle>(Api::AcquiredError(isolate)); \ | 245 return reinterpret_cast<Dart_Handle>(Api::AcquiredError(isolate)); \ |
| 250 } \ | 246 } \ |
| 251 | 247 |
| 252 #define ASSERT_CALLBACK_STATE(isolate) \ | 248 #define ASSERT_CALLBACK_STATE(isolate) \ |
| 253 ASSERT(isolate->no_callback_scope_depth() == 0) | 249 ASSERT(isolate->no_callback_scope_depth() == 0) |
| 254 | 250 |
| 255 } // namespace dart. | 251 } // namespace dart. |
| 256 | 252 |
| 257 #endif // VM_DART_API_IMPL_H_ | 253 #endif // VM_DART_API_IMPL_H_ |
| OLD | NEW |