lib: io.handle union + seeker + handle-typed read/write/close/seek dispatch (#5)
Ports ref/hare/io handle.ha: a handle is (file | *stream); ww stream is already *vtable (#94 collapse) so the payload is (file | stream). file=i32 (Hare int is 32-bit, ww int is 8B word -- width-faithful, USER-ruled). read/write/close/seek/tell match on the handle: file-arm to os.read/write/close/lseek (os plays Hare sys role), stream-arm to the unchanged st_* vtable bodies; seeker is the 4th vtable slot (copier deferred). On a file-arm syscall error the stub returns errors.unsupported with a #199b marker -- faithful errno to io.error needs io.error to spread ...errors.error (#204/#199b-blocked); only the error value is lossy until then, the type stays faithful. Regenerates w6c/wwdump combined.ww.
This commit is contained in:
@@ -37,6 +37,21 @@ export type whence = enum i32 {
|
||||
END = 2,
|
||||
};
|
||||
|
||||
// ref/hare/io/+linux/platform_file.ha:13. Hare's `file = int`; on
|
||||
// linux/x86_64 Hare's `int` is 32-bit, but ww's `int` is an 8B machine
|
||||
// word, so a literal `int` here would be width-wrong for a fd. i32 is
|
||||
// width-faithful to Hare's real fd width (USER-ruled 2026-05-31).
|
||||
export type file = i32;
|
||||
|
||||
// ref/hare/io/arch+x86_64.ha:6. ABI-compatible with POSIX off_t.
|
||||
export type off = i64;
|
||||
|
||||
// ref/hare/io/handle.ha:12. Hare spells it `(file | *stream)`; ww's
|
||||
// `stream` is already `*vtable` (the #94 collapse absorbed Hare's
|
||||
// `*stream` indirection), so the faithful ww payload is `(file |
|
||||
// stream)`, NOT a literal `*stream` which would be a double-pointer.
|
||||
export type handle = (file | stream);
|
||||
|
||||
// ref/hare/io/types.ha:11 spreads `...errors::error` into the union;
|
||||
// ww enumerates the tags explicitly (ken's #204-block — spread of an
|
||||
// errors-side tagged into this union triggers a wrapper-vs-flatten
|
||||
@@ -58,3 +73,8 @@ export type writer = fn(s: stream, buf: []u8) (size | error);
|
||||
|
||||
// ref/hare/io/types.ha:55.
|
||||
export type closer = fn(s: stream) (void | error);
|
||||
|
||||
// ref/hare/io/types.ha:76. Hare's `fn(s: *stream, off: off, w: whence)`;
|
||||
// ww's `stream` is already `*vtable` (the #94 collapse), so the param is
|
||||
// `stream` directly, mirroring the reader/writer/closer aliases above.
|
||||
export type seeker = fn(s: stream, off: off, w: whence) (off | error);
|
||||
|
||||
Reference in New Issue
Block a user