summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bleh_darwin.m15
1 files changed, 12 insertions, 3 deletions
diff --git a/bleh_darwin.m b/bleh_darwin.m
index 5a2cbcf..2ef6c21 100644
--- a/bleh_darwin.m
+++ b/bleh_darwin.m
@@ -6,6 +6,7 @@ I wanted to avoid invoking Objective-C directly, preferring to do everything dir
The main culprits are:
- data types listed as being defined in nonexistent headers
- 32-bit/64-bit type differences that are more than just a different typedef
+- wrong documentation
Go wrapper functions (bleh_darwin.go) call these directly and take care of stdint.h -> Go type conversions.
*/
@@ -29,12 +30,18 @@ These are the objc_msgSend() wrappers around NSRect. The problem is that while o
I use int64_t for maximum safety, as my coordinates are stored as Go ints and Go int -> C int (which is what is documented as happening) isn't reliable.
*/
+/*
+This is not documented in the docs, but is in various places on apple.com. In fact, the docs are actually WRONG: they imply you pass a pointer to the structure as the first argument to objc_msgSend_stret! And there might be some cases where we can't use stret because the struct is small enough... we'll see.
+*/
+static NSRect (*objc_msgSend_stret_rect)(id, SEL, ...) =
+ (NSRect (*)(id, SEL, ...)) objc_msgSend_stret;
+
struct xrect objc_msgSend_stret_rect_noargs(id obj, SEL sel)
{
NSRect s;
struct xrect t;
- objc_msgSend_stret(&s, obj, sel);
+ s = objc_msgSend_stret_rect(obj, sel);
t.x = (int64_t) s.origin.x;
t.y = (int64_t) s.origin.y;
t.width = (int64_t) s.size.width;
@@ -42,7 +49,6 @@ struct xrect objc_msgSend_stret_rect_noargs(id obj, SEL sel)
return t;
}
-
#define OurRect() (NSMakeRect((CGFloat) x, (CGFloat) y, (CGFloat) w, (CGFloat) h))
id _objc_msgSend_rect(id obj, SEL sel, int64_t x, int64_t y, int64_t w, int64_t h)
@@ -64,12 +70,15 @@ id _objc_msgSend_rect_uint_uint_bool(id obj, SEL sel, int64_t x, int64_t y, int6
Same as NSRect above, but for NSSize now.
*/
+static NSSize (*objc_msgSend_stret_size)(id, SEL, ...) =
+ (NSSize (*)(id, SEL, ...)) objc_msgSend_stret;
+
struct xsize objc_msgSend_stret_size_noargs(id obj, SEL sel)
{
NSSize s;
struct xsize t;
- objc_msgSend_stret(&s, obj, sel);
+ s = objc_msgSend_stret_size(obj, sel);
t.width = (int64_t) s.width;
t.height = (int64_t) s.height;
return t;