mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-03 14:19:05 +00:00
This commit represents the majority of the work necessary to upgrade Ghostty to use Zig 0.16.0. Key parts: * In addition to its previous responsibilities, the global state now houses state for global I/O implementations and the process environment. It is now also utilized in the main application along with the C library. Where necessary, global state is isolated from key parts of the implementation (e.g., in libghostty subsystems), and it's expected that this list will grow. * We currently manage our own C translation layer where necessary. In these cases, cImport has been removed in favor of the new external translate-c package. Due to fixes that have needed be made to properly translate the dependencies that were swapped out, as mentioned, we have had to backport fixes from the current translate-c package (and the upstream Arocc dependency). We will host this ourselves until Zig 0.17.0 is released with these fixes. * Where necessary (only a small number of cases), some stdlib code from 0.15.2 (and even from 0.17.0) has been taken, adopted, and vendored in lib/compat. Co-authored-by: Leah Amelia Chen <hi@pluie.me>
67 lines
2.0 KiB
Zig
67 lines
2.0 KiB
Zig
const std = @import("std");
|
|
const uucode = @import("uucode");
|
|
const lut = @import("lut.zig");
|
|
|
|
/// Runnable binary to generate the lookup tables and output to stdout.
|
|
pub fn main(init: std.process.Init) !void {
|
|
const alloc = init.arena.allocator();
|
|
|
|
const gen: lut.Generator(
|
|
bool,
|
|
struct {
|
|
pub fn get(ctx: @This(), cp: u21) !bool {
|
|
_ = ctx;
|
|
return if (cp > uucode.config.max_code_point)
|
|
false
|
|
else
|
|
uucode.get(.is_symbol, @intCast(cp));
|
|
}
|
|
|
|
pub fn eql(ctx: @This(), a: bool, b: bool) bool {
|
|
_ = ctx;
|
|
return a == b;
|
|
}
|
|
},
|
|
) = .{};
|
|
|
|
const t = try gen.generate(alloc);
|
|
defer alloc.free(t.stage1);
|
|
defer alloc.free(t.stage2);
|
|
defer alloc.free(t.stage3);
|
|
|
|
var buf: [4096]u8 = undefined;
|
|
var stdout = std.Io.File.stdout().writer(init.io, &buf);
|
|
try t.writeZig(&stdout.interface);
|
|
// Use flush instead of end because stdout is a pipe when captured by
|
|
// the build system, and pipes cannot be truncated (Windows returns
|
|
// INVALID_PARAMETER, Linux returns EINVAL).
|
|
try stdout.interface.flush();
|
|
|
|
// Uncomment when manually debugging to see our table sizes.
|
|
// std.log.warn("stage1={} stage2={} stage3={}", .{
|
|
// t.stage1.len,
|
|
// t.stage2.len,
|
|
// t.stage3.len,
|
|
// });
|
|
}
|
|
|
|
test "unicode symbols: tables match uucode" {
|
|
if (std.valgrind.runningOnValgrind() > 0) return error.SkipZigTest;
|
|
|
|
const testing = std.testing;
|
|
const table = @import("symbols_table.zig").table;
|
|
|
|
for (0..std.math.maxInt(u21)) |cp| {
|
|
const t = table.get(@intCast(cp));
|
|
const uu = if (cp > uucode.config.max_code_point)
|
|
false
|
|
else
|
|
uucode.get(.is_symbol, @intCast(cp));
|
|
|
|
if (t != uu) {
|
|
std.log.warn("mismatch cp=U+{x} t={} uu={}", .{ cp, t, uu });
|
|
try testing.expect(false);
|
|
}
|
|
}
|
|
}
|