OSDN Git Service

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