When we created our delegate and view classes on Mac OS X, it turned out we were accidentally subclassing the metaclass (of NSObject and NSView, respectively), not the actual superclass itself. Fixed tha. This also fixed that mysterious objc_new()/[object init] not working on the delegate class problem.
This commit is contained in:
parent
08dfb5da20
commit
8f944c7ec6
|
@ -64,10 +64,8 @@ func areaInScrollView(scrollview C.id) C.id {
|
|||
|
||||
func makeArea(parentWindow C.id, alternate bool) C.id {
|
||||
area := objc_alloc(_goArea)
|
||||
println(area)
|
||||
area = objc_msgSend_rect(area, _initWithFrame,
|
||||
0, 0, 100, 100)
|
||||
println("out")
|
||||
// TODO others?
|
||||
area = newAreaScrollView(area)
|
||||
addControl(parentWindow, area)
|
||||
|
@ -78,7 +76,7 @@ println("out")
|
|||
|
||||
var (
|
||||
_NSView = objc_getClass("NSView")
|
||||
_NSView_Class = C.object_getClass(_NSView)
|
||||
_NSView_Class = C.Class(unsafe.Pointer(_NSView))
|
||||
)
|
||||
|
||||
func makeAreaClass(name string) (C.Class, error) {
|
||||
|
|
|
@ -93,7 +93,6 @@ struct xrect objc_msgSend_stret_rect_noargs(id obj, SEL sel)
|
|||
|
||||
id _objc_msgSend_rect(id obj, SEL sel, int64_t x, int64_t y, int64_t w, int64_t h)
|
||||
{
|
||||
printf("%s\n", class_getName(objc_getMetaClass("goArea")));
|
||||
return objc_msgSend(obj, sel, OurRect());
|
||||
}
|
||||
|
||||
|
|
|
@ -64,9 +64,7 @@ func mkAppDelegate() error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("error adding NSApplication delegate buttonClicked: method (to handle button clicks): %v", err)
|
||||
}
|
||||
// TODO using objc_new() causes a segfault; find out why
|
||||
// TODO make alloc followed by init (I thought NSObject provided its own init?)
|
||||
appDelegate = objc_alloc(objc_getClass(_goAppDelegate))
|
||||
appDelegate = objc_new(objc_getClass(_goAppDelegate))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -111,7 +109,10 @@ func appDelegate_buttonClicked(self C.id, sel C.SEL, button C.id) {
|
|||
// this actually constructs the delegate class
|
||||
|
||||
var (
|
||||
_NSObject_Class = C.object_getClass(_NSObject)
|
||||
// objc_getClass() says it returns an id but it's actually a Class
|
||||
// thanks to Psy| in irc.freenode.net/##objc
|
||||
// don't call object_getClass() on this then, as I originally thought — that returns the /metaclass/ (which we don't want, and in fact I wasn't even aware we COULD subclass the metaclass directly like this)
|
||||
_NSObject_Class = C.Class(unsafe.Pointer(_NSObject))
|
||||
)
|
||||
|
||||
func makeDelegateClass(name string) (C.Class, error) {
|
||||
|
|
Loading…
Reference in New Issue