1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cxt2ary.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #include "cxt2ary.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <ary/entity.hxx>
37 #include <ary/cpp/c_class.hxx>
38 #include <ary/cpp/c_define.hxx>
39 #include <ary/cpp/c_enum.hxx>
40 #include <ary/cpp/c_enuval.hxx>
41 #include <ary/cpp/c_funct.hxx>
42 #include <ary/cpp/c_macro.hxx>
43 #include <ary/cpp/c_tydef.hxx>
44 #include <ary/cpp/c_vari.hxx>
45 #include <ary/cpp/c_gate.hxx>
46 #include <ary/cpp/cp_ce.hxx>
47 #include <ary/loc/loc_file.hxx>
48 #include <ary/doc/d_oldcppdocu.hxx>
49 #include <ary/info/docstore.hxx>
50 #include "icprivow.hxx"
52 // Implementationheaders, only to be used in this file!
53 #include "sfscope.hxx"
54 #include "sownstck.hxx"
55 #include "sdocdist.hxx"
56 #include "srecover.hxx"
65 using ary::cpp::E_Protection
;
67 ContextForAry::ContextForAry( ary::cpp::Gate
& io_rAryGate
)
68 : pGate(&io_rAryGate
),
70 pFileScopeInfo( new S_FileScopeInfo
),
71 pOwnerStack( new S_OwnerStack
),
72 pDocuDistributor( new S_DocuDistributor
),
73 pRecoveryGuard( new S_RecoveryGuard
)
75 OpenNamespace( pGate
->Ces().GlobalNamespace() );
78 ContextForAry::~ContextForAry()
83 ContextForAry::inq_CurFile() const
85 csv_assert(pFileScopeInfo
->pCurFile
!= 0);
87 return *pFileScopeInfo
->pCurFile
;
91 ContextForAry::inq_CurNamespace() const
93 return pOwnerStack
->CurNamespace();
97 ContextForAry::inq_CurClass() const
99 return pOwnerStack
->CurClass();
103 ContextForAry::inq_CurEnum() const
105 return pOwnerStack
->CurEnum();
109 ary::cpp::InputContext::Owner
&
110 ContextForAry::inq_CurOwner() const
112 return pOwnerStack
->CurOwner();
116 ContextForAry::inq_CurProtection() const
118 return pOwnerStack
->CurProtection();
122 ContextForAry::do_SetTokenResult( E_TokenDone i_eDone
,
123 E_EnvStackAction i_eWhat2DoWithEnvStack
,
124 ParseEnvironment
* i_pParseEnv2Push
)
126 aTokenResult
.eDone
= i_eDone
;
127 aTokenResult
.eStackAction
= i_eWhat2DoWithEnvStack
;
128 aTokenResult
.pEnv2Push
= i_pParseEnv2Push
;
132 ContextForAry::do_OpenNamespace( ary::cpp::Namespace
& io_rOpenedNamespace
)
134 pOwnerStack
->OpenNamespace( io_rOpenedNamespace
);
138 ContextForAry::do_OpenExternC( bool )
140 pOwnerStack
->OpenExternC();
142 // use i_bOnlyForOneDeclaration
146 ContextForAry::do_OpenClass( ary::cpp::Class
& io_rOpenedClass
)
148 pOwnerStack
->OpenClass(io_rOpenedClass
);
149 pDocuDistributor
->SetCurrentlyStoredRe(io_rOpenedClass
);
153 ContextForAry::do_OpenEnum( ary::cpp::Enum
& io_rOpenedEnum
)
155 pOwnerStack
->OpenEnum(io_rOpenedEnum
);
156 pDocuDistributor
->SetCurrentlyStoredRe(io_rOpenedEnum
);
160 ContextForAry::do_CloseBlock()
162 pOwnerStack
->CloseBlock();
166 ContextForAry::do_CloseClass()
168 pOwnerStack
->CloseClass();
172 ContextForAry::do_CloseEnum()
174 pOwnerStack
->CloseEnum();
178 ContextForAry::do_SetCurProtection( ary::cpp::E_Protection i_eProtection
)
180 pOwnerStack
->SetCurProtection(i_eProtection
);
184 ContextForAry::do_OpenTemplate( const StringVector
& i_rParameters
)
186 pFileScopeInfo
->pCurTemplateParameters
= new StringVector(i_rParameters
);
190 ContextForAry::do_Get_CurTemplateParameters()
192 return pFileScopeInfo
->pCurTemplateParameters
.Release();
196 ContextForAry::do_Close_OpenTemplate()
198 if (pFileScopeInfo
->pCurTemplateParameters
)
199 delete pFileScopeInfo
->pCurTemplateParameters
.Release();
203 ContextForAry::do_Event_Class_FinishedBase( const String
& )
209 ContextForAry::do_Event_Store_Typedef( ary::cpp::Typedef
& io_rTypedef
)
211 pDocuDistributor
->SetCurrentlyStoredRe(io_rTypedef
);
215 ContextForAry::do_Event_Store_EnumValue( ary::cpp::EnumValue
& io_rEnumValue
)
217 pDocuDistributor
->SetCurrentlyStoredRe(io_rEnumValue
);
221 ContextForAry::do_Event_Store_CppDefinition( ary::cpp::DefineEntity
& io_rDefinition
)
223 pDocuDistributor
->SetCurrentlyStoredRe(io_rDefinition
);
227 ContextForAry::do_Event_EnterFunction_ParameterList()
230 // Inform pDocuDistributor about possibility of parameters' inline documentation.
234 ContextForAry::do_Event_Function_FinishedParameter( const String
& )
240 ContextForAry::do_Event_LeaveFunction_ParameterList()
246 ContextForAry::do_Event_EnterFunction_Implementation()
252 ContextForAry::do_Event_LeaveFunction_Implementation()
258 ContextForAry::do_Event_Store_Function( ary::cpp::Function
& io_rFunction
)
260 pDocuDistributor
->SetCurrentlyStoredRe(io_rFunction
);
265 ContextForAry::do_Event_Store_Variable( ary::cpp::Variable
& io_rVariable
)
267 pDocuDistributor
->SetCurrentlyStoredRe(io_rVariable
);
271 ContextForAry::do_TakeDocu( DYN
ary::doc::OldCppDocu
& let_drInfo
)
273 let_drInfo
.Store2(*pDocuDistributor
);
277 ContextForAry::do_StartWaitingFor_Recovery()
279 pRecoveryGuard
->StartWaitingFor_Recovery();
283 ContextForAry::inq_AryGate() const
285 return * const_cast< ary::cpp::Gate
* >(pGate
);
288 const ary::cpp::InputContext
&
289 ContextForAry::inq_Context() const
295 ContextForAry::inq_CurFileName() const
297 return pFileScopeInfo
->pCurFile
!= 0
298 ? pFileScopeInfo
->pCurFile
->LocalName()
303 ContextForAry::inq_LineCount() const
305 return pFileScopeInfo
->nLineCount
;
309 ContextForAry::inq_IsWaitingFor_Recovery() const
311 return pRecoveryGuard
->IsWithinRecovery();
315 ContextForAry::inq_IsExternC() const
317 return pOwnerStack
->IsExternC();
321 ContextForAry::do_SetCurFile( ary::loc::File
& io_rCurFile
)
323 pFileScopeInfo
->pCurFile
= &io_rCurFile
;
324 pFileScopeInfo
->nLineCount
= 0;
325 pFileScopeInfo
->pCurTemplateParameters
= 0;
327 pOwnerStack
->Reset();
328 pDocuDistributor
->Reset();
329 pRecoveryGuard
->Reset();
333 ContextForAry::do_Event_IncrLineCount()
335 ++pFileScopeInfo
->nLineCount
;
336 pDocuDistributor
->Event_LineBreak();
340 ContextForAry::do_Event_SwBracketOpen()
342 pRecoveryGuard
->Hdl_SwBracketOpen();
346 ContextForAry::do_Event_SwBracketClose()
348 pRecoveryGuard
->Hdl_SwBracketClose();
352 ContextForAry::do_Event_Semicolon()
354 pRecoveryGuard
->Hdl_Semicolon();