diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Addon.zig | 6 | ||||
| -rw-r--r-- | src/kinds/addon.zig | 12 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/Addon.zig b/src/Addon.zig index 04cffcb9..209c761a 100644 --- a/src/Addon.zig +++ b/src/Addon.zig @@ -175,9 +175,9 @@ var found_text: [Kind.max_kinds][2][4096]u8 = undefined; var nfound: usize = 0; /// A static pardes's addons (`zig build static`), compiled in: the image -/// addon's module and the PDF's C, its `pardes_addon` renamed. A static -/// binary cannot dlopen, and macOS's loader has no memfd: this is how -/// either has image and PDF panes. +/// and pdf modules' `pardes_addon` declarations, which only a library +/// exports. A static binary cannot dlopen, and macOS's loader has no +/// memfd: this is how either has image and PDF panes. const compiled_in: []const *const Kind.Ops = if (@import("builtin_addons").on) &.{ &@import("image_addon").pardes_addon, &@import("pdf_addon").pardes_addon } else &.{}; /// The addons compiled in, as if loaded (`builtin` their path); else every diff --git a/src/kinds/addon.zig b/src/kinds/addon.zig index f921768f..229cf639 100644 --- a/src/kinds/addon.zig +++ b/src/kinds/addon.zig @@ -22,8 +22,13 @@ //! as Allocators, `seed`, `say`, `job`, `cancel`, `look`, `text`, `exec`, //! `select` and `found`. A body written is at most `body_max` bytes. //! -//! export const pardes_addon = addon.ops(Snake); +//! pub const pardes_addon = addon.ops(Snake); +//! comptime { +//! addon.exportLib(&pardes_addon); +//! } //! +//! The library's one export; a pardes with the kind compiled in reads the +//! declaration instead (Addon.zig), so two kinds there never collide. //! addons/snake/snake.zig, addons/life/life.zig and addons/image/image.zig //! are the examples. const std = @import("std"); @@ -231,6 +236,11 @@ fn span(p: [*c]const u8, n: u64) []const u8 { return if (p == null) "" else p[0..n]; } +/// `pardes_addon` exported, when built as a library alone. +pub fn exportLib(comptime ops_: *const c.pa_ops) void { + if (@import("builtin").output_mode == .Lib) @export(ops_, .{ .name = "pardes_addon" }); +} + /// A kind's `pa_ops`: its head, and a C function for each of its own. pub fn ops(comptime T: type) c.pa_ops { const F = struct { |
