authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-14 16:56:42 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-14 16:56:42 -07:00
log499071c2903ee2b67460c0c3e8f0446cd232702f
tree50f07d612984a44eb39146a87b9ad153c7a15472
parent089c19bcf6051fde10e69b458d68c2ac79c6e49b

allow custom helpers to return any type


1 files changed, 3 insertions(+), 8 deletions(-)

src/lib.zig+3-8
...@@ -147,14 +147,9 @@ fn do(alloc: *std.mem.Allocator, writer: anytype, comptime value: astgen.Value,...@@ -147,14 +147,9 @@ fn do(alloc: *std.mem.Allocator, writer: anytype, comptime value: astgen.Value,
147 const field_name = comptime std.fmt.comptimePrint("{d}", .{i + 1});147 const field_name = comptime std.fmt.comptimePrint("{d}", .{i + 1});
148 @field(args, field_name) = if (comptime std.mem.eql(u8, arg[0], "this")) search(arg[1..], data) else search(arg, ctx);148 @field(args, field_name) = if (comptime std.mem.eql(u8, arg[0], "this")) search(arg[1..], data) else search(arg, ctx);
149 }149 }
150 const s: []const u8 = try @call(.{}, func, args);150 const repvalue = astgen.Value{ .replacement = &.{"this"} };
151 for (s) |c| {151 const newdata = try @call(.{}, func, args);
152 if (entityLookupBefore(&[_]u8{c})) |ent| {152 try do(alloc, writer, repvalue, newdata, ctx, indent, flag1);
153 try writer.writeAll(ent.entity);
154 } else {
155 try writer.writeAll(&[_]u8{c});
156 }
157 }
158 return;153 return;
159 }154 }
160 @compileError("pek: unknown custom function: " ++ v.name);155 @compileError("pek: unknown custom function: " ++ v.name);