blob: 0e3c0721211b1edc46d90aa8f2aefe286629717e [file] [log] [blame]
Fariborz Jahanian482b4fd2012-12-04 00:47:33 +00001// RUN: rm -rf %t
2// RUN: mkdir %t
NAKAMURA Takumi60ef8b72012-12-04 01:03:31 +00003// 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
Fariborz Jahanian482b4fd2012-12-04 00:47:33 +00004// 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// rdar://12378714
11
12/**
13 * \brief This is a protocol definition
14*/
15@protocol MyProto
16@optional
17/**
18 * \brief MethodMyProto method
19 * \param[in] anObject input value
20 * \param[in] range output value is unsigned int
21 * \result return index
22 */
23- (unsigned int)MethodMyProto:(id)anObject inRange:(unsigned int)range;
24/**
25 * \brief PropertyMyProto - This is protocol's property.
26*/
27@property (copy) id PropertyMyProto;
28/**
29 * \brief ClassMethodMyProto
30*/
31+ ClassMethodMyProto;
32@end
Nico Weber1abe6ea2013-01-09 21:15:03 +000033// CHECK: <Declaration>@protocol MyProto\n@end</Declaration>
Fariborz Jahanian154120c2012-12-20 19:54:13 +000034// CHECK: <Declaration>- (unsigned int)MethodMyProto:(id)anObject inRange:(unsigned int)range;</Declaration>
Nico Weberb530fa32013-01-10 00:25:19 +000035// CHECK: <Declaration>@optional\n@property(readwrite, copy, atomic) id PropertyMyProto;</Declaration>
Fariborz Jahanian154120c2012-12-20 19:54:13 +000036// CHECK: <Declaration>+ (id)ClassMethodMyProto;</Declaration>
Fariborz Jahanian482b4fd2012-12-04 00:47:33 +000037
38/**
39 * \brief NSObject is the root class.
40*/
41@interface NSObject {
42/**
43 * \brief IvarNSObject
44*/
45 id IvarNSObject;
46}
47@end
Fariborz Jahanian154120c2012-12-20 19:54:13 +000048// CHECK: Declaration>@interface NSObject {\n id IvarNSObject;\n}\n@end</Declaration>
Fariborz Jahanian482b4fd2012-12-04 00:47:33 +000049// CHECK: <Declaration>id IvarNSObject</Declaration>
50
51/**
52 * \brief MyClass - primary class.
53*/
54@interface MyClass : NSObject<MyProto>
55{
56/**
57 * \brief IvarMyClass - IvarMyClass of values.
58*/
59 id IvarMyClass;
60}
61/**
62 * \brief MethodMyClass is instance method.
63*/
64- MethodMyClass;
65
66/**
67 * \brief ClassMethodMyClass is class method.
68*/
69+ ClassMethodMyClass;
70
71/**
72 * \brief PropertyMyClass - This is class's property.
73*/
74@property (copy) id PropertyMyClass;
75@end
76// CHECK: <Declaration>@interface MyClass : NSObject&lt;MyProto&gt; {\n id IvarMyClass;\n}\n@end</Declaration>
77// CHECK: <Declaration>id IvarMyClass</Declaration>
Fariborz Jahanian154120c2012-12-20 19:54:13 +000078// CHECK: <Declaration>- (id)MethodMyClass;</Declaration>
79// CHECK: <Declaration>+ (id)ClassMethodMyClass;</Declaration>
80// CHECK: <Declaration>@property(readwrite, copy, atomic) id PropertyMyClass;</Declaration
Fariborz Jahanian482b4fd2012-12-04 00:47:33 +000081
82/**
Fariborz Jahanianc2ef5ad2012-12-04 18:25:34 +000083 * \brief - This is class extension of MyClass
84*/
85@interface MyClass()
86{
87/**
88 * \brief IvarMyClassExtension - IvarMyClassExtension private to class extension
89*/
90 id IvarMyClassExtension;
91}
92@end
Fariborz Jahanian154120c2012-12-20 19:54:13 +000093// CHECK: <Declaration>@interface MyClass() {\n id IvarMyClassExtension;\n}\n@end</Declaration>
Fariborz Jahanianc2ef5ad2012-12-04 18:25:34 +000094// CHECK: <Declaration>id IvarMyClassExtension</Declaration>
95
96
97/**
Fariborz Jahanian482b4fd2012-12-04 00:47:33 +000098 * \brief MyClass (Category) is private to MyClass.
99*/
100@interface MyClass (Category)
101/**
102 * \brief This is private to MyClass
103 */
104- (void)MethodMyClassCategory;
105
106/**
107 * \brief PropertyMyClassCategory - This is class's private property.
108*/
109@property (copy) id PropertyMyClassCategory;
110@end
Nico Weberfa49c182013-01-09 20:36:10 +0000111// CHECK: <Declaration>@interface MyClass(Category)\n@end</Declaration>
Fariborz Jahanian154120c2012-12-20 19:54:13 +0000112// CHECK: <Declaration>- (void)MethodMyClassCategory;</Declaration>
113// CHECK: <Declaration>@property(readwrite, copy, atomic) id PropertyMyClassCategory;</Declaration>
114// CHECK: <Declaration>- (id)PropertyMyClassCategory;</Declaration>
115// CHECK: <Declaration>- (void)setPropertyMyClassCategory:(id)arg;</Declaration>
Fariborz Jahanian482b4fd2012-12-04 00:47:33 +0000116
117/// @implementation's
118
119/**
120 * \brief implementation of MyClass class.
121*/
122@implementation MyClass {
123/**
124 * \brief IvarPrivateToMyClassImpl.
125*/
126 id IvarPrivateToMyClassImpl;
127}
128/**
129 * \brief MethodMyClass is instance method implementation.
130*/
131- MethodMyClass {
132 return 0;
133}
134
135/**
136 * \brief ClassMethodMyClass is class method implementation.
137*/
138+ ClassMethodMyClass {
139 return 0;
140}
141@end
Fariborz Jahanian154120c2012-12-20 19:54:13 +0000142// CHECK: <Declaration>@implementation MyClass {\n id IvarPrivateToMyClassImpl;\n id _PropertyMyClass;\n}\n@end</Declaration>
Fariborz Jahanian482b4fd2012-12-04 00:47:33 +0000143// CHECK: <Declaration>id IvarPrivateToMyClassImpl</Declaration>
Fariborz Jahanian154120c2012-12-20 19:54:13 +0000144// CHECK: <Declaration>- (id)MethodMyClass;</Declaration>
145// CHECK: <Declaration>+ (id)ClassMethodMyClass;</Declaration>
Fariborz Jahanian482b4fd2012-12-04 00:47:33 +0000146
147/**
148 * \brief MyClass (Category) is implementation of private to MyClass.
149*/
150@implementation MyClass (Category)
151/**
152 * \brief This is private to MyClass
153 */
154- (void)MethodMyClassCategory {}
155/**
156 * \brief property getter
157*/
158- (id) PropertyMyClassCategory { return 0; }
159
160/**
161 * \brief property setter
162*/
163- (void) setPropertyMyClassCategory : (id) arg {}
164@end
Nico Weber50767d82013-01-09 23:25:37 +0000165// CHECK: <Declaration>@implementation MyClass(Category)\n@end</Declaration>
Fariborz Jahanian154120c2012-12-20 19:54:13 +0000166// CHECK: <Declaration>- (void)MethodMyClassCategory;</Declaration>
167// CHECK: <Declaration>- (id)PropertyMyClassCategory;</Declaration>
168// CHECK: <Declaration>- (void)setPropertyMyClassCategory:(id)arg;</Declaration>
Fariborz Jahanian482b4fd2012-12-04 00:47:33 +0000169
170/**
171 * \brief NSObject implementation
172*/
173@implementation NSObject
174@end
Nico Weber50767d82013-01-09 23:25:37 +0000175// CHECK: <Declaration>@implementation NSObject\n@end</Declaration>