xref: /trunk/main/autodoc/source/parser/cpp/cxt2ary.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include <precomp.h>
29 #include "cxt2ary.hxx"
30 
31 
32 // NOT FULLY DEFINED SERVICES
33 #include <ary/entity.hxx>
34 #include <ary/cpp/c_class.hxx>
35 #include <ary/cpp/c_define.hxx>
36 #include <ary/cpp/c_enum.hxx>
37 #include <ary/cpp/c_enuval.hxx>
38 #include <ary/cpp/c_funct.hxx>
39 #include <ary/cpp/c_macro.hxx>
40 #include <ary/cpp/c_tydef.hxx>
41 #include <ary/cpp/c_vari.hxx>
42 #include <ary/cpp/c_gate.hxx>
43 #include <ary/cpp/cp_ce.hxx>
44 #include <ary/loc/loc_file.hxx>
45 #include <ary/doc/d_oldcppdocu.hxx>
46 #include <ary/info/docstore.hxx>
47 #include "icprivow.hxx"
48 
49 // Implementationheaders, only to be used in this file!
50 #include "sfscope.hxx"
51 #include "sownstck.hxx"
52 #include "sdocdist.hxx"
53 #include "srecover.hxx"
54 
55 
56 
57 
58 
59 namespace cpp
60 {
61 
62 using ary::cpp::E_Protection;
63 
64 ContextForAry::ContextForAry( ary::cpp::Gate &  io_rAryGate )
65     :   pGate(&io_rAryGate),
66         aTokenResult(),
67         pFileScopeInfo( new S_FileScopeInfo ),
68         pOwnerStack( new S_OwnerStack ),
69         pDocuDistributor( new S_DocuDistributor ),
70         pRecoveryGuard( new S_RecoveryGuard )
71 {
72     OpenNamespace( pGate->Ces().GlobalNamespace() );
73 }
74 
75 ContextForAry::~ContextForAry()
76 {
77 }
78 
79 ary::loc::File &
80 ContextForAry::inq_CurFile() const
81 {
82     csv_assert(pFileScopeInfo->pCurFile != 0);
83 
84     return *pFileScopeInfo->pCurFile;
85 }
86 
87 ary::cpp::Namespace &
88 ContextForAry::inq_CurNamespace() const
89 {
90     return pOwnerStack->CurNamespace();
91 }
92 
93 ary::cpp::Class *
94 ContextForAry::inq_CurClass() const
95 {
96     return pOwnerStack->CurClass();
97 }
98 
99 ary::cpp::Enum *
100 ContextForAry::inq_CurEnum() const
101 {
102     return pOwnerStack->CurEnum();
103 }
104 
105 
106 ary::cpp::InputContext::Owner &
107 ContextForAry::inq_CurOwner() const
108 {
109     return pOwnerStack->CurOwner();
110 }
111 
112 E_Protection
113 ContextForAry::inq_CurProtection() const
114 {
115     return pOwnerStack->CurProtection();
116 }
117 
118 void
119 ContextForAry::do_SetTokenResult( E_TokenDone			i_eDone,
120 							      E_EnvStackAction	    i_eWhat2DoWithEnvStack,
121 							      ParseEnvironment *	i_pParseEnv2Push )
122 {
123     aTokenResult.eDone = i_eDone;
124     aTokenResult.eStackAction = i_eWhat2DoWithEnvStack;
125     aTokenResult.pEnv2Push = i_pParseEnv2Push;
126 }
127 
128 void
129 ContextForAry::do_OpenNamespace( ary::cpp::Namespace & io_rOpenedNamespace )
130 {
131     pOwnerStack->OpenNamespace( io_rOpenedNamespace );
132 }
133 
134 void
135 ContextForAry::do_OpenExternC( bool )
136 {
137 	pOwnerStack->OpenExternC();
138 	// KORR_FUTURE
139 	// use i_bOnlyForOneDeclaration
140 }
141 
142 void
143 ContextForAry::do_OpenClass( ary::cpp::Class & io_rOpenedClass )
144 {
145     pOwnerStack->OpenClass(io_rOpenedClass);
146     pDocuDistributor->SetCurrentlyStoredRe(io_rOpenedClass);
147 }
148 
149 void
150 ContextForAry::do_OpenEnum(	ary::cpp::Enum & io_rOpenedEnum )
151 {
152     pOwnerStack->OpenEnum(io_rOpenedEnum);
153     pDocuDistributor->SetCurrentlyStoredRe(io_rOpenedEnum);
154 }
155 
156 void
157 ContextForAry::do_CloseBlock()
158 {
159     pOwnerStack->CloseBlock();
160 }
161 
162 void
163 ContextForAry::do_CloseClass()
164 {
165     pOwnerStack->CloseClass();
166 }
167 
168 void
169 ContextForAry::do_CloseEnum()
170 {
171     pOwnerStack->CloseEnum();
172 }
173 
174 void
175 ContextForAry::do_SetCurProtection( ary::cpp::E_Protection i_eProtection )
176 {
177     pOwnerStack->SetCurProtection(i_eProtection);
178 }
179 
180 void
181 ContextForAry::do_OpenTemplate( const StringVector & i_rParameters )
182 {
183     pFileScopeInfo->pCurTemplateParameters = new StringVector(i_rParameters);
184 }
185 
186 DYN StringVector *
187 ContextForAry::do_Get_CurTemplateParameters()
188 {
189     return pFileScopeInfo->pCurTemplateParameters.Release();
190 }
191 
192 void
193 ContextForAry::do_Close_OpenTemplate()
194 {
195     if (pFileScopeInfo->pCurTemplateParameters)
196         delete pFileScopeInfo->pCurTemplateParameters.Release();
197 }
198 
199 void
200 ContextForAry::do_Event_Class_FinishedBase( const String & )
201 {
202     // KORR_FUTURE
203 }
204 
205 void
206 ContextForAry::do_Event_Store_Typedef( ary::cpp::Typedef & io_rTypedef )
207 {
208     pDocuDistributor->SetCurrentlyStoredRe(io_rTypedef);
209 }
210 
211 void
212 ContextForAry::do_Event_Store_EnumValue( ary::cpp::EnumValue & io_rEnumValue )
213 {
214     pDocuDistributor->SetCurrentlyStoredRe(io_rEnumValue);
215 }
216 
217 void
218 ContextForAry::do_Event_Store_CppDefinition( ary::cpp::DefineEntity & io_rDefinition )
219 {
220     pDocuDistributor->SetCurrentlyStoredRe(io_rDefinition);
221 }
222 
223 void
224 ContextForAry::do_Event_EnterFunction_ParameterList()
225 {
226     // KORR_FUTURE
227     // Inform pDocuDistributor about possibility of parameters' inline documentation.
228 }
229 
230 void
231 ContextForAry::do_Event_Function_FinishedParameter( const String & )
232 {
233     // KORR_FUTURE
234 }
235 
236 void
237 ContextForAry::do_Event_LeaveFunction_ParameterList()
238 {
239     // KORR_FUTURE
240 }
241 
242 void
243 ContextForAry::do_Event_EnterFunction_Implementation()
244 {
245     // KORR_FUTURE
246 }
247 
248 void
249 ContextForAry::do_Event_LeaveFunction_Implementation()
250 {
251     // KORR_FUTURE
252 }
253 
254 void
255 ContextForAry::do_Event_Store_Function( ary::cpp::Function & io_rFunction )
256 {
257     pDocuDistributor->SetCurrentlyStoredRe(io_rFunction);
258 }
259 
260 
261 void
262 ContextForAry::do_Event_Store_Variable( ary::cpp::Variable & io_rVariable )
263 {
264     pDocuDistributor->SetCurrentlyStoredRe(io_rVariable);
265 }
266 
267 void
268 ContextForAry::do_TakeDocu( DYN ary::doc::OldCppDocu & let_drInfo )
269 {
270     let_drInfo.Store2(*pDocuDistributor);
271 }
272 
273 void
274 ContextForAry::do_StartWaitingFor_Recovery()
275 {
276     pRecoveryGuard->StartWaitingFor_Recovery();
277 }
278 
279 ary::cpp::Gate &
280 ContextForAry::inq_AryGate() const
281 {
282  	return * const_cast< ary::cpp::Gate* >(pGate);
283 }
284 
285 const ary::cpp::InputContext &
286 ContextForAry::inq_Context() const
287 {
288     return *this;
289 }
290 
291 String
292 ContextForAry::inq_CurFileName() const
293 {
294     return pFileScopeInfo->pCurFile != 0
295             ?   pFileScopeInfo->pCurFile->LocalName()
296             :   String::Null_();
297 }
298 
299 uintt
300 ContextForAry::inq_LineCount() const
301 {
302     return pFileScopeInfo->nLineCount;
303 }
304 
305 bool
306 ContextForAry::inq_IsWaitingFor_Recovery() const
307 {
308     return pRecoveryGuard->IsWithinRecovery();
309 }
310 
311 bool
312 ContextForAry::inq_IsExternC() const
313 {
314  	return pOwnerStack->IsExternC();
315 }
316 
317 void
318 ContextForAry::do_SetCurFile( ary::loc::File &  io_rCurFile )
319 {
320     pFileScopeInfo->pCurFile = &io_rCurFile;
321     pFileScopeInfo->nLineCount = 0;
322     pFileScopeInfo->pCurTemplateParameters = 0;
323 
324     pOwnerStack->Reset();
325     pDocuDistributor->Reset();
326     pRecoveryGuard->Reset();
327 }
328 
329 void
330 ContextForAry::do_Event_IncrLineCount()
331 {
332     ++pFileScopeInfo->nLineCount;
333     pDocuDistributor->Event_LineBreak();
334 }
335 
336 void
337 ContextForAry::do_Event_SwBracketOpen()
338 {
339     pRecoveryGuard->Hdl_SwBracketOpen();
340 }
341 
342 void
343 ContextForAry::do_Event_SwBracketClose()
344 {
345     pRecoveryGuard->Hdl_SwBracketClose();
346 }
347 
348 void
349 ContextForAry::do_Event_Semicolon()
350 {
351 	pRecoveryGuard->Hdl_Semicolon();
352 }
353 
354 
355 
356 
357 }   // namespace cpp
358