diff options
| author | Pietro Gagliardi <[email protected]> | 2014-05-16 06:37:25 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-05-16 06:37:25 -0400 |
| commit | 14b3696d960d8e9d14129c66a50aafe1bcfc8913 (patch) | |
| tree | 14c0d5e8920cef0ff862aab27dcdcf745db99a4c | |
| parent | 8084ef53e1f64e41e35c44dac22e93635120cf46 (diff) | |
Cleaned up objc_darwin.h and changed all instances of int64_t in the wrapper structs to intptr_t.
| -rw-r--r-- | experiments/hscrolllistbox.go | 6 | ||||
| -rw-r--r-- | objc_darwin.h | 56 |
2 files changed, 26 insertions, 36 deletions
diff --git a/experiments/hscrolllistbox.go b/experiments/hscrolllistbox.go index 3975a56..7d03200 100644 --- a/experiments/hscrolllistbox.go +++ b/experiments/hscrolllistbox.go @@ -143,7 +143,7 @@ var ( ) func listboxPrefSize(control C.id) (width int, height int) { - var maxwidth C.int64_t + var maxwidth C.intptr_t listbox := listboxInScrollView(control) _, height = controlPrefSize(listbox) @@ -166,13 +166,13 @@ func (s *sysData) setRect(x int, y int, width int, height int, winheight int) er // winheight - y because (0,0) is the bottom-left corner of the window and not the top-left corner // (winheight - y) - height because (x, y) is the bottom-left corner of the control and not the top-left C.objc_msgSend_rect(s.id, _setFrame, - C.int64_t(x), C.int64_t((winheight - y) - height), C.int64_t(width), C.int64_t(height)) + C.intptr_t(x), C.intptr_t((winheight - y) - height), C.intptr_t(width), C.intptr_t(height)) // TODO having this here is a hack; split it into a separate function in listbox_darwin.go // the NSTableView:NSTableColumn ratio is what determines horizontal scrolling; see http://stackoverflow.com/questions/7050497/enable-scrolling-for-nstableview if s.ctype == c_listbox { listbox := listboxInScrollView(s.id) C.objc_msgSend_rect(listbox, _setFrame, - 0, 0, C.int64_t(width), C.int64_t(height)) + 0, 0, C.intptr_t(width), C.intptr_t(height)) } return nil } diff --git a/objc_darwin.h b/objc_darwin.h index feab715..887f343 100644 --- a/objc_darwin.h +++ b/objc_darwin.h @@ -1,52 +1,42 @@ /* 28 february 2014 */ -/* -This includes all Objective-C runtime headers for convenience. It also creates wrappers around objc_msgSend() out of necessity. - -cgo doesn't support calling variable argument list C functions, so objc_msgSend() cannot be called directly. - -Furthermore, Objective-C selectors work by basically sending the arguments to objc_msgSend() verbatim across the wire. This basically means we're stuck making wrapper functions for every possible argument list. What fun! - -The format should be self-explanatory. -*/ - -/* for some reason I now have to use an include guard after commit [master 9b4e30c] ("Started to build a single global delegate object; now to fix issues.") */ -#ifndef _OBJC_DARWIN_H_ -#define _OBJC_DARWIN_H_ +/* apparently this header is included by other headers generated by cgo, wrecking the structures below, so wheee include guards */ +/* the change that introduced this was [master 9b4e30c] ("Started to build a single global delegate object; now to fix issues.") */ +#ifndef __GO_UI_OBJC_DARWIN_H__ +#define __GO_UI_OBJC_DARWIN_H__ +/* the Objective-C runtime headers, for id */ #include <objc/message.h> #include <objc/objc.h> #include <objc/runtime.h> #include <stdint.h> -struct xrect; // TODO move that up here when finally getting rid of bleh_darwin.m - -extern id toNSString(char *); -extern char *fromNSString(id); -extern void display(id); -extern struct xrect frame(id); -extern id makeScrollView(id); -extern void giveScrollViewBezelBorder(id); -extern id scrollViewContent(id); - -// BEGIN OLD CODE - +/* wrapper types since the meaning of NSRect, NSSize, and NSPoint are CPU architectured-dependent; also because they're in an Objective-C-only header */ struct xrect { - int64_t x; - int64_t y; - int64_t width; - int64_t height; + intptr_t x; + intptr_t y; + intptr_t width; + intptr_t height; }; struct xsize { - int64_t width; - int64_t height; + intptr_t width; + intptr_t height; }; struct xpoint { - int64_t x; - int64_t y; + intptr_t x; + intptr_t y; }; +/* objc_darwin.m */ +extern id toNSString(char *); +extern char *fromNSString(id); +extern void display(id); +extern struct xrect frame(id); +extern id makeScrollView(id); +extern void giveScrollViewBezelBorder(id); +extern id scrollViewContent(id); + #endif |
