Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/class.zig
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ pub const Class = struct {
_ = c.class_replaceMethod(self.value, objc.sel(name).value, @ptrCast(&imp), null);
}

/// allows adding new methods; returns true on success.
// allows adding new methods; returns true on success.
// imp should be a function with C calling convention
// whose first two arguments are a `c.id` and a `c.SEL`.
pub fn addMethod(self: Class, name: [:0]const u8, imp: anytype) !bool {
pub fn addMethod(self: Class, name: [:0]const u8, imp: anytype) bool {
const Fn = @TypeOf(imp);
const fn_info = @typeInfo(Fn).@"fn";
assert(std.meta.eql(fn_info.calling_convention, std.builtin.CallingConvention.c));
Expand Down Expand Up @@ -207,7 +207,7 @@ test "addMethod" {
const My_Class = setup: {
const My_Class = allocateClassPair(objc.getClass("NSObject").?, "my_class").?;
defer registerClassPair(My_Class);
std.debug.assert(try My_Class.addMethod("my_addition", struct {
std.debug.assert(My_Class.addMethod("my_addition", struct {
fn imp(target: objc.c.id, sel: objc.c.SEL, a: i32, b: i32) callconv(.C) i32 {
_ = sel;
_ = target;
Expand Down