| ... | @@ -14,6 +14,7 @@ const root = @import("root"); | ... | @@ -14,6 +14,7 @@ const root = @import("root"); |
| 14 | const tracer = @import("tracer"); | 14 | const tracer = @import("tracer"); |
| 15 | const extras = @import("extras"); | 15 | const extras = @import("extras"); |
| 16 | const builtin = @import("builtin"); | 16 | const builtin = @import("builtin"); |
| | 17 | const nio = @import("nio"); |
| 17 | | 18 | |
| 18 | const tokenize = @import("./tokenize.zig"); | 19 | const tokenize = @import("./tokenize.zig"); |
| 19 | const astgen = @import("./astgen.zig"); | 20 | const astgen = @import("./astgen.zig"); |
| ... | @@ -182,7 +183,7 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val | ... | @@ -182,7 +183,7 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val |
| 182 | try do(alloc, writer, body, null, extras.join(.{ ctx, .{ .this = item, .that = jtem } }), opts); | 183 | try do(alloc, writer, body, null, extras.join(.{ ctx, .{ .this = item, .that = jtem } }), opts); |
| 183 | } | 184 | } |
| 184 | }, | 185 | }, |
| 185 | else => @compileError(std.fmt.comptimePrint("#each block cannot have {d} iterators", .{v.args.len})), | 186 | else => @compileError(nio.fmt.comptimePrint("#each block cannot have {d} iterators", .{v.args.len})), |
| 186 | } | 187 | } |
| 187 | }, | 188 | }, |
| 188 | .@"if" => { | 189 | .@"if" => { |
| ... | @@ -213,7 +214,7 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val | ... | @@ -213,7 +214,7 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val |
| 213 | .bool => try doif(alloc, writer, body, bottom, data, ctx, opts, x), | 214 | .bool => try doif(alloc, writer, body, bottom, data, ctx, opts, x), |
| 214 | .optional => try doif(alloc, writer, body, bottom, data, ctx, opts, x != null), | 215 | .optional => try doif(alloc, writer, body, bottom, data, ctx, opts, x != null), |
| 215 | .int => try doif(alloc, writer, body, bottom, data, ctx, opts, x != 0), | 216 | .int => try doif(alloc, writer, body, bottom, data, ctx, opts, x != 0), |
| 216 | else => @compileError(std.fmt.comptimePrint("pek: unable to use '{s}' in an #if block", .{@typeName(T)})), | 217 | else => @compileError(nio.fmt.comptimePrint("pek: unable to use '{s}' in an #if block", .{@typeName(T)})), |
| 217 | } | 218 | } |
| 218 | }, | 219 | }, |
| 219 | .ifnot => { | 220 | .ifnot => { |
| ... | @@ -244,7 +245,7 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val | ... | @@ -244,7 +245,7 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val |
| 244 | .bool => try doif(alloc, writer, body, bottom, data, ctx, opts, !x), | 245 | .bool => try doif(alloc, writer, body, bottom, data, ctx, opts, !x), |
| 245 | .optional => try doif(alloc, writer, body, bottom, data, ctx, opts, x == null), | 246 | .optional => try doif(alloc, writer, body, bottom, data, ctx, opts, x == null), |
| 246 | .int => try doif(alloc, writer, body, bottom, data, ctx, opts, x == 0), | 247 | .int => try doif(alloc, writer, body, bottom, data, ctx, opts, x == 0), |
| 247 | else => @compileError(std.fmt.comptimePrint("pek: unable to use '{s}' in an #ifnot block", .{@typeName(T)})), | 248 | else => @compileError(nio.fmt.comptimePrint("pek: unable to use '{s}' in an #ifnot block", .{@typeName(T)})), |
| 248 | } | 249 | } |
| 249 | }, | 250 | }, |
| 250 | .ifequal => { | 251 | .ifequal => { |
| ... | @@ -305,7 +306,7 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val | ... | @@ -305,7 +306,7 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val |
| 305 | args.@"0" = alloc; | 306 | args.@"0" = alloc; |
| 306 | args.@"1" = list.writer(); | 307 | args.@"1" = list.writer(); |
| 307 | inline for (v.args, 0..) |arg, i| { | 308 | inline for (v.args, 0..) |arg, i| { |
| 308 | const field_name = comptime std.fmt.comptimePrint("{d}", .{i + 2}); | 309 | const field_name = comptime nio.fmt.comptimePrint("{d}", .{i + 2}); |
| 309 | @field(args, field_name) = try resolveArg(arg, alloc, data, ctx, opts); | 310 | @field(args, field_name) = try resolveArg(arg, alloc, data, ctx, opts); |
| 310 | } | 311 | } |
| 311 | try @call(.auto, func, args); | 312 | try @call(.auto, func, args); |
| ... | @@ -318,7 +319,7 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val | ... | @@ -318,7 +319,7 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val |
| 318 | defer list.deinit(); | 319 | defer list.deinit(); |
| 319 | const AT = std.meta.ArgsTuple(@TypeOf(func)); | 320 | const AT = std.meta.ArgsTuple(@TypeOf(func)); |
| 320 | const ATT = std.meta.fieldInfo(AT, .@"3").type; | 321 | const ATT = std.meta.fieldInfo(AT, .@"3").type; |
| 321 | if (v.args.len != std.meta.fields(ATT).len) @compileError(std.fmt.comptimePrint("expected:{d} - actual:{d}", .{ std.meta.fields(ATT).len, v.args.len })); | 322 | if (v.args.len != std.meta.fields(ATT).len) @compileError(nio.fmt.comptimePrint("expected:{d} - actual:{d}", .{ std.meta.fields(ATT).len, v.args.len })); |
| 322 | var tupargs = @as(ATT, undefined); | 323 | var tupargs = @as(ATT, undefined); |
| 323 | _ = &tupargs; | 324 | _ = &tupargs; |
| 324 | var args = .{ | 325 | var args = .{ |
| ... | @@ -328,7 +329,7 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val | ... | @@ -328,7 +329,7 @@ fn doInner(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Val |
| 328 | tupargs, | 329 | tupargs, |
| 329 | }; | 330 | }; |
| 330 | inline for (v.args, 0..) |arg, i| { | 331 | inline for (v.args, 0..) |arg, i| { |
| 331 | const field_name = comptime std.fmt.comptimePrint("{d}", .{i}); | 332 | const field_name = comptime nio.fmt.comptimePrint("{d}", .{i}); |
| 332 | @field(args[3], field_name) = try resolveArg(arg, alloc, data, ctx, opts); | 333 | @field(args[3], field_name) = try resolveArg(arg, alloc, data, ctx, opts); |
| 333 | } | 334 | } |
| 334 | try @call(.auto, func, args); | 335 | try @call(.auto, func, args); |
| ... | @@ -505,7 +506,7 @@ fn isCodepointAnEntity(cp: u21) ?htmlentities.Entity { | ... | @@ -505,7 +506,7 @@ fn isCodepointAnEntity(cp: u21) ?htmlentities.Entity { |
| 505 | } | 506 | } |
| 506 | | 507 | |
| 507 | fn assertEqual(comptime a: usize, comptime b: usize) void { | 508 | fn assertEqual(comptime a: usize, comptime b: usize) void { |
| 508 | if (a != b) @compileError(std.fmt.comptimePrint("{d} != {d}", .{ a, b })); | 509 | if (a != b) @compileError(nio.fmt.comptimePrint("{d} != {d}", .{ a, b })); |
| 509 | } | 510 | } |
| 510 | | 511 | |
| 511 | const HtmlVoidElement = enum { | 512 | const HtmlVoidElement = enum { |