summaryrefslogtreecommitdiff
path: root/src/kinds
diff options
context:
space:
mode:
Diffstat (limited to 'src/kinds')
-rw-r--r--src/kinds/addon.zig14
-rw-r--r--src/kinds/pardes_addon.h20
2 files changed, 28 insertions, 6 deletions
diff --git a/src/kinds/addon.zig b/src/kinds/addon.zig
index 557547f6..1fa2279a 100644
--- a/src/kinds/addon.zig
+++ b/src/kinds/addon.zig
@@ -19,7 +19,7 @@
//! dump(s, buf) usize load(s, bytes, version) bool search(s, pat) void
//!
//! and pardes's side (pa_api) as the functions below: `arena` and `heap`
-//! as Allocators, `seed`, `say`, `job`, `cancel`, `look`, `text`, `exec`,
+//! as Allocators, `seed`, `say`, `job`, `draw`, `cancel`, `look`, `text`, `exec`,
//! `select` and `found`. A body written is at most `body_max` bytes.
//!
//! pub const pardes_addon = addon.ops(Snake);
@@ -36,9 +36,9 @@ pub const c = @import("pardes_addon");
const Allocator = std.mem.Allocator;
/// The ABI this file speaks: a header of another needs it brought along.
-pub const abi = 0x30001;
+pub const abi = 0x30002;
comptime {
- if (c.PA_ABI != abi) @compileError("addon.zig speaks ABI 3.1 and the header another");
+ if (c.PA_ABI != abi) @compileError("addon.zig speaks ABI 3.2 and the header another");
}
/// A word the kind brings: `opens` a pane of it, else goes to the pane's
@@ -87,6 +87,14 @@ pub fn say(text_: []const u8, how: enum { note, err }) void {
pub fn job(in: []const u8) u32 {
return api.job.?(in.ptr, @intCast(in.len));
}
+/// A picture's job (pa_api.draw): `jobRun` over a copy of `in` on a worker
+/// of the process that shows the pane, its answer to `jobDone` there alone
+/// (`token & drawn`), which keeps it for `paint` only. 0 when refused.
+pub fn draw(in: []const u8) u32 {
+ if (api.size < @sizeOf(c.pa_api)) return 0;
+ return api.draw.?(in.ptr, @intCast(in.len));
+}
+pub const drawn = c.PA_DRAWN;
/// A job's answer not yet come dropped.
pub fn cancel(token: u32) void {
api.cancel.?(token);
diff --git a/src/kinds/pardes_addon.h b/src/kinds/pardes_addon.h
index 586b03d3..11dcec38 100644
--- a/src/kinds/pardes_addon.h
+++ b/src/kinds/pardes_addon.h
@@ -37,7 +37,7 @@
/* Major in the high half: an addon of another major is refused. */
#define PA_ABI_MAJOR 3u
-#define PA_ABI_MINOR 1u
+#define PA_ABI_MINOR 2u
#define PA_ABI ((PA_ABI_MAJOR << 16) | PA_ABI_MINOR)
#define PA_OK 0
#define PA_RASTER_MAX (32u << 20) /* a placement's w*h*4 above this is dropped, said once */
@@ -225,7 +225,18 @@ typedef struct pa_api {
void (*found)(const char *rows, uint32_t n);
/* The core's PA_ABI. */
uint32_t abi, pad;
+ /* Since 3.2 (check api->size): a picture's job, made where the pane is
+ * shown. `job_run` over a copy of `in` on a worker of this process, its
+ * answer to `job_done` here alone, its token PA_DRAWN: never on the tape,
+ * in the digest or sent to another process (each that shows the pane
+ * asks its own, from the same call). A draw's answer changes pixels
+ * only: what job_done keeps of it (memory of its own, api->heap: never a
+ * PA_PLAIN kind's block, nor its token) `paint` alone reads; no other
+ * call reads it, or anything made from it. 0: refused. */
+ uint32_t (*draw)(const void *in, uint32_t n);
} pa_api;
+/* A token of api->draw's. */
+#define PA_DRAWN 0x80000000u
/* What a job allocates from, on its worker (pa_api is not there): as often
* as it needs, all of it freed after its job_done. The last it allocates
@@ -287,7 +298,10 @@ typedef struct pa_tick {
* from the session's very bytes, its keys at once
* and its pictures its own, and a client without the addon shows a line.
* A kind that breaks the promise is caught: the client's state is not the
- * session's, and it joins again without the kind. */
+ * session's, and it joins again without the kind. Its pictures are each
+ * process's own (api->draw), kept outside the block (api->heap), found by
+ * the block's address; a pane with a file is opened in a client from the
+ * file's bytes as the session's was. */
#define PA_PLAIN 0x2u
typedef struct pa_head {
@@ -376,7 +390,7 @@ _Static_assert(sizeof(pa_rect) == 16 && sizeof(pa_cells) == 8, "pa_rect");
_Static_assert(sizeof(pa_placement) == 80, "pa_placement");
_Static_assert(sizeof(pa_paint) == 48 && sizeof(pa_view) == 32 && sizeof(pa_tick) == 128, "pa_paint");
_Static_assert(sizeof(pa_key) == 8 && sizeof(pa_mouse) == 16, "pa_key");
-_Static_assert(sizeof(pa_api) == 112 && sizeof(pa_out) == 16, "pa_api");
+_Static_assert(sizeof(pa_api) == 120 && sizeof(pa_out) == 16, "pa_api");
_Static_assert(sizeof(pa_word) == 32 && sizeof(pa_head) == 56, "pa_head");
_Static_assert(sizeof(pa_ops) == 208, "pa_ops");
#endif