| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // Return a string describing the argument value at |index|. | 154 // Return a string describing the argument value at |index|. |
| 155 // (|index| is in NSInvocation's argument array). | 155 // (|index| is in NSInvocation's argument array). |
| 156 - (NSString*)argumentDescriptionAtIndex:(NSInteger)index { | 156 - (NSString*)argumentDescriptionAtIndex:(NSInteger)index { |
| 157 const char* type = [self.methodSignature getArgumentTypeAtIndex:index]; | 157 const char* type = [self.methodSignature getArgumentTypeAtIndex:index]; |
| 158 | 158 |
| 159 switch (*type) { | 159 switch (*type) { |
| 160 case '@': | 160 case '@': |
| 161 return [self objectDescriptionAtIndex:index]; | 161 return [self objectDescriptionAtIndex:index]; |
| 162 case 'q': | 162 case 'q': |
| 163 return [self longLongDescriptionAtIndex:index]; | 163 return [self longLongDescriptionAtIndex:index]; |
| 164 case 'Q': |
| 165 return [self unsignedLongLongDescriptionAtIndex:index]; |
| 164 // Add cases as needed here. | 166 // Add cases as needed here. |
| 165 default: | 167 default: |
| 166 return [NSString stringWithFormat:@"<Unknown Type:%s>", type]; | 168 return [NSString stringWithFormat:@"<Unknown Type:%s>", type]; |
| 167 } | 169 } |
| 168 } | 170 } |
| 169 | 171 |
| 170 // Return a string describing an argument at |index| that's known to be an | 172 // Return a string describing an argument at |index| that's known to be an |
| 171 // objective-C object. | 173 // objective-C object. |
| 172 - (NSString*)objectDescriptionAtIndex:(NSInteger)index { | 174 - (NSString*)objectDescriptionAtIndex:(NSInteger)index { |
| 173 __unsafe_unretained id object; | 175 __unsafe_unretained id object; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 203 | 205 |
| 204 // Returns a string describing an argument at |index| that is known to be a long | 206 // Returns a string describing an argument at |index| that is known to be a long |
| 205 // long. | 207 // long. |
| 206 - (NSString*)longLongDescriptionAtIndex:(NSInteger)index { | 208 - (NSString*)longLongDescriptionAtIndex:(NSInteger)index { |
| 207 long long value; | 209 long long value; |
| 208 | 210 |
| 209 [self getArgument:&value atIndex:index]; | 211 [self getArgument:&value atIndex:index]; |
| 210 return [NSString stringWithFormat:@"%lld", value]; | 212 return [NSString stringWithFormat:@"%lld", value]; |
| 211 } | 213 } |
| 212 | 214 |
| 215 // Returns a string describing an argument at |index| that is known to be an |
| 216 // unsigned long long. |
| 217 - (NSString*)unsignedLongLongDescriptionAtIndex:(NSInteger)index { |
| 218 unsigned long long value; |
| 219 |
| 220 [self getArgument:&value atIndex:index]; |
| 221 return [NSString stringWithFormat:@"%llu", value]; |
| 222 } |
| 223 |
| 213 @end | 224 @end |
| OLD | NEW |