| Index: runtime/vm/object.h
|
| diff --git a/runtime/vm/object.h b/runtime/vm/object.h
|
| index 59dee1d3f7d1faace9666048df7eb9fc1751a618..a7fa2f8ff6de44f883f148049fe3ebc4d2f89d24 100644
|
| --- a/runtime/vm/object.h
|
| +++ b/runtime/vm/object.h
|
| @@ -2777,6 +2777,56 @@ class ImmutableArray : public Array {
|
| };
|
|
|
|
|
| +class ByteBuffer : public Instance {
|
| + public:
|
| + intptr_t Length() const {
|
| + ASSERT(!IsNull());
|
| + return Smi::Value(raw_ptr()->length_);
|
| + }
|
| +
|
| + template<typename T>
|
| + T At(intptr_t index) const {
|
| + return *Addr<T>(index);
|
| + }
|
| + template<typename T>
|
| + void SetAt(intptr_t index, T value) const {
|
| + *Addr<T>(index) = value;
|
| + }
|
| +
|
| + virtual bool Equals(const Instance& other) const;
|
| +
|
| + static intptr_t InstanceSize() {
|
| + return RoundedAllocationSize(sizeof(RawByteBuffer));
|
| + }
|
| +
|
| + static RawByteBuffer* New(uint8_t* data,
|
| + intptr_t len,
|
| + Heap::Space space = Heap::kNew);
|
| +
|
| + private:
|
| + template<typename T>
|
| + T* Addr(intptr_t index) const {
|
| + intptr_t base = index * sizeof(T);
|
| + intptr_t limit = base + sizeof(T);
|
| + // TODO(iposva): Determine if we should throw an exception here.
|
| + ASSERT((base >= 0) && (limit <= Length()));
|
| + uint8_t* addr = &raw_ptr()->data_[base];
|
| + return reinterpret_cast<T*>(addr);
|
| + }
|
| +
|
| + void SetLength(intptr_t value) {
|
| + raw_ptr()->length_ = Smi::New(value);
|
| + }
|
| +
|
| + void SetData(uint8_t* data) const {
|
| + raw_ptr()->data_ = data;
|
| + }
|
| +
|
| + HEAP_OBJECT_IMPLEMENTATION(ByteBuffer, Instance);
|
| + friend class Class;
|
| +};
|
| +
|
| +
|
| class Closure : public Instance {
|
| public:
|
| RawFunction* function() const { return raw_ptr()->function_; }
|
|
|