hack to validate unsigned. closes #7
This commit is contained in:
parent
069d86b1c9
commit
695e59bbf5
@ -14,9 +14,9 @@ pub fn EntityTraitsType(comptime size: EntityTraitsSize) type {
|
||||
}
|
||||
|
||||
fn EntityTraitsDefinition(comptime EntityType: type, comptime IndexType: type, comptime VersionType: type) type {
|
||||
std.debug.assert(@typeInfo(EntityType) == .Int and !@typeInfo(EntityType).Int.is_signed);
|
||||
std.debug.assert(@typeInfo(IndexType) == .Int and !@typeInfo(IndexType).Int.is_signed);
|
||||
std.debug.assert(@typeInfo(VersionType) == .Int and !@typeInfo(VersionType).Int.is_signed);
|
||||
std.debug.assert(@typeInfo(EntityType) == .Int and std.meta.Int(.unsigned, @bitSizeOf(EntityType)) == EntityType);
|
||||
std.debug.assert(@typeInfo(IndexType) == .Int and std.meta.Int(.unsigned, @bitSizeOf(IndexType)) == IndexType);
|
||||
std.debug.assert(@typeInfo(VersionType) == .Int and std.meta.Int(.unsigned, @bitSizeOf(VersionType)) == VersionType);
|
||||
|
||||
if (@bitSizeOf(IndexType) + @bitSizeOf(VersionType) != @bitSizeOf(EntityType))
|
||||
@compileError("IndexType and VersionType must sum to EntityType's bit count");
|
||||
|
@ -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.
|
||||
/// the bitsize of version + id must equal the handle size.
|
||||
pub fn Handles(comptime HandleType: type, comptime IndexType: type, comptime VersionType: type) type {
|
||||
std.debug.assert(@typeInfo(HandleType) == .Int and !@typeInfo(HandleType).Int.is_signed);
|
||||
std.debug.assert(@typeInfo(IndexType) == .Int and !@typeInfo(IndexType).Int.is_signed);
|
||||
std.debug.assert(@typeInfo(VersionType) == .Int and !@typeInfo(VersionType).Int.is_signed);
|
||||
std.debug.assert(@typeInfo(HandleType) == .Int and std.meta.Int(.unsigned, @bitSizeOf(HandleType)) == HandleType);
|
||||
std.debug.assert(@typeInfo(IndexType) == .Int and std.meta.Int(.unsigned, @bitSizeOf(IndexType)) == IndexType);
|
||||
std.debug.assert(@typeInfo(VersionType) == .Int and std.meta.Int(.unsigned, @bitSizeOf(VersionType)) == VersionType);
|
||||
|
||||
if (@bitSizeOf(IndexType) + @bitSizeOf(VersionType) != @bitSizeOf(HandleType))
|
||||
@compileError("IndexType and VersionType must sum to HandleType's bit count");
|
||||
|
Loading…
x
Reference in New Issue
Block a user