diff --git a/generator.zig b/generator.zig index 34e670c..b7a0e5d 100644 --- a/generator.zig +++ b/generator.zig @@ -1191,7 +1191,7 @@ fn Generator(comptime WriterType: type) type { defer inherited_method_sets.deinit(); if (container.super) |super| { const will_generate = blk: { - if (std.mem.eql(u8, "NSObject", super.name)) break :blk true; + if (self.isExternalContainerName(super)) break :blk true; if (getNamespace(super.name).len > 0) break :blk true; for (self.containers.items) |container2| { if (std.mem.eql(u8, container2.name, super.name)) break :blk true; @@ -1202,7 +1202,7 @@ fn Generator(comptime WriterType: type) type { } for (container.protocols.items) |protocol| { const will_generate = blk: { - if (std.mem.eql(u8, "NSObject", protocol.name)) break :blk true; + if (self.isExternalContainerName(protocol)) break :blk true; if (getNamespace(protocol.name).len > 0) break :blk true; for (self.containers.items) |container2| { @@ -1221,9 +1221,18 @@ fn Generator(comptime WriterType: type) type { try self.writer.print(" return struct {{\n", .{}); for (inherited_method_sets.items) |inherited| { - try self.writer.print(" pub usingnamespace ", .{}); - try self.generateContainerName(inherited); - try self.writer.print(".Methods(T);\n", .{}); + const will_generate = blk: { + if (self.isExternalContainerName(inherited)) break :blk true; + for (self.containers.items) |container2| { + if (std.mem.eql(u8, container2.name, inherited.name)) break :blk true; + } + break :blk false; + }; + if (will_generate) { + try self.writer.print(" pub usingnamespace ", .{}); + try self.generateContainerName(inherited); + try self.writer.print(".Methods(T);\n", .{}); + } } if (inherited_method_sets.items.len > 0) { try self.writer.print("\n", .{}); @@ -1546,6 +1555,14 @@ fn Generator(comptime WriterType: type) type { try self.generateContainerSuffix(container); } + fn isExternalContainerName(self: *Self, container: *Container) bool { + const namespace = getNamespace(container.name); + if (namespace.len > 0 and !std.mem.eql(u8, namespace, self.namespace)) { + return true; + } + return false; + } + fn generateLower(self: *Self, str: []const u8) !void { for (str) |ch| { try self.writer.writeByte(std.ascii.toLower(ch)); diff --git a/src/appkit/appkit.zig b/src/appkit/appkit.zig index 9afb62a..07ab713 100644 --- a/src/appkit/appkit.zig +++ b/src/appkit/appkit.zig @@ -80,8 +80,6 @@ pub const Application = opaque { pub fn Methods(comptime T: type) type { return struct { - pub usingnamespace Responder.Methods(T); - pub fn sharedApplication() *Application { return @as(*const fn (*c.objc_class, *c.objc_selector) callconv(.C) *Application, @ptrCast(&c.objc_msgSend))(T.class(), sel_sharedApplication); } @@ -97,8 +95,6 @@ pub const Window = opaque { pub fn Methods(comptime T: type) type { return struct { - pub usingnamespace Responder.Methods(T); - pub fn initWithContentRect_styleMask_backing_defer_screen(self_: *T, contentRect_: Rect, style_: WindowStyleMask, backingStoreType_: BackingStoreType, flag_: bool, screen_: ?*Screen) *T { return @as(*const fn (*T, *c.objc_selector, Rect, WindowStyleMask, BackingStoreType, bool, ?*Screen) callconv(.C) *T, @ptrCast(&c.objc_msgSend))(self_, sel_initWithContentRect_styleMask_backing_defer_screen_, contentRect_, style_, backingStoreType_, flag_, screen_); }