1#include <stdio.h> 2#include <objc/Object.h> 3 4@interface BasicClass: Object 5{ 6 id object; 7} 8+ newWithArg: arg; 9- doIt; 10- takeArg: arg; 11- printHi; 12- (int) printNumber: (int)number; 13- (const char *) myDescription; 14@end 15 16@interface BasicClass (Private) 17- hiddenMethod; 18@end 19 20@implementation BasicClass 21+ newWithArg: arg 22{ 23 id obj = [self new]; 24 [obj takeArg: arg]; 25 return obj; 26} 27 28- doIt 29{ 30 return self; 31} 32 33- takeArg: arg 34{ 35 object = arg; 36 [self hiddenMethod]; 37 return self; 38} 39 40- printHi 41{ 42 printf("Hi\n"); 43 return self; 44} 45 46- (int) printNumber: (int)number 47{ 48 printf("%d\n", number); 49 return number+1; 50} 51 52- (const char *) myDescription 53{ 54 return "BasicClass gdb test object"; 55} 56 57@end 58 59@implementation BasicClass (Private) 60- hiddenMethod 61{ 62 return self; 63} 64@end 65 66int main (int argc, const char *argv[]) 67{ 68 id obj; 69 obj = [BasicClass new]; 70 [obj takeArg: obj]; 71 return 0; 72} 73 74const char *_NSPrintForDebugger(id object) 75{ 76 /* This is not really what _NSPrintForDebugger should do, but it 77 is a simple test if gdb can call this function */ 78 if (object && [object respondsTo: @selector(myDescription)]) 79 return [object myDescription]; 80 81 return NULL; 82} 83