| OLD | NEW |
| 1 //------------------------------------------------------------------------------
--------- | 1 /* |
| 2 // $Id$ | 2 * Copyright (c) 2006-2015 Erik Doernenburg and contributors |
| 3 // Copyright (c) 2006-2009 by Mulle Kybernetik. See License file for details. | 3 * |
| 4 //------------------------------------------------------------------------------
--------- | 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 * not use these files except in compliance with the License. You may obtain |
| 6 * a copy of the License at |
| 7 * |
| 8 * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 * |
| 10 * Unless required by applicable law or agreed to in writing, software |
| 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 * License for the specific language governing permissions and limitations |
| 14 * under the License. |
| 15 */ |
| 5 | 16 |
| 6 #import "NSInvocation+OCMAdditions.h" | 17 #import "NSInvocation+OCMAdditions.h" |
| 7 | 18 #import "OCMFunctions.h" |
| 8 | 19 |
| 9 @implementation NSInvocation(OCMAdditions) | 20 @implementation NSInvocation(OCMAdditions) |
| 10 | 21 |
| 11 - (id)getArgumentAtIndexAsObject:(int)argIndex | 22 - (BOOL)hasCharPointerArgument { |
| 12 { | 23 NSMethodSignature* signature = [self methodSignature]; |
| 13 » const char* argType; | 24 for (NSUInteger i = 0; i < [signature numberOfArguments]; i++) { |
| 14 » | 25 const char* argType = |
| 15 » argType = [[self methodSignature] getArgumentTypeAtIndex:argIndex]; | 26 OCMTypeWithoutQualifiers([signature getArgumentTypeAtIndex:i]); |
| 16 » while(strchr("rnNoORV", argType[0]) != NULL) | 27 if (strcmp(argType, "*") == 0) |
| 17 » » argType += 1; | 28 return YES; |
| 18 » | 29 } |
| 19 » if((strlen(argType) > 1) && (strchr("{^", argType[0]) == NULL) && (strcm
p("@?", argType) != 0)) | 30 return NO; |
| 20 » » [NSException raise:NSInvalidArgumentException format:@"Cannot ha
ndle argument type '%s'.", argType]; | 31 } |
| 21 » | 32 |
| 22 » switch (argType[0]) | 33 - (id)getArgumentAtIndexAsObject:(NSInteger)argIndex { |
| 23 » { | 34 const char* argType = OCMTypeWithoutQualifiers( |
| 24 » » case '#': | 35 [[self methodSignature] getArgumentTypeAtIndex:(NSUInteger)argIndex]); |
| 25 » » case '@': | 36 |
| 26 » » { | 37 if ((strlen(argType) > 1) && (strchr("{^", argType[0]) == NULL) && |
| 27 » » » id value; | 38 (strcmp("@?", argType) != 0)) |
| 28 » » » [self getArgument:&value atIndex:argIndex]; | 39 [NSException raise:NSInvalidArgumentException |
| 29 » » » return value; | 40 format:@"Cannot handle argument type '%s'.", argType]; |
| 30 » » } | 41 |
| 31 » » case ':': | 42 if (OCMIsObjectType(argType)) { |
| 32 » » { | 43 id value; |
| 33 » » » SEL s = (SEL)0; | 44 [self getArgument:&value atIndex:argIndex]; |
| 34 » » » [self getArgument:&s atIndex:argIndex]; | 45 return value; |
| 35 » » » id value = NSStringFromSelector(s); | 46 } |
| 36 » » » return value; | 47 |
| 37 » » } | 48 switch (argType[0]) { |
| 38 » » case 'i': | 49 case ':': { |
| 39 » » { | 50 SEL s = (SEL)0; |
| 40 » » » int value; | 51 [self getArgument:&s atIndex:argIndex]; |
| 41 » » » [self getArgument:&value atIndex:argIndex]; | 52 return [NSValue valueWithBytes:&s objCType:":"]; |
| 42 » » » return [NSNumber numberWithInt:value]; | 53 } |
| 43 » » }» | 54 case 'i': { |
| 44 » » case 's': | 55 int value; |
| 45 » » { | 56 [self getArgument:&value atIndex:argIndex]; |
| 46 » » » short value; | 57 return @(value); |
| 47 » » » [self getArgument:&value atIndex:argIndex]; | 58 } |
| 48 » » » return [NSNumber numberWithShort:value]; | 59 case 's': { |
| 49 » » }» | 60 short value; |
| 50 » » case 'l': | 61 [self getArgument:&value atIndex:argIndex]; |
| 51 » » { | 62 return @(value); |
| 52 » » » long value; | 63 } |
| 53 » » » [self getArgument:&value atIndex:argIndex]; | 64 case 'l': { |
| 54 » » » return [NSNumber numberWithLong:value]; | 65 long value; |
| 55 » » }» | 66 [self getArgument:&value atIndex:argIndex]; |
| 56 » » case 'q': | 67 return @(value); |
| 57 » » { | 68 } |
| 58 » » » long long value; | 69 case 'q': { |
| 59 » » » [self getArgument:&value atIndex:argIndex]; | 70 long long value; |
| 60 » » » return [NSNumber numberWithLongLong:value]; | 71 [self getArgument:&value atIndex:argIndex]; |
| 61 » » }» | 72 return @(value); |
| 62 » » case 'c': | 73 } |
| 63 » » { | 74 case 'c': { |
| 64 » » » char value; | 75 char value; |
| 65 » » » [self getArgument:&value atIndex:argIndex]; | 76 [self getArgument:&value atIndex:argIndex]; |
| 66 » » » return [NSNumber numberWithChar:value]; | 77 return @(value); |
| 67 » » }» | 78 } |
| 68 » » case 'C': | 79 case 'C': { |
| 69 » » { | 80 unsigned char value; |
| 70 » » » unsigned char value; | 81 [self getArgument:&value atIndex:argIndex]; |
| 71 » » » [self getArgument:&value atIndex:argIndex]; | 82 return @(value); |
| 72 » » » return [NSNumber numberWithUnsignedChar:value]; | 83 } |
| 73 » » }» | 84 case 'I': { |
| 74 » » case 'I': | 85 unsigned int value; |
| 75 » » { | 86 [self getArgument:&value atIndex:argIndex]; |
| 76 » » » unsigned int value; | 87 return @(value); |
| 77 » » » [self getArgument:&value atIndex:argIndex]; | 88 } |
| 78 » » » return [NSNumber numberWithUnsignedInt:value]; | 89 case 'S': { |
| 79 » » }» | 90 unsigned short value; |
| 80 » » case 'S': | 91 [self getArgument:&value atIndex:argIndex]; |
| 81 » » { | 92 return @(value); |
| 82 » » » unsigned short value; | 93 } |
| 83 » » » [self getArgument:&value atIndex:argIndex]; | 94 case 'L': { |
| 84 » » » return [NSNumber numberWithUnsignedShort:value]; | 95 unsigned long value; |
| 85 » » }» | 96 [self getArgument:&value atIndex:argIndex]; |
| 86 » » case 'L': | 97 return @(value); |
| 87 » » { | 98 } |
| 88 » » » unsigned long value; | 99 case 'Q': { |
| 89 » » » [self getArgument:&value atIndex:argIndex]; | 100 unsigned long long value; |
| 90 » » » return [NSNumber numberWithUnsignedLong:value]; | 101 [self getArgument:&value atIndex:argIndex]; |
| 91 » » }» | 102 return @(value); |
| 92 » » case 'Q': | 103 } |
| 93 » » { | 104 case 'f': { |
| 94 » » » unsigned long long value; | 105 float value; |
| 95 » » » [self getArgument:&value atIndex:argIndex]; | 106 [self getArgument:&value atIndex:argIndex]; |
| 96 » » » return [NSNumber numberWithUnsignedLongLong:value]; | 107 return @(value); |
| 97 » » }» | 108 } |
| 98 » » case 'f': | 109 case 'd': { |
| 99 » » { | 110 double value; |
| 100 » » » float value; | 111 [self getArgument:&value atIndex:argIndex]; |
| 101 » » » [self getArgument:&value atIndex:argIndex]; | 112 return @(value); |
| 102 » » » return [NSNumber numberWithFloat:value]; | 113 } |
| 103 » » }» | 114 case 'D': { |
| 104 » » case 'd': | 115 long double value; |
| 105 » » { | 116 [self getArgument:&value atIndex:argIndex]; |
| 106 » » » double value; | 117 return |
| 107 » » » [self getArgument:&value atIndex:argIndex]; | 118 [NSValue valueWithBytes:&value objCType:@encode(__typeof__(value))]; |
| 108 » » » return [NSNumber numberWithDouble:value]; | 119 } |
| 109 » » }» | 120 case 'B': { |
| 110 » » case 'B': | 121 bool value; |
| 111 » » { | 122 [self getArgument:&value atIndex:argIndex]; |
| 112 » » » bool value; | 123 return @(value); |
| 113 » » » [self getArgument:&value atIndex:argIndex]; | 124 } |
| 114 » » » return [NSNumber numberWithBool:value]; | 125 case '^': |
| 115 » » } | 126 case '*': { |
| 116 » » case '^': | 127 void* value = NULL; |
| 117 { | 128 [self getArgument:&value atIndex:argIndex]; |
| 118 void *value = NULL; | 129 return [NSValue valueWithPointer:value]; |
| 119 [self getArgument:&value atIndex:argIndex]; | 130 } |
| 120 return [NSValue valueWithPointer:value]; | 131 case '{': // structure |
| 121 } | 132 { |
| 122 » » case '{': // structure | 133 NSUInteger argSize; |
| 123 » » { | 134 NSGetSizeAndAlignment( |
| 124 » » » NSUInteger maxArgSize = [[self methodSignature] frameLen
gth]; | 135 [[self methodSignature] getArgumentTypeAtIndex:(NSUInteger)argIndex], |
| 125 » » » NSMutableData *argumentData = [[[NSMutableData alloc] in
itWithLength:maxArgSize] autorelease]; | 136 &argSize, NULL); |
| 126 » » » [self getArgument:[argumentData mutableBytes] atIndex:ar
gIndex]; | 137 if (argSize == 0) // TODO: Can this happen? Is frameLength a good choice |
| 127 » » » return [NSValue valueWithBytes:[argumentData bytes] objC
Type:argType]; | 138 // in that case? |
| 128 » » } | 139 argSize = [[self methodSignature] frameLength]; |
| 129 » » » | 140 NSMutableData* argumentData = |
| 130 » } | 141 [[[NSMutableData alloc] initWithLength:argSize] autorelease]; |
| 131 » [NSException raise:NSInvalidArgumentException format:@"Argument type '%s
' not supported", argType]; | 142 [self getArgument:[argumentData mutableBytes] atIndex:argIndex]; |
| 132 » return nil; | 143 return [NSValue valueWithBytes:[argumentData bytes] objCType:argType]; |
| 144 } |
| 145 } |
| 146 [NSException raise:NSInvalidArgumentException |
| 147 format:@"Argument type '%s' not supported", argType]; |
| 148 return nil; |
| 133 } | 149 } |
| 134 | 150 |
| 135 - (NSString *)invocationDescription | 151 - (NSString *)invocationDescription |
| 136 { | 152 { |
| 137 NSMethodSignature *methodSignature = [self methodSignature]; | 153 NSMethodSignature *methodSignature = [self methodSignature]; |
| 138 NSUInteger numberOfArgs = [methodSignature numberOfArguments]; | 154 NSUInteger numberOfArgs = [methodSignature numberOfArguments]; |
| 139 | 155 |
| 140 if (numberOfArgs == 2) | 156 if (numberOfArgs == 2) |
| 141 return NSStringFromSelector([self selector]); | 157 return NSStringFromSelector([self selector]); |
| 142 | 158 |
| 143 NSArray *selectorParts = [NSStringFromSelector([self selector]) componen
tsSeparatedByString:@":"]; | 159 NSArray *selectorParts = [NSStringFromSelector([self selector]) componen
tsSeparatedByString:@":"]; |
| 144 NSMutableString *description = [[NSMutableString alloc] init]; | 160 NSMutableString *description = [[NSMutableString alloc] init]; |
| 145 unsigned int i; | 161 NSUInteger i; |
| 146 for(i = 2; i < numberOfArgs; i++) | 162 for (i = 2; i < numberOfArgs; i++) { |
| 147 { | 163 [description appendFormat:@"%@%@:", (i > 2 ? @" " : @""), |
| 148 [description appendFormat:@"%@%@:", (i > 2 ? @" " : @""), [selec
torParts objectAtIndex:(i - 2)]]; | 164 [selectorParts objectAtIndex:(i - 2)]]; |
| 149 [description appendString:[self argumentDescriptionAtIndex:i]]; | 165 [description |
| 150 } | 166 appendString:[self argumentDescriptionAtIndex:(NSInteger)i]]; |
| 151 | 167 } |
| 152 return [description autorelease]; | 168 |
| 153 } | 169 return [description autorelease]; |
| 154 | 170 } |
| 155 - (NSString *)argumentDescriptionAtIndex:(int)argIndex | 171 |
| 156 { | 172 - (NSString*)argumentDescriptionAtIndex:(NSInteger)argIndex { |
| 157 const char *argType = [[self methodSignature] getArgumentTypeAtIndex:arg
Index]; | 173 const char* argType = OCMTypeWithoutQualifiers( |
| 158 if(strchr("rnNoORV", argType[0]) != NULL) | 174 [[self methodSignature] getArgumentTypeAtIndex:(NSUInteger)argIndex]); |
| 159 argType += 1; | 175 |
| 160 | 176 switch (*argType) { |
| 161 switch(*argType) | 177 case '@': |
| 162 { | 178 return [self objectDescriptionAtIndex:argIndex]; |
| 163 case '@': return [self objectDescriptionAtIndex:argIndex]; | 179 case 'B': |
| 164 case 'B': return [self boolDescriptionAtIndex:argIndex]; | 180 return [self boolDescriptionAtIndex:argIndex]; |
| 165 case 'c': return [self charDescriptionAtIndex:argIndex]; | 181 case 'c': |
| 166 case 'C': return [self unsignedCharDescriptionAtIndex:argI
ndex]; | 182 return [self charDescriptionAtIndex:argIndex]; |
| 167 case 'i': return [self intDescriptionAtIndex:argIndex]; | 183 case 'C': |
| 168 case 'I': return [self unsignedIntDescriptionAtIndex:argIn
dex]; | 184 return [self unsignedCharDescriptionAtIndex:argIndex]; |
| 169 case 's': return [self shortDescriptionAtIndex:argIndex]; | 185 case 'i': |
| 170 case 'S': return [self unsignedShortDescriptionAtIndex:arg
Index]; | 186 return [self intDescriptionAtIndex:argIndex]; |
| 171 case 'l': return [self longDescriptionAtIndex:argIndex]; | 187 case 'I': |
| 172 case 'L': return [self unsignedLongDescriptionAtIndex:argI
ndex]; | 188 return [self unsignedIntDescriptionAtIndex:argIndex]; |
| 173 case 'q': return [self longLongDescriptionAtIndex:argIndex
]; | 189 case 's': |
| 174 case 'Q': return [self unsignedLongLongDescriptionAtIndex:
argIndex]; | 190 return [self shortDescriptionAtIndex:argIndex]; |
| 175 case 'd': return [self doubleDescriptionAtIndex:argIndex]; | 191 case 'S': |
| 176 case 'f': return [self floatDescriptionAtIndex:argIndex]; | 192 return [self unsignedShortDescriptionAtIndex:argIndex]; |
| 177 // Why does this throw EXC_BAD_ACCESS when appending the string? | 193 case 'l': |
| 178 // case NSObjCStructType: return [self structDescriptionAtI
ndex:index]; | 194 return [self longDescriptionAtIndex:argIndex]; |
| 179 case '^': return [self pointerDescriptionAtIndex:argIndex]
; | 195 case 'L': |
| 180 case '*': return [self cStringDescriptionAtIndex:argIndex]
; | 196 return [self unsignedLongDescriptionAtIndex:argIndex]; |
| 181 case ':': return [self selectorDescriptionAtIndex:argIndex
]; | 197 case 'q': |
| 182 default: return [@"<??" stringByAppendingString:@">"]; /
/ avoid confusion with trigraphs... | 198 return [self longLongDescriptionAtIndex:argIndex]; |
| 183 } | 199 case 'Q': |
| 184 | 200 return [self unsignedLongLongDescriptionAtIndex:argIndex]; |
| 185 } | 201 case 'd': |
| 186 | 202 return [self doubleDescriptionAtIndex:argIndex]; |
| 187 | 203 case 'f': |
| 188 - (NSString *)objectDescriptionAtIndex:(int)anInt | 204 return [self floatDescriptionAtIndex:argIndex]; |
| 189 { | 205 case 'D': |
| 190 id object; | 206 return [self longDoubleDescriptionAtIndex:argIndex]; |
| 191 | 207 case '{': |
| 192 [self getArgument:&object atIndex:anInt]; | 208 return [self structDescriptionAtIndex:argIndex]; |
| 193 if (object == nil) | 209 case '^': |
| 194 return @"nil"; | 210 return [self pointerDescriptionAtIndex:argIndex]; |
| 195 else if(![object isProxy] && [object isKindOfClass:[NSString class]]) | 211 case '*': |
| 196 return [NSString stringWithFormat:@"@\"%@\"", [object descriptio
n]]; | 212 return [self cStringDescriptionAtIndex:argIndex]; |
| 197 else | 213 case ':': |
| 198 return [object description]; | 214 return [self selectorDescriptionAtIndex:argIndex]; |
| 199 } | 215 default: |
| 200 | 216 return [@"<??" |
| 201 - (NSString *)boolDescriptionAtIndex:(int)anInt | 217 stringByAppendingString:@">"]; // avoid confusion with trigraphs... |
| 202 { | 218 } |
| 203 bool value; | 219 } |
| 204 | 220 |
| 205 [self getArgument:&value atIndex:anInt]; | 221 - (NSString*)objectDescriptionAtIndex:(NSInteger)anInt { |
| 206 return value ? @"YES" : @"NO"; | 222 id object; |
| 207 } | 223 |
| 208 | 224 [self getArgument:&object atIndex:anInt]; |
| 209 - (NSString *)charDescriptionAtIndex:(int)anInt | 225 if (object == nil) |
| 210 { | 226 return @"nil"; |
| 211 unsigned char buffer[128]; | 227 else if (![object isProxy] && [object isKindOfClass:[NSString class]]) |
| 212 memset(buffer, 0x0, 128); | 228 return [NSString stringWithFormat:@"@\"%@\"", [object description]]; |
| 213 | 229 else |
| 214 [self getArgument:&buffer atIndex:anInt]; | 230 // The description cannot be nil, if it is then replace it |
| 215 | 231 return [object description] ?: @"<nil description>"; |
| 216 // If there's only one character in the buffer, and it's 0 or 1, then we
have a BOOL | 232 } |
| 217 if (buffer[1] == '\0' && (buffer[0] == 0 || buffer[0] == 1)) | 233 |
| 218 return [NSString stringWithFormat:@"%@", (buffer[0] == 1 ? @"YES
" : @"NO")]; | 234 - (NSString*)boolDescriptionAtIndex:(NSInteger)anInt { |
| 219 else | 235 bool value; |
| 220 return [NSString stringWithFormat:@"'%c'", *buffer]; | 236 [self getArgument:&value atIndex:anInt]; |
| 221 } | 237 return value ? @"YES" : @"NO"; |
| 222 | 238 } |
| 223 - (NSString *)unsignedCharDescriptionAtIndex:(int)anInt | 239 |
| 224 { | 240 - (NSString*)charDescriptionAtIndex:(NSInteger)anInt { |
| 225 unsigned char buffer[128]; | 241 unsigned char buffer[128]; |
| 226 memset(buffer, 0x0, 128); | 242 memset(buffer, 0x0, 128); |
| 227 | 243 |
| 228 [self getArgument:&buffer atIndex:anInt]; | 244 [self getArgument:&buffer atIndex:anInt]; |
| 229 return [NSString stringWithFormat:@"'%c'", *buffer]; | 245 |
| 230 } | 246 // If there's only one character in the buffer, and it's 0 or 1, then we have |
| 231 | 247 // a BOOL |
| 232 - (NSString *)intDescriptionAtIndex:(int)anInt | 248 if (buffer[1] == '\0' && (buffer[0] == 0 || buffer[0] == 1)) |
| 233 { | 249 return (buffer[0] == 1 ? @"YES" : @"NO"); |
| 234 int intValue; | 250 else |
| 235 | 251 return [NSString stringWithFormat:@"'%c'", *buffer]; |
| 236 [self getArgument:&intValue atIndex:anInt]; | 252 } |
| 237 return [NSString stringWithFormat:@"%d", intValue]; | 253 |
| 238 } | 254 - (NSString*)unsignedCharDescriptionAtIndex:(NSInteger)anInt { |
| 239 | 255 unsigned char buffer[128]; |
| 240 - (NSString *)unsignedIntDescriptionAtIndex:(int)anInt | 256 memset(buffer, 0x0, 128); |
| 241 { | 257 |
| 242 unsigned int intValue; | 258 [self getArgument:&buffer atIndex:anInt]; |
| 243 | 259 return [NSString stringWithFormat:@"'%c'", *buffer]; |
| 244 [self getArgument:&intValue atIndex:anInt]; | 260 } |
| 245 return [NSString stringWithFormat:@"%d", intValue]; | 261 |
| 246 } | 262 - (NSString*)intDescriptionAtIndex:(NSInteger)anInt { |
| 247 | 263 int intValue; |
| 248 - (NSString *)shortDescriptionAtIndex:(int)anInt | 264 |
| 249 { | 265 [self getArgument:&intValue atIndex:anInt]; |
| 250 short shortValue; | 266 return [NSString stringWithFormat:@"%d", intValue]; |
| 251 | 267 } |
| 252 [self getArgument:&shortValue atIndex:anInt]; | 268 |
| 253 return [NSString stringWithFormat:@"%hi", shortValue]; | 269 - (NSString*)unsignedIntDescriptionAtIndex:(NSInteger)anInt { |
| 254 } | 270 unsigned int intValue; |
| 255 | 271 |
| 256 - (NSString *)unsignedShortDescriptionAtIndex:(int)anInt | 272 [self getArgument:&intValue atIndex:anInt]; |
| 257 { | 273 return [NSString stringWithFormat:@"%d", intValue]; |
| 258 unsigned short shortValue; | 274 } |
| 259 | 275 |
| 260 [self getArgument:&shortValue atIndex:anInt]; | 276 - (NSString*)shortDescriptionAtIndex:(NSInteger)anInt { |
| 261 return [NSString stringWithFormat:@"%hu", shortValue]; | 277 short shortValue; |
| 262 } | 278 |
| 263 | 279 [self getArgument:&shortValue atIndex:anInt]; |
| 264 - (NSString *)longDescriptionAtIndex:(int)anInt | 280 return [NSString stringWithFormat:@"%hi", shortValue]; |
| 265 { | 281 } |
| 266 long longValue; | 282 |
| 267 | 283 - (NSString*)unsignedShortDescriptionAtIndex:(NSInteger)anInt { |
| 268 [self getArgument:&longValue atIndex:anInt]; | 284 unsigned short shortValue; |
| 269 return [NSString stringWithFormat:@"%ld", longValue]; | 285 |
| 270 } | 286 [self getArgument:&shortValue atIndex:anInt]; |
| 271 | 287 return [NSString stringWithFormat:@"%hu", shortValue]; |
| 272 - (NSString *)unsignedLongDescriptionAtIndex:(int)anInt | 288 } |
| 273 { | 289 |
| 274 unsigned long longValue; | 290 - (NSString*)longDescriptionAtIndex:(NSInteger)anInt { |
| 275 | 291 long longValue; |
| 276 [self getArgument:&longValue atIndex:anInt]; | 292 |
| 277 return [NSString stringWithFormat:@"%lu", longValue]; | 293 [self getArgument:&longValue atIndex:anInt]; |
| 278 } | 294 return [NSString stringWithFormat:@"%ld", longValue]; |
| 279 | 295 } |
| 280 - (NSString *)longLongDescriptionAtIndex:(int)anInt | 296 |
| 281 { | 297 - (NSString*)unsignedLongDescriptionAtIndex:(NSInteger)anInt { |
| 282 long long longLongValue; | 298 unsigned long longValue; |
| 283 | 299 |
| 284 [self getArgument:&longLongValue atIndex:anInt]; | 300 [self getArgument:&longValue atIndex:anInt]; |
| 285 return [NSString stringWithFormat:@"%qi", longLongValue]; | 301 return [NSString stringWithFormat:@"%lu", longValue]; |
| 286 } | 302 } |
| 287 | 303 |
| 288 - (NSString *)unsignedLongLongDescriptionAtIndex:(int)anInt | 304 - (NSString*)longLongDescriptionAtIndex:(NSInteger)anInt { |
| 289 { | 305 long long longLongValue; |
| 290 unsigned long long longLongValue; | 306 |
| 291 | 307 [self getArgument:&longLongValue atIndex:anInt]; |
| 292 [self getArgument:&longLongValue atIndex:anInt]; | 308 return [NSString stringWithFormat:@"%qi", longLongValue]; |
| 293 return [NSString stringWithFormat:@"%qu", longLongValue]; | 309 } |
| 294 } | 310 |
| 295 | 311 - (NSString*)unsignedLongLongDescriptionAtIndex:(NSInteger)anInt { |
| 296 - (NSString *)doubleDescriptionAtIndex:(int)anInt; | 312 unsigned long long longLongValue; |
| 297 { | 313 |
| 298 double doubleValue; | 314 [self getArgument:&longLongValue atIndex:anInt]; |
| 299 | 315 return [NSString stringWithFormat:@"%qu", longLongValue]; |
| 300 [self getArgument:&doubleValue atIndex:anInt]; | 316 } |
| 301 return [NSString stringWithFormat:@"%f", doubleValue]; | 317 |
| 302 } | 318 - (NSString*)doubleDescriptionAtIndex:(NSInteger)anInt { |
| 303 | 319 double doubleValue; |
| 304 - (NSString *)floatDescriptionAtIndex:(int)anInt | 320 |
| 305 { | 321 [self getArgument:&doubleValue atIndex:anInt]; |
| 306 float floatValue; | 322 return [NSString stringWithFormat:@"%f", doubleValue]; |
| 307 | 323 } |
| 308 [self getArgument:&floatValue atIndex:anInt]; | 324 |
| 309 return [NSString stringWithFormat:@"%f", floatValue]; | 325 - (NSString*)floatDescriptionAtIndex:(NSInteger)anInt { |
| 310 } | 326 float floatValue; |
| 311 | 327 |
| 312 - (NSString *)structDescriptionAtIndex:(int)anInt; | 328 [self getArgument:&floatValue atIndex:anInt]; |
| 313 { | 329 return [NSString stringWithFormat:@"%f", floatValue]; |
| 314 void *buffer; | 330 } |
| 315 | 331 |
| 316 [self getArgument:&buffer atIndex:anInt]; | 332 - (NSString*)longDoubleDescriptionAtIndex:(NSInteger)anInt { |
| 317 return [NSString stringWithFormat:@":(struct)%p", buffer]; | 333 long double longDoubleValue; |
| 318 } | 334 |
| 319 | 335 [self getArgument:&longDoubleValue atIndex:anInt]; |
| 320 - (NSString *)pointerDescriptionAtIndex:(int)anInt | 336 return [NSString stringWithFormat:@"%Lf", longDoubleValue]; |
| 321 { | 337 } |
| 322 void *buffer; | 338 |
| 323 | 339 - (NSString*)structDescriptionAtIndex:(NSInteger)anInt { |
| 324 [self getArgument:&buffer atIndex:anInt]; | 340 return [NSString |
| 325 return [NSString stringWithFormat:@"%p", buffer]; | 341 stringWithFormat:@"(%@)", |
| 326 } | 342 [[self getArgumentAtIndexAsObject:anInt] description]]; |
| 327 | 343 } |
| 328 - (NSString *)cStringDescriptionAtIndex:(int)anInt | 344 |
| 329 { | 345 - (NSString*)pointerDescriptionAtIndex:(NSInteger)anInt { |
| 330 char buffer[128]; | 346 void* buffer; |
| 331 | 347 |
| 332 memset(buffer, 0x0, 128); | 348 [self getArgument:&buffer atIndex:anInt]; |
| 333 | 349 return [NSString stringWithFormat:@"%p", buffer]; |
| 334 [self getArgument:&buffer atIndex:anInt]; | 350 } |
| 335 return [NSString stringWithFormat:@"\"%s\"", buffer]; | 351 |
| 336 } | 352 - (NSString*)cStringDescriptionAtIndex:(NSInteger)anInt { |
| 337 | 353 char buffer[104]; |
| 338 - (NSString *)selectorDescriptionAtIndex:(int)anInt | 354 char* cStringPtr; |
| 339 { | 355 |
| 340 SEL selectorValue; | 356 [self getArgument:&cStringPtr atIndex:anInt]; |
| 341 | 357 strlcpy(buffer, cStringPtr, sizeof(buffer)); |
| 342 [self getArgument:&selectorValue atIndex:anInt]; | 358 strlcpy(buffer + 100, "...", (sizeof(buffer) - 100)); |
| 343 return [NSString stringWithFormat:@"@selector(%@)", NSStringFromSelector
(selectorValue)]; | 359 return [NSString stringWithFormat:@"\"%s\"", buffer]; |
| 360 } |
| 361 |
| 362 - (NSString*)selectorDescriptionAtIndex:(NSInteger)anInt { |
| 363 SEL selectorValue; |
| 364 |
| 365 [self getArgument:&selectorValue atIndex:anInt]; |
| 366 return [NSString |
| 367 stringWithFormat:@"@selector(%@)", NSStringFromSelector(selectorValue)]; |
| 344 } | 368 } |
| 345 | 369 |
| 346 @end | 370 @end |
| OLD | NEW |