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