comment-objc-decls.m revision 60ef8b72664eda5e42910d38148d44de32ee117e
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// 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
33// CHECK: <Declaration>@protocol MyProto\n@end</Declaration>
34// CHECK: <Declaration>- (unsigned int) MethodMyProto:(id)anObject inRange:(unsigned int)range</Declaration>
35// CHECK: <Declaration>@optional\n@property ( readwrite,copy,atomic ) id PropertyMyProto</Declaration>
36// CHECK: <Declaration>+ (id) ClassMethodMyProto</Declaration>
37
38/**
39 * \brief NSObject is the root class.
40*/
41@interface NSObject {
42/**
43 * \brief IvarNSObject
44*/
45  id IvarNSObject;
46}
47@end
48// CHECK: Declaration>@interface NSObject{\n    id IvarNSObject;\n}\n@end</Declaration>
49// 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>
78// CHECK: <Declaration>- (id) MethodMyClass</Declaration>
79// CHECK: <Declaration>+ (id) ClassMethodMyClass</Declaration>
80// CHECK: <Declaration>@property ( readwrite,copy,atomic ) id PropertyMyClass</Declaration
81
82/**
83 * \brief MyClass (Category) is private to MyClass.
84*/
85@interface MyClass (Category)
86/**
87 * \brief This is private to MyClass
88 */
89- (void)MethodMyClassCategory;
90
91/**
92 * \brief PropertyMyClassCategory - This is class's private property.
93*/
94@property (copy) id PropertyMyClassCategory;
95@end
96// CHECK: <Declaration>@interface MyClass(Category)\n@end</Declaration>
97// CHECK: <Declaration>- (void) MethodMyClassCategory</Declaration>
98// CHECK: <Declaration>@property ( readwrite,copy,atomic ) id PropertyMyClassCategory</Declaration>
99// CHECK: <Declaration>- (id) PropertyMyClassCategory</Declaration>
100// CHECK: <Declaration>- (void) setPropertyMyClassCategory:(id)arg</Declaration>
101
102/// @implementation's
103
104/**
105 * \brief implementation of MyClass class.
106*/
107@implementation MyClass {
108/**
109 * \brief IvarPrivateToMyClassImpl.
110*/
111  id IvarPrivateToMyClassImpl;
112}
113/**
114 * \brief MethodMyClass is instance method implementation.
115*/
116- MethodMyClass {
117  return 0;
118}
119
120/**
121 * \brief ClassMethodMyClass is class method implementation.
122*/
123+ ClassMethodMyClass {
124  return 0;
125}
126@end
127// CHECK: <Declaration>@implementation MyClass{\n    id IvarPrivateToMyClassImpl;\n    id _PropertyMyClass;\n}\n@end</Declaration>
128// CHECK: <Declaration>id IvarPrivateToMyClassImpl</Declaration>
129// CHECK: <Declaration>- (id) MethodMyClass</Declaration>
130// CHECK: <Declaration>+ (id) ClassMethodMyClass</Declaration>
131
132/**
133 * \brief MyClass (Category) is implementation of private to MyClass.
134*/
135@implementation MyClass (Category)
136/**
137 * \brief This is private to MyClass
138 */
139- (void)MethodMyClassCategory {}
140/**
141 * \brief property getter
142*/
143- (id) PropertyMyClassCategory { return 0; }
144
145/**
146 * \brief property setter
147*/
148- (void) setPropertyMyClassCategory : (id) arg {}
149@end
150// CHECK: <Declaration>@implementation MyClass(Category)\n@end</Declaration>
151// CHECK: <Declaration>- (void) MethodMyClassCategory</Declaration>
152// CHECK: <Declaration>- (id) PropertyMyClassCategory</Declaration>
153// CHECK: <Declaration>- (void) setPropertyMyClassCategory:(id)arg</Declaration>
154
155/**
156 * \brief NSObject implementation
157*/
158@implementation NSObject
159@end
160// CHECK: <Declaration>@implementation NSObject@end</Declaration>
161