Skip to content

feat(seq): template MessageSeq on the container, like StringSeq - #117

Merged
Andste82 merged 1 commit into
mainfrom
feat/message-seq-container-template
Aug 19, 2026
Merged

Andste82 merged 1 commit into
mainfrom
feat/message-seq-container-template

Conversation

@Andste82

Copy link
Copy Markdown
Member

Closes #116. The prerequisite for generated C++ dropping sofabgen::WrapperSeq.

The change

MessageSeq was templated on the element and held std::vector<T> *out —
the destination was hard-wired. StringSeq is templated on the container and
holds C &out, which is why it already serves both storage profiles. This brings
MessageSeq to the same shape, so it can collect into an InlineVector<T, N> as
well as a std::vector.

That is exactly what generated code needs: the static-storage profiles
instantiate their own collector as WrapperSeq<sofab::InlineVector<Elem, N>>,
which the element-templated MessageSeq could not express — which is also why
MessageSeq was emitted zero times while WrapperSeq was emitted instead
(sofa-buffers/generator#345).

The old spelling keeps working

detail::namesSeqContainer() tells the two readings apart from the argument
alone: an argument names a container when its value_type is something this
collector reads as an element (a message, or a row container). The readings can
only collide for an element that is itself a sequence of messages or a row of
rows — and under the element reading such an element is handed to
IStreamImpl::read, which has no overload for it. So what the container reading
takes over is code that never compiled. CappedMsg in the test file still uses
MessageSeq<SeqRow> and is exercised as before.

Tests

Header-only, so built directly with g++ 15.2 (-std=c++20), no cmake in this
environment:

suite result
test_roundtrip.cpp 2421 checks, 0 failures
test_roundtrip.cpp with -DSOFAB_STRICT_UTF8=0 2398 checks, 0 failures
test_vectors.cpp against assets/test_vectors.json 81 vectors, 729 checks, 0 failures; 11 invalid_utf8 vectors

One fix to a new test

"the rejected element is never allocated for" failed as written. The
destination was correctly empty, but the allocation counter was captured at the
top of the block — before the decoder and the wire vector were constructed — so
it counted four setup allocations and would have passed or failed on setup rather
than on the rejected element. Moved the capture to just before feed, matching
the neighbouring bound-vs-cap case that does the same thing. With it, the
assertion tests what it says and passes.

Provenance

Written by a subagent that could not build, test or push — every shell call in its
session was refused by a worktree-isolation guard — so it left the work
uncommitted in the checkout. This picks it up, runs the suites it never got to
run, fixes the one failure that surfaced, and opens the PR.

Part of sofa-buffers/generator#345.

MessageSeq was templated on the ELEMENT and held std::vector<T> *out, i.e.
the destination was hard-wired. StringSeq is templated on the CONTAINER and
holds C &out, which is why it already serves both storage profiles. This
brings MessageSeq to the same shape, so it can collect into an
InlineVector<T, N> as well as a std::vector.

That is the prerequisite for generated C++ dropping its own
sofabgen::WrapperSeq: the static-storage profiles instantiate it as
WrapperSeq<sofab::InlineVector<Elem, N>>, which the element-templated
MessageSeq could not express — which is also why MessageSeq was emitted zero
times and WrapperSeq was emitted instead (generator#345).

The old spelling keeps working. detail::namesSeqContainer() tells the two
readings apart from the argument alone: an argument names a container when
its value_type is something this collector reads as an element. The two can
only collide for an element that is itself a sequence of messages or a row of
rows, and under the element reading such an element goes to IStreamImpl::read,
which has no overload for it — so what the container reading takes over is
code that never compiled.

Closes #116.
@Andste82
Andste82 merged commit 31e4b15 into main Aug 19, 2026
10 of 11 checks passed
@Andste82
Andste82 deleted the feat/message-seq-container-template branch August 19, 2026 05:20
@Andste82 Andste82 mentioned this pull request Sep 24, 2026
Andste82 added a commit that referenced this pull request Sep 24, 2026
The git tag is the source of truth for the version; this brings every package
manifest in line with the v0.11.0 tag that follows.

Since v0.10.0 this library changes wire output (#99: trailing default array
elements stay on the wire; #104: arrays and payloads past the §6.2 format
ceiling are refused) and public API (#77, #76, #127/#128, #135, #117). Both
are breaking under the pre-1.0 rule that a minor bump may break API or wire
output, hence 0.10 -> 0.11.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MessageSeq: template it on the container, like StringSeq, so generated code can use it

1 participant