Commit 5ace519a authored by Nils Fenner's avatar Nils Fenner

fix least dependend code related to const-correctness

parent c08609d5
...@@ -466,10 +466,10 @@ public: ...@@ -466,10 +466,10 @@ public:
inline MessageSize totalSize() const { return _reader.totalSize().asPublic(); } inline MessageSize totalSize() const { return _reader.totalSize().asPublic(); }
kj::ArrayPtr<const byte> getDataSection() { kj::ArrayPtr<const byte> getDataSection() const {
return _reader.getDataSectionAsBlob(); return _reader.getDataSectionAsBlob();
} }
List<AnyPointer>::Reader getPointerSection() { List<AnyPointer>::Reader getPointerSection() const {
return List<AnyPointer>::Reader(_reader.getPointerSectionAsList()); return List<AnyPointer>::Reader(_reader.getPointerSectionAsList());
} }
...@@ -646,10 +646,10 @@ public: ...@@ -646,10 +646,10 @@ public:
: _reader(_::PointerHelpers<FromReader<T>>::getInternalReader(kj::fwd<T>(value))) {} : _reader(_::PointerHelpers<FromReader<T>>::getInternalReader(kj::fwd<T>(value))) {}
#endif #endif
inline ElementSize getElementSize() { return _reader.getElementSize(); } inline ElementSize getElementSize() const { return _reader.getElementSize(); }
inline uint size() { return unbound(_reader.size() / ELEMENTS); } inline uint size() const { return unbound(_reader.size() / ELEMENTS); }
inline kj::ArrayPtr<const byte> getRawBytes() { return _reader.asRawBytes(); } inline kj::ArrayPtr<const byte> getRawBytes() const { return _reader.asRawBytes(); }
Equality equals(AnyList::Reader right) const; Equality equals(AnyList::Reader right) const;
bool operator==(AnyList::Reader right) const; bool operator==(AnyList::Reader right) const;
...@@ -661,7 +661,7 @@ public: ...@@ -661,7 +661,7 @@ public:
return _reader.totalSize().asPublic(); return _reader.totalSize().asPublic();
} }
template <typename T> ReaderFor<T> as() { template <typename T> ReaderFor<T> as() const {
// T must be List<U>. // T must be List<U>.
return ReaderFor<T>(_reader); return ReaderFor<T>(_reader);
} }
......
...@@ -3079,7 +3079,7 @@ Data::Reader ListReader::asData() { ...@@ -3079,7 +3079,7 @@ Data::Reader ListReader::asData() {
return Data::Reader(reinterpret_cast<const byte*>(ptr), unbound(elementCount / ELEMENTS)); return Data::Reader(reinterpret_cast<const byte*>(ptr), unbound(elementCount / ELEMENTS));
} }
kj::ArrayPtr<const byte> ListReader::asRawBytes() { kj::ArrayPtr<const byte> ListReader::asRawBytes() const {
KJ_REQUIRE(structPointerCount == ZERO * POINTERS, KJ_REQUIRE(structPointerCount == ZERO * POINTERS,
"Expected data only, got pointers.") { "Expected data only, got pointers.") {
return kj::ArrayPtr<const byte>(); return kj::ArrayPtr<const byte>();
......
...@@ -597,8 +597,8 @@ public: ...@@ -597,8 +597,8 @@ public:
inline StructDataBitCount getDataSectionSize() const { return dataSize; } inline StructDataBitCount getDataSectionSize() const { return dataSize; }
inline StructPointerCount getPointerSectionSize() const { return pointerCount; } inline StructPointerCount getPointerSectionSize() const { return pointerCount; }
inline kj::ArrayPtr<const byte> getDataSectionAsBlob(); inline kj::ArrayPtr<const byte> getDataSectionAsBlob() const;
inline _::ListReader getPointerSectionAsList(); inline _::ListReader getPointerSectionAsList() const;
kj::Array<word> canonicalize(); kj::Array<word> canonicalize();
...@@ -780,7 +780,7 @@ public: ...@@ -780,7 +780,7 @@ public:
Data::Reader asData(); Data::Reader asData();
// Reinterpret the list as a blob. Throws an exception if the elements are not byte-sized. // Reinterpret the list as a blob. Throws an exception if the elements are not byte-sized.
kj::ArrayPtr<const byte> asRawBytes(); kj::ArrayPtr<const byte> asRawBytes() const;
template <typename T> template <typename T>
KJ_ALWAYS_INLINE(T getDataElement(ElementCount index) const); KJ_ALWAYS_INLINE(T getDataElement(ElementCount index) const);
...@@ -1080,12 +1080,12 @@ inline PointerBuilder StructBuilder::getPointerField(StructPointerOffset ptrInde ...@@ -1080,12 +1080,12 @@ inline PointerBuilder StructBuilder::getPointerField(StructPointerOffset ptrInde
// ------------------------------------------------------------------- // -------------------------------------------------------------------
inline kj::ArrayPtr<const byte> StructReader::getDataSectionAsBlob() { inline kj::ArrayPtr<const byte> StructReader::getDataSectionAsBlob() const {
return kj::ArrayPtr<const byte>(reinterpret_cast<const byte*>(data), return kj::ArrayPtr<const byte>(reinterpret_cast<const byte*>(data),
unbound(dataSize / BITS_PER_BYTE / BYTES)); unbound(dataSize / BITS_PER_BYTE / BYTES));
} }
inline _::ListReader StructReader::getPointerSectionAsList() { inline _::ListReader StructReader::getPointerSectionAsList() const {
return _::ListReader(segment, capTable, pointers, pointerCount * (ONE * ELEMENTS / POINTERS), return _::ListReader(segment, capTable, pointers, pointerCount * (ONE * ELEMENTS / POINTERS),
ONE * POINTERS * BITS_PER_POINTER / ELEMENTS, ZERO * BITS, ONE * POINTERS, ONE * POINTERS * BITS_PER_POINTER / ELEMENTS, ZERO * BITS, ONE * POINTERS,
ElementSize::POINTER, nestingLimit); ElementSize::POINTER, nestingLimit);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment