Browse files

fixed some problems with recent ivar changes, merged NuAnywhere updat…

…e from Jeff.
  • Loading branch information...
1 parent 955551d commit 728fbdefd8f9f44ac552d0dab66815d527d11c02 @timburks committed Jun 19, 2011
View
4 Nukefile
@@ -113,10 +113,10 @@ END)
(set @cflags (+ @cflags " -DHAVE_CONFIG_H"))
(ifDarwin
- (then (set @arch '("i386")))) ;; optionally add "ppc" or "ppc64" to the list
+ (then (set @arch '("x86_64")))) ;; optionally add "ppc" or "ppc64" to the list
(if (or isSnowLeopard isLion)
- (then (set @arch (append @arch '("x86_64")))))
+ (then (set @arch (append @arch '("i386")))))
(set @includes
((@inc_dirs map: (do (inc) " -I#{inc}")) join))
View
2 examples/NuAnywhere/NuConsole/Nukefile
@@ -11,7 +11,7 @@
(if (or (isSnowLeopard) (isLion))
(then
(set @ldflags " -framework Cocoa -framework Nu -framework Carbon -framework mach_inject_bundle -all_load ")
- (set @arch '("x86_64")))
+ (set @arch '("x86_64" "i386")))
(else
(set @ldflags " -framework Cocoa -framework Nu -framework Carbon -linject -L../libinject -all_load ")))
View
1 examples/NuAnywhere/NuConsole/objc/NuInjectBundle.m
@@ -12,6 +12,7 @@ @implementation ConsoleInitializer
- (id) run:(id) object
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ NSLog(@"starting");
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *main_path = [bundle pathForResource:@"main" ofType:@"nu"];
if (main_path) {
View
2 examples/NuAnywhere/NuInject/Nukefile
@@ -13,7 +13,7 @@
(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")))
+ (set @arch '("x86_64" )))
(else
;; If not Snow Leopard, then use the included version of mach_star
(set @includes " -I../libinject/objc")
View
43 objc/NuObject.m
@@ -343,19 +343,11 @@ - (id) handleUnknownMessage:(id) message withContext:(NSMutableDictionary *) con
int message_length = [message length];
if (message_length == 1) {
// try to automatically get an ivar
- @try
- {
- NSString *ivarName = [[message car] stringValue];
- //NSLog(@"looking for ivar %@", ivarName);
- // ivar name is the first (only) token of the message
+ NSString *ivarName = [[message car] stringValue];
+ if ([self hasValueForIvar:ivarName]) {
id result = [self valueForIvar:ivarName];
- // NSLog(@"returning %@ = %@", ivarName, [result description]);
return result;
}
- @catch (id error) {
- //NSLog(@"skipping this error: %@", [error description]);
- // no ivar, keep going
- }
}
else if (message_length == 2) {
// try to automatically set an ivar
@@ -397,20 +389,39 @@ - (id) valueForIvar:(NSString *) name
if (result) {
return result;
} else {
- NSLog(@"NO VALUE");
+ return Nu__null;
}
- }
- [NSException raise:@"NuNoInstanceVariable"
- format:@"Unable to get ivar named %@ for object %@",
- name, self];
-
+ }
return Nu__null;
}
void *location = (void *)&(((char *)self)[ivar_getOffset(v)]);
id result = get_nu_value_from_objc_value(location, ivar_getTypeEncoding(v));
return result;
}
+- (BOOL) hasValueForIvar:(NSString *) name
+{
+ Ivar v = class_getInstanceVariable([self class], [name cStringUsingEncoding:NSUTF8StringEncoding]);
+ if (!v) {
+ // look for sparse ivar storage
+ NSMutableDictionary *sparseIvars = [self associatedObjectForKey:@"__nuivars"];
+ if (sparseIvars) {
+ // NSLog(@"sparse %@", [sparseIvars description]);
+ id result = [sparseIvars objectForKey:name];
+ if (result) {
+ return YES;
+ } else {
+ return NO;
+ }
+ }
+ return NO;
+ }
+ void *location = (void *)&(((char *)self)[ivar_getOffset(v)]);
+ id result = get_nu_value_from_objc_value(location, ivar_getTypeEncoding(v));
+ return YES;
+}
+
+
- (void) setValue:(id) value forIvar:(NSString *)name
{
Ivar v = class_getInstanceVariable([self class], [name cStringUsingEncoding:NSUTF8StringEncoding]);
View
3 tools/nuke
@@ -150,7 +150,6 @@
(ivar (id) action) ;; a block which performs the necessary build action
(ivar (int) isFile) ;; if nonzero, task is a file task
(ivar (id) result) ;; the result of executing the task
- (ivar-accessors)
;; @discussion Create a task with a specified name.
(- (id) initWithName:(id) name is
@@ -856,7 +855,7 @@ END)
;; an instance method of a NukeProject; so all instance variables in a Nukefile
;; belong to the NukeProject instance.
(class NukeProject is NSObject
- (ivars)
+ (ivar (id) datamodels (id) tasks (id) framework_install_path )
;; Get the dictionary of tasks managed by a project.
(- (id) tasks is @tasks)

0 comments on commit 728fbde

Please sign in to comment.