summaryrefslogtreecommitdiff
path: root/src/Kind.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Kind.zig')
-rw-r--r--src/Kind.zig18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/Kind.zig b/src/Kind.zig
index 54c7e0e7..055b17f9 100644
--- a/src/Kind.zig
+++ b/src/Kind.zig
@@ -275,7 +275,7 @@ pub fn openFile(p: *Pardes, id: usize, k: u8, path: []const u8) !*Pane {
/// if the kind refused, in `slot.refused`. One call for both cores.
pub fn reopen(p: ?*Pardes, id: usize, s: *Slot, bytes: ?[]const u8) bool {
// A replica has no kind's code: what the open says is the authority's.
- if (authorityOnly("a kind's open")) return false;
+ if (tape.authorityOnly("a kind's open")) return false;
var cl: Call = .{ .p = p, .id = id, .slot = s };
const prev = cl.begin("open");
if (p) |core| if (core.kinds.byName(s.nameOf())) |k| {
@@ -530,7 +530,7 @@ fn prefixOf(p: *const Pardes, slot: *const Slot, buf: *[400]u8) []const u8 {
pub fn key(p: *Pardes, id: usize, k: pardes.Key) bool {
const slot = (p.panes[id] orelse return false).addon orelse return false;
if (!caps(p, slot).key) return false;
- if (authorityOnly("a key into a kind's pane")) return true;
+ if (tape.authorityOnly("a key into a kind's pane")) return true;
const pk: c.pa_key = .{ .cp = k.cp, .ctrl = @intFromBool(k.ctrl), .alt = @intFromBool(k.alt), .shift = @intFromBool(k.shift), .view = p.live + 1 };
var cl: Call = .{ .p = p, .id = id, .slot = slot };
const prev = cl.begin("key");
@@ -554,7 +554,7 @@ pub fn takesKeys(p: *const Pardes, s: *const Slot) bool {
pub fn search(p: *Pardes, id: usize, pat: []const u8) ?[]const u8 {
const slot = (p.panes[id] orelse return null).addon orelse return null;
if (!caps(p, slot).search) return null;
- if (authorityOnly("a kind's search")) return null;
+ if (tape.authorityOnly("a kind's search")) return null;
var cl: Call = .{ .p = p, .id = id, .slot = slot };
const prev = cl.begin("search");
if (slot.ops) |o| o.search.?(slot.st, pat.ptr, @intCast(pat.len));
@@ -570,7 +570,7 @@ pub fn address(p: *Pardes, id: usize, text: []const u8, said: *Buf(160)) bool {
const slot = (p.panes[id] orelse return false).addon orelse return false;
// By its caps, not its code: a Shadow calls as the authority does.
if (!caps(p, slot).address) return false;
- if (authorityOnly("a kind's address")) return true;
+ if (tape.authorityOnly("a kind's address")) return true;
var cl: Call = .{ .p = p, .id = id, .slot = slot, .missing = said };
const prev = cl.begin("address");
if (slot.ops) |o| cl.ret = o.address.?(slot.st, text.ptr, @intCast(text.len));
@@ -587,7 +587,7 @@ pub fn takesMouse(p: *const Pardes, s: *const Slot) bool {
pub fn mouse(p: *Pardes, id: usize, m: pardes.Mouse, col: u16, row: u16) bool {
const slot = (p.panes[id] orelse return false).addon orelse return false;
if (!caps(p, slot).mouse) return false;
- if (authorityOnly("the mouse in a kind's pane")) return true;
+ if (tape.authorityOnly("the mouse in a kind's pane")) return true;
const pm: c.pa_mouse = .{
.button = switch (m.button) {
.left => c.PA_LEFT,
@@ -815,7 +815,7 @@ pub fn ctl(p: *Pardes, id: usize, line: []const u8, reply: *[160]u8) ?[]const u8
const slot = (p.panes[id] orelse return "no such pane").addon orelse return "not a kind's pane";
if (!slot.live) return "its addon is not loaded";
if (!caps(p, slot).ctl) return "its kind takes no words";
- if (authorityOnly("a kind's word")) return null;
+ if (tape.authorityOnly("a kind's word")) return null;
var cl: Call = .{ .p = p, .id = id, .slot = slot };
const prev = cl.begin("ctl");
@memset(reply, 0);
@@ -841,12 +841,6 @@ pub fn ctlRead(pane: *const Pane, buf: []u8) []const u8 {
return buf[0..@min(buf.len, f(slot.st, buf.ptr, @intCast(buf.len)))];
}
-fn authorityOnly(comptime why: []const u8) bool {
- if (!tape.speculating()) return false;
- tape.poison(why);
- return true;
-}
-
// ---- a call into a kind ----
/// What a call into a kind did that the core takes on: its answer, a