Skip to content

Commit

Permalink
Check whether the receiver specifies forwardingTarget for the given s…
Browse files Browse the repository at this point in the history
…elector.

After exhausting all other possible outcomes, add a call to -forwardingTargetForSelector: to check whether there is another object that should receive the message.  If so, then send try sending the message to that target. This allows classes defined in Nu to take advantage of "fast" message forwarding by implementing -forwardingTargetForSelector:
  • Loading branch information
chapados committed Aug 24, 2011
1 parent c46ca99 commit 82347bd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion objc/NuObject.m
Expand Up @@ -244,6 +244,10 @@ - (id) sendMessage:(id)cdr withContext:(NSMutableDictionary *)context
// Messaging null is ok.
else if (self == Nu__null) {
}
else if ( (target = [target forwardingTargetForSelector:sel]) ) {
//NSLog(@"found forwarding target: %@ for selector: %@", target, NSStringFromSelector(sel));
result = [target sendMessage:cdr withContext:context];
}
// Otherwise, call the overridable handler for unknown messages.
else {
//NSLog(@"calling handle unknown message for %@", [cdr stringValue]);
Expand All @@ -258,7 +262,6 @@ - (id) sendMessage:(id)cdr withContext:(NSMutableDictionary *)context
[result autorelease];
return result;
}

- (id) evalWithArguments:(id)cdr context:(NSMutableDictionary *)context
{
return [self sendMessage:cdr withContext:context];
Expand Down

0 comments on commit 82347bd

Please sign in to comment.