update to latest zig

This commit is contained in:
Mitchell Hashimoto
2022-12-21 18:30:21 -08:00
parent e210c91d10
commit 6f3bc5186d
7 changed files with 20 additions and 20 deletions

6
flake.lock generated
View File

@ -109,11 +109,11 @@
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1671236459,
"narHash": "sha256-J9Ow+I5cLUGE8IJMV08TAZP1DD4EP1TYnqgXVDIVzSU=",
"lastModified": 1671668597,
"narHash": "sha256-oD+Zx3IeXx2d91AiD5O74P4582iRPTPabCt6HDhagSo=",
"owner": "mitchellh",
"repo": "zig-overlay",
"rev": "9a123723c252f3d2aad8523a6fbcba1b7a3c9698",
"rev": "64fcf1f2efcc63e97830e203f8e64ca20137ffa2",
"type": "github"
},
"original": {

View File

@ -14,7 +14,7 @@ pub fn Handle(comptime T: type) type {
return struct {
// note: this has to be here: https://github.com/ziglang/zig/issues/11367
const tInfo = @typeInfo(T).Struct;
const HandleType = tInfo.fields[0].field_type;
const HandleType = tInfo.fields[0].type;
// Request handle to be closed. close_cb will be called asynchronously
// after this call. This MUST be called on each handle before memory

View File

@ -18,7 +18,7 @@ pub fn Stream(comptime T: type) type {
return struct {
// note: this has to be here: https://github.com/ziglang/zig/issues/11367
const tInfo = @typeInfo(T).Struct;
const HandleType = tInfo.fields[0].field_type;
const HandleType = tInfo.fields[0].type;
/// Returns 1 if the stream is readable, 0 otherwise.
pub fn isReadable(self: T) !bool {
@ -165,7 +165,7 @@ pub const WriteReq = struct {
/// T should be a high-level handle type such as "Pipe".
pub fn handle(self: WriteReq, comptime HT: type) ?HT {
const tInfo = @typeInfo(HT).Struct;
const HandleType = tInfo.fields[0].field_type;
const HandleType = tInfo.fields[0].type;
return if (self.req.handle) |ptr|
return HT{ .handle = @ptrCast(HandleType, ptr) }

View File

@ -126,23 +126,23 @@ fn MsgSendFn(
// Build up our argument types.
const Fn = std.builtin.Type.Fn;
const args: []Fn.Param = args: {
const params: []Fn.Param = params: {
var acc: [argsInfo.fields.len + 2]Fn.Param = undefined;
// First argument is always the target and selector.
acc[0] = .{ .arg_type = Target, .is_generic = false, .is_noalias = false };
acc[1] = .{ .arg_type = c.SEL, .is_generic = false, .is_noalias = false };
acc[0] = .{ .type = Target, .is_generic = false, .is_noalias = false };
acc[1] = .{ .type = c.SEL, .is_generic = false, .is_noalias = false };
// Remaining arguments depend on the args given, in the order given
for (argsInfo.fields) |field, i| {
acc[i + 2] = .{
.arg_type = field.field_type,
.type = field.type,
.is_generic = false,
.is_noalias = false,
};
}
break :args &acc;
break :params &acc;
};
// Copy the alignment of a normal function type so equality works
@ -156,7 +156,7 @@ fn MsgSendFn(
.is_generic = false,
.is_var_args = false,
.return_type = Return,
.args = args,
.params = params,
},
});
}

View File

@ -87,9 +87,9 @@ fn parseIntoField(
// For optional fields, we just treat it as the child type.
// This lets optional fields default to null but get set by
// the CLI.
const Field = switch (@typeInfo(field.field_type)) {
const Field = switch (@typeInfo(field.type)) {
.Optional => |opt| opt.child,
else => field.field_type,
else => field.type,
};
const fieldInfo = @typeInfo(Field);
@ -97,7 +97,7 @@ fn parseIntoField(
// that to set the value.
if (fieldInfo == .Struct and @hasDecl(Field, "parseCLI")) {
const fnInfo = @typeInfo(@TypeOf(Field.parseCLI)).Fn;
switch (fnInfo.args.len) {
switch (fnInfo.params.len) {
// 1 arg = (input) => output
1 => @field(dst, field.name) = try Field.parseCLI(value),
@ -291,11 +291,11 @@ test "parseIntoField: unsigned numbers" {
const alloc = arena.allocator();
var data: struct {
@"u8": u8,
u8: u8,
} = undefined;
try parseIntoField(@TypeOf(data), alloc, &data, "u8", "1");
try testing.expectEqual(@as(u8, 1), data.@"u8");
try testing.expectEqual(@as(u8, 1), data.u8);
}
test "parseIntoField: optional field" {

View File

@ -42,7 +42,7 @@ pub fn parse(input: []const u8) !Binding {
// Check if its a modifier
const modsInfo = @typeInfo(key.Mods).Struct;
inline for (modsInfo.fields) |field| {
if (field.field_type == bool) {
if (field.type == bool) {
if (std.mem.eql(u8, part, field.name)) {
// Repeat not allowed
if (@field(result.mods, field.name)) return Error.InvalidFormat;
@ -90,7 +90,7 @@ pub fn parse(input: []const u8) !Binding {
inline for (actionInfo.fields) |field| {
if (std.mem.eql(u8, action, field.name)) {
// If the field type is void we expect no value
switch (field.field_type) {
switch (field.type) {
void => {
if (colonIdx != null) return Error.InvalidFormat;
break :action @unionInit(Action, field.name, {});

2
vendor/zig-libxml2 vendored

@ -1 +1 @@
Subproject commit 47fc435b1b5885345693a09b19f2fdcfb91082d8
Subproject commit 2fad039cd983084b615347333790680983c2f4d4