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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 static FinalizablePersistentHandle* UnwrapAsPrologueWeakPersistentHandle( | 104 static FinalizablePersistentHandle* UnwrapAsPrologueWeakPersistentHandle( |
105 const ApiState& state, | 105 const ApiState& state, |
106 Dart_Handle object); | 106 Dart_Handle object); |
107 | 107 |
108 // Casts the internal Isolate* type to the external Dart_Isolate type. | 108 // Casts the internal Isolate* type to the external Dart_Isolate type. |
109 static Dart_Isolate CastIsolate(Isolate* isolate); | 109 static Dart_Isolate CastIsolate(Isolate* isolate); |
110 | 110 |
111 // Gets the handle used to designate successful return. | 111 // Gets the handle used to designate successful return. |
112 static Dart_Handle Success(Isolate* isolate); | 112 static Dart_Handle Success(Isolate* isolate); |
113 | 113 |
| 114 // Returns true if the handle holds a Smi. |
| 115 static bool IsSmi(Dart_Handle handle) { |
| 116 RawObject* raw = *(reinterpret_cast<RawObject**>(handle)); |
| 117 return !raw->IsHeapObject(); |
| 118 } |
| 119 |
| 120 // Returns the value of a Smi. |
| 121 static intptr_t SmiValue(Dart_Handle handle) { |
| 122 uword value = *(reinterpret_cast<uword*>(handle)); |
| 123 return Smi::ValueFromRaw(value); |
| 124 } |
| 125 |
114 // Generates a handle used to designate an error return. | 126 // Generates a handle used to designate an error return. |
115 static Dart_Handle NewError(const char* format, ...); | 127 static Dart_Handle NewError(const char* format, ...); |
116 | 128 |
117 // Gets a handle to Null. | 129 // Gets a handle to Null. |
118 static Dart_Handle Null(Isolate* isolate); | 130 static Dart_Handle Null(Isolate* isolate); |
119 | 131 |
120 // Gets a handle to True. | 132 // Gets a handle to True. |
121 static Dart_Handle True(Isolate* isolate); | 133 static Dart_Handle True(Isolate* isolate); |
122 | 134 |
123 // Gets a handle to False | 135 // Gets a handle to False |
(...skipping 29 matching lines...) Expand all Loading... |
153 } | 165 } |
154 private: | 166 private: |
155 Isolate* saved_isolate_; | 167 Isolate* saved_isolate_; |
156 | 168 |
157 DISALLOW_COPY_AND_ASSIGN(IsolateSaver); | 169 DISALLOW_COPY_AND_ASSIGN(IsolateSaver); |
158 }; | 170 }; |
159 | 171 |
160 } // namespace dart. | 172 } // namespace dart. |
161 | 173 |
162 #endif // VM_DART_API_IMPL_H_ | 174 #endif // VM_DART_API_IMPL_H_ |
OLD | NEW |