Repository navigation
feat(seq): RowSeq, a collector for rows the stream cannot read on its own - #151
Merged
Merged
Conversation
…ot read MessageSeq hands each element to IStreamImpl::read, which reads a message or a span of native scalars and nothing else. A row that is itself a wrapper sequence (array<array<string>>, array<array<struct>>, deeper) is neither, and an enum or boolean row has to bind through a view of its elements. The generator therefore emitted its own collector for such rows, per field, into every user's header (sofa-buffers/generator#629) -- a static helper whose shape is the same for every schema, and one the corelib suite could not see: generator#627 found it applying the index bound before the §7.3 wire-type test. RowSeq<C, Reader> takes the row read from the caller and owns the rest, in the order every other collector here applies it: - §7.3 first: an element whose wire type contradicts the row's is skipped before the index bound and before the placement. The row's wire type is published as elemWire, so the stream runs the same test at the element header and applies the bound only to an element that survives it. - the §5.1 index bound in §6.3's categories (detail::seqIndexAdmitted): schema count, receiver cap, destination capacity. - placement at dest[id], with the gap filled. - §7.4 replace-whole via prepare(). The Reader states the row's wire type through a static constexpr wire() -- a function, because a local class, which is where generated code declares it, may not have static data members -- and reads the placed row in operator(). The schema count and the receiver cap are constructor arguments, as on StringSeq, so neither can be left out. test_roundtrip.cpp's rowSeqCollector() pins placement with a gap, byte-by-byte resume, §7.3 before the bound (in range and past it), §7.4 replace and the skipped-repeat case, all three refusal tiers, heap-free storage with no allocation, and an array-wire row. Removing the §7.3 test from RowSeq fails two of its checks.
clang instantiates a polymorphic class's virtual members for sizeof, so pairing ByteRowReader with a container of string rows failed to compile there. Compare against the members' size instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
sofab::RowSeq<C, Reader>: a wrapper-array collector for rows the stream cannot read on its own: a row that is itself a wrapper sequence (array<array<string>>,array<array<struct>>, deeper), or an enum/boolean row that has to bind through a view of its elements.MessageSeqhands each element toIStreamImpl::read, which reads a message or a span of native scalars and nothing else. For other rows the generator emitted its own collector per field into every user's header. That collector was a static helper, and this suite could not see it. sofa-buffers/generator#627 found it applying the index bound before the §7.3 test.RowSeqtakes the row read from the caller (Reader) and owns the rest, in the order every other collector here applies it:elemWire, so the stream runs the test at the element header, ahead of the bound.detail::seqIndexAdmitted).dest[id], with the gap filled.prepare().The reader has two parts:
static constexpr detail::Wire wire()names the row's wire type. It is a function because a local class, where generated code declares the reader, may not have static data members.operator()(IStreamImpl &, Row &)reads the placed row.The schema
countand the receiver index cap are constructor arguments, as onStringSeq, so neither can be left out.Tests
test_roundtrip.cpprowSeqCollector()covers:Removing the §7.3 test from
RowSeqfails two of these checks.ctestpasses 6/6.Consumers
sofa-buffers/generator#629 makes the C++ backend emit only the reader and this call. The generator PR follows. Its
lang-cppjob pins corelibmain, so it goes green once this and the corelib-c-cpp twin are merged.