Properly cast Fixed in Dispatcher

Fixes the following error:

    ./zig-wayland/common.zig:75:44: error: cannot cast a value of type '.wayland.common.Fixed'
                          4 => @bitCast(f.field_type, args[i].u),
                                         ^
    ./zig-wayland/common.zig:75:44: note: use @intToEnum for type coercion
                          4 => @bitCast(f.field_type, args[i].u),
                                         ^
    ./zig-wayland/common.zig:75:64: note: referenced here
                                4 => @bitCast(f.field_type, args[i].u),
This commit is contained in:
Reiner Gerecke
2020-10-18 17:27:27 +02:00
committed by Isaac Freund
parent f4d11e4ed2
commit 1849d4e513
+7 -4
View File
@@ -71,10 +71,13 @@ pub fn Dispatcher(comptime Obj: type, comptime Data: type) type {
if (payload_num == opcode) {
var payload_data: payload_field.field_type = undefined;
inline for (@typeInfo(payload_field.field_type).Struct.fields) |f, i| {
@field(payload_data, f.name) = switch (@sizeOf(f.field_type)) {
4 => @bitCast(f.field_type, args[i].u),
8 => @intToPtr(f.field_type, @ptrToInt(args[i].s)),
else => unreachable,
@field(payload_data, f.name) = switch (f.field_type) {
Fixed => @intToEnum(Fixed, args[i].i),
else => switch (@sizeOf(f.field_type)) {
4 => @bitCast(f.field_type, args[i].u),
8 => @intToPtr(f.field_type, @ptrToInt(args[i].s)),
else => unreachable,
},
};
}