mach: fix compiler error regarding zig changes (#645)

This commit is contained in:
Benjaaaa 2022-12-25 17:19:48 -03:00 committed by GitHub
parent 0e67b92676
commit 052d3a7da8
Failed to generate hash of commit
3 changed files with 10 additions and 11 deletions

View file

@ -81,10 +81,10 @@ pub const ArchetypeStorage = struct {
fn debugValidateRow(storage: *ArchetypeStorage, gpa: Allocator, row: anytype) void {
inline for (std.meta.fields(@TypeOf(row))) |field, index| {
const column = storage.columns[index];
if (typeId(field.field_type) != column.type_id) {
if (typeId(field.type) != column.type_id) {
const msg = std.mem.concat(gpa, u8, &.{
"unexpected type: ",
@typeName(field.field_type),
@typeName(field.type),
" expected: ",
column.name,
}) catch |err| @panic(@errorName(err));
@ -179,7 +179,7 @@ pub const ArchetypeStorage = struct {
const fields = std.meta.fields(@TypeOf(row));
inline for (fields) |field, index| {
const ColumnType = field.field_type;
const ColumnType = field.type;
if (@sizeOf(ColumnType) == 0) continue;
const column = storage.columns[index];
const column_values = @ptrCast([*]ColumnType, @alignCast(@alignOf(ColumnType), &storage.block[column.offset]));
@ -375,10 +375,10 @@ pub fn Entities(comptime all_components: anytype) type {
const namespaces = std.meta.fields(@TypeOf(all_components));
var fields: [namespaces.len]std.builtin.Type.UnionField = undefined;
inline for (namespaces) |namespace, i| {
const component_enum = std.meta.FieldEnum(namespace.field_type);
const component_enum = std.meta.FieldEnum(namespace.type);
fields[i] = .{
.name = namespace.name,
.field_type = component_enum,
.type = component_enum,
.alignment = @alignOf(component_enum),
};
}

View file

@ -42,7 +42,7 @@ pub fn Messages(comptime messages: anytype) type {
const message_type = @field(messages, message_field.name);
fields = fields ++ [_]std.builtin.Type.UnionField{.{
.name = message_field.name,
.field_type = message_type,
.type = message_type,
.alignment = if (message_type == void) 0 else @alignOf(message_type),
}};
}
@ -80,7 +80,6 @@ pub fn MessagesTag(comptime messages: anytype) type {
return @Type(.{
.Enum = .{
.layout = .Auto,
.tag_type = std.meta.Int(.unsigned, @floatToInt(u16, math.ceil(math.log2(@intToFloat(f64, message_fields.len))))),
.fields = fields,
.decls = &[_]std.builtin.Type.Declaration{},
@ -99,7 +98,7 @@ fn NamespacedComponents(comptime modules: anytype) type {
if (@hasField(@TypeOf(module), "components")) {
fields = fields ++ [_]std.builtin.Type.StructField{.{
.name = module_field.name,
.field_type = @TypeOf(module.components),
.type = @TypeOf(module.components),
.default_value = null,
.is_comptime = false,
.alignment = @alignOf(@TypeOf(module.components)),
@ -204,7 +203,7 @@ fn NamespacedGlobals(comptime modules: anytype) type {
if (@hasField(@TypeOf(module), "globals")) {
fields = fields ++ [_]std.builtin.Type.StructField{.{
.name = module_field.name,
.field_type = module.globals,
.type = module.globals,
.default_value = null,
.is_comptime = false,
.alignment = @alignOf(module.globals),

View file

@ -28,12 +28,12 @@ pub const Context = struct {
var data: backends.BackendContext = blk: {
if (backend) |b| {
break :blk try @typeInfo(
std.meta.fieldInfo(backends.BackendContext, b).field_type,
std.meta.fieldInfo(backends.BackendContext, b).type,
).Pointer.child.init(allocator, options);
} else {
inline for (std.meta.fields(Backend)) |b, i| {
if (@typeInfo(
std.meta.fieldInfo(backends.BackendContext, @intToEnum(Backend, b.value)).field_type,
std.meta.fieldInfo(backends.BackendContext, @intToEnum(Backend, b.value)).type,
).Pointer.child.init(allocator, options)) |d| {
break :blk d;
} else |err| {