adjust data section method types & names

parent 67009d41
......@@ -134,7 +134,7 @@ StructEqualityResult equal(AnyList::Reader left, AnyList::Reader right) {
case ElementSize::FOUR_BYTES:
case ElementSize::EIGHT_BYTES:
if(left.getElementSize() == right.getElementSize()) {
if(memcmp(left.getData().begin(), right.getData().begin(), left.getData().size()) == 0) {
if(memcmp(left.getRawBytes().begin(), right.getRawBytes().begin(), left.getRawBytes().size()) == 0) {
return StructEqualityResult::EQUAL;
} else {
return StructEqualityResult::NOT_EQUAL;
......
......@@ -427,7 +427,7 @@ public:
: _reader(_::PointerHelpers<FromReader<T>>::getInternalReader(kj::fwd<T>(value))) {}
#endif
Data::Reader getDataSection() {
kj::ArrayPtr<const byte> getDataSection() {
return _reader.getDataSectionAsBlob();
}
List<AnyPointer>::Reader getPointerSection() {
......@@ -457,7 +457,7 @@ public:
: _builder(_::PointerHelpers<FromBuilder<T>>::getInternalBuilder(kj::fwd<T>(value))) {}
#endif
inline Data::Builder getDataSection() {
inline kj::ArrayPtr<byte> getDataSection() {
return _builder.getDataSectionAsBlob();
}
List<AnyPointer>::Builder getPointerSection() {
......@@ -571,7 +571,7 @@ public:
inline ElementSize getElementSize() { return _reader.getElementSize(); }
inline uint size() { return _reader.size() / ELEMENTS; }
inline Data::Reader getData() { return _reader.asDataOfAnySize(); }
inline kj::ArrayPtr<const byte> getRawBytes() { return _reader.asRawBytes(); }
template <typename T> ReaderFor<T> as() {
// T must be List<U>.
......
......@@ -2605,13 +2605,13 @@ Data::Reader ListReader::asData() {
return Data::Reader(reinterpret_cast<const byte*>(ptr), elementCount / ELEMENTS);
}
Data::Reader ListReader::asDataOfAnySize() {
kj::ArrayPtr<const byte> ListReader::asRawBytes() {
KJ_REQUIRE(structPointerCount == 0 * POINTERS,
"Expected data only, got pointers.") {
return Data::Reader();
return kj::ArrayPtr<const byte>();
}
return Data::Reader(reinterpret_cast<const byte*>(ptr), structDataSize * elementCount / ELEMENTS);
return kj::ArrayPtr<const byte>(reinterpret_cast<const byte*>(ptr), structDataSize * elementCount / ELEMENTS);
}
......
......@@ -406,7 +406,7 @@ public:
inline BitCount getDataSectionSize() const { return dataSize; }
inline WirePointerCount getPointerSectionSize() const { return pointerCount; }
inline Data::Builder getDataSectionAsBlob();
inline kj::ArrayPtr<byte> getDataSectionAsBlob();
inline _::ListBuilder getPointerSectionAsList();
template <typename T>
......@@ -487,7 +487,7 @@ public:
inline BitCount getDataSectionSize() const { return dataSize; }
inline WirePointerCount getPointerSectionSize() const { return pointerCount; }
inline Data::Reader getDataSectionAsBlob();
inline kj::ArrayPtr<const byte> getDataSectionAsBlob();
inline _::ListReader getPointerSectionAsList();
template <typename T>
......@@ -654,7 +654,7 @@ public:
Data::Reader asData();
// Reinterpret the list as a blob. Throws an exception if the elements are not byte-sized.
Data::Reader asDataOfAnySize();
kj::ArrayPtr<const byte> asRawBytes();
template <typename T>
KJ_ALWAYS_INLINE(T getDataElement(ElementCount index) const);
......@@ -821,8 +821,8 @@ inline PointerReader PointerReader::getRootUnchecked(const word* location) {
// -------------------------------------------------------------------
inline Data::Builder StructBuilder::getDataSectionAsBlob() {
return Data::Builder(reinterpret_cast<byte*>(data), dataSize / BITS_PER_BYTE / BYTES);
inline kj::ArrayPtr<byte> StructBuilder::getDataSectionAsBlob() {
return kj::ArrayPtr<byte>(reinterpret_cast<byte*>(data), dataSize / BITS_PER_BYTE / BYTES);
}
inline _::ListBuilder StructBuilder::getPointerSectionAsList() {
......@@ -905,8 +905,8 @@ inline PointerBuilder StructBuilder::getPointerField(WirePointerCount ptrIndex)
// -------------------------------------------------------------------
inline Data::Reader StructReader::getDataSectionAsBlob() {
return Data::Reader(reinterpret_cast<const byte*>(data), dataSize / BITS_PER_BYTE / BYTES);
inline kj::ArrayPtr<const byte> StructReader::getDataSectionAsBlob() {
return kj::ArrayPtr<const byte>(reinterpret_cast<const byte*>(data), dataSize / BITS_PER_BYTE / BYTES);
}
inline _::ListReader StructReader::getPointerSectionAsList() {
......
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