ecs: improve compatibility with self-hosted compiler
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
4a421b8130
commit
f1ae31ae86
1 changed files with 4 additions and 4 deletions
|
|
@ -78,7 +78,7 @@ pub const ArchetypeStorage = struct {
|
||||||
gpa.free(storage.columns);
|
gpa.free(storage.columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debugValidateRow(storage: *ArchetypeStorage, gpa: Allocator, comptime row: anytype) void {
|
fn debugValidateRow(storage: *ArchetypeStorage, gpa: Allocator, row: anytype) void {
|
||||||
inline for (std.meta.fields(@TypeOf(row))) |field, index| {
|
inline for (std.meta.fields(@TypeOf(row))) |field, index| {
|
||||||
const column = storage.columns[index];
|
const column = storage.columns[index];
|
||||||
if (typeId(field.field_type) != column.typeId) {
|
if (typeId(field.field_type) != column.typeId) {
|
||||||
|
|
@ -102,7 +102,7 @@ pub const ArchetypeStorage = struct {
|
||||||
return row_index;
|
return row_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn append(storage: *ArchetypeStorage, gpa: Allocator, comptime row: anytype) !u32 {
|
pub fn append(storage: *ArchetypeStorage, gpa: Allocator, row: anytype) !u32 {
|
||||||
if (is_debug) storage.debugValidateRow(gpa, row);
|
if (is_debug) storage.debugValidateRow(gpa, row);
|
||||||
|
|
||||||
try storage.ensureUnusedCapacity(gpa, 1);
|
try storage.ensureUnusedCapacity(gpa, 1);
|
||||||
|
|
@ -174,7 +174,7 @@ pub const ArchetypeStorage = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the entire row's values in the table.
|
/// Sets the entire row's values in the table.
|
||||||
pub fn setRow(storage: *ArchetypeStorage, gpa: Allocator, row_index: u32, comptime row: anytype) void {
|
pub fn setRow(storage: *ArchetypeStorage, gpa: Allocator, row_index: u32, row: anytype) void {
|
||||||
if (is_debug) storage.debugValidateRow(gpa, row);
|
if (is_debug) storage.debugValidateRow(gpa, row);
|
||||||
|
|
||||||
const fields = std.meta.fields(@TypeOf(row));
|
const fields = std.meta.fields(@TypeOf(row));
|
||||||
|
|
@ -188,7 +188,7 @@ pub const ArchetypeStorage = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the value of the named components (columns) for the given row in the table.
|
/// Sets the value of the named components (columns) for the given row in the table.
|
||||||
pub fn set(storage: *ArchetypeStorage, gpa: Allocator, row_index: u32, name: []const u8, comptime component: anytype) void {
|
pub fn set(storage: *ArchetypeStorage, gpa: Allocator, row_index: u32, name: []const u8, component: anytype) void {
|
||||||
const ColumnType = @TypeOf(component);
|
const ColumnType = @TypeOf(component);
|
||||||
if (@sizeOf(ColumnType) == 0) return;
|
if (@sizeOf(ColumnType) == 0) return;
|
||||||
for (storage.columns) |column| {
|
for (storage.columns) |column| {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue