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/object.h" | 9 #include "vm/object.h" |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 Dart_Handle object); | 73 Dart_Handle object); |
74 CLASS_LIST_FOR_HANDLES(DECLARE_UNWRAP) | 74 CLASS_LIST_FOR_HANDLES(DECLARE_UNWRAP) |
75 #undef DECLARE_UNWRAP | 75 #undef DECLARE_UNWRAP |
76 | 76 |
77 // Validates and converts the passed in handle as a local handle. | 77 // Validates and converts the passed in handle as a local handle. |
78 static LocalHandle* UnwrapAsLocalHandle(const ApiState& state, | 78 static LocalHandle* UnwrapAsLocalHandle(const ApiState& state, |
79 Dart_Handle object); | 79 Dart_Handle object); |
80 | 80 |
81 // Validates and converts the passed in handle as a persistent handle. | 81 // Validates and converts the passed in handle as a persistent handle. |
82 static PersistentHandle* UnwrapAsPersistentHandle(const ApiState& state, | 82 static PersistentHandle* UnwrapAsPersistentHandle(const ApiState& state, |
83 Dart_Handle object); | 83 Dart_PersistentHandle object
); |
84 | 84 |
85 // Validates and converts the passed in handle as a weak persistent handle. | 85 // Validates and converts the passed in handle as a weak persistent handle. |
86 static FinalizablePersistentHandle* UnwrapAsWeakPersistentHandle( | 86 static FinalizablePersistentHandle* UnwrapAsWeakPersistentHandle( |
87 const ApiState& state, | 87 const ApiState& state, |
88 Dart_Handle object); | 88 Dart_WeakPersistentHandle object); |
89 | 89 |
90 // Validates and converts the passed in handle as a prologue weak | 90 // Validates and converts the passed in handle as a prologue weak |
91 // persistent handle. | 91 // persistent handle. |
92 static FinalizablePersistentHandle* UnwrapAsPrologueWeakPersistentHandle( | 92 static FinalizablePersistentHandle* UnwrapAsPrologueWeakPersistentHandle( |
93 const ApiState& state, | 93 const ApiState& state, |
94 Dart_Handle object); | 94 Dart_WeakPersistentHandle object); |
95 | 95 |
96 // Returns an Error handle if isolate is in an inconsistent state. | 96 // Returns an Error handle if isolate is in an inconsistent state. |
97 // Returns a Success handle when no error condition exists. | 97 // Returns a Success handle when no error condition exists. |
98 static Dart_Handle CheckIsolateState(Isolate *isolate); | 98 static Dart_Handle CheckIsolateState(Isolate *isolate); |
99 | 99 |
100 // Casts the internal Isolate* type to the external Dart_Isolate type. | 100 // Casts the internal Isolate* type to the external Dart_Isolate type. |
101 static Dart_Isolate CastIsolate(Isolate* isolate); | 101 static Dart_Isolate CastIsolate(Isolate* isolate); |
102 | 102 |
103 // Gets the handle used to designate successful return. | 103 // Gets the handle used to designate successful return. |
104 static Dart_Handle Success(Isolate* isolate); | 104 static Dart_Handle Success(Isolate* isolate); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 // Gets a handle to False | 148 // Gets a handle to False |
149 static Dart_Handle False(Isolate* isolate); | 149 static Dart_Handle False(Isolate* isolate); |
150 | 150 |
151 // Retrieves the top ApiLocalScope. | 151 // Retrieves the top ApiLocalScope. |
152 static ApiLocalScope* TopScope(Isolate* isolate); | 152 static ApiLocalScope* TopScope(Isolate* isolate); |
153 | 153 |
154 // Performs one-time initialization needed by the API. | 154 // Performs one-time initialization needed by the API. |
155 static void InitOnce(); | 155 static void InitOnce(); |
156 | 156 |
| 157 // Allocates handles for objects in the VM isolate. |
| 158 static void InitHandles(); |
| 159 |
157 // Helper function to get the peer value of an external string object. | 160 // Helper function to get the peer value of an external string object. |
158 static bool ExternalStringGetPeerHelper(Dart_Handle object, void** peer); | 161 static bool ExternalStringGetPeerHelper(Dart_Handle object, void** peer); |
159 | 162 |
160 private: | 163 private: |
161 // Thread local key used by the API. Currently holds the current | 164 // Thread local key used by the API. Currently holds the current |
162 // ApiNativeScope if any. | 165 // ApiNativeScope if any. |
163 static ThreadLocalKey api_native_key_; | 166 static ThreadLocalKey api_native_key_; |
| 167 static Dart_Handle true_handle_; |
| 168 static Dart_Handle false_handle_; |
| 169 static Dart_Handle null_handle_; |
164 | 170 |
165 friend class ApiNativeScope; | 171 friend class ApiNativeScope; |
166 }; | 172 }; |
167 | 173 |
168 class IsolateSaver { | 174 class IsolateSaver { |
169 public: | 175 public: |
170 explicit IsolateSaver(Isolate* current_isolate) | 176 explicit IsolateSaver(Isolate* current_isolate) |
171 : saved_isolate_(current_isolate) { | 177 : saved_isolate_(current_isolate) { |
172 } | 178 } |
173 ~IsolateSaver() { | 179 ~IsolateSaver() { |
(...skipping 14 matching lines...) Expand all Loading... |
188 isolate->DecrementNoCallbackScopeDepth() | 194 isolate->DecrementNoCallbackScopeDepth() |
189 | 195 |
190 #define CHECK_CALLBACK_STATE(isolate) \ | 196 #define CHECK_CALLBACK_STATE(isolate) \ |
191 if (isolate->no_callback_scope_depth() != 0) { \ | 197 if (isolate->no_callback_scope_depth() != 0) { \ |
192 return reinterpret_cast<Dart_Handle>(Api::AcquiredError(isolate)); \ | 198 return reinterpret_cast<Dart_Handle>(Api::AcquiredError(isolate)); \ |
193 } \ | 199 } \ |
194 | 200 |
195 } // namespace dart. | 201 } // namespace dart. |
196 | 202 |
197 #endif // VM_DART_API_IMPL_H_ | 203 #endif // VM_DART_API_IMPL_H_ |
OLD | NEW |