Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: runtime/vm/dart_api_impl.h

Issue 15772005: - Add different types for persistent and weak persistent handles (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 static RawObject* UnwrapHandle(Dart_Handle object); 67 static RawObject* UnwrapHandle(Dart_Handle object);
68 68
69 // Unwraps a raw Type from the handle. The handle will be null if 69 // Unwraps a raw Type from the handle. The handle will be null if
70 // the object was not of the requested Type. 70 // the object was not of the requested Type.
71 #define DECLARE_UNWRAP(Type) \ 71 #define DECLARE_UNWRAP(Type) \
72 static const Type& Unwrap##Type##Handle(Isolate* isolate, \ 72 static const Type& Unwrap##Type##Handle(Isolate* isolate, \
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.
78 static LocalHandle* UnwrapAsLocalHandle(const ApiState& state,
79 Dart_Handle object);
80
81 // Validates and converts the passed in handle as a persistent handle. 77 // Validates and converts the passed in handle as a persistent handle.
82 static PersistentHandle* UnwrapAsPersistentHandle(const ApiState& state, 78 static PersistentHandle* UnwrapAsPersistentHandle(Dart_PersistentHandle object );
83 Dart_Handle object);
84 79
85 // Validates and converts the passed in handle as a weak persistent handle. 80 // Validates and converts the passed in handle as a weak persistent handle.
86 static FinalizablePersistentHandle* UnwrapAsWeakPersistentHandle( 81 static FinalizablePersistentHandle* UnwrapAsWeakPersistentHandle(
87 const ApiState& state, 82 Dart_WeakPersistentHandle object);
88 Dart_Handle object);
89 83
90 // Validates and converts the passed in handle as a prologue weak 84 // Validates and converts the passed in handle as a prologue weak
91 // persistent handle. 85 // persistent handle.
92 static FinalizablePersistentHandle* UnwrapAsPrologueWeakPersistentHandle( 86 static FinalizablePersistentHandle* UnwrapAsPrologueWeakPersistentHandle(
93 const ApiState& state, 87 Dart_WeakPersistentHandle object);
94 Dart_Handle object);
95 88
96 // Returns an Error handle if isolate is in an inconsistent state. 89 // Returns an Error handle if isolate is in an inconsistent state.
97 // Returns a Success handle when no error condition exists. 90 // Returns a Success handle when no error condition exists.
98 static Dart_Handle CheckIsolateState(Isolate *isolate); 91 static Dart_Handle CheckIsolateState(Isolate *isolate);
99 92
100 // Casts the internal Isolate* type to the external Dart_Isolate type. 93 // Casts the internal Isolate* type to the external Dart_Isolate type.
101 static Dart_Isolate CastIsolate(Isolate* isolate); 94 static Dart_Isolate CastIsolate(Isolate* isolate);
102 95
103 // Gets the handle used to designate successful return. 96 // Gets the handle used to designate successful return.
104 static Dart_Handle Success(Isolate* isolate); 97 static Dart_Handle Success(Isolate* isolate);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 140
148 // Gets a handle to False 141 // Gets a handle to False
149 static Dart_Handle False(Isolate* isolate); 142 static Dart_Handle False(Isolate* isolate);
150 143
151 // Retrieves the top ApiLocalScope. 144 // Retrieves the top ApiLocalScope.
152 static ApiLocalScope* TopScope(Isolate* isolate); 145 static ApiLocalScope* TopScope(Isolate* isolate);
153 146
154 // Performs one-time initialization needed by the API. 147 // Performs one-time initialization needed by the API.
155 static void InitOnce(); 148 static void InitOnce();
156 149
150 // Allocates handles for objects in the VM isolate.
151 static void InitHandles();
152
157 // Helper function to get the peer value of an external string object. 153 // Helper function to get the peer value of an external string object.
158 static bool ExternalStringGetPeerHelper(Dart_Handle object, void** peer); 154 static bool ExternalStringGetPeerHelper(Dart_Handle object, void** peer);
159 155
160 private: 156 private:
161 // Thread local key used by the API. Currently holds the current 157 // Thread local key used by the API. Currently holds the current
162 // ApiNativeScope if any. 158 // ApiNativeScope if any.
163 static ThreadLocalKey api_native_key_; 159 static ThreadLocalKey api_native_key_;
160 static Dart_Handle true_handle_;
161 static Dart_Handle false_handle_;
162 static Dart_Handle null_handle_;
164 163
165 friend class ApiNativeScope; 164 friend class ApiNativeScope;
166 }; 165 };
167 166
168 class IsolateSaver { 167 class IsolateSaver {
169 public: 168 public:
170 explicit IsolateSaver(Isolate* current_isolate) 169 explicit IsolateSaver(Isolate* current_isolate)
171 : saved_isolate_(current_isolate) { 170 : saved_isolate_(current_isolate) {
172 } 171 }
173 ~IsolateSaver() { 172 ~IsolateSaver() {
(...skipping 14 matching lines...) Expand all
188 isolate->DecrementNoCallbackScopeDepth() 187 isolate->DecrementNoCallbackScopeDepth()
189 188
190 #define CHECK_CALLBACK_STATE(isolate) \ 189 #define CHECK_CALLBACK_STATE(isolate) \
191 if (isolate->no_callback_scope_depth() != 0) { \ 190 if (isolate->no_callback_scope_depth() != 0) { \
192 return reinterpret_cast<Dart_Handle>(Api::AcquiredError(isolate)); \ 191 return reinterpret_cast<Dart_Handle>(Api::AcquiredError(isolate)); \
193 } \ 192 } \
194 193
195 } // namespace dart. 194 } // namespace dart.
196 195
197 #endif // VM_DART_API_IMPL_H_ 196 #endif // VM_DART_API_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698