mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
pkg/objc starting
This commit is contained in:
@ -11,6 +11,7 @@ const libxml2 = @import("vendor/zig-libxml2/libxml2.zig");
|
|||||||
const libuv = @import("pkg/libuv/build.zig");
|
const libuv = @import("pkg/libuv/build.zig");
|
||||||
const libpng = @import("pkg/libpng/build.zig");
|
const libpng = @import("pkg/libpng/build.zig");
|
||||||
const macos = @import("pkg/macos/build.zig");
|
const macos = @import("pkg/macos/build.zig");
|
||||||
|
const objc = @import("pkg/objc/build.zig");
|
||||||
const stb_image_resize = @import("pkg/stb_image_resize/build.zig");
|
const stb_image_resize = @import("pkg/stb_image_resize/build.zig");
|
||||||
const utf8proc = @import("pkg/utf8proc/build.zig");
|
const utf8proc = @import("pkg/utf8proc/build.zig");
|
||||||
const zlib = @import("pkg/zlib/build.zig");
|
const zlib = @import("pkg/zlib/build.zig");
|
||||||
@ -194,6 +195,7 @@ fn addDeps(
|
|||||||
step.addPackage(imgui.pkg);
|
step.addPackage(imgui.pkg);
|
||||||
step.addPackage(glfw.pkg);
|
step.addPackage(glfw.pkg);
|
||||||
step.addPackage(libuv.pkg);
|
step.addPackage(libuv.pkg);
|
||||||
|
step.addPackage(objc.pkg);
|
||||||
step.addPackage(stb_image_resize.pkg);
|
step.addPackage(stb_image_resize.pkg);
|
||||||
step.addPackage(utf8proc.pkg);
|
step.addPackage(utf8proc.pkg);
|
||||||
|
|
||||||
|
10
pkg/objc/build.zig
Normal file
10
pkg/objc/build.zig
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
pub const pkg = std.build.Pkg{
|
||||||
|
.name = "objc",
|
||||||
|
.source = .{ .path = thisDir() ++ "/main.zig" },
|
||||||
|
};
|
||||||
|
|
||||||
|
fn thisDir() []const u8 {
|
||||||
|
return std.fs.path.dirname(@src().file) orelse ".";
|
||||||
|
}
|
4
pkg/objc/c.zig
Normal file
4
pkg/objc/c.zig
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
pub usingnamespace @cImport({
|
||||||
|
@cInclude("objc/runtime.h");
|
||||||
|
@cInclude("objc/message.h");
|
||||||
|
});
|
20
pkg/objc/class.zig
Normal file
20
pkg/objc/class.zig
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
const c = @import("c.zig");
|
||||||
|
|
||||||
|
pub const Class = struct {
|
||||||
|
value: c.Class,
|
||||||
|
|
||||||
|
/// Returns the class definition of a specified class.
|
||||||
|
pub fn getClass(name: [:0]const u8) ?Class {
|
||||||
|
return Class{
|
||||||
|
.value = c.objc_getClass(name.ptr) orelse return null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
test {
|
||||||
|
const testing = std.testing;
|
||||||
|
const NSObject = Class.getClass("NSObject");
|
||||||
|
try testing.expect(NSObject != null);
|
||||||
|
try testing.expect(Class.getClass("NoWay") == null);
|
||||||
|
}
|
6
pkg/objc/main.zig
Normal file
6
pkg/objc/main.zig
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
pub const c = @import("c.zig");
|
||||||
|
pub usingnamespace @import("class.zig");
|
||||||
|
|
||||||
|
test {
|
||||||
|
@import("std").testing.refAllDecls(@This());
|
||||||
|
}
|
Reference in New Issue
Block a user