OLD | NEW |
1 //------------------------------------------------------------------------------
--------- | 1 //------------------------------------------------------------------------------
--------- |
2 // $Id: NSInvocation+OCMAdditions.m 67 2010-08-02 03:25:16Z erik $ | 2 // $Id$ |
3 // Copyright (c) 2006-2009 by Mulle Kybernetik. See License file for details. | 3 // Copyright (c) 2006-2009 by Mulle Kybernetik. See License file for details. |
4 //------------------------------------------------------------------------------
--------- | 4 //------------------------------------------------------------------------------
--------- |
5 | 5 |
6 #import "NSInvocation+OCMAdditions.h" | 6 #import "NSInvocation+OCMAdditions.h" |
7 | 7 |
8 | 8 |
9 @implementation NSInvocation(OCMAdditions) | 9 @implementation NSInvocation(OCMAdditions) |
10 | 10 |
11 - (id)getArgumentAtIndexAsObject:(int)argIndex | 11 - (id)getArgumentAtIndexAsObject:(int)argIndex |
12 { | 12 { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 return [NSNumber numberWithBool:value]; | 114 return [NSNumber numberWithBool:value]; |
115 } | 115 } |
116 case '^': | 116 case '^': |
117 { | 117 { |
118 void *value = NULL; | 118 void *value = NULL; |
119 [self getArgument:&value atIndex:argIndex]; | 119 [self getArgument:&value atIndex:argIndex]; |
120 return [NSValue valueWithPointer:value]; | 120 return [NSValue valueWithPointer:value]; |
121 } | 121 } |
122 case '{': // structure | 122 case '{': // structure |
123 { | 123 { |
124 » » » unsigned maxArgSize = [[self methodSignature] frameLengt
h]; | 124 » » » NSUInteger maxArgSize = [[self methodSignature] frameLen
gth]; |
125 NSMutableData *argumentData = [[[NSMutableData alloc] in
itWithLength:maxArgSize] autorelease]; | 125 NSMutableData *argumentData = [[[NSMutableData alloc] in
itWithLength:maxArgSize] autorelease]; |
126 [self getArgument:[argumentData mutableBytes] atIndex:ar
gIndex]; | 126 [self getArgument:[argumentData mutableBytes] atIndex:ar
gIndex]; |
127 return [NSValue valueWithBytes:[argumentData bytes] objC
Type:argType]; | 127 return [NSValue valueWithBytes:[argumentData bytes] objC
Type:argType]; |
128 } | 128 } |
129 | 129 |
130 } | 130 } |
131 [NSException raise:NSInvalidArgumentException format:@"Argument type '%s
' not supported", argType]; | 131 [NSException raise:NSInvalidArgumentException format:@"Argument type '%s
' not supported", argType]; |
132 return nil; | 132 return nil; |
133 } | 133 } |
134 | 134 |
135 - (NSString *)invocationDescription | 135 - (NSString *)invocationDescription |
136 { | 136 { |
137 NSMethodSignature *methodSignature = [self methodSignature]; | 137 NSMethodSignature *methodSignature = [self methodSignature]; |
138 » unsigned int numberOfArgs = [methodSignature numberOfArguments]; | 138 » NSUInteger numberOfArgs = [methodSignature numberOfArguments]; |
139 | 139 |
140 if (numberOfArgs == 2) | 140 if (numberOfArgs == 2) |
141 return NSStringFromSelector([self selector]); | 141 return NSStringFromSelector([self selector]); |
142 | 142 |
143 NSArray *selectorParts = [NSStringFromSelector([self selector]) componen
tsSeparatedByString:@":"]; | 143 NSArray *selectorParts = [NSStringFromSelector([self selector]) componen
tsSeparatedByString:@":"]; |
144 NSMutableString *description = [[NSMutableString alloc] init]; | 144 NSMutableString *description = [[NSMutableString alloc] init]; |
145 » int i; | 145 » unsigned int i; |
146 for(i = 2; i < numberOfArgs; i++) | 146 for(i = 2; i < numberOfArgs; i++) |
147 { | 147 { |
148 [description appendFormat:@"%@%@:", (i > 2 ? @" " : @""), [selec
torParts objectAtIndex:(i - 2)]]; | 148 [description appendFormat:@"%@%@:", (i > 2 ? @" " : @""), [selec
torParts objectAtIndex:(i - 2)]]; |
149 [description appendString:[self argumentDescriptionAtIndex:i]]; | 149 [description appendString:[self argumentDescriptionAtIndex:i]]; |
150 } | 150 } |
151 | 151 |
152 return [description autorelease]; | 152 return [description autorelease]; |
153 } | 153 } |
154 | 154 |
155 - (NSString *)argumentDescriptionAtIndex:(int)argIndex | 155 - (NSString *)argumentDescriptionAtIndex:(int)argIndex |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 328 |
329 - (NSString *)selectorDescriptionAtIndex:(int)anInt | 329 - (NSString *)selectorDescriptionAtIndex:(int)anInt |
330 { | 330 { |
331 SEL selectorValue; | 331 SEL selectorValue; |
332 | 332 |
333 [self getArgument:&selectorValue atIndex:anInt]; | 333 [self getArgument:&selectorValue atIndex:anInt]; |
334 return [NSString stringWithFormat:@"@selector(%@)", NSStringFromSelector
(selectorValue)]; | 334 return [NSString stringWithFormat:@"@selector(%@)", NSStringFromSelector
(selectorValue)]; |
335 } | 335 } |
336 | 336 |
337 @end | 337 @end |
OLD | NEW |