Add arch tagline
[bpt/emacs.git] / test / cedet / tests / testsubclass.cpp
1 /* Special test file for Semantic Analyzer and complex C++ inheritance.
2 */
3
4 //#include <iostream>
5 #include "testsubclass.hh"
6
7 void animal::moose::setFeet(int numfeet) //^1^
8 {
9 if (numfeet > 4) {
10 std::cerr << "Why would a moose have more than 4 feet?" << std::endl;
11 return;
12 }
13
14 fFeet = numfeet;
15 }
16
17 int animal::moose::getFeet() //^2^
18 {
19 return fFeet;
20 }
21
22 void animal::moose::doNothing() //^3^
23 {
24 animal::moose foo();
25
26 fFeet = N// -15-
27 ; // #15# ( "NAME1" "NAME2" "NAME3" )
28 }
29
30
31 void deer::moose::setAntlers(bool have_antlers) //^4^
32 {
33 fAntlers = have_antlers;
34 }
35
36 bool deer::moose::getAntlers() //^5^
37 // %1% ( ( "testsubclass.cpp" "testsubclass.hh" ) ( "deer::moose::doSomething" "deer::moose::getAntlers" "moose" ) )
38 {
39 return fAntlers;
40 }
41
42 bool i_dont_have_symrefs()
43 // %2% ( ("testsubclass.cpp" ) ("i_dont_have_symrefs"))
44 {
45 }
46
47 void deer::moose::doSomething() //^6^
48 {
49 // All these functions should be identified by semantic analyzer.
50 getAntlers();
51 setAntlers(true);
52
53 getFeet();
54 setFeet(true);
55
56 doNothing();
57
58 fSomeField = true;
59
60 fIsValid = true;
61 }
62
63 void deer::alces::setLatin(bool l) {
64 fLatin = l;
65 }
66
67 bool deer::alces::getLatin() {
68 return fLatin;
69 }
70
71 void deer::alces::doLatinStuff(moose moosein) {
72 // All these functions should be identified by semantic analyzer.
73 getFeet();
74 setFeet(true);
75
76 getLatin();
77 setLatin(true);
78
79 doNothing();
80
81 deer::moose foo();
82
83
84 }
85
86 moose deer::alces::createMoose()
87 {
88 moose MooseVariableName;
89 bool tmp;
90 int itmp;
91 bool fool;
92 int fast;
93
94 MooseVariableName = createMoose();
95
96 doLatinStuff(MooseVariableName);
97
98 tmp = this.f// -1-
99 // #1# ( "fAlcesBool" "fIsValid" "fLatin" )
100 ;
101
102 itmp = this.f// -2-
103 // #2# ( "fAlcesInt" "fGreek" "fIsProtectedInt" )
104 ;
105
106 tmp = f// -3-
107 // #3# ( "fAlcesBool" "fIsValid" "fLatin" "fool" )
108 ;
109
110 itmp = f// -4-
111 // #4# ( "fAlcesInt" "fGreek" "fIsProtectedInt" "fast" )
112 ;
113
114 MooseVariableName = m// -5-
115 // #5# ( "moose" )
116
117 return MooseVariableName;
118 }
119
120 /** Test Scope Changes
121 *
122 * This function is rigged to make sure the scope changes to account
123 * for different locations in local variable parsing.
124 */
125 int someFunction(int mPickle)
126 {
127 moose mMoose = deer::alces::createMoose();
128
129 if (mPickle == 1) {
130
131 int mOption1 = 2;
132
133 m// -5-
134 // #5# ( "mMoose" "mOption1" "mPickle" )
135 ;
136
137 } else {
138
139 int mOption2 = 2;
140
141 m// -6-
142 // #6# ( "mMoose" "mOption2" "mPickle" )
143 ;
144 }
145
146 }
147
148 // Thanks Ming-Wei Chang for this next example.
149
150 namespace pub_priv {
151
152 class A{
153 private:
154 void private_a(){}
155 public:
156 void public_a();
157 };
158
159 void A::public_a() {
160 A other_a;
161
162 other_a.p// -7-
163 // #7# ( "private_a" "public_a" )
164 ;
165 }
166
167 int some_regular_function(){
168 A a;
169 a.p// -8-
170 // #8# ( "public_a" )
171 ;
172 return 0;
173 }
174
175 }
176
177
178 /** Test Scope w/in a function (non-method) with classes using
179 * different levels of inheritance.
180 */
181 int otherFunction()
182 {
183 sneaky::antelope Antelope(1);
184 sneaky::jackalope Jackalope(1);
185 sneaky::bugalope Bugalope(1);
186
187 Antelope.// -9-
188 // #9# ( "fAntyPublic" "fQuadPublic" "testAccess")
189 ;
190
191 Jackalope.// -10-
192 // #10# ( "fBunnyPublic" "testAccess")
193 ;
194
195 Jackalope// @1@ 6
196 ;
197 Jackalope;
198 Jackalope;
199 Jackalope;
200
201 Bugalope.// -11-
202 // #11# ( "fBugPublic" "testAccess")
203 ;
204 Bugalope// @2@ 3
205 ;
206 }
207
208 /** Test methods within each class for types of access to the baseclass.
209 */
210
211 bool sneaky::antelope::testAccess() //^7^
212 {
213 this.// -12-
214 // #12# ( "fAntyPrivate" "fAntyProtected" "fAntyPublic" "fQuadProtected" "fQuadPublic" "testAccess" )
215 ;
216 }
217
218 bool sneaky::jackalope::testAccess() //^8^
219 {
220 this.// -13-
221 // #13# ( "fBunnyPrivate" "fBunnyProtected" "fBunnyPublic" "fQuadProtected" "fQuadPublic" "testAccess" )
222 ;
223 }
224
225 bool sneaky::bugalope::testAccess() //^9^
226 {
227 this.// -14-
228 // #14# ( "fBugPrivate" "fBugProtected" "fBugPublic" "fQuadPublic" "testAccess" )
229 ;
230 }
231
232 // arch-tag: 20a08c42-9ba6-4c8d-966a-893b37c841ef