plan9port/src/cmd/devdraw/macargv.m
Russ Cox 310ae03327 all: fix or silence all INSTALL warnings on macOS
Should be a clean build now.

Change-Id: Id3460371cb5e8d4071f8faa9c2aec870d213a067
Reviewed-on: https://plan9port-review.googlesource.com/2781
Reviewed-by: Russ Cox <rsc@swtch.com>
2017-01-06 21:37:31 +00:00

50 lines
1.2 KiB
Objective-C

#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
#include <u.h>
#include <libc.h>
AUTOFRAMEWORK(Foundation)
AUTOFRAMEWORK(Cocoa)
@interface appdelegate : NSObject<NSApplicationDelegate> @end
void
main(void)
{
if(OSX_VERSION < 100700)
[NSAutoreleasePool new];
[NSApplication sharedApplication];
NSObject<NSApplicationDelegate> *delegate = [appdelegate new];
[NSApp setDelegate:delegate];
NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager]; /* Register a call-back for URL Events */
[appleEventManager setEventHandler:delegate andSelector:@selector(handleGetURLEvent:withReplyEvent:)
forEventClass:kInternetEventClass andEventID:kAEGetURL];
[NSApp run];
}
@implementation appdelegate
- (void)application:(id)arg openFiles:(NSArray*)file
{
int i,n;
NSString *s;
n = [file count];
for(i=0; i<n; i++){
s = [file objectAtIndex:i];
print("%s\n", [s UTF8String]);
}
[NSApp terminate:self];
}
- (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
NSString* url = [[event descriptorForKeyword:keyDirectObject] stringValue];
print("%s\n", [url UTF8String] + (sizeof("plumb:") - 1));
[NSApp terminate:self];
}
@end