pkg: replace @cImport with addTranslateC in pkg/

@cImport is going to disappear in Zig 0.17. Its deprecated in Zig 0.16.
Let's remove it now.

Replace @cImport with addTranslateC across pkg/ packages. Each
package now has a c_import.h header that is translated at build
time via addTranslateC and exposed as a "cimport" module import.

Converted packages:
- dcimgui
- fontconfig
- freetype
- glslang
- harfbuzz
- macos
- oniguruma
- opengl
- sentry
- spirv-cross
- wuffs

Omitted:
- gtk4-layer-shell - This has a bit more complexity with how it
  interacts with GTK headers, so I need to consider this a bit more.
- src/ - It'll be cleaner to do this separately.
This commit is contained in:
Mitchell Hashimoto
2026-04-16 21:19:41 -07:00
parent ca7516bea6
commit eccd07f009
149 changed files with 390 additions and 195 deletions

View File

@@ -45,6 +45,29 @@ pub fn build(b: *std.Build) !void {
mod.addOptions("build_options", options);
mod.linkLibrary(lib);
{
const tc = b.addTranslateC(.{
.root_source_file = b.path("c_import.h"),
.target = target,
.optimize = optimize,
});
if (target.result.os.tag.isDarwin()) {
const libc = try std.zig.LibCInstallation.findNative(.{
.allocator = b.allocator,
.target = &target.result,
.verbose = false,
});
tc.addSystemIncludePath(.{ .cwd_relative = libc.sys_include_dir.? });
}
if (b.lazyDependency("bindings", .{})) |bindings| {
tc.addIncludePath(bindings.path(""));
}
if (b.lazyDependency("imgui", .{})) |imgui| {
tc.addIncludePath(imgui.path(""));
}
mod.addImport("c", tc.createModule());
}
// We need to add proper Apple SDKs to find stdlib headers
if (target.result.os.tag.isDarwin()) {
if (!target.query.isNative()) {
@@ -196,6 +219,20 @@ pub fn build(b: *std.Build) !void {
});
test_exe.root_module.addOptions("build_options", options);
test_exe.linkLibrary(lib);
{
const tc = b.addTranslateC(.{
.root_source_file = b.path("c_import.h"),
.target = target,
.optimize = optimize,
});
if (b.lazyDependency("bindings", .{})) |bindings| {
tc.addIncludePath(bindings.path(""));
}
if (b.lazyDependency("imgui", .{})) |imgui| {
tc.addIncludePath(imgui.path(""));
}
test_exe.root_module.addImport("c", tc.createModule());
}
const tests_run = b.addRunArtifact(test_exe);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&tests_run.step);

7
pkg/dcimgui/c_import.h Normal file
View File

@@ -0,0 +1,7 @@
// This is set during the build so it also has to be set
// during import time to get the right types. Without this
// you get stack size mismatches on some structs.
#define IMGUI_USE_WCHAR32 1
#define IMGUI_HAS_DOCK 1
#include "dcimgui.h"

View File

@@ -1,14 +1,6 @@
pub const build_options = @import("build_options");
pub const c = @cImport({
// This is set during the build so it also has to be set
// during import time to get the right types. Without this
// you get stack size mismatches on some structs.
@cDefine("IMGUI_USE_WCHAR32", "1");
@cDefine("IMGUI_HAS_DOCK", "1");
@cInclude("dcimgui.h");
});
pub const c = @import("c");
// OpenGL3 backend
pub extern fn ImGui_ImplOpenGL3_Init(glsl_version: ?[*:0]const u8) callconv(.c) bool;

View File

@@ -242,6 +242,18 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
if (b.lazyDependency("fontconfig", .{})) |upstream| {
lib.addIncludePath(upstream.path(""));
module.addIncludePath(upstream.path(""));
{
const tc = b.addTranslateC(.{
.root_source_file = b.path("c_import.h"),
.target = target,
.optimize = optimize,
});
tc.addIncludePath(b.path("override/include"));
tc.addIncludePath(upstream.path(""));
module.addImport("c", tc.createModule());
}
lib.addCSourceFiles(.{
.root = upstream.path(""),
.files = srcs,

View File

@@ -1,3 +0,0 @@
pub const c = @cImport({
@cInclude("fontconfig/fontconfig.h");
});

View File

@@ -0,0 +1 @@
#include "fontconfig/fontconfig.h"

View File

@@ -1,6 +1,6 @@
const std = @import("std");
const assert = std.debug.assert;
const c = @import("c.zig").c;
const c = @import("c");
pub const CharSet = opaque {
pub fn create() *CharSet {

View File

@@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c.zig").c;
const c = @import("c");
const Error = @import("main.zig").Error;
pub const Weight = enum(c_uint) {

View File

@@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c.zig").c;
const c = @import("c");
const Error = @import("main.zig").Error;
const CharSet = @import("char_set.zig").CharSet;
const FontSet = @import("font_set.zig").FontSet;

View File

@@ -1,6 +1,6 @@
const std = @import("std");
const assert = std.debug.assert;
const c = @import("c.zig").c;
const c = @import("c");
const Pattern = @import("pattern.zig").Pattern;
pub const FontSet = opaque {

View File

@@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c.zig").c;
const c = @import("c");
const Config = @import("config.zig").Config;
pub fn init() bool {

View File

@@ -1,6 +1,6 @@
const std = @import("std");
const assert = std.debug.assert;
const c = @import("c.zig").c;
const c = @import("c");
pub const LangSet = opaque {
pub fn create() *LangSet {

View File

@@ -11,7 +11,7 @@ const pattern = @import("pattern.zig");
const range = @import("range.zig");
const value = @import("value.zig");
pub const c = @import("c.zig").c;
pub const c = @import("c");
pub const init = initpkg.init;
pub const fini = initpkg.fini;
pub const initLoadConfig = initpkg.initLoadConfig;

View File

@@ -1,6 +1,6 @@
const std = @import("std");
const assert = std.debug.assert;
const c = @import("c.zig").c;
const c = @import("c");
pub const Matrix = extern struct {
xx: f64,

View File

@@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c.zig").c;
const c = @import("c");
const Property = @import("main.zig").Property;
pub const ObjectSet = opaque {

View File

@@ -1,6 +1,6 @@
const std = @import("std");
const assert = std.debug.assert;
const c = @import("c.zig").c;
const c = @import("c");
const Error = @import("main.zig").Error;
const ObjectSet = @import("main.zig").ObjectSet;
const Property = @import("main.zig").Property;

View File

@@ -1,6 +1,6 @@
const std = @import("std");
const assert = std.debug.assert;
const c = @import("c.zig").c;
const c = @import("c");
pub const Range = opaque {
pub fn destroy(self: *Range) void {

View File

@@ -1,6 +1,6 @@
const std = @import("std");
const assert = std.debug.assert;
const c = @import("c.zig").c;
const c = @import("c");
const CharSet = @import("main.zig").CharSet;
const LangSet = @import("main.zig").LangSet;
const Matrix = @import("main.zig").Matrix;

View File

@@ -1,7 +1,7 @@
const Library = @This();
const std = @import("std");
const c = @import("c.zig").c;
const c = @import("c");
const Face = @import("face.zig").Face;
const errors = @import("errors.zig");
const Error = errors.Error;

View File

@@ -36,6 +36,27 @@ pub fn build(b: *std.Build) !void {
module.addIncludePath(b.path(""));
{
const tc = b.addTranslateC(.{
.root_source_file = b.path("c_import.h"),
.target = target,
.optimize = optimize,
});
if (target.result.os.tag.isDarwin()) {
const libc = try std.zig.LibCInstallation.findNative(.{
.allocator = b.allocator,
.target = &target.result,
.verbose = false,
});
tc.addSystemIncludePath(.{ .cwd_relative = libc.sys_include_dir.? });
}
tc.addIncludePath(b.path(""));
if (b.lazyDependency("freetype", .{})) |upstream| {
tc.addIncludePath(upstream.path("include"));
}
module.addImport("c", tc.createModule());
}
if (b.systemIntegrationOption("freetype", .{})) {
module.linkSystemLibrary("freetype2", dynamic_link_opts);
if (test_exe) |exe| {

View File

@@ -1,3 +0,0 @@
pub const c = @cImport({
@cInclude("freetype-zig.h");
});

1
pkg/freetype/c_import.h Normal file
View File

@@ -0,0 +1 @@
#include "freetype-zig.h"

View File

@@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c.zig").c;
const c = @import("c");
/// Compute (a*b)/0x10000 with maximum accuracy. Its main use is to multiply
/// a given value by a 16.16 fixed-point factor.

View File

@@ -1,4 +1,4 @@
const c = @import("c.zig").c;
const c = @import("c");
// Thanks to Mach (https://github.com/hexops/mach) for this work, I didn't
// do this manually. I wrote the other Freetype bindings by hand but this

View File

@@ -1,6 +1,6 @@
const std = @import("std");
const Allocator = std.mem.Allocator;
const c = @import("c.zig").c;
const c = @import("c");
const errors = @import("errors.zig");
const Library = @import("Library.zig");
const Tag = @import("tag.zig").Tag;

View File

@@ -3,7 +3,7 @@ const errors = @import("errors.zig");
const face = @import("face.zig");
const tag = @import("tag.zig");
pub const c = @import("c.zig").c;
pub const c = @import("c");
pub const testing = @import("test.zig");
pub const Library = @import("Library.zig");

View File

@@ -17,6 +17,25 @@ pub fn build(b: *std.Build) !void {
if (upstream) |v| module.addIncludePath(v.path(""));
module.addIncludePath(b.path("override"));
{
const tc = b.addTranslateC(.{
.root_source_file = b.path("c_import.h"),
.target = target,
.optimize = optimize,
});
if (target.result.os.tag.isDarwin()) {
const libc = try std.zig.LibCInstallation.findNative(.{
.allocator = b.allocator,
.target = &target.result,
.verbose = false,
});
tc.addSystemIncludePath(.{ .cwd_relative = libc.sys_include_dir.? });
}
if (upstream) |v| tc.addIncludePath(v.path(""));
tc.addIncludePath(b.path("override"));
module.addImport("c", tc.createModule());
}
if (target.query.isNative()) {
const test_exe = b.addTest(.{
.name = "test",

View File

@@ -1,4 +0,0 @@
pub const c = @cImport({
@cInclude("glslang/Include/glslang_c_interface.h");
@cInclude("glslang/Public/resource_limits_c.h");
});

2
pkg/glslang/c_import.h Normal file
View File

@@ -0,0 +1,2 @@
#include "glslang/Include/glslang_c_interface.h"
#include "glslang/Public/resource_limits_c.h"

View File

@@ -1,4 +1,4 @@
const c = @import("c.zig").c;
const c = @import("c");
pub fn init() !void {
if (c.glslang_initialize_process() == 0) return error.GlslangInitFailed;

View File

@@ -2,7 +2,7 @@ const initpkg = @import("init.zig");
const program = @import("program.zig");
const shader = @import("shader.zig");
pub const c = @import("c.zig").c;
pub const c = @import("c");
pub const testing = @import("test.zig");
pub const init = initpkg.init;

View File

@@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c.zig").c;
const c = @import("c");
const testlib = @import("test.zig");
const Shader = @import("shader.zig").Shader;

View File

@@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c.zig").c;
const c = @import("c");
const testlib = @import("test.zig");
pub const Shader = opaque {

View File

@@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c.zig").c;
const c = @import("c");
const Error = @import("errors.zig").Error;
/// Data type holding the memory modes available to client programs.

View File

@@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c.zig").c;
const c = @import("c");
const common = @import("common.zig");
const Error = @import("errors.zig").Error;
const Direction = common.Direction;

View File

@@ -168,6 +168,36 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
if (b.lazyDependency("harfbuzz", .{})) |upstream| {
lib.addIncludePath(upstream.path("src"));
module.addIncludePath(upstream.path("src"));
{
const tc = b.addTranslateC(.{
.root_source_file = b.path("c_import.h"),
.target = target,
.optimize = optimize,
});
tc.addIncludePath(upstream.path("src"));
if (freetype_enabled) {
tc.defineCMacro("GHOSTTY_HARFBUZZ_FREETYPE", "1");
if (!b.systemIntegrationOption("freetype", .{})) {
if (freetype.builder.lazyDependency("freetype", .{})) |freetype_dep| {
tc.addIncludePath(freetype_dep.path("include"));
}
}
}
if (coretext_enabled) {
tc.defineCMacro("GHOSTTY_HARFBUZZ_CORETEXT", "1");
if (target.result.os.tag.isDarwin()) {
const libc = try std.zig.LibCInstallation.findNative(.{
.allocator = b.allocator,
.target = &target.result,
.verbose = false,
});
tc.addSystemIncludePath(.{ .cwd_relative = libc.sys_include_dir.? });
}
}
module.addImport("c", tc.createModule());
}
lib.addCSourceFile(.{
.file = upstream.path("src/harfbuzz.cc"),
.flags = flags.items,

View File

@@ -1,8 +0,0 @@
const builtin = @import("builtin");
const build_options = @import("build_options");
pub const c = @cImport({
@cInclude("hb.h");
if (build_options.freetype) @cInclude("hb-ft.h");
if (build_options.coretext) @cInclude("hb-coretext.h");
});

9
pkg/harfbuzz/c_import.h Normal file
View File

@@ -0,0 +1,9 @@
#include "hb.h"
#ifdef GHOSTTY_HARFBUZZ_FREETYPE
#include "hb-ft.h"
#endif
#ifdef GHOSTTY_HARFBUZZ_CORETEXT
#include "hb-coretext.h"
#endif

View File

@@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c.zig").c;
const c = @import("c");
/// The direction of a text segment or buffer.
///

View File

@@ -1,6 +1,6 @@
const macos = @import("macos");
const std = @import("std");
const c = @import("c.zig").c;
const c = @import("c");
const Face = @import("face.zig").Face;
const Font = @import("font.zig").Font;
const Error = @import("errors.zig").Error;

View File

@@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c.zig").c;
const c = @import("c");
/// A font face is an object that represents a single face from within a font family.
///

View File

@@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c.zig").c;
const c = @import("c");
const Face = @import("face.zig").Face;
const Error = @import("errors.zig").Error;

View File

@@ -1,6 +1,6 @@
const freetype = @import("freetype");
const std = @import("std");
const c = @import("c.zig").c;
const c = @import("c");
const Face = @import("face.zig").Face;
const Font = @import("font.zig").Font;
const Error = @import("errors.zig").Error;

View File

@@ -7,7 +7,7 @@ const font = @import("font.zig");
const shapepkg = @import("shape.zig");
const versionpkg = @import("version.zig");
pub const c = @import("c.zig").c;
pub const c = @import("c");
pub const freetype = @import("freetype.zig");
pub const coretext = @import("coretext.zig");
pub const MemoryMode = blob.MemoryMode;

View File

@@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c.zig").c;
const c = @import("c");
const Font = @import("font.zig").Font;
const Buffer = @import("buffer.zig").Buffer;
const Feature = @import("common.zig").Feature;

View File

@@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c.zig").c;
const c = @import("c");
pub const Version = struct {
major: u32,

View File

@@ -1,4 +1,4 @@
pub const c = @import("animation/c.zig").c;
pub const c = @import("c");
/// https://developer.apple.com/documentation/quartzcore/calayer/contents_gravity_values?language=objc
pub extern "c" const kCAGravityTopLeft: *anyopaque;

View File

@@ -1 +0,0 @@
pub const c = @import("../main.zig").c;

View File

@@ -12,6 +12,36 @@ pub fn build(b: *std.Build) !void {
.optimize = optimize,
});
if (target.result.os.tag.isDarwin()) {
const tc = b.addTranslateC(.{
.root_source_file = b.path("c_import.h"),
.target = target,
.optimize = optimize,
});
const libc = try std.zig.LibCInstallation.findNative(.{
.allocator = b.allocator,
.target = &target.result,
.verbose = false,
});
tc.addSystemIncludePath(.{ .cwd_relative = libc.sys_include_dir.? });
// Framework headers (CoreFoundation, CoreGraphics, etc.)
const sdk_path = std.fs.path.dirname(std.fs.path.dirname(libc.sys_include_dir.?).?).?;
tc.addSystemFrameworkPath(.{
.cwd_relative = try std.fs.path.join(b.allocator, &.{
sdk_path,
"System",
"Library",
"Frameworks",
}),
});
module.addImport("c", tc.createModule());
} else {
module.addImport("c", b.createModule(.{
.root_source_file = b.path("c_empty.zig"),
}));
}
const lib = b.addLibrary(.{
.name = "macos",
.root_module = b.createModule(.{

2
pkg/macos/c_empty.zig Normal file
View File

@@ -0,0 +1,2 @@
// Empty stub for non-Darwin targets where the macOS C headers
// are not available.

20
pkg/macos/c_import.h Normal file
View File

@@ -0,0 +1,20 @@
// All of our C imports consolidated into one place. We used to
// import them one by one in each package but Zig 0.14 has some
// kind of issue with that I wasn't able to minimize.
#include <CoreFoundation/CoreFoundation.h>
#include <CoreGraphics/CoreGraphics.h>
#include <CoreText/CoreText.h>
#include <CoreVideo/CoreVideo.h>
#include <CoreVideo/CVPixelBuffer.h>
#include <QuartzCore/CALayer.h>
#include <IOSurface/IOSurfaceRef.h>
#include <dispatch/dispatch.h>
#include <os/log.h>
#include <os/signpost.h>
#ifdef __APPLE__
#include <TargetConditionals.h>
#if TARGET_OS_MAC && !TARGET_OS_IPHONE
#include <Carbon/Carbon.h>
#endif
#endif

View File

@@ -1,4 +1,4 @@
pub const c = @import("carbon/c.zig").c;
pub const c = @import("c");
test {
@import("std").testing.refAllDecls(@This());

View File

@@ -1 +0,0 @@
pub const c = @import("../main.zig").c;

View File

@@ -1,4 +1,4 @@
pub const c = @import("dispatch/c.zig").c;
pub const c = @import("c");
pub const data = @import("dispatch/data.zig");
pub const queue = @import("dispatch/queue.zig");
pub const Data = data.Data;

View File

@@ -1 +0,0 @@
pub const c = @import("../main.zig").c;

View File

@@ -1,6 +1,6 @@
const std = @import("std");
const foundation = @import("../foundation.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const Data = opaque {
pub const DESTRUCTOR_DEFAULT = c.DISPATCH_DATA_DESTRUCTOR_DEFAULT;

View File

@@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c.zig").c;
const c = @import("c");
pub const Queue = *anyopaque; // dispatch_queue_t

View File

@@ -9,7 +9,7 @@ const string = @import("foundation/string.zig");
const typepkg = @import("foundation/type.zig");
const url = @import("foundation/url.zig");
pub const c = @import("foundation/c.zig").c;
pub const c = @import("c");
pub const Array = array.Array;
pub const MutableArray = array.MutableArray;
pub const AttributedString = attributed_string.AttributedString;

View File

@@ -1,7 +1,7 @@
const std = @import("std");
const Allocator = std.mem.Allocator;
const base = @import("base.zig");
const c = @import("c.zig").c;
const c = @import("c");
const cftype = @import("type.zig");
const ComparisonResult = base.ComparisonResult;
const Range = base.Range;

View File

@@ -3,7 +3,7 @@ const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const text = @import("../text.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const AttributedString = opaque {
pub fn create(

View File

@@ -1,6 +1,6 @@
const std = @import("std");
const assert = std.debug.assert;
const c = @import("c.zig").c;
const c = @import("c");
pub const ComparisonResult = enum(c_int) {
less = -1,

View File

@@ -1 +0,0 @@
pub const c = @import("../main.zig").c;

View File

@@ -2,7 +2,7 @@ const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const CharacterSet = opaque {
pub fn createWithCharactersInString(

View File

@@ -1,7 +1,7 @@
const std = @import("std");
const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const Data = opaque {
pub fn createWithBytesNoCopy(data: []const u8) Allocator.Error!*Data {

View File

@@ -2,7 +2,7 @@ const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const Dictionary = opaque {
pub fn create(

View File

@@ -1,7 +1,7 @@
const std = @import("std");
const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const Number = opaque {
pub fn create(

View File

@@ -2,7 +2,7 @@ const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const String = opaque {
pub fn createWithBytes(

View File

@@ -1,7 +1,7 @@
const std = @import("std");
const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const URL = opaque {
pub fn createWithString(str: *foundation.String, base: ?*URL) Allocator.Error!*URL {

View File

@@ -6,7 +6,7 @@ const geometry = @import("graphics/geometry.zig");
const image = @import("graphics/image.zig");
const path = @import("graphics/path.zig");
pub const c = @import("graphics/c.zig").c;
pub const c = @import("c");
pub const AffineTransform = affine_transform.AffineTransform;
pub const BitmapContext = bitmap_context.BitmapContext;
pub const ColorSpace = color_space.ColorSpace;

View File

@@ -1,6 +1,6 @@
const std = @import("std");
const assert = std.debug.assert;
const c = @import("c.zig").c;
const c = @import("c");
pub const AffineTransform = extern struct {
a: c.CGFloat,

View File

@@ -3,7 +3,7 @@ const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const graphics = @import("../graphics.zig");
const Context = @import("context.zig").Context;
const c = @import("c.zig").c;
const c = @import("c");
pub const BitmapContext = opaque {
pub const context = Context(BitmapContext);

View File

@@ -1 +0,0 @@
pub const c = @import("../main.zig").c;

View File

@@ -1,7 +1,7 @@
const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const c = @import("c.zig").c;
const c = @import("c");
pub const ColorSpace = opaque {
pub fn createDeviceGray() Allocator.Error!*ColorSpace {

View File

@@ -2,7 +2,7 @@ const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const graphics = @import("../graphics.zig");
const c = @import("c.zig").c;
const c = @import("c");
/// Returns a struct that has all the shared context functions for the
/// given type.

View File

@@ -1,3 +1,3 @@
const c = @import("c.zig").c;
const c = @import("c");
pub const Glyph = c.CGGlyph;

View File

@@ -1,6 +1,6 @@
const std = @import("std");
const assert = std.debug.assert;
const c = @import("c.zig").c;
const c = @import("c");
pub const Point = extern struct {
x: c.CGFloat,

View File

@@ -3,7 +3,7 @@ const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const graphics = @import("../graphics.zig");
const context = @import("context.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const ImageAlphaInfo = enum(c_uint) {
none = c.kCGImageAlphaNone,

View File

@@ -3,7 +3,7 @@ const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const graphics = @import("../graphics.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const Path = opaque {
pub fn createWithRect(

View File

@@ -1,6 +1,6 @@
const iosurface = @import("iosurface/iosurface.zig");
pub const c = @import("iosurface/c.zig").c;
pub const c = @import("c");
pub const IOSurface = iosurface.IOSurface;
test {

View File

@@ -1 +0,0 @@
pub const c = @import("../main.zig").c;

View File

@@ -1,7 +1,7 @@
const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const c = @import("c.zig").c;
const c = @import("c");
const foundation = @import("../foundation.zig");
const graphics = @import("../graphics.zig");
const video = @import("../video.zig");

View File

@@ -1,5 +1,3 @@
const builtin = @import("builtin");
pub const carbon = @import("carbon.zig");
pub const foundation = @import("foundation.zig");
pub const animation = @import("animation.zig");
@@ -10,25 +8,7 @@ pub const text = @import("text.zig");
pub const video = @import("video.zig");
pub const iosurface = @import("iosurface.zig");
// All of our C imports consolidated into one place. We used to
// import them one by one in each package but Zig 0.14 has some
// kind of issue with that I wasn't able to minimize.
pub const c = @cImport({
@cInclude("CoreFoundation/CoreFoundation.h");
@cInclude("CoreGraphics/CoreGraphics.h");
@cInclude("CoreText/CoreText.h");
@cInclude("CoreVideo/CoreVideo.h");
@cInclude("CoreVideo/CVPixelBuffer.h");
@cInclude("QuartzCore/CALayer.h");
@cInclude("IOSurface/IOSurfaceRef.h");
@cInclude("dispatch/dispatch.h");
@cInclude("os/log.h");
@cInclude("os/signpost.h");
if (builtin.os.tag == .macos) {
@cInclude("Carbon/Carbon.h");
}
});
pub const c = @import("c");
test {
@import("std").testing.refAllDecls(@This());

View File

@@ -1,6 +1,6 @@
const log = @import("os/log.zig");
pub const c = @import("os/c.zig");
pub const c = @import("c");
pub const signpost = @import("os/signpost.zig");
pub const Log = log.Log;
pub const LogType = log.LogType;

View File

@@ -1 +0,0 @@
pub const c = @import("../main.zig").c;

View File

@@ -1,7 +1,7 @@
const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const c = @import("c.zig").c;
const c = @import("c");
pub const Log = opaque {
pub fn create(

View File

@@ -1,7 +1,7 @@
const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const c = @import("c.zig").c;
const c = @import("c");
const logpkg = @import("log.zig");
const Log = logpkg.Log;

View File

@@ -10,7 +10,7 @@ const paragraph_style = @import("text/paragraph_style.zig");
const run = @import("text/run.zig");
const stylized_strings = @import("text/stylized_strings.zig");
pub const c = @import("text/c.zig").c;
pub const c = @import("c");
pub const Font = font.Font;
pub const FontTableTag = font.FontTableTag;
pub const FontCollection = font_collection.FontCollection;

View File

@@ -1 +0,0 @@
pub const c = @import("../main.zig").c;

View File

@@ -4,7 +4,7 @@ const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const graphics = @import("../graphics.zig");
const text = @import("../text.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const Font = opaque {
pub fn createWithFontDescriptor(desc: *const text.FontDescriptor, size: f32) Allocator.Error!*Font {

View File

@@ -2,7 +2,7 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const text = @import("../text.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const FontCollection = opaque {
pub fn createFromAvailableFonts() Allocator.Error!*FontCollection {

View File

@@ -1,7 +1,7 @@
const std = @import("std");
const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const FontDescriptor = opaque {
pub fn createWithNameAndSize(name: *foundation.String, size: f64) Allocator.Error!*FontDescriptor {

View File

@@ -2,7 +2,7 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const FontDescriptor = @import("./font_descriptor.zig").FontDescriptor;
const c = @import("c.zig").c;
const c = @import("c");
pub fn createFontDescriptorsFromURL(url: *foundation.URL) ?*foundation.Array {
return @ptrFromInt(@intFromPtr(c.CTFontManagerCreateFontDescriptorsFromURL(

View File

@@ -4,7 +4,7 @@ const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const graphics = @import("../graphics.zig");
const text = @import("../text.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const Frame = opaque {
pub fn release(self: *Frame) void {

View File

@@ -4,7 +4,7 @@ const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const graphics = @import("../graphics.zig");
const text = @import("../text.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const Framesetter = opaque {
pub fn createWithAttributedString(str: *foundation.AttributedString) Allocator.Error!*Framesetter {

View File

@@ -4,7 +4,7 @@ const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const graphics = @import("../graphics.zig");
const text = @import("../text.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const Line = opaque {
pub fn createWithAttributedString(str: *foundation.AttributedString) Allocator.Error!*Line {

View File

@@ -4,7 +4,7 @@ const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const graphics = @import("../graphics.zig");
const text = @import("../text.zig");
const c = @import("c.zig").c;
const c = @import("c");
// https://developer.apple.com/documentation/coretext/ctparagraphstyle?language=objc
pub const ParagraphStyle = opaque {

View File

@@ -4,7 +4,7 @@ const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const graphics = @import("../graphics.zig");
const text = @import("../text.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const Run = opaque {
pub fn release(self: *Run) void {

View File

@@ -1,5 +1,5 @@
const foundation = @import("../foundation.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const StringAttribute = enum {
font,

View File

@@ -4,7 +4,7 @@ const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
const graphics = @import("../graphics.zig");
const text = @import("../text.zig");
const c = @import("c.zig").c;
const c = @import("c");
pub const Typesetter = opaque {
pub fn createWithAttributedStringAndOptions(

View File

@@ -1,7 +1,7 @@
const display_link = @import("video/display_link.zig");
const pixel_format = @import("video/pixel_format.zig");
pub const c = @import("video/c.zig").c;
pub const c = @import("c");
pub const DisplayLink = display_link.DisplayLink;
pub const PixelFormat = pixel_format.PixelFormat;

Some files were not shown because too many files have changed in this diff Show More