update: filters

This commit is contained in:
Lucas F. 2026-01-04 21:38:31 -03:00
parent e5305f85c9
commit d1c63cddda
5 changed files with 2401 additions and 57 deletions

View file

@ -40,7 +40,7 @@ pub const Context = struct {
.bool => Value{ .bool = value },
.int, .comptime_int => Value{ .int = @intCast(value) },
.float, .comptime_float => Value{ .float = @floatCast(value) },
.pointer => Value{ .string = std.fmt.allocPrint(self.allocator(), "{s}", .{value}) catch "" },
.pointer => Value{ .string = try std.fmt.allocPrint(self.allocator(), "{s}", .{value}) },
.@"struct" => blk: {
var dict = std.StringHashMapUnmanaged(Value){};
inline for (std.meta.fields(T)) |field| {
@ -59,13 +59,14 @@ pub const Context = struct {
},
.optional => if (value) |v| try self.toValue(v) else .null,
.null => .null,
// CASO ESPECIAL: o valor é um Value (ex: lista de Value)
.@"union" => if (T == Value) value else @compileError("Unsupported union type: " ++ @typeName(T)),
else => @compileError("Unsupported type: " ++ @typeName(T)),
};
}
pub fn set(self: *Context, key: []const u8, value: anytype) !void {
const v = try self.toValue(value);
const gop = try self.map.getOrPut(self.allocator(), key);
if (!gop.found_existing) {
gop.key_ptr.* = try self.allocator().dupe(u8, key);