diff --git a/src/build/Config.zig b/src/build/Config.zig index 7dfdb913d..474674d3a 100644 --- a/src/build/Config.zig +++ b/src/build/Config.zig @@ -589,16 +589,6 @@ pub fn genericMacOSTarget( }); } -/// The extension to use for a shared library on the given target. -pub fn sharedLibExt(target: std.Build.ResolvedTarget) []const u8 { - return if (target.result.os.tag.isDarwin()) - "dylib" - else if (target.result.os.tag == .windows) - return "dll" - else - return "so"; -} - /// The possible entrypoints for the exe artifact. This has no effect on /// other artifact types (i.e. lib, wasm_module). /// diff --git a/src/build/GhosttyExe.zig b/src/build/GhosttyExe.zig index 1dfc4b4b7..083aecdb5 100644 --- a/src/build/GhosttyExe.zig +++ b/src/build/GhosttyExe.zig @@ -1,7 +1,6 @@ const Ghostty = @This(); const std = @import("std"); -const builtin = @import("builtin"); const Config = @import("Config.zig"); const SharedDeps = @import("SharedDeps.zig"); diff --git a/src/terminal/c_api.zig b/src/terminal/c_api.zig index debffdc59..2ea0820f2 100644 --- a/src/terminal/c_api.zig +++ b/src/terminal/c_api.zig @@ -1,30 +1,40 @@ const std = @import("std"); +const assert = std.debug.assert; const builtin = @import("builtin"); const lib_alloc = @import("../lib/allocator.zig"); const CAllocator = lib_alloc.Allocator; const osc = @import("osc.zig"); +/// C: GhosttyOscParser pub const GhosttyOscParser = extern struct { parser: *osc.Parser, + + comptime { + // C API is an opaque pointer so the sizes must match. + assert(@sizeOf(@This()) == @sizeOf(usize)); + } }; +/// C: GhosttyResult pub const Result = enum(c_int) { success = 0, out_of_memory = -1, }; pub fn ghostty_vt_osc_new( - c_alloc_: ?*const CAllocator, + alloc_: ?*const CAllocator, result: *GhosttyOscParser, ) callconv(.c) Result { - const alloc = lib_alloc.default(c_alloc_); - const ptr = alloc.create(osc.Parser) catch return .out_of_memory; + const alloc = lib_alloc.default(alloc_); + const ptr = alloc.create(osc.Parser) catch + return .out_of_memory; ptr.* = .initAlloc(alloc); result.* = .{ .parser = ptr }; return .success; } pub fn ghostty_vt_osc_free(parser: GhosttyOscParser) callconv(.c) void { + // C-built parsers always have an associated allocator. const alloc = parser.parser.alloc.?; parser.parser.deinit(); alloc.destroy(parser.parser); diff --git a/src/terminal/main.zig b/src/terminal/main.zig index 4106786e1..4064c0c9c 100644 --- a/src/terminal/main.zig +++ b/src/terminal/main.zig @@ -64,9 +64,6 @@ pub const isSafePaste = sanitize.isSafePaste; /// This is set to true when we're building the C library. pub const is_c_lib = @import("root") == @import("../lib_vt.zig"); - -/// This is the C API for this package. Do NOT reference this unless -/// you want a bunch of symbols exported into your final artifact. pub const c_api = @import("c_api.zig"); test {