Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed some problems with recent ivar changes, merged NuAnywhere updat…
…e from Jeff.
  • Loading branch information
timburks committed Jun 19, 2011
1 parent 955551d commit 728fbde
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Nukefile
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion examples/NuAnywhere/NuConsole/Nukefile
Expand Up @@ -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 ")))

Expand Down
1 change: 1 addition & 0 deletions examples/NuAnywhere/NuConsole/objc/NuInjectBundle.m
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion examples/NuAnywhere/NuInject/Nukefile
Expand Up @@ -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")
Expand Down
43 changes: 27 additions & 16 deletions objc/NuObject.m
Expand Up @@ -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
Expand Down Expand Up @@ -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]);
Expand Down
3 changes: 1 addition & 2 deletions tools/nuke
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 728fbde

Please sign in to comment.