lib/encoding/hex: align to Hare io-streaming surface
The old buffer surface (encodedsize/decodedsize + encode(dst,src) i32 + decode(dst,src) (i32|invalid)) does not exist in Hare — it predates the #94 io vtable and mis-cited hex.ha:175 while implementing a different signature. Replace it with Hare's real surface (ref/hare/encoding/hex/hex.ha): - newencoder(out: io.handle) (:28) — write-only encoder stream. - encode(out: io.handle, in) (size | io.error) (:91). - encodestr(in) str (:68). - decodestr(s) ([]u8 | errors.invalid) (:175). Divergences (documented at-site): - The streaming DECODER (newdecoder/decode_reader, :120,:129) is DEFERRED to #247, blocked on #199b: Hare's decode_reader returns errors::invalid, which fits Hare's io::error (spreads ...errors::error). ww's io.error (lib/io/types.ww:55-62) does not carry errors.invalid, and io.read's (size|eof|error) can't propagate it, so a hex decoder *stream* can't faithfully report invalid hex through io.read yet. decodestr ships as a direct transform meanwhile. - nomem dropped from encodestr/decodestr returns (ww memio.dynamic has no failure path — same memio.string rule-9 carve-out, memio.ww:208). - The local hex.invalid type is deleted in favor of errors.invalid (that was the original divergence). - encode uses a single io.write rather than Hare's io::writeall (ww has none — fmt.fprint:498-501: callers drive write-all over raw io.write; encode_writer is whole-slice so a single write is equivalent). - dump (:212) deferred: ww has no default-arg support and fmt's formattable lacks u64 (#209), so the address column can't be ported faithfully yet. hex is now import-bearing, so it moves off the 900_stdlib standalone- compile list (like fmt/os/strings/bufio/bytes/errors before it); coverage stays at 979_hex_run.c. The stale "mirrors lib/encoding/hex.encode" comments in lib/encoding/utf8/utf8.ww are updated, which regenerates the 6 selfhost combined.ww (5 cmd + test/smoke) (comment-only, byte-id-neutral).
This commit is contained in:
@@ -17,7 +17,6 @@ static const char *modules[] = {
|
||||
"lib/sort/sort.ww",
|
||||
"lib/path/path.ww",
|
||||
"lib/encoding/utf8/utf8.ww",
|
||||
"lib/encoding/hex/hex.ww",
|
||||
"lib/encoding/base32/base32.ww",
|
||||
"lib/encoding/base64/base64.ww",
|
||||
"lib/hash/fnv/fnv.ww",
|
||||
@@ -39,13 +38,15 @@ static const char *modules[] = {
|
||||
* os.strerror (ww folds Hare's sys role into os); lib/strings.iterator
|
||||
* + lib/strings.next reference utf8.decoder / utf8.done;
|
||||
* lib/bytes.tokenize references os.assert + types.I64_MAX/MIN per
|
||||
* ref/hare/bytes/tokenize.ha:23-24,42-43. Coverage lives at
|
||||
* ref/hare/bytes/tokenize.ha:23-24,42-43; lib/encoding/hex graduated
|
||||
* to Hare's io-streaming surface (references io.handle / fmt.fprint /
|
||||
* memio.dynamic / strconv / errors.invalid). Coverage lives at
|
||||
* lib/bufio/bufiotest.ww + lib/bytes/bytestest.ww +
|
||||
* lib/errors/errnotest.ww + lib/fmt/fmttest.ww + lib/os/stattest.ww
|
||||
* + lib/strings/stringstest.ww (wired at 998_bufio_run.c,
|
||||
* 967_bytes_run.c, 902_errno_run.c, 970_fmt_run.c, 976_stat_run.c,
|
||||
* 966_strings_run.c), plus the bufio.scanline / fmt.println e2e
|
||||
* rows in test/wcc/700_e2e.c. */
|
||||
* + lib/strings/stringstest.ww + lib/encoding/hex/hextest.ww (wired
|
||||
* at 998_bufio_run.c, 967_bytes_run.c, 902_errno_run.c, 970_fmt_run.c,
|
||||
* 976_stat_run.c, 966_strings_run.c, 979_hex_run.c), plus the
|
||||
* bufio.scanline / fmt.println e2e rows in test/wcc/700_e2e.c. */
|
||||
"lib/net/net.ww",
|
||||
NULL
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user