1*78bc99aaSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*78bc99aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*78bc99aaSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*78bc99aaSAndrew Rist * distributed with this work for additional information 6*78bc99aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*78bc99aaSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*78bc99aaSAndrew Rist * "License"); you may not use this file except in compliance 9*78bc99aaSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*78bc99aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*78bc99aaSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*78bc99aaSAndrew Rist * software distributed under the License is distributed on an 15*78bc99aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*78bc99aaSAndrew Rist * KIND, either express or implied. See the License for the 17*78bc99aaSAndrew Rist * specific language governing permissions and limitations 18*78bc99aaSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*78bc99aaSAndrew Rist *************************************************************/ 21cdf0e10cSrcweir 22cdf0e10cSrcweir #include <precomp.h> 23cdf0e10cSrcweir #include <s2_luidl/pe_struc.hxx> 24cdf0e10cSrcweir 25cdf0e10cSrcweir 26cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES 27cdf0e10cSrcweir #include <ary/idl/i_gate.hxx> 28cdf0e10cSrcweir #include <ary/idl/i_struct.hxx> 29cdf0e10cSrcweir #include <ary/idl/ip_ce.hxx> 30cdf0e10cSrcweir #include <ary/doc/d_oldidldocu.hxx> 31cdf0e10cSrcweir #include <s2_luidl/tk_ident.hxx> 32cdf0e10cSrcweir #include <s2_luidl/tk_punct.hxx> 33cdf0e10cSrcweir #include <s2_luidl/tk_keyw.hxx> 34cdf0e10cSrcweir #include <s2_luidl/pe_type2.hxx> 35cdf0e10cSrcweir #include <s2_luidl/pe_selem.hxx> 36cdf0e10cSrcweir 37cdf0e10cSrcweir 38cdf0e10cSrcweir 39cdf0e10cSrcweir namespace csi 40cdf0e10cSrcweir { 41cdf0e10cSrcweir namespace uidl 42cdf0e10cSrcweir { 43cdf0e10cSrcweir 44cdf0e10cSrcweir 45cdf0e10cSrcweir PE_Struct::PE_Struct() 46cdf0e10cSrcweir // : aWork, 47cdf0e10cSrcweir // pStati 48cdf0e10cSrcweir { 49cdf0e10cSrcweir pStati = new S_Stati(*this); 50cdf0e10cSrcweir } 51cdf0e10cSrcweir 52cdf0e10cSrcweir void 53cdf0e10cSrcweir PE_Struct::EstablishContacts( UnoIDL_PE * io_pParentPE, 54cdf0e10cSrcweir ary::Repository & io_rRepository, 55cdf0e10cSrcweir TokenProcessing_Result & o_rResult ) 56cdf0e10cSrcweir { 57cdf0e10cSrcweir UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult); 58cdf0e10cSrcweir Work().pPE_Element->EstablishContacts(this,io_rRepository,o_rResult); 59cdf0e10cSrcweir Work().pPE_Type->EstablishContacts(this,io_rRepository,o_rResult); 60cdf0e10cSrcweir } 61cdf0e10cSrcweir 62cdf0e10cSrcweir PE_Struct::~PE_Struct() 63cdf0e10cSrcweir { 64cdf0e10cSrcweir } 65cdf0e10cSrcweir 66cdf0e10cSrcweir void 67cdf0e10cSrcweir PE_Struct::ProcessToken( const Token & i_rToken ) 68cdf0e10cSrcweir { 69cdf0e10cSrcweir i_rToken.Trigger(*Stati().pCurStatus); 70cdf0e10cSrcweir } 71cdf0e10cSrcweir 72cdf0e10cSrcweir 73cdf0e10cSrcweir void 74cdf0e10cSrcweir PE_Struct::InitData() 75cdf0e10cSrcweir { 76cdf0e10cSrcweir Work().InitData(); 77cdf0e10cSrcweir Stati().pCurStatus = &Stati().aWaitForName; 78cdf0e10cSrcweir } 79cdf0e10cSrcweir 80cdf0e10cSrcweir void 81cdf0e10cSrcweir PE_Struct::TransferData() 82cdf0e10cSrcweir { 83cdf0e10cSrcweir if (NOT Work().bIsPreDeclaration) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir csv_assert(Work().sData_Name.size() > 0); 86cdf0e10cSrcweir csv_assert(Work().nCurStruct.IsValid()); 87cdf0e10cSrcweir } 88cdf0e10cSrcweir Stati().pCurStatus = &Stati().aNone; 89cdf0e10cSrcweir } 90cdf0e10cSrcweir 91cdf0e10cSrcweir void 92cdf0e10cSrcweir PE_Struct::ReceiveData() 93cdf0e10cSrcweir { 94cdf0e10cSrcweir Stati().pCurStatus->On_SubPE_Left(); 95cdf0e10cSrcweir } 96cdf0e10cSrcweir 97cdf0e10cSrcweir PE_Struct::S_Work::S_Work() 98cdf0e10cSrcweir : sData_Name(), 99cdf0e10cSrcweir sData_TemplateParam(), 100cdf0e10cSrcweir bIsPreDeclaration(false), 101cdf0e10cSrcweir nCurStruct(0), 102cdf0e10cSrcweir pPE_Element(0), 103cdf0e10cSrcweir nCurParsed_ElementRef(0), 104cdf0e10cSrcweir pPE_Type(0), 105cdf0e10cSrcweir nCurParsed_Base(0) 106cdf0e10cSrcweir 107cdf0e10cSrcweir { 108cdf0e10cSrcweir pPE_Element = new PE_StructElement(nCurParsed_ElementRef,nCurStruct,sData_TemplateParam); 109cdf0e10cSrcweir pPE_Type = new PE_Type(nCurParsed_Base); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir 112cdf0e10cSrcweir void 113cdf0e10cSrcweir PE_Struct::S_Work::InitData() 114cdf0e10cSrcweir { 115cdf0e10cSrcweir sData_Name.clear(); 116cdf0e10cSrcweir sData_TemplateParam.clear(); 117cdf0e10cSrcweir bIsPreDeclaration = false; 118cdf0e10cSrcweir nCurStruct = 0; 119cdf0e10cSrcweir nCurParsed_ElementRef = 0; 120cdf0e10cSrcweir nCurParsed_Base = 0; 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir void 124cdf0e10cSrcweir PE_Struct::S_Work::Prepare_PE_QualifiedName() 125cdf0e10cSrcweir { 126cdf0e10cSrcweir nCurParsed_ElementRef = 0; 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir void 130cdf0e10cSrcweir PE_Struct::S_Work::Prepare_PE_Element() 131cdf0e10cSrcweir { 132cdf0e10cSrcweir nCurParsed_Base = 0; 133cdf0e10cSrcweir } 134cdf0e10cSrcweir 135cdf0e10cSrcweir void 136cdf0e10cSrcweir PE_Struct::S_Work::Data_Set_Name( const char * i_sName ) 137cdf0e10cSrcweir { 138cdf0e10cSrcweir sData_Name = i_sName; 139cdf0e10cSrcweir } 140cdf0e10cSrcweir 141cdf0e10cSrcweir void 142cdf0e10cSrcweir PE_Struct::S_Work::Data_Set_TemplateParam( const char * i_sTemplateParam ) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir sData_TemplateParam = i_sTemplateParam; 145cdf0e10cSrcweir } 146cdf0e10cSrcweir 147cdf0e10cSrcweir PE_Struct::S_Stati::S_Stati(PE_Struct & io_rStruct) 148cdf0e10cSrcweir : aNone(io_rStruct), 149cdf0e10cSrcweir aWaitForName(io_rStruct), 150cdf0e10cSrcweir aGotName(io_rStruct), 151cdf0e10cSrcweir aWaitForTemplateParam(io_rStruct), 152cdf0e10cSrcweir aWaitForTemplateEnd(io_rStruct), 153cdf0e10cSrcweir aWaitForBase(io_rStruct), 154cdf0e10cSrcweir aGotBase(io_rStruct), 155cdf0e10cSrcweir aWaitForElement(io_rStruct), 156cdf0e10cSrcweir aWaitForFinish(io_rStruct), 157cdf0e10cSrcweir pCurStatus(0) 158cdf0e10cSrcweir { 159cdf0e10cSrcweir pCurStatus = &aNone; 160cdf0e10cSrcweir } 161cdf0e10cSrcweir 162cdf0e10cSrcweir 163cdf0e10cSrcweir //*********************** Stati ***************************// 164cdf0e10cSrcweir 165cdf0e10cSrcweir 166cdf0e10cSrcweir UnoIDL_PE & 167cdf0e10cSrcweir PE_Struct::PE_StructState::MyPE() 168cdf0e10cSrcweir { 169cdf0e10cSrcweir return rStruct; 170cdf0e10cSrcweir } 171cdf0e10cSrcweir 172cdf0e10cSrcweir 173cdf0e10cSrcweir void 174cdf0e10cSrcweir PE_Struct::State_WaitForName::Process_Identifier( const TokIdentifier & i_rToken ) 175cdf0e10cSrcweir { 176cdf0e10cSrcweir Work().Data_Set_Name(i_rToken.Text()); 177cdf0e10cSrcweir MoveState( Stati().aGotName ); 178cdf0e10cSrcweir SetResult(done,stay); 179cdf0e10cSrcweir } 180cdf0e10cSrcweir 181cdf0e10cSrcweir void 182cdf0e10cSrcweir PE_Struct::State_GotName::Process_Punctuation( const TokPunctuation & i_rToken ) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir if ( i_rToken.Id() != TokPunctuation::Semicolon ) 185cdf0e10cSrcweir { 186cdf0e10cSrcweir switch (i_rToken.Id()) 187cdf0e10cSrcweir { 188cdf0e10cSrcweir case TokPunctuation::Colon: 189cdf0e10cSrcweir MoveState( Stati().aWaitForBase ); 190cdf0e10cSrcweir SetResult(done,push_sure,Work().pPE_Type.Ptr()); 191cdf0e10cSrcweir Work().Prepare_PE_QualifiedName(); 192cdf0e10cSrcweir break; 193cdf0e10cSrcweir case TokPunctuation::CurledBracketOpen: 194cdf0e10cSrcweir PE().store_Struct(); 195cdf0e10cSrcweir MoveState( Stati().aWaitForElement ); 196cdf0e10cSrcweir SetResult(done,stay); 197cdf0e10cSrcweir break; 198cdf0e10cSrcweir case TokPunctuation::Lesser: 199cdf0e10cSrcweir MoveState( Stati().aWaitForTemplateParam ); 200cdf0e10cSrcweir SetResult(done,stay); 201cdf0e10cSrcweir break; 202cdf0e10cSrcweir default: 203cdf0e10cSrcweir SetResult(not_done,pop_failure); 204cdf0e10cSrcweir } // end switch 205cdf0e10cSrcweir } 206cdf0e10cSrcweir else 207cdf0e10cSrcweir { 208cdf0e10cSrcweir Work().sData_Name.clear(); 209cdf0e10cSrcweir SetResult(done,pop_success); 210cdf0e10cSrcweir } 211cdf0e10cSrcweir } 212cdf0e10cSrcweir 213cdf0e10cSrcweir void 214cdf0e10cSrcweir PE_Struct::State_WaitForTemplateParam::Process_Identifier( const TokIdentifier & i_rToken ) 215cdf0e10cSrcweir { 216cdf0e10cSrcweir Work().Data_Set_TemplateParam(i_rToken.Text()); 217cdf0e10cSrcweir MoveState( Stati().aWaitForTemplateEnd ); 218cdf0e10cSrcweir SetResult(done,stay); 219cdf0e10cSrcweir } 220cdf0e10cSrcweir 221cdf0e10cSrcweir void 222cdf0e10cSrcweir PE_Struct::State_WaitForTemplateEnd::Process_Punctuation( const TokPunctuation & ) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir // Assume: TokPunctuation::Greater 225cdf0e10cSrcweir MoveState( Stati().aGotName ); 226cdf0e10cSrcweir SetResult(done,stay); 227cdf0e10cSrcweir } 228cdf0e10cSrcweir 229cdf0e10cSrcweir void 230cdf0e10cSrcweir PE_Struct::State_WaitForBase::On_SubPE_Left() 231cdf0e10cSrcweir { 232cdf0e10cSrcweir MoveState(Stati().aGotBase); 233cdf0e10cSrcweir } 234cdf0e10cSrcweir 235cdf0e10cSrcweir void 236cdf0e10cSrcweir PE_Struct::State_GotBase::Process_Punctuation( const TokPunctuation & i_rToken ) 237cdf0e10cSrcweir { 238cdf0e10cSrcweir if ( i_rToken.Id() == TokPunctuation::CurledBracketOpen ) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir PE().store_Struct(); 241cdf0e10cSrcweir MoveState( Stati().aWaitForElement ); 242cdf0e10cSrcweir SetResult(done,stay); 243cdf0e10cSrcweir } 244cdf0e10cSrcweir else 245cdf0e10cSrcweir { 246cdf0e10cSrcweir SetResult(not_done,pop_failure); 247cdf0e10cSrcweir } 248cdf0e10cSrcweir } 249cdf0e10cSrcweir 250cdf0e10cSrcweir void 251cdf0e10cSrcweir PE_Struct::State_WaitForElement::Process_Identifier( const TokIdentifier & ) 252cdf0e10cSrcweir { 253cdf0e10cSrcweir SetResult( not_done, push_sure, Work().pPE_Element.Ptr() ); 254cdf0e10cSrcweir Work().Prepare_PE_Element(); 255cdf0e10cSrcweir } 256cdf0e10cSrcweir 257cdf0e10cSrcweir void 258cdf0e10cSrcweir PE_Struct::State_WaitForElement::Process_NameSeparator() 259cdf0e10cSrcweir { 260cdf0e10cSrcweir SetResult( not_done, push_sure, Work().pPE_Element.Ptr()); 261cdf0e10cSrcweir Work().Prepare_PE_Element(); 262cdf0e10cSrcweir } 263cdf0e10cSrcweir 264cdf0e10cSrcweir void 265cdf0e10cSrcweir PE_Struct::State_WaitForElement::Process_BuiltInType( const TokBuiltInType & ) 266cdf0e10cSrcweir { 267cdf0e10cSrcweir SetResult( not_done, push_sure, Work().pPE_Element.Ptr()); 268cdf0e10cSrcweir Work().Prepare_PE_Element(); 269cdf0e10cSrcweir } 270cdf0e10cSrcweir 271cdf0e10cSrcweir void 272cdf0e10cSrcweir PE_Struct::State_WaitForElement::Process_TypeModifier(const TokTypeModifier & ) 273cdf0e10cSrcweir { 274cdf0e10cSrcweir SetResult( not_done, push_sure, Work().pPE_Element.Ptr()); 275cdf0e10cSrcweir Work().Prepare_PE_Element(); 276cdf0e10cSrcweir } 277cdf0e10cSrcweir 278cdf0e10cSrcweir void 279cdf0e10cSrcweir PE_Struct::State_WaitForElement::Process_Punctuation( const TokPunctuation & i_rToken ) 280cdf0e10cSrcweir { 281cdf0e10cSrcweir if ( i_rToken.Id() == TokPunctuation::CurledBracketClose ) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir MoveState( Stati().aWaitForFinish ); 284cdf0e10cSrcweir SetResult( done, stay ); 285cdf0e10cSrcweir } 286cdf0e10cSrcweir else 287cdf0e10cSrcweir { 288cdf0e10cSrcweir SetResult( not_done, pop_failure ); 289cdf0e10cSrcweir } 290cdf0e10cSrcweir } 291cdf0e10cSrcweir 292cdf0e10cSrcweir void 293cdf0e10cSrcweir PE_Struct::State_WaitForFinish::Process_Punctuation( const TokPunctuation & i_rToken ) 294cdf0e10cSrcweir { 295cdf0e10cSrcweir if (i_rToken.Id() == TokPunctuation::Semicolon) 296cdf0e10cSrcweir { 297cdf0e10cSrcweir MoveState( Stati().aNone ); 298cdf0e10cSrcweir SetResult( done, pop_success ); 299cdf0e10cSrcweir } 300cdf0e10cSrcweir else 301cdf0e10cSrcweir { 302cdf0e10cSrcweir SetResult( not_done, pop_failure ); 303cdf0e10cSrcweir } 304cdf0e10cSrcweir } 305cdf0e10cSrcweir 306cdf0e10cSrcweir void 307cdf0e10cSrcweir PE_Struct::store_Struct() 308cdf0e10cSrcweir { 309cdf0e10cSrcweir ary::idl::Struct & 310cdf0e10cSrcweir rCe = Gate().Ces().Store_Struct( 311cdf0e10cSrcweir CurNamespace().CeId(), 312cdf0e10cSrcweir Work().sData_Name, 313cdf0e10cSrcweir Work().nCurParsed_Base, 314cdf0e10cSrcweir Work().sData_TemplateParam ); 315cdf0e10cSrcweir PassDocuAt(rCe); 316cdf0e10cSrcweir Work().nCurStruct = rCe.CeId(); 317cdf0e10cSrcweir } 318cdf0e10cSrcweir 319cdf0e10cSrcweir 320cdf0e10cSrcweir } // namespace uidl 321cdf0e10cSrcweir } // namespace csi 322