authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-31 23:43:43 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-01 02:22:54 -07:00
logd6a5f02589e46e5adab2b7b530b4c9e2c6ce4edb
treed5ef5a28915f584369e5ad8eb2da3a386b6accc2
parent79f550e35d12a4536aaf3defffaa497de9fa5de0
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

update to zig 0.15.2


2 files changed, 12 insertions(+), 12 deletions(-)

README.md+1-1
...@@ -3,7 +3,7 @@...@@ -3,7 +3,7 @@
3![loc](https://sloc.xyz/github/nektro/zig-pek)3![loc](https://sloc.xyz/github/nektro/zig-pek)
4[![license](https://img.shields.io/github/license/nektro/zig-pek.svg)](https://github.com/nektro/zig-pek/blob/master/LICENSE)4[![license](https://img.shields.io/github/license/nektro/zig-pek.svg)](https://github.com/nektro/zig-pek/blob/master/LICENSE)
5[![nektro @ github sponsors](https://img.shields.io/badge/sponsors-nektro-purple?logo=github)](https://github.com/sponsors/nektro)5[![nektro @ github sponsors](https://img.shields.io/badge/sponsors-nektro-purple?logo=github)](https://github.com/sponsors/nektro)
6[![Zig](https://img.shields.io/badge/Zig-0.14-f7a41d)](https://ziglang.org/)6[![Zig](https://img.shields.io/badge/Zig-0.15-f7a41d)](https://ziglang.org/)
7[![Zigmod](https://img.shields.io/badge/Zigmod-latest-f7a41d)](https://github.com/nektro/zigmod)7[![Zigmod](https://img.shields.io/badge/Zigmod-latest-f7a41d)](https://github.com/nektro/zigmod)
88
9A comptime HTML preprocessor with a builtin template engine for Zig.9A comptime HTML preprocessor with a builtin template engine for Zig.
src/lib.zig+11-11
...@@ -40,7 +40,7 @@ pub fn compileInner(alloc: std.mem.Allocator, writer: anytype, comptime value: a...@@ -40,7 +40,7 @@ pub fn compileInner(alloc: std.mem.Allocator, writer: anytype, comptime value: a
40 try do(alloc, writer, value, data, data, opts);40 try do(alloc, writer, value, data, data, opts);
41}41}
4242
43pub const Writer = std.ArrayList(u8).Writer;43pub const Writer = *std.Io.Writer;
4444
45fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype, comptime opts: DoOptions) anyerror!void {45fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype, comptime opts: DoOptions) anyerror!void {
46 comptime var skipindent = false;46 comptime var skipindent = false;
...@@ -297,33 +297,33 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val...@@ -297,33 +297,33 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val
297 .function => |v| {297 .function => |v| {
298 if (!v.raw and @hasDecl(opts.Ctx, "pek_" ++ v.name)) {298 if (!v.raw and @hasDecl(opts.Ctx, "pek_" ++ v.name)) {
299 const func = @field(opts.Ctx, "pek_" ++ v.name);299 const func = @field(opts.Ctx, "pek_" ++ v.name);
300 var list = std.ArrayList(u8).init(alloc);300 var list = std.Io.Writer.Allocating.init(alloc);
301 defer list.deinit();301 defer list.deinit();
302 comptime var types: [v.args.len]type = @splat(void);302 comptime var types: [v.args.len]type = @splat(void);
303 inline for (v.args, &types) |arg, *T| T.* = ResolveArg(arg, @TypeOf(data), @TypeOf(ctx));303 inline for (v.args, &types) |arg, *T| T.* = ResolveArg(arg, @TypeOf(data), @TypeOf(ctx));
304 var args: std.meta.Tuple(&types) = undefined;304 var args: std.meta.Tuple(&types) = undefined;
305 inline for (v.args, 0..) |arg, i| args[i] = try resolveArg(arg, alloc, data, ctx, opts);305 inline for (v.args, 0..) |arg, i| args[i] = try resolveArg(arg, alloc, data, ctx, opts);
306 try @call(.auto, func, .{ alloc, list.writer() } ++ args);306 try @call(.auto, func, .{ alloc, &list.writer } ++ args);
307 try writeReplacementString(writer, v.raw, opts.escaped, try list.toOwnedSlice());307 try writeReplacementString(writer, v.raw, opts.escaped, try list.toOwnedSlice());
308 return;308 return;
309 }309 }
310 if (v.raw and @hasDecl(opts.Ctx, "pek__" ++ v.name)) {310 if (v.raw and @hasDecl(opts.Ctx, "pek__" ++ v.name)) {
311 const func = @field(opts.Ctx, "pek__" ++ v.name);311 const func = @field(opts.Ctx, "pek__" ++ v.name);
312 var list = std.ArrayList(u8).init(alloc);312 var list = std.Io.Writer.Allocating.init(alloc);
313 defer list.deinit();313 defer list.deinit();
314 const Tup = @typeInfo(@TypeOf(func)).@"fn".params[3].type.?;314 const Tup = @typeInfo(@TypeOf(func)).@"fn".params[3].type.?;
315 if (@typeInfo(Tup).@"struct".fields.len == 0) {315 if (@typeInfo(Tup).@"struct".fields.len == 0) {
316 // edge case branch because 'struct {}' is counted as a non-tuple316 // edge case branch because 'struct {}' is counted as a non-tuple
317 try @call(.auto, func, .{ alloc, list.writer(), opts, Tup{} });317 try @call(.auto, func, .{ alloc, &list.writer, opts, Tup{} });
318 try writeReplacementString(writer, v.raw, opts.escaped, list.items);318 try writeReplacementString(writer, v.raw, opts.escaped, list.written());
319 return;319 return;
320 }320 }
321 comptime var types: [v.args.len]type = @splat(void);321 comptime var types: [v.args.len]type = @splat(void);
322 inline for (v.args, &types) |arg, *T| T.* = ResolveArg(arg, @TypeOf(data), @TypeOf(ctx));322 inline for (v.args, &types) |arg, *T| T.* = ResolveArg(arg, @TypeOf(data), @TypeOf(ctx));
323 var args: std.meta.Tuple(&types) = undefined;323 var args: std.meta.Tuple(&types) = undefined;
324 inline for (v.args, 0..) |arg, i| args[i] = try resolveArg(arg, alloc, data, ctx, opts);324 inline for (v.args, 0..) |arg, i| args[i] = try resolveArg(arg, alloc, data, ctx, opts);
325 try @call(.auto, func, .{ alloc, list.writer(), opts, args });325 try @call(.auto, func, .{ alloc, &list.writer, opts, args });
326 try writeReplacementString(writer, v.raw, opts.escaped, list.items);326 try writeReplacementString(writer, v.raw, opts.escaped, list.written());
327 return;327 return;
328 }328 }
329 if (v.raw and @hasDecl(opts.Ctx, "pek_" ++ v.name)) {329 if (v.raw and @hasDecl(opts.Ctx, "pek_" ++ v.name)) {
...@@ -352,11 +352,11 @@ fn resolveArg(comptime arg: astgen.Arg, alloc: std.mem.Allocator, data: anytype,...@@ -352,11 +352,11 @@ fn resolveArg(comptime arg: astgen.Arg, alloc: std.mem.Allocator, data: anytype,
352 .lookup => |av| search(av, ctx),352 .lookup => |av| search(av, ctx),
353 .int => |av| av,353 .int => |av| av,
354 .value => |av| {354 .value => |av| {
355 var list = std.ArrayList(u8).init(alloc);355 var list = std.Io.Writer.Allocating.init(alloc);
356 comptime var newopts = opts;356 comptime var newopts = opts;
357 newopts.escaped = false;357 newopts.escaped = false;
358 try do(alloc, list.writer(), astgen.Value{ .body = av }, data, ctx, newopts);358 try do(alloc, &list.writer, astgen.Value{ .body = av }, data, ctx, newopts);
359 return list.items;359 return list.written();
360 },360 },
361 };361 };
362}362}