summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-03-30 13:21:10 -0400
committerPietro Gagliardi <[email protected]>2014-03-30 13:21:10 -0400
commit8f944c7ec6ba0efaa6dd649934bc2badaef5ab22 (patch)
treefb68e290da74f0c8f964f6fe3ed996eb49f64194
parent08dfb5da2034c33b68d7247dd16925960b3b88a3 (diff)
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.
-rw-r--r--area_darwin.go4
-rw-r--r--bleh_darwin.m1
-rw-r--r--delegate_darwin.go9
3 files changed, 6 insertions, 8 deletions
diff --git a/area_darwin.go b/area_darwin.go
index a767411..ecefc76 100644
--- a/area_darwin.go
+++ b/area_darwin.go
@@ -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) {
diff --git a/bleh_darwin.m b/bleh_darwin.m
index fb57bb3..ac6182a 100644
--- a/bleh_darwin.m
+++ b/bleh_darwin.m
@@ -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());
}
diff --git a/delegate_darwin.go b/delegate_darwin.go
index c60689d..7f14d04 100644
--- a/delegate_darwin.go
+++ b/delegate_darwin.go
@@ -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) {