| 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 VM_DART_API_MESSAGE_H_ | 5 #ifndef VM_DART_API_MESSAGE_H_ |
| 6 #define VM_DART_API_MESSAGE_H_ | 6 #define VM_DART_API_MESSAGE_H_ |
| 7 | 7 |
| 8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
| 9 #include "vm/snapshot.h" | 9 #include "vm/snapshot.h" |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 // Use this C structure for reading internal objects in the serialized | 13 // Use this C structure for reading internal objects in the serialized |
| 14 // data. These are objects that we need to process in order to | 14 // data. These are objects that we need to process in order to |
| 15 // generate the Dart_CObject graph but that we don't want to expose in | 15 // generate the Dart_CObject graph but that we don't want to expose in |
| 16 // that graph. | 16 // that graph. |
| 17 // TODO(sjesse): Remove this when message serialization format is | 17 // TODO(sjesse): Remove this when message serialization format is |
| 18 // updated. | 18 // updated. |
| 19 struct Dart_CObject_Internal : public Dart_CObject { | 19 struct Dart_CObject_Internal : public Dart_CObject { |
| 20 enum Type { | 20 enum Type { |
| 21 kTypeArguments = Dart_CObject::kNumberOfTypes, | 21 kTypeArguments = Dart_CObject::kNumberOfTypes, |
| 22 kDynamicType, | 22 kDynamicType, |
| 23 }; | 23 }; |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 | 26 |
| 27 // Reads a message snapshot into a C structure. | 27 // Reads a message snapshot into a C structure. |
| 28 class ApiMessageReader : public BaseReader { | 28 class ApiMessageReader : public BaseReader { |
| 29 public: | 29 public: |
| 30 // The allocator passed is used to allocate memory for the C structure used |
| 31 // to represent the message snapshot. This allocator must keep track of the |
| 32 // memory allocated as there is no way to run through the resulting C |
| 33 // structure and free the individual pieces. Using a zone based allocator is |
| 34 // recommended. |
| 30 ApiMessageReader(const uint8_t* buffer, intptr_t length, ReAlloc alloc); | 35 ApiMessageReader(const uint8_t* buffer, intptr_t length, ReAlloc alloc); |
| 31 ~ApiMessageReader() { } | 36 ~ApiMessageReader() { } |
| 32 | 37 |
| 33 Dart_CObject* ReadMessage(); | 38 Dart_CObject* ReadMessage(); |
| 34 | 39 |
| 35 private: | 40 private: |
| 36 class BackRefNode { | 41 class BackRefNode { |
| 37 public: | 42 public: |
| 38 BackRefNode(Dart_CObject* reference, DeserializeState state) | 43 BackRefNode(Dart_CObject* reference, DeserializeState state) |
| 39 : reference_(reference), state_(state) {} | 44 : reference_(reference), state_(state) {} |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 Dart_CObject** forward_list_; | 160 Dart_CObject** forward_list_; |
| 156 intptr_t forward_list_length_; | 161 intptr_t forward_list_length_; |
| 157 intptr_t forward_id_; | 162 intptr_t forward_id_; |
| 158 | 163 |
| 159 DISALLOW_COPY_AND_ASSIGN(ApiMessageWriter); | 164 DISALLOW_COPY_AND_ASSIGN(ApiMessageWriter); |
| 160 }; | 165 }; |
| 161 | 166 |
| 162 } // namespace dart | 167 } // namespace dart |
| 163 | 168 |
| 164 #endif // VM_DART_API_MESSAGE_H_ | 169 #endif // VM_DART_API_MESSAGE_H_ |
| OLD | NEW |