| 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); | 14 DECLARE_FLAG(bool, trace_api); |
| 15 | 15 |
| 16 class ApiLocalScope; | 16 class ApiLocalScope; |
| 17 class ApiState; | 17 class ApiState; |
| 18 class FinalizablePersistentHandle; | 18 class FinalizablePersistentHandle; |
| 19 class LocalHandle; | 19 class LocalHandle; |
| 20 class PersistentHandle; | 20 class PersistentHandle; |
| 21 class ReusableObjectHandleScope; |
| 21 | 22 |
| 22 const char* CanonicalFunction(const char* func); | 23 const char* CanonicalFunction(const char* func); |
| 23 | 24 |
| 24 #define CURRENT_FUNC CanonicalFunction(__FUNCTION__) | 25 #define CURRENT_FUNC CanonicalFunction(__FUNCTION__) |
| 25 | 26 |
| 26 #if defined(DEBUG) | 27 #if defined(DEBUG) |
| 27 #define TRACE_API_CALL(name) \ | 28 #define TRACE_API_CALL(name) \ |
| 28 if (FLAG_trace_api) { \ | 29 if (FLAG_trace_api) { \ |
| 29 OS::Print("Calling API func: %s\n", name); \ | 30 OS::Print("Calling API func: %s\n", name); \ |
| 30 } | 31 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 static RawObject* UnwrapHandle(Dart_Handle object); | 116 static RawObject* UnwrapHandle(Dart_Handle object); |
| 116 | 117 |
| 117 // Unwraps a raw Type from the handle. The handle will be null if | 118 // Unwraps a raw Type from the handle. The handle will be null if |
| 118 // the object was not of the requested Type. | 119 // the object was not of the requested Type. |
| 119 #define DECLARE_UNWRAP(Type) \ | 120 #define DECLARE_UNWRAP(Type) \ |
| 120 static const Type& Unwrap##Type##Handle(Isolate* isolate, \ | 121 static const Type& Unwrap##Type##Handle(Isolate* isolate, \ |
| 121 Dart_Handle object); | 122 Dart_Handle object); |
| 122 CLASS_LIST_FOR_HANDLES(DECLARE_UNWRAP) | 123 CLASS_LIST_FOR_HANDLES(DECLARE_UNWRAP) |
| 123 #undef DECLARE_UNWRAP | 124 #undef DECLARE_UNWRAP |
| 124 | 125 |
| 126 // Unwraps the raw object from the handle using a reused handle. |
| 127 static const String& UnwrapStringHandle( |
| 128 const ReusableObjectHandleScope& reused, Dart_Handle object); |
| 129 static const Instance& UnwrapInstanceHandle( |
| 130 const ReusableObjectHandleScope& reused, Dart_Handle object); |
| 131 |
| 125 // Validates and converts the passed in handle as a persistent handle. | 132 // Validates and converts the passed in handle as a persistent handle. |
| 126 static PersistentHandle* UnwrapAsPersistentHandle( | 133 static PersistentHandle* UnwrapAsPersistentHandle( |
| 127 Dart_PersistentHandle object); | 134 Dart_PersistentHandle object); |
| 128 | 135 |
| 129 // Validates and converts the passed in handle as a weak persistent handle. | 136 // Validates and converts the passed in handle as a weak persistent handle. |
| 130 static FinalizablePersistentHandle* UnwrapAsWeakPersistentHandle( | 137 static FinalizablePersistentHandle* UnwrapAsWeakPersistentHandle( |
| 131 Dart_WeakPersistentHandle object); | 138 Dart_WeakPersistentHandle object); |
| 132 | 139 |
| 133 // Validates and converts the passed in handle as a prologue weak | 140 // Validates and converts the passed in handle as a prologue weak |
| 134 // persistent handle. | 141 // persistent handle. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 // Retrieves the top ApiLocalScope. | 205 // Retrieves the top ApiLocalScope. |
| 199 static ApiLocalScope* TopScope(Isolate* isolate); | 206 static ApiLocalScope* TopScope(Isolate* isolate); |
| 200 | 207 |
| 201 // Performs one-time initialization needed by the API. | 208 // Performs one-time initialization needed by the API. |
| 202 static void InitOnce(); | 209 static void InitOnce(); |
| 203 | 210 |
| 204 // Allocates handles for objects in the VM isolate. | 211 // Allocates handles for objects in the VM isolate. |
| 205 static void InitHandles(); | 212 static void InitHandles(); |
| 206 | 213 |
| 207 // Helper function to get the peer value of an external string object. | 214 // Helper function to get the peer value of an external string object. |
| 208 static bool StringGetPeerHelper(Dart_NativeArguments args, | 215 static bool StringGetPeerHelper(NativeArguments* args, |
| 209 int arg_index, | 216 int arg_index, |
| 210 void** peer); | 217 void** peer); |
| 211 | 218 |
| 212 // Helper function to get the native field from a native receiver argument. | 219 // Helper function to get the native field from a native receiver argument. |
| 213 static bool GetNativeReceiver(Dart_NativeArguments args, intptr_t* value); | 220 static bool GetNativeReceiver(NativeArguments* args, intptr_t* value); |
| 214 | 221 |
| 215 // Helper function to get the boolean value of a Bool native argument. | 222 // Helper function to get the boolean value of a Bool native argument. |
| 216 static bool GetNativeBooleanArgument(Dart_NativeArguments args, | 223 static bool GetNativeBooleanArgument(NativeArguments* args, |
| 217 int arg_index, | 224 int arg_index, |
| 218 bool* value); | 225 bool* value); |
| 219 | 226 |
| 220 // Helper function to set the return value of native functions. | 227 // Helper function to set the return value of native functions. |
| 221 static void SetReturnValue(NativeArguments* args, Dart_Handle retval) { | 228 static void SetReturnValue(NativeArguments* args, Dart_Handle retval) { |
| 222 args->SetReturnUnsafe(UnwrapHandle(retval)); | 229 args->SetReturnUnsafe(UnwrapHandle(retval)); |
| 223 } | 230 } |
| 224 static void SetSmiReturnValue(NativeArguments* args, intptr_t retval) { | 231 static void SetSmiReturnValue(NativeArguments* args, intptr_t retval) { |
| 225 args->SetReturnUnsafe(Smi::New(retval)); | 232 args->SetReturnUnsafe(Smi::New(retval)); |
| 226 } | 233 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 if (isolate->no_callback_scope_depth() != 0) { \ | 279 if (isolate->no_callback_scope_depth() != 0) { \ |
| 273 return reinterpret_cast<Dart_Handle>(Api::AcquiredError(isolate)); \ | 280 return reinterpret_cast<Dart_Handle>(Api::AcquiredError(isolate)); \ |
| 274 } \ | 281 } \ |
| 275 | 282 |
| 276 #define ASSERT_CALLBACK_STATE(isolate) \ | 283 #define ASSERT_CALLBACK_STATE(isolate) \ |
| 277 ASSERT(isolate->no_callback_scope_depth() == 0) | 284 ASSERT(isolate->no_callback_scope_depth() == 0) |
| 278 | 285 |
| 279 } // namespace dart. | 286 } // namespace dart. |
| 280 | 287 |
| 281 #endif // VM_DART_API_IMPL_H_ | 288 #endif // VM_DART_API_IMPL_H_ |
| OLD | NEW |