lib/bufio: add Option C parallel vstream API (#94 fold-e4)

Adds bufio_vstream + isbuffered_v alongside the pre-vtable
bufio.init / bufio.isbuffered surface, mirroring fold-e2's
lib/memio and fold-e3's lib/fmt parallel-API shape. The OLD
bufio.ww surface stays untouched; fold-eFinal (#50) atomically
flips the package shape, drops the `_v` suffix, and retires the
legacy callbacks.

bufio_ctx wraps an underlying *io.stream (OLD API) — bufio_vstream
src parameter type stays *io.stream until io fold-2 lands
`handle = (file | int)` (drew-deferred). vt is the first field
for the intrusive vstream→*bufio_ctx cast, same shape as
memio/fmt vstream wrappers.

Sibling task filed:

  #210  struct-lit slice-typed field silently drops under
        alloc(T{slice = val})?. Parallel to #207 for slice fields;
        scalar/ptr fields in the same alloc-struct-lit populate
        correctly. Workaround: post-alloc field-assign
        c.slicefield = val. Documented inline; drops out on close.

Other deferrals retained inline: #206 cast wrappers (3 vtable
wire-up + 2 isbuffered_v comparand), #173 nomem-widen for the
io.closed → io.error boundary, #207 alloc-zero-chain for vt.

bufio is not embedded in any selfhost combined.ww (test-only);
no Makefile regen needed (#110-blind safe).

test/wcc/778_bufio_vstream_run pins the 5-row scenario set:
write+flush, read+refill, isbuffered_v discriminator, OLD/NEW
boundary check, and a branched-callee #105 row. cs+ww+byte-id
green on all 5 rows.

make test: 211 passed (was 210).
This commit is contained in:
2026-05-29 10:24:02 +09:00
parent 2a405a4ad6
commit c62e8e5560
3 changed files with 803 additions and 0 deletions

View File

@@ -328,6 +328,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
$(BIN)/test_io_vtable_run \
$(BIN)/test_memio_vstream_run \
$(BIN)/test_fmt_vstream_run \
$(BIN)/test_bufio_vstream_run \
$(BIN)/test_use_promote_alias \
$(BIN)/test_field_signed $(BIN)/test_frame_argcount \
$(BIN)/test_selfhost $(BIN)/test_w6a_ww $(BIN)/test_w6l_ww \
@@ -704,6 +705,13 @@ $(BIN)/test_fmt_vstream_run: test/wcc/777_fmt_vstream_run.c \
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
$(BIN)/test_bufio_vstream_run: test/wcc/778_bufio_vstream_run.c \
$(BIN)/ww $(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
$(BIN)/ww_ww $(BIN)/w6c_ww $(BIN)/w6a_ww $(BIN)/w6l_ww \
lib/bufio/bufio.ww lib/bufio/vstream.ww \
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
$(BIN)/test_arrlit_str_full: test/wcc/711_arrlit_str_full.c \
$(BIN)/ww $(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
$(BIN)/ww_ww $(BIN)/w6c_ww $(BIN)/w6a_ww $(BIN)/w6l_ww \