Debian Codegraph @

clang/test/Index/comment-objc-decls.m

raw
1 // RUN: rm -rf %t
2 // RUN: mkdir %t
3 // RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target x86_64-apple-darwin10 %s > %t/out
4 // RUN: FileCheck %s < %t/out
5
6 // Ensure that XML we generate is not invalid.
7 // RUN: FileCheck %s -check-prefix=WRONG < %t/out
8 // WRONG-NOT: CommentXMLInvalid
9
10 /**
11 * \brief This is a protocol definition
12 */
13 @protocol MyProto
14 @optional
15 /**
16 * \brief MethodMyProto method
17 * \param[in] anObject input value
18 * \param[in] range output value is unsigned int
19 * \result return index
20 */
21 - (unsigned int)MethodMyProto:(nullable id)anObject inRange:(unsigned int)range;
22 /**
23 * \brief PropertyMyProto - This is protocol's property.
24 */
25 @property (copy, nonnull) id PropertyMyProto;
26 /**
27 * \brief ClassMethodMyProto
28 */
29 + ClassMethodMyProto;
30 @end
31 // CHECK: <Declaration>@protocol MyProto\n@end</Declaration>
32 // CHECK: <Declaration>- (unsigned int)MethodMyProto:(nullable id)anObject inRange:(unsigned int)range;</Declaration>
33 // CHECK: <Declaration>@optional\n@property(atomic, copy, readwrite, nonnull) id PropertyMyProto;</Declaration>
34 // CHECK: <Declaration>+ (id)ClassMethodMyProto;</Declaration>
35
36 /**
37 * \brief NSObject is the root class.
38 */
39 @interface NSObject {
40 /**
41 * \brief IvarNSObject
42 */
43 id IvarNSObject;
44 }
45 @end
46 // CHECK: Declaration>@interface NSObject {\n id IvarNSObject;\n}\n@end</Declaration>
47 // CHECK: <Declaration>id IvarNSObject</Declaration>
48
49 /**
50 * \brief MyClass - primary class.
51 */
52 @interface MyClass : NSObject<MyProto>
53 {
54 /**
55 * \brief IvarMyClass - IvarMyClass of values.
56 */
57 id IvarMyClass;
58 }
59 /**
60 * \brief MethodMyClass is instance method.
61 */
62 - MethodMyClass;
63
64 /**
65 * \brief ClassMethodMyClass is class method.
66 */
67 + ClassMethodMyClass;
68
69 /**
70 * \brief PropertyMyClass - This is class's property.
71 */
72 @property (copy) id PropertyMyClass;
73 @end
74 // CHECK: <Declaration>@interface MyClass : NSObject &lt;MyProto&gt; {\n id IvarMyClass;\n}\n@end</Declaration>
75 // CHECK: <Declaration>id IvarMyClass</Declaration>
76 // CHECK: <Declaration>- (id)MethodMyClass;</Declaration>
77 // CHECK: <Declaration>+ (id)ClassMethodMyClass;</Declaration>
78 // CHECK: <Declaration>@property(atomic, copy, readwrite) id PropertyMyClass;</Declaration
79
80 /**
81 * \brief - This is class extension of MyClass
82 */
83 @interface MyClass()
84 {
85 /**
86 * \brief IvarMyClassExtension - IvarMyClassExtension private to class extension
87 */
88 id IvarMyClassExtension;
89 }
90 @end
91 // CHECK: <Declaration>@interface MyClass () {\n id IvarMyClassExtension;\n}\n@end</Declaration>
92 // CHECK: <Declaration>id IvarMyClassExtension</Declaration>
93
94
95 /**
96 * \brief MyClass (Category) is private to MyClass.
97 */
98 @interface MyClass (Category)
99 /**
100 * \brief This is private to MyClass
101 */
102 - (void)MethodMyClassCategory;
103
104 /**
105 * \brief PropertyMyClassCategory - This is class's private property.
106 */
107 @property (copy) id PropertyMyClassCategory;
108 @end
109 // CHECK: <Declaration>@interface MyClass (Category)\n@end</Declaration>
110 // CHECK: <Declaration>- (void)MethodMyClassCategory;</Declaration>
111 // CHECK: <Declaration>@property(atomic, copy, readwrite) id PropertyMyClassCategory;</Declaration>
112 // CHECK: <Declaration>- (id)PropertyMyClassCategory;</Declaration>
113 // CHECK: <Declaration>- (void)setPropertyMyClassCategory:(id)arg;</Declaration>
114
115 /// @implementation's
116
117 /**
118 * \brief implementation of MyClass class.
119 */
120 @implementation MyClass {
121 /**
122 * \brief IvarPrivateToMyClassImpl.
123 */
124 id IvarPrivateToMyClassImpl;
125 }
126 /**
127 * \brief MethodMyClass is instance method implementation.
128 */
129 - MethodMyClass {
130 return 0;
131 }
132
133 /**
134 * \brief ClassMethodMyClass is class method implementation.
135 */
136 + ClassMethodMyClass {
137 return 0;
138 }
139 @end
140 // CHECK: <Declaration>@implementation MyClass {\n id IvarPrivateToMyClassImpl;\n id _PropertyMyClass;\n}\n@end</Declaration>
141 // CHECK: <Declaration>id IvarPrivateToMyClassImpl</Declaration>
142 // CHECK: <Declaration>- (id)MethodMyClass;</Declaration>
143 // CHECK: <Declaration>+ (id)ClassMethodMyClass;</Declaration>
144
145 /**
146 * \brief MyClass (Category) is implementation of private to MyClass.
147 */
148 @implementation MyClass (Category)
149 /**
150 * \brief This is private to MyClass
151 */
152 - (void)MethodMyClassCategory {}
153 /**
154 * \brief property getter
155 */
156 - (id) PropertyMyClassCategory { return 0; }
157
158 /**
159 * \brief property setter
160 */
161 - (void) setPropertyMyClassCategory : (id) arg {}
162 @end
163 // CHECK: <Declaration>@implementation MyClass (Category)\n@end</Declaration>
164 // CHECK: <Declaration>- (void)MethodMyClassCategory;</Declaration>
165 // CHECK: <Declaration>- (id)PropertyMyClassCategory;</Declaration>
166 // CHECK: <Declaration>- (void)setPropertyMyClassCategory:(id)arg;</Declaration>
167
168 /**
169 * \brief NSObject implementation
170 */
171 @implementation NSObject
172 @end
173 // CHECK: <Declaration>@implementation NSObject\n@end</Declaration>