found fix for comptime decl stuff, avoid more codegen changes

This commit is contained in:
Emil Lerch 2023-08-05 13:00:55 -07:00
parent e5b3f03681
commit e49ed1b7ad
Signed by: lobo
GPG Key ID: A7B62D657EF764F8

View File

@ -983,13 +983,13 @@ fn buildQuery(allocator: std.mem.Allocator, request: anytype) ![]const u8 {
const writer = buffer.writer(); const writer = buffer.writer();
defer buffer.deinit(); defer buffer.deinit();
var prefix = "?"; var prefix = "?";
// TODO: This was a pain before, and it's a pain now. Clearly our codegen if (@hasDecl(@TypeOf(request), "http_query")) {
// needs to emit a declaration 100% of the time const query_arguments = @field(@TypeOf(request), "http_query");
const query_arguments = @TypeOf(request).http_query; inline for (@typeInfo(@TypeOf(query_arguments)).Struct.fields) |arg| {
inline for (@typeInfo(@TypeOf(query_arguments)).Struct.fields) |arg| { const val = @field(request, arg.name);
const val = @field(request, arg.name); if (try addQueryArg(arg.type, prefix, @field(query_arguments, arg.name), val, writer))
if (try addQueryArg(arg.type, prefix, @field(query_arguments, arg.name), val, writer)) prefix = "&";
prefix = "&"; }
} }
return buffer.toOwnedSlice(); return buffer.toOwnedSlice();
} }