mirror of
https://git.xeondev.com/LR/S.git
synced 2026-03-24 16:42:49 +01:00
fix(proto): oneof codegen and encoding fixes
This commit is contained in:
@@ -336,7 +336,7 @@ fn compileMessage(mode: CompilationMode, arena: Allocator, l: *Lexer, out: *Io.W
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (output_structures)
|
if (output_structures)
|
||||||
try out.writeAll(" },\n");
|
try out.writeAll(" } = null,\n");
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ pub fn decodeMessage(r: *Io.Reader, allocator: Allocator, comptime Message: type
|
|||||||
field_names = field_names ++ .{field.name};
|
field_names = field_names ++ .{field.name};
|
||||||
} else if (comptime oneofUnion(field.type)) |oneof| {
|
} else if (comptime oneofUnion(field.type)) |oneof| {
|
||||||
oneof_names = oneof_names ++ .{field.name};
|
oneof_names = oneof_names ++ .{field.name};
|
||||||
oneof_types = oneof_types ++ .{oneof};
|
oneof_types = oneof_types ++ .{field.type};
|
||||||
inline for (oneof.fields) |oneof_field| {
|
inline for (oneof.fields) |oneof_field| {
|
||||||
field_names = field_names ++ .{oneof_field.name};
|
field_names = field_names ++ .{oneof_field.name};
|
||||||
}
|
}
|
||||||
@@ -221,9 +221,9 @@ pub fn decodeMessage(r: *Io.Reader, allocator: Allocator, comptime Message: type
|
|||||||
} else {
|
} else {
|
||||||
@field(message, field.name) = try decodeField(r, allocator, field.type, wire_type);
|
@field(message, field.name) = try decodeField(r, allocator, field.type, wire_type);
|
||||||
}
|
}
|
||||||
} else inline for (oneof_names, oneof_types) |oneof_name, Oneof| inline for (@typeInfo(Oneof).@"union".fields) |oneof_field| {
|
} else inline for (oneof_names, oneof_types) |oneof_name, Oneof| inline for (@typeInfo(std.meta.Child(Oneof)).@"union".fields) |oneof_field| {
|
||||||
if (comptime std.mem.eql(u8, oneof_field.name, field_name)) {
|
if (comptime std.mem.eql(u8, oneof_field.name, field_name)) {
|
||||||
@field(message, oneof_name) = @unionInit(Oneof, field_name, try decodeField(r, allocator, oneof_field.type, wire_type));
|
@field(message, oneof_name) = @unionInit(std.meta.Child(Oneof), field_name, try decodeField(r, allocator, oneof_field.type, wire_type));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user