diff options
| author | Pietro Gagliardi <[email protected]> | 2014-03-05 20:09:15 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-03-05 20:09:15 -0500 |
| commit | d29e1b8710ffe259ad7b532fb76056c52e2061ae (patch) | |
| tree | ca2bd348094e603498a91dcacafe73e35c8867c1 /bleh_darwin.m | |
| parent | 011836e94de2b1ba2c9fc729649db63f715997f9 (diff) | |
Have ui.Go() return on main() return on Mac OS X.
Diffstat (limited to 'bleh_darwin.m')
| -rw-r--r-- | bleh_darwin.m | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/bleh_darwin.m b/bleh_darwin.m index ca9c91a..08b02bb 100644 --- a/bleh_darwin.m +++ b/bleh_darwin.m @@ -7,6 +7,7 @@ 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 +though this is not always the case. Go wrapper functions (bleh_darwin.go) call these directly and take care of stdint.h -> Go type conversions. */ @@ -17,6 +18,7 @@ Go wrapper functions (bleh_darwin.go) call these directly and take care of stdin #include <Foundation/NSGeometry.h> #include <AppKit/NSKeyValueBinding.h> +#include <AppKit/NSEvent.h> /* exception to the above: cgo doesn't like Nil and delegate_darwin.go has //export so I can't have this there */ Class NilClass = Nil; @@ -155,3 +157,30 @@ uintptr_t *NSIndexSetEntries(id indexset, uintptr_t count) free(nsuints); return ret; } + +/* +See uitask_darwin.go: we need to synthesize a NSEvent so -[NSApplication stop:] will work. We cannot simply init the default NSEvent though (it throws an exception) so we must do it "the right way". This involves a very convoluted initializer; we'll just do it here to keep things clean on the Go side (this will only be run once anyway, on program exit). +*/ + +static id c_NSEvent; +static SEL s_newEvent; +static BOOL newEvent_init = NO; + +id makeDummyEvent() +{ + if (newEvent_init == NO) { + c_NSEvent = objc_getClass("NSEvent"); + s_newEvent = sel_getUid("otherEventWithType:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:"); + newEvent_init = YES; + } + return objc_msgSend(c_NSEvent, s_newEvent, + (NSUInteger) NSApplicationDefined, /* otherEventWithType: */ + NSMakePoint(0, 0), /* location: */ + (NSUInteger) 0, /* modifierFlags: */ + (double) 0, /* timestamp: */ + (NSInteger) 0, /* windowNumber: */ + nil, /* context: */ + (short) 0, /* subtype: */ + (NSInteger) 0, /* data1: */ + (NSInteger) 0); /* data2: */ +} |
