Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/encoding.zig
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ pub const Encoding = union(enum) {
.@"opaque" => .void,
.@"enum" => |m| .init(m.tag_type),
.array => |arr| .{ .array = .{ .len = arr.len, .arr_type = arr.child } },
.@"struct" => .{ .structure = .{ .struct_type = T, .show_type_spec = true } },
.@"struct" => |m| switch (m.layout) {
.@"packed" => .init(m.backing_integer.?),
else => .{ .structure = .{ .struct_type = T, .show_type_spec = true } },
},
.@"union" => .{ .@"union" = .{
.union_type = T,
.show_type_spec = true,
Expand Down Expand Up @@ -323,6 +326,13 @@ test "Enum(c_uint) to Encoding.uint encoding" {
try encodingMatchesType(TestEnum, "I");
}

test "TestPackedStruct to Encoding.uint encoding" {
const TestPackedStruct = packed struct(u32) {
_: u32,
};
try encodingMatchesType(TestPackedStruct, "I");
}

test "*TestStruct to Encoding.pointer encoding" {
const TestStruct = extern struct {
float: f32,
Expand Down