From b460466e4b7d479a015bb686adb42056ef189abe Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 3 Jul 2014 11:53:21 -0400 Subject: Implemented Post() on Mac OS X. --- delegateuitask_darwin.m | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'delegateuitask_darwin.m') diff --git a/delegateuitask_darwin.m b/delegateuitask_darwin.m index a1f9501..94051c0 100644 --- a/delegateuitask_darwin.m +++ b/delegateuitask_darwin.m @@ -56,6 +56,13 @@ extern NSRect dummyRect; @implementation appDelegate +- (void)uipost:(id)pv +{ + NSValue *v = (NSValue *) pv; + + appDelegate_uipost([v pointerValue]); +} + - (BOOL)windowShouldClose:(id)win { return appDelegate_windowShouldClose(win); @@ -123,6 +130,18 @@ BOOL initCocoa(id appDelegate) return YES; } +void uipost(id appDelegate, void *data) +{ + // need an autorelease pool here + NSAutoreleasePool *pool; + + pool = [NSAutoreleasePool new]; + [appDelegate performSelectorOnMainThread:@selector(uipost:) + withObject:[NSValue valueWithPointer:data] + waitUntilDone:YES]; // note this bit; see uitask_darwin.go for details + [pool release]; +} + void breakMainLoop(void) { NSEvent *e; -- cgit v1.2.3