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 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; |
(...skipping 20 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 know to be a long | |
lpromero
2017/01/18 13:14:02
s/know/known
gambard
2017/01/18 14:19:09
Done.
| |
204 // long. | |
205 - (NSString*)longLongDescriptionAtIndex:(NSInteger)index { | |
206 long long longLong; | |
lpromero
2017/01/18 13:14:02
s/longLong/value.
gambard
2017/01/18 14:19:09
Done.
| |
207 | |
208 [self getArgument:&longLong atIndex:index]; | |
209 return [NSString stringWithFormat:@"%lld", longLong]; | |
210 } | |
211 | |
201 @end | 212 @end |
OLD | NEW |