diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-06 20:57:28 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-06 21:34:14 -0300 |
| commit | 9589f6878ffd2501b4ce5a034ead58119d38749c (patch) | |
| tree | bb5dafdd90f552144b29ad3468fac30b38992f2b /src/config.zig | |
| parent | 76b493ef40a02931eb86805aa30040a594b72ec8 (diff) | |
| download | pardes-9589f6878ffd2501b4ce5a034ead58119d38749c.tar.gz pardes-9589f6878ffd2501b4ce5a034ead58119d38749c.zip | |
kinds #42, what a Zig kind over a C library needs of the module and the core: addon.zig's `init` at load (a library's own setup, MuPDF's allocator) and a body the kind holds (`body(s) []const u8`, any length: a PDF page's text is past body_max), the Debug budget counting only the kind's own time (the file's hash before `open` and pa_api.heap's allocations are the core's: a region's first took 23 ms of a PDF's open, which was the breach), `current` the loop's thread's (a job's heap call is in no call), an Output's arg set from itself (a kind's rows found after its search refill its +Search with its own arg: the @memcpy aliased), and the docs test reading the words of Zig kinds (`.{ .name = "PdfFit"`) beside C's
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/config.zig')
| -rw-r--r-- | src/config.zig | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/config.zig b/src/config.zig index a2aed287..ee7d76f7 100644 --- a/src/config.zig +++ b/src/config.zig @@ -1489,8 +1489,9 @@ const doc_typ = struct { /// The other build's builtins (docs/typ/builtins-*.json), so the docs /// may name a window-only word in a terminal build's test, and back. var other_build: []const u8 = ""; - /// The shipped addons' sources (addons/*/*.c): their words are named - /// in the docs too, `PA_WORD("PdfFit", ...`. + /// The shipped addons' sources (addons/*/*.c and *.zig): their words + /// are named in the docs too, `PA_WORD("PdfFit", ...` or a Zig kind's + /// `.{ .name = "PdfFit"`. var addon_sources: []const u8 = ""; fn loadAddons(gpa: std.mem.Allocator) !void { @@ -1502,20 +1503,28 @@ const doc_typ = struct { var sub = try root.openDir(io, k.name, .{ .iterate = true }); defer sub.close(io); var files = sub.iterate(); - while (try files.next(io)) |f| if (std.mem.endsWith(u8, f.name, ".c")) { + while (try files.next(io)) |f| if (std.mem.endsWith(u8, f.name, ".c") or std.mem.endsWith(u8, f.name, ".zig")) { addon_sources = try std.mem.concat(gpa, u8, &.{ addon_sources, try sub.readFileAlloc(io, f.name, gpa, .limited(1 << 20)) }); }; }; } + /// One of the shipped addons' words, a C kind's or a Zig kind's. + fn addonWord(name: []const u8) bool { + var buf: [96]u8 = undefined; + const c = std.fmt.bufPrint(&buf, "PA_WORD(\"{s}\",", .{name}) catch return false; + if (std.mem.indexOf(u8, addon_sources, c) != null) return true; + const zig = std.fmt.bufPrint(&buf, ".{{ .name = \"{s}\"", .{name}) catch return false; + return std.mem.indexOf(u8, addon_sources, zig) != null; + } + fn word(w: []const u8) bool { const name = w[0 .. std.mem.indexOfScalar(u8, w, '+') orelse w.len]; if (std.meta.stringToEnum(Builtin, name) != null) return true; var buf: [96]u8 = undefined; const needle = std.fmt.bufPrint(&buf, "{{\"name\": \"{s}\",", .{name}) catch return false; if (std.mem.indexOf(u8, other_build, needle) != null) return true; - const addon = std.fmt.bufPrint(&buf, "PA_WORD(\"{s}\",", .{name}) catch return false; - return std.mem.indexOf(u8, addon_sources, addon) != null; + return addonWord(name); } fn chord(tok: []const u8) ?Chord { @@ -1605,9 +1614,7 @@ const doc_typ = struct { if (!std.mem.startsWith(u8, shown, "Term ") or !std.mem.endsWith(u8, shown, " Collapse Del")) return false; var mid = std.mem.tokenizeScalar(u8, shown["Term ".len .. shown.len - " Collapse Del".len], ' '); while (mid.next()) |x| { - var buf: [96]u8 = undefined; - const addon = std.fmt.bufPrint(&buf, "PA_WORD(\"{s}\",", .{x}) catch return false; - if (std.mem.indexOf(u8, addon_sources, addon) == null) return false; + if (!addonWord(x)) return false; } return true; } |
