Skip to content
Open
Show file tree
Hide file tree
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
20 changes: 10 additions & 10 deletions src/class.zig
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ pub const Class = struct {
pub const msgSendSuper = msg_send.msgSendSuper;

// Returns a property with a given name of a given class.
pub fn getProperty(self: Class, name: [:0]const u8) ?objc.Property {
pub fn getProperty(self: Class, name: [*:0]const u8) ?objc.Property {
return objc.Property{
.value = c.class_getProperty(self.value, name.ptr) orelse return null,
.value = c.class_getProperty(self.value, name) orelse return null,
};
}

Expand Down Expand Up @@ -56,7 +56,7 @@ pub const Class = struct {
// currently only allows for overriding methods previously defined, e.g. by a superclass.
// imp should be a function with C calling convention
// whose first two arguments are a `c.id` and a `c.SEL`.
pub fn replaceMethod(self: Class, name: [:0]const u8, imp: anytype) void {
pub fn replaceMethod(self: Class, name: [*:0]const u8, imp: anytype) void {
const fn_info = @typeInfo(@TypeOf(imp)).@"fn";
assert(std.meta.eql(fn_info.calling_convention, std.builtin.CallingConvention.c));
assert(fn_info.is_var_args == false);
Expand All @@ -69,7 +69,7 @@ pub const Class = struct {
/// 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 All @@ -88,26 +88,26 @@ pub const Class = struct {

// only call this function between allocateClassPair and registerClassPair
// this adds an Ivar of type `id`.
pub fn addIvar(self: Class, name: [:0]const u8) bool {
pub fn addIvar(self: Class, name: [*:0]const u8) bool {
// The return type is i8 when we're cross compiling, unsure why.
const result = c.class_addIvar(self.value, name, @sizeOf(c.id), @alignOf(c.id), "@");
return boolResult(@TypeOf(c.class_addIvar), result);
}
};

pub fn getClass(name: [:0]const u8) ?Class {
return .{ .value = c.objc_getClass(name.ptr) orelse return null };
pub fn getClass(name: [*:0]const u8) ?Class {
return .{ .value = c.objc_getClass(name) orelse return null };
}

pub fn getMetaClass(name: [:0]const u8) ?Class {
pub fn getMetaClass(name: [*:0]const u8) ?Class {
return .{ .value = c.objc_getMetaClass(name) orelse return null };
}

// begin by calling this function, then call registerClassPair on the result when you are finished
pub fn allocateClassPair(superclass: ?Class, name: [:0]const u8) ?Class {
pub fn allocateClassPair(superclass: ?Class, name: [*:0]const u8) ?Class {
return .{ .value = c.objc_allocateClassPair(
if (superclass) |cls| cls.value else null,
name.ptr,
name,
0,
) orelse return null };
}
Expand Down
8 changes: 4 additions & 4 deletions src/object.zig
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub const Object = struct {
/// Set a property. This is a helper around getProperty and is
/// strictly less performant than doing it manually. Consider doing
/// this manually if performance is critical.
pub fn setProperty(self: Object, comptime n: [:0]const u8, v: anytype) void {
pub fn setProperty(self: Object, comptime n: [*:0]const u8, v: anytype) void {
const Class = self.getClass().?;
const setter = setter: {
// See getProperty for why we do this.
Expand All @@ -59,7 +59,7 @@ pub const Object = struct {
/// Get a property. This is a helper around Class.getProperty and is
/// strictly less performant than doing it manually. Consider doing
/// this manually if performance is critical.
pub fn getProperty(self: Object, comptime T: type, comptime n: [:0]const u8) T {
pub fn getProperty(self: Object, comptime T: type, comptime n: [*:0]const u8) T {
const Class = self.getClass().?;
const getter = getter: {
// Sometimes a property is not a property because it has been
Expand Down Expand Up @@ -91,12 +91,12 @@ pub const Object = struct {
return c.object_isClass(self.value) == 1;
}

pub fn getInstanceVariable(self: Object, name: [:0]const u8) Object {
pub fn getInstanceVariable(self: Object, name: [*:0]const u8) Object {
const ivar = c.object_getInstanceVariable(self.value, name, null);
return fromId(c.object_getIvar(self.value, ivar));
}

pub fn setInstanceVariable(self: Object, name: [:0]const u8, val: Object) void {
pub fn setInstanceVariable(self: Object, name: [*:0]const u8, val: Object) void {
const ivar = c.object_getInstanceVariable(self.value, name, null);
c.object_setIvar(self.value, ivar, val.value);
}
Expand Down
4 changes: 2 additions & 2 deletions src/property.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ pub const Property = extern struct {
}

/// Returns the value of a property attribute given the attribute name.
pub fn copyAttributeValue(self: Property, attr: [:0]const u8) ?[:0]u8 {
pub fn copyAttributeValue(self: Property, attr: [*:0]const u8) ?[:0]u8 {
return std.mem.sliceTo(
c.property_copyAttributeValue(self.value, attr.ptr) orelse return null,
c.property_copyAttributeValue(self.value, attr) orelse return null,
0,
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/protocol.zig
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub const Protocol = extern struct {

pub fn getProperty(
self: Protocol,
name: [:0]const u8,
name: [*:0]const u8,
is_required: bool,
is_instance: bool,
) ?objc.Property {
Expand All @@ -39,6 +39,6 @@ pub const Protocol = extern struct {
}
};

pub fn getProtocol(name: [:0]const u8) ?Protocol {
pub fn getProtocol(name: [*:0]const u8) ?Protocol {
return .{ .value = c.objc_getProtocol(name) orelse return null };
}
6 changes: 3 additions & 3 deletions src/sel.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const std = @import("std");
const c = @import("c.zig").c;

// Shorthand, equivalent to Sel.registerName
pub inline fn sel(name: [:0]const u8) Sel {
pub inline fn sel(name: [*:0]const u8) Sel {
return Sel.registerName(name);
}

Expand All @@ -11,9 +11,9 @@ pub const Sel = struct {

/// 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 {
pub fn registerName(name: [*:0]const u8) Sel {
return Sel{
.value = c.sel_registerName(name.ptr),
.value = c.sel_registerName(name),
};
}

Expand Down