OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 RUNTIME_VM_DART_API_MESSAGE_H_ | 5 #ifndef RUNTIME_VM_DART_API_MESSAGE_H_ |
6 #define RUNTIME_VM_DART_API_MESSAGE_H_ | 6 #define RUNTIME_VM_DART_API_MESSAGE_H_ |
7 | 7 |
8 #include "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" |
9 #include "platform/utils.h" | 9 #include "platform/utils.h" |
10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 struct _Dart_CObject* class_name; | 34 struct _Dart_CObject* class_name; |
35 } as_class; | 35 } as_class; |
36 struct { | 36 struct { |
37 struct _Dart_CObject* buffer; | 37 struct _Dart_CObject* buffer; |
38 int offset_in_bytes; | 38 int offset_in_bytes; |
39 int length; | 39 int length; |
40 } as_view; | 40 } as_view; |
41 } internal; | 41 } internal; |
42 }; | 42 }; |
43 | 43 |
44 | |
45 // Reads a message snapshot into a C structure. | 44 // Reads a message snapshot into a C structure. |
46 class ApiMessageReader : public BaseReader { | 45 class ApiMessageReader : public BaseReader { |
47 public: | 46 public: |
48 // The ApiMessageReader object must be enclosed by an ApiNativeScope. | 47 // The ApiMessageReader object must be enclosed by an ApiNativeScope. |
49 // Allocation of all C Heap objects is done in the zone associated with | 48 // Allocation of all C Heap objects is done in the zone associated with |
50 // the enclosing ApiNativeScope. | 49 // the enclosing ApiNativeScope. |
51 ApiMessageReader(const uint8_t* buffer, intptr_t length); | 50 ApiMessageReader(const uint8_t* buffer, intptr_t length); |
52 explicit ApiMessageReader(Message* message); | 51 explicit ApiMessageReader(Message* message); |
53 ~ApiMessageReader() {} | 52 ~ApiMessageReader() {} |
54 | 53 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 Zone* zone_; // Zone in which C heap objects are allocated. | 145 Zone* zone_; // Zone in which C heap objects are allocated. |
147 ApiGrowableArray<BackRefNode*> backward_references_; | 146 ApiGrowableArray<BackRefNode*> backward_references_; |
148 ApiGrowableArray<Dart_CObject*> vm_isolate_references_; | 147 ApiGrowableArray<Dart_CObject*> vm_isolate_references_; |
149 Dart_CObject** vm_symbol_references_; | 148 Dart_CObject** vm_symbol_references_; |
150 | 149 |
151 Dart_CObject type_arguments_marker; | 150 Dart_CObject type_arguments_marker; |
152 Dart_CObject dynamic_type_marker; | 151 Dart_CObject dynamic_type_marker; |
153 static _Dart_CObject* singleton_uint32_typed_data_; | 152 static _Dart_CObject* singleton_uint32_typed_data_; |
154 }; | 153 }; |
155 | 154 |
156 | |
157 class ApiMessageWriter : public BaseWriter { | 155 class ApiMessageWriter : public BaseWriter { |
158 public: | 156 public: |
159 static const intptr_t kInitialSize = 512; | 157 static const intptr_t kInitialSize = 512; |
160 ApiMessageWriter(uint8_t** buffer, ReAlloc alloc) | 158 ApiMessageWriter(uint8_t** buffer, ReAlloc alloc) |
161 : BaseWriter(buffer, alloc, NULL, kInitialSize), | 159 : BaseWriter(buffer, alloc, NULL, kInitialSize), |
162 object_id_(0), | 160 object_id_(0), |
163 forward_list_(NULL), | 161 forward_list_(NULL), |
164 forward_list_length_(0), | 162 forward_list_length_(0), |
165 forward_id_(0) { | 163 forward_id_(0) { |
166 ASSERT(kDartCObjectTypeMask >= Dart_CObject_kNumberOfTypes - 1); | 164 ASSERT(kDartCObjectTypeMask >= Dart_CObject_kNumberOfTypes - 1); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 bool WriteCObjectInlined(Dart_CObject* object, Dart_CObject_Type type); | 196 bool WriteCObjectInlined(Dart_CObject* object, Dart_CObject_Type type); |
199 | 197 |
200 intptr_t object_id_; | 198 intptr_t object_id_; |
201 Dart_CObject** forward_list_; | 199 Dart_CObject** forward_list_; |
202 intptr_t forward_list_length_; | 200 intptr_t forward_list_length_; |
203 intptr_t forward_id_; | 201 intptr_t forward_id_; |
204 | 202 |
205 DISALLOW_COPY_AND_ASSIGN(ApiMessageWriter); | 203 DISALLOW_COPY_AND_ASSIGN(ApiMessageWriter); |
206 }; | 204 }; |
207 | 205 |
208 | |
209 // This class handles translation of certain RawObjects to CObjects for | 206 // This class handles translation of certain RawObjects to CObjects for |
210 // NativeMessageHandlers. | 207 // NativeMessageHandlers. |
211 // | 208 // |
212 // TODO(zra): Expand to support not only null, but also other VM heap objects | 209 // TODO(zra): Expand to support not only null, but also other VM heap objects |
213 // as well. | 210 // as well. |
214 class ApiObjectConverter : public AllStatic { | 211 class ApiObjectConverter : public AllStatic { |
215 public: | 212 public: |
216 static bool CanConvert(const RawObject* raw_obj) { | 213 static bool CanConvert(const RawObject* raw_obj) { |
217 return !raw_obj->IsHeapObject() || (raw_obj == Object::null()); | 214 return !raw_obj->IsHeapObject() || (raw_obj == Object::null()); |
218 } | 215 } |
(...skipping 24 matching lines...) Expand all Loading... |
243 | 240 |
244 static void ConvertNull(Dart_CObject* c_obj) { | 241 static void ConvertNull(Dart_CObject* c_obj) { |
245 c_obj->type = Dart_CObject_kNull; | 242 c_obj->type = Dart_CObject_kNull; |
246 c_obj->value.as_int64 = 0; | 243 c_obj->value.as_int64 = 0; |
247 } | 244 } |
248 }; | 245 }; |
249 | 246 |
250 } // namespace dart | 247 } // namespace dart |
251 | 248 |
252 #endif // RUNTIME_VM_DART_API_MESSAGE_H_ | 249 #endif // RUNTIME_VM_DART_API_MESSAGE_H_ |
OLD | NEW |