fix for ziglang pull 6246
This commit is contained in:
parent
6b4ed304a6
commit
f1171b78c8
@ -14,9 +14,9 @@ pub fn EntityTraitsType(comptime size: EntityTraitsSize) type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn EntityTraitsDefinition(comptime EntityType: type, comptime IndexType: type, comptime VersionType: type) type {
|
fn EntityTraitsDefinition(comptime EntityType: type, comptime IndexType: type, comptime VersionType: type) type {
|
||||||
std.debug.assert(@typeInfo(EntityType) == .Int and !EntityType.is_signed);
|
std.debug.assert(@typeInfo(EntityType) == .Int and !@typeInfo(EntityType).Int.is_signed);
|
||||||
std.debug.assert(@typeInfo(IndexType) == .Int and !IndexType.is_signed);
|
std.debug.assert(@typeInfo(IndexType) == .Int and !@typeInfo(IndexType).Int.is_signed);
|
||||||
std.debug.assert(@typeInfo(VersionType) == .Int and !VersionType.is_signed);
|
std.debug.assert(@typeInfo(VersionType) == .Int and !@typeInfo(VersionType).Int.is_signed);
|
||||||
|
|
||||||
if (@bitSizeOf(IndexType) + @bitSizeOf(VersionType) != @bitSizeOf(EntityType))
|
if (@bitSizeOf(IndexType) + @bitSizeOf(VersionType) != @bitSizeOf(EntityType))
|
||||||
@compileError("IndexType and VersionType must sum to EntityType's bit count");
|
@compileError("IndexType and VersionType must sum to EntityType's bit count");
|
||||||
|
@ -85,7 +85,7 @@ pub const OwningGroup = struct {
|
|||||||
|
|
||||||
var component_ptrs: [component_info.fields.len][*]u8 = undefined;
|
var component_ptrs: [component_info.fields.len][*]u8 = undefined;
|
||||||
inline for (component_info.fields) |field, i| {
|
inline for (component_info.fields) |field, i| {
|
||||||
const storage = group.registry.assure(field.field_type.Child);
|
const storage = group.registry.assure(@typeInfo(field.field_type).Pointer.child);
|
||||||
component_ptrs[i] = @ptrCast([*]u8, storage.instances.items.ptr);
|
component_ptrs[i] = @ptrCast([*]u8, storage.instances.items.ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ pub const OwningGroup = struct {
|
|||||||
// fill and return the struct
|
// fill and return the struct
|
||||||
var comps: Components = undefined;
|
var comps: Components = undefined;
|
||||||
inline for (@typeInfo(Components).Struct.fields) |field, i| {
|
inline for (@typeInfo(Components).Struct.fields) |field, i| {
|
||||||
const typed_ptr = @ptrCast([*]field.field_type.Child, @alignCast(@alignOf(field.field_type.Child), it.component_ptrs[i]));
|
const typed_ptr = @ptrCast([*]@typeInfo(field.field_type).Pointer.child, @alignCast(@alignOf(@typeInfo(field.field_type).Pointer.child), it.component_ptrs[i]));
|
||||||
@field(comps, field.name) = &typed_ptr[it.index];
|
@field(comps, field.name) = &typed_ptr[it.index];
|
||||||
}
|
}
|
||||||
return comps;
|
return comps;
|
||||||
|
@ -4,9 +4,9 @@ const std = @import("std");
|
|||||||
/// you choose the type of the handle (aka its size) and how much of that goes to the index and the version.
|
/// you choose the type of the handle (aka its size) and how much of that goes to the index and the version.
|
||||||
/// the bitsize of version + id must equal the handle size.
|
/// the bitsize of version + id must equal the handle size.
|
||||||
pub fn Handles(comptime HandleType: type, comptime IndexType: type, comptime VersionType: type) type {
|
pub fn Handles(comptime HandleType: type, comptime IndexType: type, comptime VersionType: type) type {
|
||||||
std.debug.assert(@typeInfo(HandleType) == .Int and !HandleType.is_signed);
|
std.debug.assert(@typeInfo(HandleType) == .Int and !@typeInfo(HandleType).Int.is_signed);
|
||||||
std.debug.assert(@typeInfo(IndexType) == .Int and !IndexType.is_signed);
|
std.debug.assert(@typeInfo(IndexType) == .Int and !@typeInfo(IndexType).Int.is_signed);
|
||||||
std.debug.assert(@typeInfo(VersionType) == .Int and !VersionType.is_signed);
|
std.debug.assert(@typeInfo(VersionType) == .Int and !@typeInfo(VersionType).Int.is_signed);
|
||||||
|
|
||||||
if (@bitSizeOf(IndexType) + @bitSizeOf(VersionType) != @bitSizeOf(HandleType))
|
if (@bitSizeOf(IndexType) + @bitSizeOf(VersionType) != @bitSizeOf(HandleType))
|
||||||
@compileError("IndexType and VersionType must sum to HandleType's bit count");
|
@compileError("IndexType and VersionType must sum to HandleType's bit count");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user