On Thursday, 14 December 2017 at 14:07:25 UTC, Adam D. Ruppe wrote:
I was playing with this myself based on Jacob's code and made it look like this:

extern (Objective-C) interface ViewController : NSViewController {
        extern (C)
        @ObjCMethodOverride("loadView")
        static void loadView(ViewController self, SEL sel) {
                printf("loadView\n");
        }

        extern (C)
        @ObjCMethodOverride("viewDidLoad")
        static void viewDidLoad(ViewController self, SEL sel) {
                printf("viewDidLoad\n");
        }

        ViewController init() @selector("init");
        mixin RegisterObjCClass;
}



so the mixin does some registering based on the method override attrs. It is still static with self cuz I actually felt hiding that made things a bit worse (inheritance wouldn't work like you expect), but most the registration stuff is now pulled from the attribute metadata.


Of course, my goal here isn't actually to do all of obj-c... just enough to port my simpledisplay.d. So I'm not sure if I'll make this public yet or just leave it as private and/or undocumented inside my library file.

This looks pretty awesome and very much like something I was looking for. Would really appreciate if you could share your work. Otherwise I'll have to roll up my sleeves and try hacking it on my own :)

Thanks for sharing your ideas!

Reply via email to