OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/showcase/common/protocol_alerter.h" | 5 #import "ios/showcase/common/protocol_alerter.h" |
6 | 6 |
7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
8 | 8 |
9 #import "base/logging.h" | 9 #import "base/logging.h" |
10 #import "base/strings/sys_string_conversions.h" | 10 #import "base/strings/sys_string_conversions.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 151 } |
152 | 152 |
153 // Return a string describing the argument value at |index|. | 153 // Return a string describing the argument value at |index|. |
154 // (|index| is in NSInvocation's argument array). | 154 // (|index| is in NSInvocation's argument array). |
155 - (NSString*)argumentDescriptionAtIndex:(NSInteger)index { | 155 - (NSString*)argumentDescriptionAtIndex:(NSInteger)index { |
156 const char* type = [self.methodSignature getArgumentTypeAtIndex:index]; | 156 const char* type = [self.methodSignature getArgumentTypeAtIndex:index]; |
157 | 157 |
158 switch (*type) { | 158 switch (*type) { |
159 case '@': | 159 case '@': |
160 return [self objectDescriptionAtIndex:index]; | 160 return [self objectDescriptionAtIndex:index]; |
| 161 case 'q': |
| 162 return [self longLongDescriptionAtIndex:index]; |
161 // Add cases as needed here. | 163 // Add cases as needed here. |
162 default: | 164 default: |
163 return [NSString stringWithFormat:@"<Unknown Type:%c>", *type]; | 165 return [NSString stringWithFormat:@"<Unknown Type:%c>", *type]; |
164 } | 166 } |
165 } | 167 } |
166 | 168 |
167 // Return a string describing an argument at |index| that's known to an | 169 // Return a string describing an argument at |index| that's known to be an |
168 // objective-C object. | 170 // objective-C object. |
169 - (NSString*)objectDescriptionAtIndex:(NSInteger)index { | 171 - (NSString*)objectDescriptionAtIndex:(NSInteger)index { |
170 id object; | 172 id object; |
171 | 173 |
172 [self getArgument:&object atIndex:index]; | 174 [self getArgument:&object atIndex:index]; |
173 if (!object) | 175 if (!object) |
174 return @"nil"; | 176 return @"nil"; |
175 | 177 |
176 NSString* description = [object description]; | 178 NSString* description = [object description]; |
177 NSString* className = NSStringFromClass([object class]); | 179 NSString* className = NSStringFromClass([object class]); |
(...skipping 13 matching lines...) Expand all Loading... |
191 NSRange range = NSMakeRange(0, description.length); | 193 NSRange range = NSMakeRange(0, description.length); |
192 NSString* classPlusAddress = | 194 NSString* classPlusAddress = |
193 [className stringByAppendingString:@": 0x[0-9a-c]+"]; | 195 [className stringByAppendingString:@": 0x[0-9a-c]+"]; |
194 return [description | 196 return [description |
195 stringByReplacingOccurrencesOfString:classPlusAddress | 197 stringByReplacingOccurrencesOfString:classPlusAddress |
196 withString:className | 198 withString:className |
197 options:NSRegularExpressionSearch | 199 options:NSRegularExpressionSearch |
198 range:range]; | 200 range:range]; |
199 } | 201 } |
200 | 202 |
| 203 // Returns a string describing an argument at |index| that is known to be a long |
| 204 // long. |
| 205 - (NSString*)longLongDescriptionAtIndex:(NSInteger)index { |
| 206 long long value; |
| 207 |
| 208 [self getArgument:&value atIndex:index]; |
| 209 return [NSString stringWithFormat:@"%lld", value]; |
| 210 } |
| 211 |
201 @end | 212 @end |
OLD | NEW |