From 0f81de017ca7b52e951bb70f6f5f3e8c88b425e6 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 13:28:30 -0300 Subject: kinds #25, addons in Zig: src/kinds/addon.zig, over the translated header and nothing of the core, makes a kind's pa_ops from a struct of the functions it has (its head from name, version, extensions and words; a public function of no kind's name a compile error), the pane's arena and a job's pa_out as std Allocators, typed keys, a Window to put text in, a Paint for the prefix and placements, tick's flags and a Deadline, dump and load as an extern struct's bytes in one line each, and body and ctl over a Writer; snake.zig and image.zig (stb_image in stb.c, static, beside any zstbi) replace snake.c and image.c with the same goldens, harness and perf cell, and addon-test runs their own zig tests Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- docs/shared-libs.md | 2 +- docs/typ/reference.typ | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'docs') diff --git a/docs/shared-libs.md b/docs/shared-libs.md index e730efbd..384dc2f1 100644 --- a/docs/shared-libs.md +++ b/docs/shared-libs.md @@ -45,7 +45,7 @@ are the binaries before both addons. ## Image panes became an addon (2026-11-06) -`lib/pardes/addons/image.so` (addons/image/image.c) decodes image panes with +`lib/pardes/addons/image.so` (addons/image/image.zig and stb.c) decodes image panes with its own stb_image, PNG, JPEG and inflate included: the binaries keep none of stb_image but its resize (a kitty PNG's downscale; the decoder and the writer are patched out of zstbi.c), and a kitty `f=100` PNG is wuffs's alone. A diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ index ff035fac..c66de5ad 100644 --- a/docs/typ/reference.typ +++ b/docs/typ/reference.typ @@ -980,9 +980,15 @@ in C or anything that speaks C, and links nothing of pardes: the records are the header's, and what pardes does for it (an allocation from the pane's arena, memory that outlives a call, a job off the loop, a Look or an Exec, a message, a new text pane, its selection) it is handed at load. -`addons/fake/fake.c` uses every function and `addons/snake/snake.c` is a -game in it; a kind with only a head and `paint` is a valid one. Pictures -are an addon too, `addons/image/image.c` (PNG, JPEG, GIF, BMP, PPM, PGM and +`addons/fake/fake.c` uses every function; a kind with only a head and +`paint` is a valid one. In Zig, `src/kinds/addon.zig` (over the same +header, and nothing of the core) makes the `pa_ops` from a struct of the +functions a kind has (`export const pardes_addon = addon.ops(Snake);`), +with the pane's arena as a `std.mem.Allocator`, typed keys, a window to +`put` text in, a deadline for `tick`, a struct's bytes as its record, and +its own `zig test` (`zig build addon-test` runs them): +`addons/snake/snake.zig` is a game in it. Pictures +are an addon too, `addons/image/image.zig` (PNG, JPEG, GIF, BMP, PPM, PGM and TGA through stb_image, at most 1280 pixels a side), which `zig build image` installs as `/lib/pardes/addons/image.so`, and so are PDFs, `addons/pdf/pdf.c` over MuPDF (its pages rendered on jobs, two at once), -- cgit v1.3