mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
pkg/objc: selectors
This commit is contained in:
@ -195,12 +195,12 @@ 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);
|
||||||
|
|
||||||
// Mac Stuff
|
// Mac Stuff
|
||||||
if (step.target.isDarwin()) {
|
if (step.target.isDarwin()) {
|
||||||
|
step.addPackage(objc.pkg);
|
||||||
step.addPackage(macos.pkg);
|
step.addPackage(macos.pkg);
|
||||||
_ = try macos.link(b, step, .{});
|
_ = try macos.link(b, step, .{});
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
pub const c = @import("c.zig");
|
pub const c = @import("c.zig");
|
||||||
pub usingnamespace @import("class.zig");
|
pub usingnamespace @import("class.zig");
|
||||||
|
pub usingnamespace @import("sel.zig");
|
||||||
|
|
||||||
test {
|
test {
|
||||||
@import("std").testing.refAllDecls(@This());
|
@import("std").testing.refAllDecls(@This());
|
||||||
|
25
pkg/objc/sel.zig
Normal file
25
pkg/objc/sel.zig
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
const c = @import("c.zig");
|
||||||
|
|
||||||
|
pub const Sel = struct {
|
||||||
|
value: c.SEL,
|
||||||
|
|
||||||
|
/// Registers a method with the Objective-C runtime system, maps the
|
||||||
|
/// method name to a selector, and returns the selector value.
|
||||||
|
pub fn registerName(name: [:0]const u8) Sel {
|
||||||
|
return Sel{
|
||||||
|
.value = c.sel_registerName(name.ptr),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the name of the method specified by a given selector.
|
||||||
|
pub fn getName(self: Sel) [:0]const u8 {
|
||||||
|
return std.mem.sliceTo(c.sel_getName(self.value), 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
test {
|
||||||
|
const testing = std.testing;
|
||||||
|
const sel = Sel.registerName("yo");
|
||||||
|
try testing.expectEqualStrings("yo", sel.getName());
|
||||||
|
}
|
Reference in New Issue
Block a user