(klass)
| 288 | # Notice that evaluateExpression doesn't work with variable arguments. such as -[NSString stringWithFormat:] |
| 289 | # I remove the "free(methods)" because it would cause evaluateExpressionValue to raise exception some time. |
| 290 | def getMethods(klass): |
| 291 | tmpString = """ |
| 292 | unsigned int outCount; |
| 293 | Method *methods = (Method *)class_copyMethodList((Class)$cls, &outCount); |
| 294 | NSMutableArray *result = (id)[NSMutableArray array]; |
| 295 | |
| 296 | for (int i = 0; i < outCount; i++) { |
| 297 | NSMutableDictionary *m = (id)[NSMutableDictionary dictionary]; |
| 298 | |
| 299 | SEL name = (SEL)method_getName(methods[i]); |
| 300 | [m setObject:(id)NSStringFromSelector(name) forKey:@"name"]; |
| 301 | |
| 302 | char * encoding = (char *)method_getTypeEncoding(methods[i]); |
| 303 | [m setObject:(id)[NSString stringWithUTF8String:encoding] forKey:@"type_encoding"]; |
| 304 | |
| 305 | NSMutableArray *types = (id)[NSMutableArray array]; |
| 306 | NSInteger args = (NSInteger)method_getNumberOfArguments(methods[i]); |
| 307 | for (int idx = 0; idx < args; idx++) { |
| 308 | char *type = (char *)method_copyArgumentType(methods[i], idx); |
| 309 | [types addObject:(id)[NSString stringWithUTF8String:type]]; |
| 310 | } |
| 311 | [m setObject:types forKey:@"parameters_type"]; |
| 312 | |
| 313 | char *ret_type = (char *)method_copyReturnType(methods[i]); |
| 314 | [m setObject:(id)[NSString stringWithUTF8String:ret_type] forKey:@"return_type"]; |
| 315 | |
| 316 | long imp = (long)method_getImplementation(methods[i]); |
| 317 | [m setObject:[NSNumber numberWithLongLong:imp] forKey:@"implementation"]; |
| 318 | |
| 319 | [result addObject:m]; |
| 320 | } |
| 321 | RETURN(result); |
| 322 | """ |
| 323 | command = string.Template(tmpString).substitute(cls=klass) |
| 324 | methods = fb.evaluate(command) |
| 325 | return [Method(m) for m in methods] |
| 326 | |
| 327 | |
| 328 | class Method: |
no test coverage detected