lib: collapse the parallel vstream scaffold onto the single Hare io surface (#94 fold-eFinal)
The Option-C parallel _v vstream API was scaffolding to bring the io stack up alongside the old surface; carrying both permanently is a rule-9 divergence from ref/hare, which has exactly one io surface. Collapse onto that surface (stream = *vtable, ref/hare/io/stream.ha) and rename the _v symbols to their Hare names (io vstream->stream, fmt vfprint->fprint, bufio/memio/log surfaces, log.new). Deletes the 4 lib/*/vstream.ww scaffold files; regenerates w6c/wwdump combined.ww. cstage and wwstage stay byte-identical and combined_ww_fresh holds; all 220 tests pass.
This commit is contained in:
46
lib/io/io.ww
46
lib/io/io.ww
@@ -1,44 +1,26 @@
|
||||
// io — stream interface (Plan 9 Bio / Hare io::stream shape).
|
||||
//
|
||||
// No closures, no methods. A `stream` is a struct of function
|
||||
// pointers plus a `ctx: *void`. The error channel is the return
|
||||
// value of read/write/close — Hare-shaped tagged unions instead of
|
||||
// errno-style integer sentinels.
|
||||
// No closures, no methods. A `stream` is a pointer to a `vtable` of
|
||||
// function pointers (lib/io/stream.ww); read/write/close dispatch
|
||||
// through it. The error channel is the return value — Hare-shaped
|
||||
// tagged unions instead of errno-style integer sentinels.
|
||||
//
|
||||
// This file owns the eof / underread variant tags; lib/io/stream.ww
|
||||
// owns the `vtable` + `stream` + read/write/close dispatchers, and
|
||||
// lib/io/types.ww owns the error union, mode/whence enums, and the
|
||||
// reader/writer/closer fn-type aliases. #94 fold-eFinal collapsed the
|
||||
// pre-vtable `stream` struct + `closed` tag into the single vtable
|
||||
// surface; the dispatchers are read/write/close (over `stream`),
|
||||
// final over `handle` at io fold-2 (#5).
|
||||
package io;
|
||||
|
||||
// eof — read past the end of the stream. Hare uses the `done`
|
||||
// singleton for EOF; ww doesn't have `done` yet so we ship a
|
||||
// named-void variant tag.
|
||||
package io;
|
||||
|
||||
// named-void variant tag. Lifts to `done` with #93.
|
||||
export type eof = void;
|
||||
|
||||
// closed — operation attempted on a stream that has already been
|
||||
// closed. ww-specific: Hare's io collapses this into the wider
|
||||
// errors union, but our stream vtable has no handle-ownership
|
||||
// semantics, so a distinct tag is honest. Named void.
|
||||
export type closed = void;
|
||||
|
||||
// underread — an I/O handle hit eof partway through a fixed-size
|
||||
// read. Payload is the byte count actually delivered. Mirrors
|
||||
// Hare's `io::underread = !size`; ww uses i32 because the
|
||||
// underlying buffer-length type is i32 today.
|
||||
export type underread = !i32;
|
||||
|
||||
export type stream = struct {
|
||||
ctx: *void,
|
||||
read: fn(s: *stream, buf: []u8) (i32 | eof | closed),
|
||||
write: fn(s: *stream, buf: []u8) (i32 | closed),
|
||||
close: fn(s: *stream) (void | closed),
|
||||
};
|
||||
|
||||
export fn read(s: *stream, buf: []u8) (i32 | eof | closed) = {
|
||||
return s.read(s, buf);
|
||||
};
|
||||
|
||||
export fn write(s: *stream, buf: []u8) (i32 | closed) = {
|
||||
return s.write(s, buf);
|
||||
};
|
||||
|
||||
export fn close(s: *stream) (void | closed) = {
|
||||
return s.close(s);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user