Add support for serializing single enums

dev
LeRoyce Pearson 2023-08-10 19:27:47 -06:00
parent 6bdc230417
commit f00806d7f6
3 changed files with 9 additions and 3 deletions

View File

@ -287,7 +287,7 @@ pub fn main() !void {
.width = framebuffer_size[0], .width = framebuffer_size[0],
.height = framebuffer_size[1], .height = framebuffer_size[1],
.stride = framebuffer_size[0] * @sizeOf([4]u8), .stride = framebuffer_size[0] * @sizeOf([4]u8),
.format = @intFromEnum(wayland.core.Shm.Format.argb8888), .format = .argb8888,
} }, } },
); );
try socket.writeAll(std.mem.sliceAsBytes(message)); try socket.writeAll(std.mem.sliceAsBytes(message));

View File

@ -112,8 +112,7 @@ pub const ShmPool = struct {
width: i32, width: i32,
height: i32, height: i32,
stride: i32, stride: i32,
// Shm.Format format: Shm.Format,
format: u32,
}, },
destroy: void, destroy: void,
resize: struct { resize: struct {

View File

@ -176,6 +176,13 @@ pub fn serializeArguments(comptime Signature: type, buffer: []u32, message: Sign
buffer[pos] = @bitCast(@field(message, field.name)); buffer[pos] = @bitCast(@field(message, field.name));
pos += 1; pos += 1;
}, },
.Enum => |enum_info| if (enum_info.tag_type == u32) {
if (pos >= buffer.len) return error.OutOfMemory;
buffer[pos] = @intFromEnum(@field(message, field.name));
pos += 1;
} else {
@compileError("Unsupported type " ++ @typeName(field.type));
},
.Pointer => |ptr| switch (ptr.size) { .Pointer => |ptr| switch (ptr.size) {
.Slice => { .Slice => {
const str = @field(message, field.name); const str = @field(message, field.name);