diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-06 22:49:11 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-06 23:38:31 -0300 |
| commit | c36e38e0a26f9bdef2892621b99390dedd35686d (patch) | |
| tree | c5817e8f3be6c9a2c930bd0d3576752e5feef070 /addons | |
| parent | 227111c84a2945087abb4395daf63c7b23ba5bab (diff) | |
| download | pardes-c36e38e0a26f9bdef2892621b99390dedd35686d.tar.gz pardes-c36e38e0a26f9bdef2892621b99390dedd35686d.zip | |
kinds #48, the export rule finished: every Zig kind declares `pub const pardes_addon = addon.ops(T)` and calls `addon.exportLib(&pardes_addon)` in a comptime block, which exports it only when the output is a library (Zig 0.17 analyses no `pub const` of a library's root and no comptime block of a type made in a generic function, so the export cannot live in `ops` alone: one comptime line in the kind is the spelling that works), and a pardes with kinds compiled in reads the declarations; image.zig's `pub export`, snake's and life's `export` go, no rename anywhere, and fake.c stays the loader's test, never compiled in
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/image/image.zig | 5 | ||||
| -rw-r--r-- | addons/life/life.zig | 5 | ||||
| -rw-r--r-- | addons/pdf/pdf.zig | 3 | ||||
| -rw-r--r-- | addons/snake/snake.zig | 5 |
4 files changed, 13 insertions, 5 deletions
diff --git a/addons/image/image.zig b/addons/image/image.zig index 88ae1e2d..09b17ca7 100644 --- a/addons/image/image.zig +++ b/addons/image/image.zig @@ -89,7 +89,10 @@ pub const Image = struct { } }; -pub export const pardes_addon = addon.ops(Image); +pub const pardes_addon = addon.ops(Image); +comptime { + addon.exportLib(&pardes_addon); +} test "a job decodes a picture to its size and pixels, and one past max_dim is scaled to fit" { var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); diff --git a/addons/life/life.zig b/addons/life/life.zig index 2f459e07..278990f8 100644 --- a/addons/life/life.zig +++ b/addons/life/life.zig @@ -4,7 +4,10 @@ const std = @import("std"); const addon = @import("addon"); -export const pardes_addon = addon.ops(Life); +pub const pardes_addon = addon.ops(Life); +comptime { + addon.exportLib(&pardes_addon); +} const W = 32; const H = 16; diff --git a/addons/pdf/pdf.zig b/addons/pdf/pdf.zig index 4704e7c7..45f1e22a 100644 --- a/addons/pdf/pdf.zig +++ b/addons/pdf/pdf.zig @@ -29,9 +29,8 @@ const m = @import("pdf_bridge"); const c = addon.c; pub const pardes_addon = addon.ops(Pdf); -// A library's one export; a static pardes reads the declaration (Addon.zig). comptime { - if (@import("builtin").output_mode == .Lib) @export(&pardes_addon, .{ .name = "pardes_addon" }); + addon.exportLib(&pardes_addon); } const gap_px = 8; // between two pages of the strip diff --git a/addons/snake/snake.zig b/addons/snake/snake.zig index cdbf74d9..dab5846e 100644 --- a/addons/snake/snake.zig +++ b/addons/snake/snake.zig @@ -130,7 +130,10 @@ pub const Snake = extern struct { pub const load = addon.loadBytes; }; -export const pardes_addon = addon.ops(Snake); +pub const pardes_addon = addon.ops(Snake); +comptime { + addon.exportLib(&pardes_addon); +} test "it eats, grows a segment and a point, dies on the wall, and its record is its state" { var s = std.mem.zeroInit(Snake, .{ .rng = 3 }); |
