Compare commits
3 Commits
f99e1eab67
...
52278ab8e0
Author | SHA1 | Date | |
---|---|---|---|
52278ab8e0 | |||
946c67f154 | |||
1ab9bba9da |
10
build.zig
10
build.zig
@ -38,17 +38,9 @@ pub fn build(builder: *std.Build) void {
|
|||||||
ona_exe.addModule("ona", ona_module);
|
ona_exe.addModule("ona", ona_module);
|
||||||
ona_exe.addModule("kym", kym_module);
|
ona_exe.addModule("kym", kym_module);
|
||||||
|
|
||||||
ona_exe.install();
|
|
||||||
// ona_exe.addIncludeDir("./ext");
|
// ona_exe.addIncludeDir("./ext");
|
||||||
ona_exe.linkSystemLibrary("SDL2");
|
ona_exe.linkSystemLibrary("SDL2");
|
||||||
ona_exe.linkLibC();
|
ona_exe.linkLibC();
|
||||||
|
builder.installArtifact(ona_exe);
|
||||||
const run_cmd = ona_exe.run();
|
|
||||||
|
|
||||||
run_cmd.step.dependOn(builder.getInstallStep());
|
|
||||||
|
|
||||||
if (builder.args) |args| run_cmd.addArgs(args);
|
|
||||||
|
|
||||||
builder.step("run", "Run Ona application").dependOn(&run_cmd.step);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,13 +164,22 @@ pub fn equals(this: []const u8, that: []const u8) bool {
|
|||||||
|
|
||||||
var null_context = @as(usize, 0);
|
var null_context = @as(usize, 0);
|
||||||
|
|
||||||
|
pub const null_allocator = Allocator.bind(&null_context, struct {
|
||||||
|
fn reallocate(context: *usize, options: AllocationOptions) ?[]u8 {
|
||||||
|
debug.assert(context.* == 0);
|
||||||
|
debug.assert(options.allocation == null);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
pub const null_writer = Writer.bind(&null_context, struct {
|
pub const null_writer = Writer.bind(&null_context, struct {
|
||||||
pub fn write(context: *usize, buffer: []const u8) usize {
|
fn write(context: *usize, buffer: []const u8) usize {
|
||||||
debug.assert(context.* == 0);
|
debug.assert(context.* == 0);
|
||||||
|
|
||||||
return buffer.len;
|
return buffer.len;
|
||||||
}
|
}
|
||||||
});
|
}.write);
|
||||||
|
|
||||||
pub fn overlaps(pointer: [*]u8, memory_range: []u8) bool {
|
pub fn overlaps(pointer: [*]u8, memory_range: []u8) bool {
|
||||||
return (pointer >= memory_range.ptr) and (pointer < (memory_range.ptr + memory_range.len));
|
return (pointer >= memory_range.ptr) and (pointer < (memory_range.ptr + memory_range.len));
|
||||||
|
@ -97,8 +97,33 @@ pub fn Dense(comptime key: Key, comptime Element: type) type {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove(_: *Self, _: u128) bool {
|
pub fn remove(self: *Self, slot: KeySlot) bool {
|
||||||
// TODO: Implement.
|
const redirect = &self.slots[slot.index];
|
||||||
|
|
||||||
|
if (slot.salt != redirect.salt) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const free_index = redirect.index;
|
||||||
|
|
||||||
|
self.values = self.values[0 .. (self.values.len - 1)];
|
||||||
|
|
||||||
|
if (self.values.len > 0) {
|
||||||
|
const free_data = &self.data[free_index];
|
||||||
|
const free_erase = &self.erase[free_index];
|
||||||
|
const last_data = &self.data[self.values.len];
|
||||||
|
const last_erase = &self.erase[self.values.len];
|
||||||
|
|
||||||
|
free_data.* = last_data.*;
|
||||||
|
free_erase.* = last_erase.*;
|
||||||
|
self.slots[free_erase.*].index = free_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
redirect.salt = math.max(redirect.salt +% 1, 1);
|
||||||
|
redirect.index = self.next_free;
|
||||||
|
self.next_free = slot.index;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user