From 1ca52fc338c4a862a50254420ecd60428dd32a6e Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 20 Nov 2026 15:02:36 -0300 Subject: build: the step lib-test is consumer-test (P37, ruled with the names): the step, its name and its two variables in build/tools.zig (lib_test, lib_test_step -> consumer_test, consumer_test_step; the description already says it builds the library from a package that depends on pardes) and the one reader in build/tests.zig, and where it is named: build.zig's head comment, test/consumer/build.zig's, docs/typ/building.typ (the paragraph and the steps' table) and the Unreleased entry of core/CHANGELOG.md that introduced the step (rewrapped); the scripts under .scratch that name it are listed in reports/pardes-slots.md for the coordinator; `zig build consumer-test -Dplatform=tui` builds and tests test/consumer; gate on the stack through this change and the docking vocabulary (load 4-32): tui core-test 871/1028 (157 skipped), shell-test 1070/1073, pane-test 183/184, term-test 17/17, kitty-test 45/45, behaviour-test 275/275 and --replay 275/275, consumer-test passes, addon-test 5/5, process-test 0 of 144 (tty boot: msg failed once at load 32 and passed alone), replicas --clients 5 and --bytes --clients 5: diverged 0, unequal 0, deltas wrong 0, quiet checks differed 0, unlisted stops 0, corpus 22 of 22, no leak; the semantics word a73794ff9e03f814 as on merge40; daemon.py --far, --games, --window-clients pass, plain fails 2 of 4 at "client C agrees with a shell's output" (a timeout), as merge40's build does 3 of 6; the macOS library (x86_64-linux, aarch64-macos, the ABI guard 2/2) and the FreeBSD cross-build build; frames 77/77, gui unit-test 1666/1670 (the perf check's BaselineHarnessMismatch), perfab corpus2x +0.054% (noise 0.054%), the 121 per-operation counts within 0.1% against tree2 (key-down on medium 10,039,720 and render on medium 11,454,636, merge40's gate 10,039,703 and 11,454,619) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- test/consumer/build.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/consumer/build.zig b/test/consumer/build.zig index ca63bb6e..c643bfb3 100644 --- a/test/consumer/build.zig +++ b/test/consumer/build.zig @@ -1,5 +1,5 @@ //! A package that depends on pardes, as a program would (build.zig's head -//! comment has its lines): pardes's `lib-test`, which `unit-test` runs, +//! comment has its lines): pardes's `consumer-test`, which `unit-test` runs, //! runs `zig build test` here. `pardes-syntax` with the minimal grammars, //! as a program that draws source text itself takes it; and //! `pardes-editor` with no grammar of pardes's and one of its own, C's, -- cgit v1.3 From a3be36960661a9d4c857c9c38797cc7f0690a71a Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 20 Nov 2026 15:03:12 -0300 Subject: macos: the State field runtime is callbacks, as its type became macos.Callbacks (P37): runtime/macos.zig's field, pardes_init's and initCore's parameter, the store of it, its six readers (st.callbacks.set_clipboard, read_clipboard, wakeup and their userdata) and six test literals; abi/pardes.h's pardes_init prototype names its parameter callbacks (the typedef already did); the Swift locals that build the struct and hand it in, `var runtime` and `&runtime` -> `callbacks` at dev/macos/Sources/AppDelegate.swift:135 and :171 and test/macos_e2e.swift:171 and :203 (not built here: the Swift app needs macOS; by reading the name meets nothing in either scope); the prose "the runtime" (the host app, macos.zig:135, :264) stays; the ABI guard (unit-test -Dplatform=macos, "pardes.h matches the Zig boundary") 2/2 on Linux; gate on the stack through this change and the docking vocabulary (load 4-32): tui core-test 871/1028 (157 skipped), shell-test 1070/1073, pane-test 183/184, term-test 17/17, kitty-test 45/45, behaviour-test 275/275 and --replay 275/275, consumer-test passes, addon-test 5/5, process-test 0 of 144 (tty boot: msg failed once at load 32 and passed alone), replicas --clients 5 and --bytes --clients 5: diverged 0, unequal 0, deltas wrong 0, quiet checks differed 0, unlisted stops 0, corpus 22 of 22, no leak; the semantics word a73794ff9e03f814 as on merge40; daemon.py --far, --games, --window-clients pass, plain fails 2 of 4 at "client C agrees with a shell's output" (a timeout), as merge40's build does 3 of 6; the macOS library (x86_64-linux, aarch64-macos, the ABI guard 2/2) and the FreeBSD cross-build build; frames 77/77, gui unit-test 1666/1670 (the perf check's BaselineHarnessMismatch), perfab corpus2x +0.054% (noise 0.054%), the 121 per-operation counts within 0.1% against tree2 (key-down on medium 10,039,720 and render on medium 11,454,636, merge40's gate 10,039,703 and 11,454,619) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- abi/pardes.h | 2 +- dev/macos/Sources/AppDelegate.swift | 4 ++-- runtime/macos.zig | 34 +++++++++++++++++----------------- test/macos_e2e.swift | 4 ++-- 4 files changed, 22 insertions(+), 22 deletions(-) (limited to 'test') diff --git a/abi/pardes.h b/abi/pardes.h index ca65b8f3..24eb6701 100644 --- a/abi/pardes.h +++ b/abi/pardes.h @@ -223,7 +223,7 @@ typedef struct { // core defers each shell's greeting until it has seen one), and the first // forkpty takes its winsize straight off the core — boot at 80x24 and the // shell draws its first prompt to a width the window never had. -int pardes_init(const pardes_callbacks_s *runtime, uint16_t cols, uint16_t rows); +int pardes_init(const pardes_callbacks_s *callbacks, uint16_t cols, uint16_t rows); void pardes_deinit(void); // Drain pty output into the core and perform the effects it queued. Call after diff --git a/dev/macos/Sources/AppDelegate.swift b/dev/macos/Sources/AppDelegate.swift index 4168999f..5ee775cf 100644 --- a/dev/macos/Sources/AppDelegate.swift +++ b/dev/macos/Sources/AppDelegate.swift @@ -132,7 +132,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate { // to change the day macos_min_version reaches 14. NSApp.activate(ignoringOtherApps: true) - var runtime = pardes_callbacks_s( + var callbacks = pardes_callbacks_s( userdata: Unmanaged.passUnretained(self).toOpaque(), wakeup: { ud in // A pty reader thread. Every other function in pardes.h is @@ -168,7 +168,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate { // greeting until it has seen a size, so a correction sent afterwards // arrives with the first prompt already wrapped to the wrong width. let grid = view.gridSize - let rc = pardes_init(&runtime, grid.cols, grid.rows) + let rc = pardes_init(&callbacks, grid.cols, grid.rows) if rc != 0 { NSLog("pardes: the core failed to boot at \(grid.cols)x\(grid.rows), pardes_init returned \(rc)") // Not NSApp.terminate — that runs applicationWillTerminate, which diff --git a/runtime/macos.zig b/runtime/macos.zig index 4f9a9c33..1954cfa5 100644 --- a/runtime/macos.zig +++ b/runtime/macos.zig @@ -250,7 +250,7 @@ const State = struct { io: std.Io, core: *pardes.Pardes, started: bool = false, - runtime: Callbacks, + callbacks: Callbacks, tag_cells: [pardes.MAX_TAG_LAYERS][]Cell = @splat(&.{}), layer_cells: [pardes.MAX_PANES][]Cell = @splat(&.{}), cells: []Cell = &.{}, @@ -290,9 +290,9 @@ const State = struct { var state: ?State = null; -export fn pardes_init(runtime: ?*const Callbacks, cols_arg: u16, rows_arg: u16) c_int { +export fn pardes_init(callbacks: ?*const Callbacks, cols_arg: u16, rows_arg: u16) c_int { if (state != null) return 1; // already up; deinit first - initCore(runtime, cols_arg, rows_arg) catch |err| { + initCore(callbacks, cols_arg, rows_arg) catch |err| { log.err("init failed: {t}", .{err}); return 2; }; @@ -302,7 +302,7 @@ export fn pardes_init(runtime: ?*const Callbacks, cols_arg: u16, rows_arg: u16) /// The shell's gpa in a Debug build, as std.start's is for the others. var debug_gpa: std.heap.DebugAllocator(.{}) = .init; -fn initCore(runtime: ?*const Callbacks, cols_arg: u16, rows_arg: u16) !void { +fn initCore(callbacks: ?*const Callbacks, cols_arg: u16, rows_arg: u16) !void { // The allocator every other shell gets from std.start: a DebugAllocator // in Debug, libc's malloc otherwise. libc's measured at least as fast as // std.heap.smp_allocator everywhere and faster on MuPDF's page-sized @@ -373,7 +373,7 @@ fn initCore(runtime: ?*const Callbacks, cols_arg: u16, rows_arg: u16) !void { .core = core, .config_arena = config_arena, .prompt_rcs = prompt_rcs, - .runtime = if (runtime) |r| r.* else .{}, + .callbacks = if (callbacks) |c| c.* else .{}, }; const st = &state.?; st.inbox = .{ .gpa = gpa, .lsp_allocator = gpa, .io = io, .wake_fn = wakeHost, .wake_ctx = st }; @@ -1758,14 +1758,14 @@ fn dumpThemes(ctx: ?*anyopaque, id: pardes.Pane.Id) void { fn setClipboard(ctx: ?*anyopaque, text: []const u8) void { const st = hostState(ctx); - const cb = st.runtime.set_clipboard orelse return; - cb(st.runtime.userdata, text.ptr, text.len); + const cb = st.callbacks.set_clipboard orelse return; + cb(st.callbacks.userdata, text.ptr, text.len); } fn readClipboard(ctx: ?*anyopaque) void { const st = hostState(ctx); - const cb = st.runtime.read_clipboard orelse return; - cb(st.runtime.userdata); + const cb = st.callbacks.read_clipboard orelse return; + cb(st.callbacks.userdata); } fn openLink(_: ?*anyopaque, url: []const u8) void { @@ -1803,9 +1803,9 @@ fn wakeHost(ctx: ?*anyopaque) void { } fn wake(st: *State) void { - const cb = st.runtime.wakeup orelse return; + const cb = st.callbacks.wakeup orelse return; if (st.wake_pending.swap(true, .acq_rel)) return; - cb(st.runtime.userdata); + cb(st.callbacks.userdata); } fn captureEnv(arena: std.mem.Allocator) ?std.process.Environ.Map { @@ -2058,7 +2058,7 @@ test "mac queued results never cancel a newer LSP request" { .threaded = undefined, .io = std.testing.io, .core = core, - .runtime = .{}, + .callbacks = .{}, .config_arena = .init(gpa), .prompt_rcs = .{}, .inbox = .{ .gpa = gpa, .lsp_allocator = gpa, .io = std.testing.io }, @@ -2101,7 +2101,7 @@ test "mac worker setup failures finish matching LSP and pipe requests" { .threaded = undefined, .io = failing_io, .core = core, - .runtime = .{}, + .callbacks = .{}, .config_arena = .init(gpa), .prompt_rcs = .{}, .inbox = .{ .gpa = failing.allocator(), .lsp_allocator = failing.allocator(), .io = failing_io }, @@ -2224,7 +2224,7 @@ test "mac Restore keeps host state and rejects callbacks from the old core" { .threaded = undefined, .io = std.testing.io, .core = core, - .runtime = .{}, + .callbacks = .{}, .config_arena = .init(gpa), .prompt_rcs = .{}, .inbox = .{ .gpa = gpa, .lsp_allocator = gpa, .io = std.testing.io }, @@ -2325,7 +2325,7 @@ test "mac Restore cancels a PTY reader waiting for output capacity" { .threaded = undefined, .io = io, .core = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }), - .runtime = .{}, + .callbacks = .{}, .config_arena = .init(gpa), .prompt_rcs = .{}, .inbox = .{ .gpa = gpa, .lsp_allocator = gpa, .io = io }, @@ -2627,7 +2627,7 @@ test "mac row metrics ABI preserves PDF cell dimensions and the unrendered grid" const gpa = std.testing.allocator; const core = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); defer core.deinit(); - state = .{ .gpa = gpa, .threaded = undefined, .io = std.testing.io, .core = core, .runtime = .{}, .config_arena = .init(gpa), .prompt_rcs = .{} }; + state = .{ .gpa = gpa, .threaded = undefined, .io = std.testing.io, .core = core, .callbacks = .{}, .config_arena = .init(gpa), .prompt_rcs = .{} }; defer { state.?.config_arena.deinit(); state = null; @@ -2646,7 +2646,7 @@ test "mac tag layer ABI preserves logical capacity and physical grip" { const gpa = std.testing.allocator; const core = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 8, .rows = 3 }); defer core.deinit(); - state = .{ .gpa = gpa, .threaded = undefined, .io = std.testing.io, .core = core, .runtime = .{}, .config_arena = .init(gpa), .prompt_rcs = .{} }; + state = .{ .gpa = gpa, .threaded = undefined, .io = std.testing.io, .core = core, .callbacks = .{}, .config_arena = .init(gpa), .prompt_rcs = .{} }; defer { for (state.?.tag_cells) |cells| gpa.free(cells); state.?.config_arena.deinit(); diff --git a/test/macos_e2e.swift b/test/macos_e2e.swift index 38d27808..25d83957 100644 --- a/test/macos_e2e.swift +++ b/test/macos_e2e.swift @@ -168,7 +168,7 @@ private final class Driver: PardesViewDelegate { message: "the view measured \(got.cols)x\(got.rows) cells, not the \(cols)x\(rows) the script asked for") } - var runtime = pardes_callbacks_s( + var callbacks = pardes_callbacks_s( userdata: Unmanaged.passUnretained(host).toOpaque(), wakeup: { ud in // A pty reader thread. One flag and out — see Host.woke. @@ -200,7 +200,7 @@ private final class Driver: PardesViewDelegate { text.withCString { pardes_paste($0, text.utf8.count) } }) - let rc = pardes_init(&runtime, got.cols, got.rows) + let rc = pardes_init(&callbacks, got.cols, got.rows) guard rc == 0 else { throw ScriptError(message: "pardes_init returned \(rc) at \(cols)x\(rows)") } -- cgit v1.3 From 2d75490196a9d15eff6ac471e9584101a5697afe Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 20 Nov 2026 15:21:27 -0300 Subject: core: the switchboard's view fields are View.Id: Authority.view_of and Peer.view (P21: the fields; the last change of the slots work, apart for the pair's merge): the in-process Authority's openView, leave, closeView and take, and Peers' input, closeViewOf and the welcome hand the core its view's id with no conversion (9 .at( and an .index() go); Screens.flush's view parameter, which its body never read, goes with its four arguments (Peers, the in-process harness, echo.zig's, test/replicas.zig's); the undrawn mask's shift narrows the slot's integer, which the compiler caught (core/replica.zig:2362, :2507: the old @intCast narrowed the bare u8; a view's slot as a bit index, no fault), as it caught test/replicas.zig:1047's detach_view, a view's slot as a bare u8 against a peer's (no fault: p.view.index() == k); Replica.view and Joined.view stay u8: their readers (the echo, drawOne, the frontends' own view, client.zig, session.zig) index and compare with the core's live as integers (+4, +8 by the estimate); neither field typed here is dumped or digested and the welcome's byte is the same; the conversions fall: the core's code 427 -> 425 (.at( 333 -> 328, .index() 73 -> 76); gate on the whole stack (load 5-22): tui core-test 871/1028 (157 skipped), shell-test 1070/1073, pane-test 183/184, term-test 17/17, kitty-test 45/45, behaviour-test 275/275 and --replay 275/275, consumer-test passes, addon-test 5/5, process-test 0 of 144, replicas --clients 5 (diverged 0, unequal 0, deltas 1976/0 1937/0 1831/0, quiet 651/0 673/0 779/0, unlisted 0, corpus 22 of 22, no leak) and --bytes --clients 5 (diverged 0, unequal 0, quiet 693/0 586/0 829/0, unlisted 0, corpus 22 of 22); the semantics word a73794ff9e03f814 as merge40's; daemon.py --far, --games, --window-clients pass, --upgrade both ways against merge39's build (3f9dfd3b9d8bdc64; merge40's has this word, which the test refuses) pass, plain fails at "client C agrees with a shell's output" 4 of 6 as merge40's build does 3 of 6 (alternated: 2 of 4 each); the macOS library (x86_64-linux, aarch64-macos, the ABI guard 2/2) and the FreeBSD cross-build build; frames 77/77, gui unit-test 1666/1670 (the perf check's BaselineHarnessMismatch), perfab corpus2x -0.014% (noise 0.078%), the 121 per-operation counts within 0.1% against tree2 (key-down on medium 10,039,745, render on medium 11,454,642, client-key-down on medium 1,983,990; merge40's gate 10,039,703, 11,454,619, 1,984,321) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- core/echo.zig | 2 +- core/replica.zig | 40 ++++++++++++++++++++-------------------- test/replicas.zig | 4 ++-- 3 files changed, 23 insertions(+), 23 deletions(-) (limited to 'test') diff --git a/core/echo.zig b/core/echo.zig index 40200696..f35c9f9d 100644 --- a/core/echo.zig +++ b/core/echo.zig @@ -614,7 +614,7 @@ const Rig = struct { for (msgs.items) |m| gpa.free(m); msgs.deinit(gpa); } - try g.screens.flush(g.a.core, g.peer, g.r.view, &msgs); + try g.screens.flush(g.a.core, g.peer, &msgs); for (msgs.items) |m| if (g.r.screen(m)) |reply| { _ = try g.screens.take(g.a.core, g.peer, reply); }; diff --git a/core/replica.zig b/core/replica.zig index ff1e138e..1a127ad4 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -157,7 +157,7 @@ pub const Authority = struct { seq: u32 = 0, /// Each client's view (core/views.zig): its own layout, focus and /// cursors over the session's text. The first client has the session's. - view_of: [64]u8 = @splat(0), + view_of: [64]Pardes.View.Id = @splat(.at(0)), /// Steps of its own taken since the last unit (`output`): one unit, /// `pending`, sent before the next input it steps and at a frame. batched: u32 = 0, @@ -279,7 +279,7 @@ pub const Authority = struct { }; a.core.pump(a.host) catch {}; was.end(); - a.view_of[client] = k.index(); + a.view_of[client] = k; a.seq += 1; return .{ .view = k.index(), .unit = try a.unit(0, a.seq) }; } @@ -296,7 +296,7 @@ pub const Authority = struct { const again = if (back) |v| a.core.rejoinView(.at(v)) else false; const k = (if (again) back else if (a.core.openView()) |o| o.index() else null) orelse return null; a.core.undrawn |= @as(u8, 1) << @intCast(k); - a.view_of[client] = k; + a.view_of[client] = .at(k); a.seq += 1; const u = try a.unit(0, a.seq); var blobs: std.ArrayListUnmanaged(walk.Deferred) = .empty; @@ -322,8 +322,8 @@ pub const Authority = struct { std.debug.assert(a.batched == 0); const was = Stepping.begin(&a.t, null); const k = a.view_of[client]; - a.core.undrawn &= ~(@as(u8, 1) << @intCast(k)); - if (again) a.core.awayView(.at(k)) else a.core.closeView(.at(k)); + a.core.undrawn &= ~(@as(u8, 1) << @intCast(k.index())); + if (again) a.core.awayView(k) else a.core.closeView(k); was.end(); a.seq += 1; return a.unit(0, a.seq); @@ -333,7 +333,7 @@ pub const Authority = struct { pub fn closeView(a: *Authority, client: u16) ![]const u8 { std.debug.assert(a.batched == 0); const was = Stepping.begin(&a.t, null); - a.core.closeView(.at(a.view_of[client])); + a.core.closeView(a.view_of[client]); was.end(); a.seq += 1; return a.unit(0, a.seq); @@ -345,7 +345,7 @@ pub const Authority = struct { std.debug.assert(a.batched == 0); const in = parseInput(msg) orelse return error.BadInput; const was = Stepping.begin(&a.t, null); - a.core.toView(.at(a.view_of[in.client])); + a.core.toView(a.view_of[in.client]); a.t.stamp = stampOf(in); a.core.update(in.event); a.core.step(); @@ -450,7 +450,7 @@ pub const Screens = struct { /// What `peer` is owed of every terminal, each a message onto `out` /// (owned): nothing for one it has as it is, or with `bound` in flight. - pub fn flush(s: *Screens, core: *Pardes, peer: u16, _: u8, out: *std.ArrayListUnmanaged([]u8)) !void { + pub fn flush(s: *Screens, core: *Pardes, peer: u16, out: *std.ArrayListUnmanaged([]u8)) !void { const t0 = nowNs(); defer s.encode_ns += nowNs() - t0; for (core.panes, 0..) |slot, id| { @@ -1667,7 +1667,7 @@ pub const Peer = struct { peers: *Peers, fd: c_int, id: u16, - view: u8, + view: Pardes.View.Id, /// Its process (its socket's peer), for `--ps`; 0 not known. pid: libc.pid_t = 0, /// Its bye said it joins again for its view (a divergence's rejoin): @@ -2201,7 +2201,7 @@ pub const Peers = struct { // The terminals as this step reads them, then the step, the rows // it read, its unit (part B terminal notes' order). ps.screensOut(core, .flush); - core.toView(.at(peer.view)); + core.toView(peer.view); ps.t.stamp = stampOf(in); core.update(in.event); core.step(); @@ -2239,7 +2239,7 @@ pub const Peers = struct { ps.msgs.clearRetainingCapacity(); } (switch (what) { - .flush => ps.screens.flush(core, peer.sid, peer.view, &ps.msgs), + .flush => ps.screens.flush(core, peer.sid, &ps.msgs), .fill => ps.screens.fill(core, peer.sid, &ps.msgs), }) catch return; if (what == .flush) if (ps.flushed) |h| h.f(h.ctx, core, &ps.screens); @@ -2325,12 +2325,12 @@ pub const Peers = struct { core.gpa.free(bytes); return daemon.refuseReplica(fd, "out of memory"); }; - peer.* = .{ .peers = ps, .fd = fd, .id = ps.next_id, .view = k, .limit = lag_max, .dump = bytes, .blobs = blobs, .dump_gpa = core.gpa }; + peer.* = .{ .peers = ps, .fd = fd, .id = ps.next_id, .view = .at(k), .limit = lag_max, .dump = bytes, .blobs = blobs, .dump_gpa = core.gpa }; ps.next_id +%= 1; if (ps.next_id == 0) ps.next_id = 1; // The session's digest as dumped, for the joiner to check its load by. const digest = tape.digestOf(core); - peer.welcome_len = (wire.encodeServer(&peer.welcome, .{ .welcome = .{ .pid = @intCast(libc.getpid()), .session = ps.name[0..@min(ps.name.len, wire.max_name)], .client = peer.id, .view = .at(k), .dump_len = whole, .gmtoff = gmtoff(), .digest = digest, .semantics = wire.semantics, .blobs = @intCast(blobs.items.len) } }) catch unreachable).len; + peer.welcome_len = (wire.encodeServer(&peer.welcome, .{ .welcome = .{ .pid = @intCast(libc.getpid()), .session = ps.name[0..@min(ps.name.len, wire.max_name)], .client = peer.id, .view = peer.view, .dump_len = whole, .gmtoff = gmtoff(), .digest = digest, .semantics = wire.semantics, .blobs = @intCast(blobs.items.len) } }) catch unreachable).len; if (ps.threads) peer.writer = std.Thread.spawn(.{}, Peer.writeLoop, .{peer}) catch null; if (ps.threads) peer.reader = std.Thread.spawn(.{}, Peer.readLoop, .{peer}) catch null; if (ps.threads and (peer.writer == null or peer.reader == null)) { @@ -2359,7 +2359,7 @@ pub const Peers = struct { log.info("client {d} left '{s}'", .{ peer.id, ps.name }); ps.tellClients(); ps.screens.dropPeer(peer.sid); - core.undrawn &= ~(@as(u8, 1) << @intCast(peer.view)); + core.undrawn &= ~(@as(u8, 1) << @intCast(peer.view.index())); ps.closeViewOf(core, peer, peer.again); if (ps.count() == 0) core.unattended = ps.detached; if (ps.count() == 0 and peer.close and !ps.kept) ps.closed = true; @@ -2374,7 +2374,7 @@ pub const Peers = struct { /// session no one else watches leaves the session its layout, for a /// client that comes after to find. fn closeViewOf(ps: *Peers, core: *Pardes, peer: *Peer, again: bool) void { - if (again) core.awayView(.at(peer.view)) else if (ps.count() == 0 and ps.detached) core.leaveView(.at(peer.view)) else core.closeView(.at(peer.view)); + if (again) core.awayView(peer.view) else if (ps.count() == 0 and ps.detached) core.leaveView(peer.view) else core.closeView(peer.view); } /// Its threads ended and joined, its link closed. @@ -2466,7 +2466,7 @@ pub const Peers = struct { /// Detach typed in client view `k`'s: told it left the session running /// (`left`), its last word; the client goes, and its reader says so. pub fn detach(ps: *Peers, k: u8) bool { - for (ps.list) |slot| if (slot) |peer| if (peer.view == k) { + for (ps.list) |slot| if (slot) |peer| if (peer.view.index() == k) { ps.kept = true; var out: [wire.max_name + 8]u8 = undefined; peer.last(wire.encodeServer(&out, .{ .left = ps.name[0..@min(ps.name.len, wire.max_name)] }) catch unreachable); @@ -2504,7 +2504,7 @@ pub const Peers = struct { fn drop(ps: *Peers, core: *Pardes, again: bool) void { for (&ps.list) |*slot| if (slot.*) |peer| { slot.* = null; - core.undrawn &= ~(@as(u8, 1) << @intCast(peer.view)); + core.undrawn &= ~(@as(u8, 1) << @intCast(peer.view.index())); ps.closeViewOf(core, peer, again); ps.screens.dropPeer(peer.sid); ps.letGo(peer); @@ -3470,7 +3470,7 @@ fn deliver(a: *Authority, screens: *Screens, peer: u16, r: *Replica, comptime wh msgs.deinit(gpa); } switch (what) { - .flush => try screens.flush(a.core, peer, r.view, &msgs), + .flush => try screens.flush(a.core, peer, &msgs), .fill => { try screens.fill(a.core, peer, &msgs); screens.filled(a.core); @@ -3503,7 +3503,7 @@ fn farJoinOnce(ps: *Peers, core: *Pardes, have: ?*Have) !Joined { var whole = state.len; for (blobs.items) |b| whole += b.bytes.len; const peer = try ps.gpa.create(Peer); - peer.* = .{ .peers = ps, .fd = fds[0], .id = 1, .view = 0, .dump = state, .blobs = blobs, .dump_gpa = core.gpa }; + peer.* = .{ .peers = ps, .fd = fds[0], .id = 1, .view = .at(0), .dump = state, .blobs = blobs, .dump_gpa = core.gpa }; peer.welcome_len = (wire.encodeServer(&peer.welcome, .{ .welcome = .{ .pid = 1, .session = "t", .dump_len = whole, .blobs = @intCast(blobs.items.len) } }) catch unreachable).len; const Serve = struct { fn run(p: *Peer) void { @@ -5159,7 +5159,7 @@ test "a client that diverged joins again for its view: kept for it meanwhile, it const back = try joinedNow(a, 3, opened.view); defer back.deinit(); try std.testing.expectEqual(digestOf(a), back.digest()); - a.view_of[3] = opened.view; + a.view_of[3] = .at(opened.view); const u = try gpa.dupe(u8, try a.take(try back.input(.{ .key = .{ .cp = 'l', .text = "l" } }))); defer gpa.free(u); old.confirm(u); diff --git a/test/replicas.zig b/test/replicas.zig index 6a6d43b4..d78e3e02 100644 --- a/test/replicas.zig +++ b/test/replicas.zig @@ -1044,7 +1044,7 @@ const Soak = struct { // A Detach typed in a client's view, or one cut off for its lag: its // link shut, it hears its end and nothing after; its reader's end // said (the next boundary lets it go). - if (s.detach_view) |k| for (s.clients) |*cl| if (cl.peer) |p| if (p.view == k and !cl.shut) { + if (s.detach_view) |k| for (s.clients) |*cl| if (cl.peer) |p| if (p.view.index() == k and !cl.shut) { cl.shut = true; }; s.detach_view = null; @@ -1931,7 +1931,7 @@ fn flushAll(sc: *replica.Screens, core: *pardes.Pardes, ps: []const u16, list: * for (ps, 0..) |peer, c| { list.clearRetainingCapacity(); // Terminals alone cross: the view is not read. - try sc.flush(core, peer, 0, list); + try sc.flush(core, peer, list); for (list.items) |bytes| { tot.deltas += 1; tot.delta_bytes += bytes.len; -- cgit v1.3