authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-10 01:37:58 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-10 01:37:58 -07:00
log487fb89143d9f59d7d4c170e76fc6f996c7c1745
tree647e0fcea1d67613a6d5bab4795a5e76c2709b9b
parent5bd838ca3428a4ede13c5c5c94b36e7b93510bc2
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

more function logic cleanup


1 files changed, 5 insertions(+), 9 deletions(-)

src/lib.zig+5-9
...@@ -295,7 +295,8 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val...@@ -295,7 +295,8 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val
295 }295 }
296 },296 },
297 .function => |v| {297 .function => |v| {
298 if (!v.raw and @hasDecl(opts.Ctx, "pek_" ++ v.name)) {298 if (!v.raw) {
299 if (@hasDecl(opts.Ctx, "pek__" ++ v.name)) @compileError("pek: attempted to call raw custom function: '_" ++ v.name ++ "' but did not use '{#" ++ v.name ++ "}'");
299 const func = @field(opts.Ctx, "pek_" ++ v.name);300 const func = @field(opts.Ctx, "pek_" ++ v.name);
300 var list = std.Io.Writer.Allocating.init(alloc);301 var list = std.Io.Writer.Allocating.init(alloc);
301 defer list.deinit();302 defer list.deinit();
...@@ -307,7 +308,8 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val...@@ -307,7 +308,8 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val
307 try writeReplacementString(writer, v.raw, opts.escaped, try list.toOwnedSlice());308 try writeReplacementString(writer, v.raw, opts.escaped, try list.toOwnedSlice());
308 return;309 return;
309 }310 }
310 if (v.raw and @hasDecl(opts.Ctx, "pek__" ++ v.name)) {311 if (v.raw) {
312 if (@hasDecl(opts.Ctx, "pek_" ++ v.name)) @compileError("pek: attempted to call safe custom function: '" ++ v.name ++ "' but did not use '{" ++ v.name ++ "}'");
311 const func = @field(opts.Ctx, "pek__" ++ v.name);313 const func = @field(opts.Ctx, "pek__" ++ v.name);
312 var list = std.Io.Writer.Allocating.init(alloc);314 var list = std.Io.Writer.Allocating.init(alloc);
313 defer list.deinit();315 defer list.deinit();
...@@ -326,13 +328,7 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val...@@ -326,13 +328,7 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val
326 try writeReplacementString(writer, v.raw, opts.escaped, list.written());328 try writeReplacementString(writer, v.raw, opts.escaped, list.written());
327 return;329 return;
328 }330 }
329 if (v.raw and @hasDecl(opts.Ctx, "pek_" ++ v.name)) {331 comptime unreachable;
330 @compileError("pek: attempted to call safe custom function: '" ++ v.name ++ "' but did not use '{" ++ v.name ++ "}'");
331 }
332 if (!v.raw and @hasDecl(opts.Ctx, "pek__" ++ v.name)) {
333 @compileError("pek: attempted to call raw custom function: '_" ++ v.name ++ "' but did not use '{#" ++ v.name ++ "}'");
334 }
335 @compileError("pek: unknown custom function: " ++ v.name);
336 },332 },
337 else => unreachable,333 else => unreachable,
338 }334 }