1#import <Foundation/Foundation.h>
2
3@protocol MyProtocol
4
5-(const char *)hello;
6
7@end
8
9static int _class_int = 123;
10
11@interface BaseClass : NSObject
12{
13 int _backedInt;
14 int _access_count;
15}
16
17- (int) nonexistantInt;
18- (void) setNonexistantInt: (int) in_int;
19
20- (int) myGetUnbackedInt;
21- (void) mySetUnbackedInt: (int) in_int;
22
23- (int) getAccessCount;
24
25+ (int) propConflict;
26
27+(BaseClass *) baseClassWithBackedInt: (int) inInt andUnbackedInt: (int) inOtherInt;
28
29@property(getter=myGetUnbackedInt,setter=mySetUnbackedInt:) int unbackedInt;
30@property int backedInt;
31@property (nonatomic, assign) id <MyProtocol> idWithProtocol;
32@property(class) int classInt;
33@property(getter=propConflict,readonly) int propConflict;
34@property(readonly,class) int propConflict;
35@end
36
37@implementation BaseClass
38@synthesize unbackedInt;
39@synthesize backedInt = _backedInt;
40
41+ (BaseClass *) baseClassWithBackedInt: (int) inInt andUnbackedInt: (int) inOtherInt
42{
43 BaseClass *new = [[BaseClass alloc] init];
44
45 new->_backedInt = inInt;
46 new->unbackedInt = inOtherInt;
47
48 return new;
49}
50
51- (int) myGetUnbackedInt
52{
53 // NSLog (@"Getting BaseClass::unbackedInt - %d.\n", unbackedInt);
54 _access_count++;
55 return unbackedInt;
56}
57
58- (void) mySetUnbackedInt: (int) in_int
59{
60 // NSLog (@"Setting BaseClass::unbackedInt from %d to %d.", unbackedInt, in_int);
61 _access_count++;
62 unbackedInt = in_int;
63}
64
65- (int) nonexistantInt
66{
67 // NSLog (@"Getting BaseClass::nonexistantInt - %d.\n", 5);
68 _access_count++;
69 return 6;
70}
71
72- (void) setNonexistantInt: (int) in_int
73{
74 // NSLog (@"Setting BaseClass::nonexistantInt from 7 to %d.", in_int);
75 _access_count++;
76}
77
78+ (int) classInt
79{
80 return _class_int;
81}
82
83+ (void) setClassInt:(int) n
84{
85 _class_int = n;
86}
87
88- (int) getAccessCount
89{
90 return _access_count;
91}
92
93- (int) propConflict
94{
95 return 4;
96}
97+ (int) propConflict
98{
99 return 6;
100}
101@end
102
103typedef BaseClass TypedefBaseClass;
104
105int
106main ()
107{
108 BaseClass *mine = [BaseClass baseClassWithBackedInt: 10 andUnbackedInt: 20];
109 TypedefBaseClass *typedefd = mine;
110 int propConflict = mine.propConflict + BaseClass.propConflict;
111
112 // Set a breakpoint here.
113 int nonexistant = mine.nonexistantInt;
114
115 int backedInt = mine.backedInt;
116
117 int unbackedInt = mine.unbackedInt;
118
119 id idWithProtocol = mine.idWithProtocol;
120
121 NSLog (@"Results for %p: nonexistant: %d backed: %d unbacked: %d accessCount: %d.",
122 mine,
123 nonexistant,
124 backedInt,
125 unbackedInt,
126 [mine getAccessCount]);
127 return 0;
128
129}
130
131

source code of lldb/test/API/lang/objc/objc-property/main.m