summaryrefslogtreecommitdiff
path: root/src/ninep/events.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-21 17:25:52 -0300
committerGabriel Schneider <[email protected]>2026-10-22 10:03:15 -0300
commit23518c9d7c061f8a06f6632da8b64b37801b514f (patch)
tree1f9688a5c2b2c224f47dd538ffab275b1f54da5c /src/ninep/events.zig
parentbc3d18d27f9fc1155db7fac3946c4d38774f9e65 (diff)
downloadpardes-23518c9d7c061f8a06f6632da8b64b37801b514f.tar.gz
pardes-23518c9d7c061f8a06f6632da8b64b37801b514f.zip
zig fmt for Zig 0.17
Diffstat (limited to 'src/ninep/events.zig')
-rw-r--r--src/ninep/events.zig30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/ninep/events.zig b/src/ninep/events.zig
index 7b73dc0e..78788c3c 100644
--- a/src/ninep/events.zig
+++ b/src/ninep/events.zig
@@ -542,7 +542,7 @@ pub const Action = enum(u8) {
tag_exec = 'x',
pub fn char(a: Action) u8 {
- return @intFromEnum(a);
+ return @backingInt(a);
}
pub fn fromChar(c: u8) ?Action {
@@ -550,7 +550,7 @@ pub const Action = enum(u8) {
}
pub fn onTag(a: Action) bool {
- return @intFromEnum(a) >= 'a';
+ return @backingInt(a) >= 'a';
}
};
@@ -889,7 +889,7 @@ test "a stream read at an offset inside its last answer gets the rest of it agai
defer p.deinit();
p.update(.tick);
while (p.nextEffect()) |_| {}
- const log = @intFromEnum(tree.TopFile.log);
+ const log = @backingInt(tree.TopFile.log);
const f = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle;
const frozen: u64 = call(p, .{ .tag = 2, .op = .read, .node = log, .handle = f, .size = 8192 }).bytes.len;
_ = call(p, .{ .tag = 3, .op = .write, .node = log, .handle = f, .data = "follow" });
@@ -897,7 +897,7 @@ test "a stream read at an offset inside its last answer gets the rest of it agai
notePath(p, "dump", "/b");
const Read = struct {
fn at(pp: *Pardes, h: u32, off: u64) []const u8 {
- return call(pp, .{ .tag = 4, .op = .read, .node = @intFromEnum(tree.TopFile.log), .handle = h, .off = off, .size = 128 }).bytes;
+ return call(pp, .{ .tag = 4, .op = .read, .node = @backingInt(tree.TopFile.log), .handle = h, .off = off, .size = 128 }).bytes;
}
};
try testing.expectEqualStrings("dump /a\n", Read.at(p, f, frozen));
@@ -1130,7 +1130,7 @@ test "writing an event record back performs the action it names" {
// A look written back sets what look reads back.
_ = wr(p, event, "FL0 3\n");
var want_serial: [16]u8 = undefined;
- try testing.expectEqualStrings(try std.fmt.bufPrint(&want_serial, "{d}\n", .{serial}), rd(p, @intFromEnum(tree.TopFile.look), 0, 64).bytes);
+ try testing.expectEqualStrings(try std.fmt.bufPrint(&want_serial, "{d}\n", .{serial}), rd(p, @backingInt(tree.TopFile.look), 0, 64).bytes);
// Well formed but past the text: said so, not "bad event syntax".
try testing.expectEqualStrings("range past end of body", wr(p, event, "MX0 999\n").reply.ename);
@@ -1144,7 +1144,7 @@ test "the log records whether or not anyone reads, and an open that follows wait
const gpa = testing.allocator;
const p = try withFile(gpa, "logged\n");
defer p.deinit();
- const log = @intFromEnum(tree.TopFile.log);
+ const log = @backingInt(tree.TopFile.log);
var expected: [4200]u8 = undefined;
// Nobody holds /log open, and the pane is recorded anyway.
@@ -1256,21 +1256,21 @@ test "a refused or failed write is an err record in the log, saying which file a
p.update(.tick); // the pane's `new` is logged before the log is opened
while (p.nextEffect()) |_| {}
const serial = serialOf(p);
- const log = @intFromEnum(tree.TopFile.log);
+ const log = @backingInt(tree.TopFile.log);
const f = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle;
const frozen = call(p, .{ .tag = 2, .op = .read, .node = log, .handle = f, .size = 1 << 16 }).bytes.len;
_ = call(p, .{ .tag = 3, .op = .write, .node = log, .handle = f, .data = "follow" });
var want: [128]u8 = undefined;
const next = struct {
fn record(pp: *Pardes, h: u32, off: usize) []const u8 {
- return call(pp, .{ .tag = 4, .op = .read, .node = @intFromEnum(tree.TopFile.log), .handle = h, .off = off, .size = 4096 }).bytes;
+ return call(pp, .{ .tag = 4, .op = .read, .node = @backingInt(tree.TopFile.log), .handle = h, .off = off, .size = 4096 }).bytes;
}
};
_ = wr(p, Node.of(serial, .addr), "/nowhere/");
try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "err {d} addr: no match for regexp\n", .{serial}), next.record(p, f, frozen));
- _ = wr(p, @intFromEnum(tree.TopFile.ctl), "Bogus");
+ _ = wr(p, @backingInt(tree.TopFile.ctl), "Bogus");
try testing.expectEqualStrings("err - ctl: unknown control message \"Bogus\"\n", next.record(p, f, frozen));
- _ = wr(p, @intFromEnum(tree.TopFile.focus), "99999");
+ _ = wr(p, @backingInt(tree.TopFile.focus), "99999");
try testing.expectEqualStrings("err - focus: no such pane\n", next.record(p, f, frozen));
// A write that succeeds says nothing.
_ = wr(p, Node.of(serial, .addr), "#0");
@@ -1373,7 +1373,7 @@ test "opens of the log share the open records, and a closed one frees its record
const gpa = testing.allocator;
const p = try withFile(gpa, "x\n");
defer p.deinit();
- const log = @intFromEnum(tree.TopFile.log);
+ const log = @backingInt(tree.TopFile.log);
var handles: [tree.open_slots]u32 = undefined;
for (&handles) |*h| h.* = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle;
try testing.expectEqual(E.NFILE, call(p, .{ .tag = 2, .op = .open, .node = log }).errno());
@@ -1447,7 +1447,7 @@ test "follow new skips what the log held and waits for what comes after" {
p.update(.tick); // the pane's `new` is logged first
while (p.nextEffect()) |_| {}
p.setMessage(0, "before the open");
- const log = @intFromEnum(tree.TopFile.log);
+ const log = @backingInt(tree.TopFile.log);
const h = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle;
try testing.expectEqual(Status.ok, call(p, .{ .tag = 2, .op = .write, .node = log, .handle = h, .data = "follow new\n" }).reply.status);
try testing.expectEqual(Status.again, call(p, .{ .tag = 3, .op = .read, .node = log, .handle = h, .size = 4096 }).reply.status);
@@ -1461,7 +1461,7 @@ test "a long msg record is cut between words at its cap, with an ellipsis" {
defer p.deinit();
const long = std.mem.asBytes(&@as([60][5]u8, @splat("word ".*))); // 300 bytes
_ = wr(p, Node.of(serialOf(p), .ctl), "Msg " ++ long ++ "\n");
- const log = @intFromEnum(tree.TopFile.log);
+ const log = @backingInt(tree.TopFile.log);
const h = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle;
const text = call(p, .{ .tag = 2, .op = .read, .node = log, .handle = h, .size = 1 << 16 }).bytes;
const at = std.mem.lastIndexOf(u8, text, "msg ").?;
@@ -1485,8 +1485,8 @@ test "a record is one line of UTF-8: DEL and C1 are spaces, bytes not UTF-8 are
test "a long err record keeps its end, its middle given up to an ellipsis" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
- _ = wr(p, @intFromEnum(tree.TopFile.ctl), "Bogus" ++ std.mem.asBytes(&@as([40][8]u8, @splat("abcdefgh".*))) ++ "\n");
- const log = @intFromEnum(tree.TopFile.log);
+ _ = wr(p, @backingInt(tree.TopFile.ctl), "Bogus" ++ std.mem.asBytes(&@as([40][8]u8, @splat("abcdefgh".*))) ++ "\n");
+ const log = @backingInt(tree.TopFile.log);
const h = call(p, .{ .tag = 1, .op = .open, .node = log }).reply.handle;
const text = call(p, .{ .tag = 2, .op = .read, .node = log, .handle = h, .size = 1 << 16 }).bytes;
const at = std.mem.lastIndexOf(u8, text, "err - ctl: ").?;