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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. | 114 // Returns true if the handle holds a Smi. |
115 static bool IsSmi(Dart_Handle handle) { | 115 static bool IsSmi(Dart_Handle handle) { |
| 116 // TODO(turnidge): Assumes RawObject* is at offset zero. Fix. |
116 RawObject* raw = *(reinterpret_cast<RawObject**>(handle)); | 117 RawObject* raw = *(reinterpret_cast<RawObject**>(handle)); |
117 return !raw->IsHeapObject(); | 118 return !raw->IsHeapObject(); |
118 } | 119 } |
119 | 120 |
120 // Returns the value of a Smi. | 121 // Returns the value of a Smi. |
121 static intptr_t SmiValue(Dart_Handle handle) { | 122 static intptr_t SmiValue(Dart_Handle handle) { |
| 123 // TODO(turnidge): Assumes RawObject* is at offset zero. Fix. |
122 uword value = *(reinterpret_cast<uword*>(handle)); | 124 uword value = *(reinterpret_cast<uword*>(handle)); |
123 return Smi::ValueFromRaw(value); | 125 return Smi::ValueFromRaw(value); |
124 } | 126 } |
125 | 127 |
126 static intptr_t ClassId(Dart_Handle handle) { | 128 static intptr_t ClassId(Dart_Handle handle) { |
| 129 // TODO(turnidge): Assumes RawObject* is at offset zero. Fix. |
127 RawObject* raw = *(reinterpret_cast<RawObject**>(handle)); | 130 RawObject* raw = *(reinterpret_cast<RawObject**>(handle)); |
128 if (!raw->IsHeapObject()) { | 131 if (!raw->IsHeapObject()) { |
129 return kSmiCid; | 132 return kSmiCid; |
130 } | 133 } |
131 return raw->GetClassId(); | 134 return raw->GetClassId(); |
132 } | 135 } |
133 | 136 |
134 // Generates a handle used to designate an error return. | 137 // Generates a handle used to designate an error return. |
135 static Dart_Handle NewError(const char* format, ...); | 138 static Dart_Handle NewError(const char* format, ...); |
136 | 139 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 } | 173 } |
171 private: | 174 private: |
172 Isolate* saved_isolate_; | 175 Isolate* saved_isolate_; |
173 | 176 |
174 DISALLOW_COPY_AND_ASSIGN(IsolateSaver); | 177 DISALLOW_COPY_AND_ASSIGN(IsolateSaver); |
175 }; | 178 }; |
176 | 179 |
177 } // namespace dart. | 180 } // namespace dart. |
178 | 181 |
179 #endif // VM_DART_API_IMPL_H_ | 182 #endif // VM_DART_API_IMPL_H_ |
OLD | NEW |