From 27d5038731b6d90305a657a2353cab66248b83ab Mon Sep 17 00:00:00 2001 From: Jeff Buck Date: Sat, 18 Jun 2011 19:38:46 -0400 Subject: [PATCH] Added support for NuAnywhere on 10.7 --- examples/NuAnywhere/NuConsole/Nukefile | 2 +- examples/NuAnywhere/NuInject/Nukefile | 4 +++- nu/console.nu | 4 ++-- objc/NuHandler.m | 19 ++++++++++++++++++- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/examples/NuAnywhere/NuConsole/Nukefile b/examples/NuAnywhere/NuConsole/Nukefile index 6a424a3..e877330 100644 --- a/examples/NuAnywhere/NuConsole/Nukefile +++ b/examples/NuAnywhere/NuConsole/Nukefile @@ -8,7 +8,7 @@ (set @cflags " -g -fobjc-gc") -(if (isSnowLeopard) +(if (or (isSnowLeopard) (isLion)) (then (set @ldflags " -framework Cocoa -framework Nu -framework Carbon -framework mach_inject_bundle -all_load ") (set @arch '("x86_64"))) diff --git a/examples/NuAnywhere/NuInject/Nukefile b/examples/NuAnywhere/NuInject/Nukefile index 831e43c..26e2c7d 100644 --- a/examples/NuAnywhere/NuInject/Nukefile +++ b/examples/NuAnywhere/NuInject/Nukefile @@ -9,7 +9,9 @@ (then ;; Make sure you download and build the mach_inject_bundle first ;; Get it at git://github.com/rentzsch/mach_star.git - (set @cflags "-isysroot /Developer/SDKs/MacOSX10.6.sdk ") + (if (isSnowLeopard) + (then (set @cflags "-isysroot /Developer/SDKs/MacOSX10.6.sdk ")) + (else (set @cflags "-isysroot /Developer/SDKs/MacOSX10.7.sdk "))) (set @ldflags " -framework Cocoa -framework Nu -framework Carbon -framework mach_inject_bundle") (set @arch '("x86_64"))) (else diff --git a/nu/console.nu b/nu/console.nu index 4d1f5e7..fbea929 100644 --- a/nu/console.nu +++ b/nu/console.nu @@ -110,7 +110,7 @@ styleMask:(+ NSTitledWindowMask NSClosableWindowMask NSMiniaturizableWindowMask NSResizableWindowMask NSUtilityWindowMask) backing:NSBackingStoreBuffered defer:NO)) - (set @console ((NuConsoleViewController alloc) initWithFrame: (list 0 0 (- (third ((self window) frame)) 17) (fourth ((self window) frame))))) + (set @console ((NuConsoleViewController alloc) initWithFrame: (list 0 0 (- (((self window) frame) objectAtIndex:2) 17) (((self window) frame) objectAtIndex:3)))) (self setMyShowConsole:NO) (self addMenuItem) (set @exitWhenClosed NO) @@ -371,7 +371,7 @@ (- (NSRange) textView:(id) textview willChangeSelectionFromCharacterRange:(NSRange) oldRange toCharacterRange:(NSRange) newRange is - (if (and (eq (second newRange) 0) + (if (and (eq (newRange second) 0) (< (first newRange) @startOfInput)) (then oldRange) (else newRange))) diff --git a/objc/NuHandler.m b/objc/NuHandler.m index e23ba25..daedae7 100644 --- a/objc/NuHandler.m +++ b/objc/NuHandler.m @@ -70,6 +70,23 @@ static id collect_arguments(struct handler_description *description, va_list ap) CGRect x = va_arg(ap, CGRect); [cursor setCar:get_nu_value_from_objc_value(&x, type)]; } +#else + else if (!strcmp(type, "{_NSRect={_NSPoint=dd}{_NSSize=dd}}")) { + NSRect x = va_arg(ap, NSRect); + [cursor setCar:get_nu_value_from_objc_value(&x, type)]; + } + else if (!strcmp(type, "{_NSPoint=dd}")) { + NSPoint x = va_arg(ap, NSPoint); + [cursor setCar:get_nu_value_from_objc_value(&x, type)]; + } + else if (!strcmp(type, "{_NSSize=dd}")) { + NSSize x = va_arg(ap, NSSize); + [cursor setCar:get_nu_value_from_objc_value(&x, type)]; + } + else if (!strcmp(type, "{_NSRange=QQ}")) { + NSRange x = va_arg(ap, NSRange); + [cursor setCar:get_nu_value_from_objc_value(&x, type)]; + } #endif else { NSLog(@"unsupported argument type %s, see objc/handler.m to add support for it", type); @@ -141,7 +158,7 @@ static IMP handler_returning_void(void *userdata) { #define MAKE_HANDLER_WITH_TYPE(type) \ static IMP handler_returning_ ## type (void* userdata) \ { \ -return imp_implementationWithBlock(^(id receiver, ...) { \ +return imp_implementationWithBlock(^(id receiver, ...) { \ struct handler_description description; \ description.handler = NULL; \ description.description = userdata; \