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_DATASTREAM_H_ | 5 #ifndef VM_DATASTREAM_H_ |
6 #define VM_DATASTREAM_H_ | 6 #define VM_DATASTREAM_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "platform/utils.h" | 9 #include "platform/utils.h" |
10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 typedef uint8_t* (*ReAlloc)(uint8_t* ptr, intptr_t old_size, intptr_t new_size); | 23 typedef uint8_t* (*ReAlloc)(uint8_t* ptr, intptr_t old_size, intptr_t new_size); |
24 | 24 |
25 // Stream for reading various types from a buffer. | 25 // Stream for reading various types from a buffer. |
26 class ReadStream : public ValueObject { | 26 class ReadStream : public ValueObject { |
27 public: | 27 public: |
28 ReadStream(const uint8_t* buffer, intptr_t size) : buffer_(buffer), | 28 ReadStream(const uint8_t* buffer, intptr_t size) : buffer_(buffer), |
29 current_(buffer), | 29 current_(buffer), |
30 end_(buffer + size) {} | 30 end_(buffer + size) {} |
31 | 31 |
| 32 void SetStream(const uint8_t* buffer, intptr_t size) { |
| 33 buffer_ = buffer; |
| 34 current_ = buffer; |
| 35 end_ = buffer + size; |
| 36 } |
| 37 |
32 template<int N, typename T> | 38 template<int N, typename T> |
33 class Raw { }; | 39 class Raw { }; |
34 | 40 |
35 template<typename T> | 41 template<typename T> |
36 class Raw<1, T> { | 42 class Raw<1, T> { |
37 public: | 43 public: |
38 static T Read(ReadStream* st) { | 44 static T Read(ReadStream* st) { |
39 return bit_cast<T>(st->ReadByte()); | 45 return bit_cast<T>(st->ReadByte()); |
40 } | 46 } |
41 }; | 47 }; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 intptr_t current_size_; | 253 intptr_t current_size_; |
248 ReAlloc alloc_; | 254 ReAlloc alloc_; |
249 intptr_t increment_size_; | 255 intptr_t increment_size_; |
250 | 256 |
251 DISALLOW_COPY_AND_ASSIGN(WriteStream); | 257 DISALLOW_COPY_AND_ASSIGN(WriteStream); |
252 }; | 258 }; |
253 | 259 |
254 } // namespace dart | 260 } // namespace dart |
255 | 261 |
256 #endif // VM_DATASTREAM_H_ | 262 #endif // VM_DATASTREAM_H_ |
OLD | NEW |