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 <s2_luidl/pe_servi.hxx> 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES 33*cdf0e10cSrcweir #include <ary/idl/i_gate.hxx> 34*cdf0e10cSrcweir #include <ary/idl/i_service.hxx> 35*cdf0e10cSrcweir #include <ary/idl/i_siservice.hxx> 36*cdf0e10cSrcweir #include <ary/idl/ip_ce.hxx> 37*cdf0e10cSrcweir #include <ary/doc/d_oldidldocu.hxx> 38*cdf0e10cSrcweir #include <s2_luidl/pe_func2.hxx> 39*cdf0e10cSrcweir #include <s2_luidl/pe_property.hxx> 40*cdf0e10cSrcweir #include <s2_luidl/pe_type2.hxx> 41*cdf0e10cSrcweir #include <s2_luidl/tk_keyw.hxx> 42*cdf0e10cSrcweir #include <s2_luidl/tk_ident.hxx> 43*cdf0e10cSrcweir #include <s2_luidl/tk_punct.hxx> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir namespace csi 48*cdf0e10cSrcweir { 49*cdf0e10cSrcweir namespace uidl 50*cdf0e10cSrcweir { 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir PE_Service::PE_Service() 55*cdf0e10cSrcweir : eState(e_none), 56*cdf0e10cSrcweir sData_Name(), 57*cdf0e10cSrcweir bIsPreDeclaration(false), 58*cdf0e10cSrcweir pCurService(0), 59*cdf0e10cSrcweir pCurSiService(0), 60*cdf0e10cSrcweir nCurService(0), 61*cdf0e10cSrcweir pPE_Property(0), 62*cdf0e10cSrcweir nCurParsed_Property(0), 63*cdf0e10cSrcweir pPE_Type(0), 64*cdf0e10cSrcweir nCurParsed_Type(0), 65*cdf0e10cSrcweir pPE_Constructor(0), 66*cdf0e10cSrcweir bOptionalMember(false) 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir pPE_Property = new PE_Property(nCurService); 69*cdf0e10cSrcweir pPE_Type = new PE_Type(nCurParsed_Type); 70*cdf0e10cSrcweir pPE_Constructor = new PE_Function(nCurService, PE_Function::constructor); 71*cdf0e10cSrcweir } 72*cdf0e10cSrcweir 73*cdf0e10cSrcweir void 74*cdf0e10cSrcweir PE_Service::EstablishContacts( UnoIDL_PE * io_pParentPE, 75*cdf0e10cSrcweir ary::Repository & io_rRepository, 76*cdf0e10cSrcweir TokenProcessing_Result & o_rResult ) 77*cdf0e10cSrcweir { 78*cdf0e10cSrcweir UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult); 79*cdf0e10cSrcweir pPE_Property->EstablishContacts(this,io_rRepository,o_rResult); 80*cdf0e10cSrcweir pPE_Type->EstablishContacts(this,io_rRepository,o_rResult); 81*cdf0e10cSrcweir pPE_Constructor->EstablishContacts(this,io_rRepository,o_rResult); 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir PE_Service::~PE_Service() 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir } 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir void 89*cdf0e10cSrcweir PE_Service::ProcessToken( const Token & i_rToken ) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir i_rToken.Trigger(*this); 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir void 96*cdf0e10cSrcweir PE_Service::Process_MetaType( const TokMetaType & i_rToken ) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir switch ( i_rToken.Id() ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir case TokMetaType::mt_service: 101*cdf0e10cSrcweir if (eState == need_name) 102*cdf0e10cSrcweir SetResult(done, stay ); 103*cdf0e10cSrcweir else if (eState == e_std) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir SetResult(done, push_sure, pPE_Type.Ptr()); 106*cdf0e10cSrcweir eState = in_service_type; 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir else 109*cdf0e10cSrcweir On_Default(); 110*cdf0e10cSrcweir break; 111*cdf0e10cSrcweir case TokMetaType::mt_interface: 112*cdf0e10cSrcweir if (eState == e_std) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir SetResult(done, push_sure, pPE_Type.Ptr()); 115*cdf0e10cSrcweir eState = in_ifc_type; 116*cdf0e10cSrcweir } 117*cdf0e10cSrcweir else 118*cdf0e10cSrcweir On_Default(); 119*cdf0e10cSrcweir break; 120*cdf0e10cSrcweir case TokMetaType::mt_property: 121*cdf0e10cSrcweir if (eState == e_std) 122*cdf0e10cSrcweir { 123*cdf0e10cSrcweir StartProperty(); 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir else 126*cdf0e10cSrcweir On_Default(); 127*cdf0e10cSrcweir break; 128*cdf0e10cSrcweir default: 129*cdf0e10cSrcweir // KORR_FUTURE: 130*cdf0e10cSrcweir // Should throw syntax error warning. 131*cdf0e10cSrcweir ; 132*cdf0e10cSrcweir } // end switch 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir void 136*cdf0e10cSrcweir PE_Service::Process_Identifier( const TokIdentifier & i_rToken ) 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir if (eState == need_name) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir sData_Name = i_rToken.Text(); 141*cdf0e10cSrcweir SetResult(done, stay); 142*cdf0e10cSrcweir eState = need_curlbr_open; 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir else if (eState == e_std_sib) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir SetResult(not_done, push_sure, pPE_Constructor.Ptr()); 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir else 149*cdf0e10cSrcweir On_Default(); 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir void 153*cdf0e10cSrcweir PE_Service::Process_Punctuation( const TokPunctuation & i_rToken ) 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir switch (i_rToken.Id()) 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir case TokPunctuation::Colon: 158*cdf0e10cSrcweir if (eState == need_curlbr_open) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir SetResult(done, push_sure, pPE_Type.Ptr()); 161*cdf0e10cSrcweir eState = need_base_interface; 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir else 164*cdf0e10cSrcweir On_Default(); 165*cdf0e10cSrcweir break; 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir case TokPunctuation::CurledBracketOpen: 168*cdf0e10cSrcweir if (eState == need_curlbr_open) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir pCurService = &Gate().Ces().Store_Service( 171*cdf0e10cSrcweir CurNamespace().CeId(), 172*cdf0e10cSrcweir sData_Name ); 173*cdf0e10cSrcweir nCurService = pCurService->CeId(); 174*cdf0e10cSrcweir PassDocuAt(*pCurService); 175*cdf0e10cSrcweir SetResult(done, stay); 176*cdf0e10cSrcweir eState = e_std; 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir else if (eState == need_curlbr_open_sib) 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir SetResult(done, stay); 181*cdf0e10cSrcweir eState = e_std_sib; 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir else 184*cdf0e10cSrcweir On_Default(); 185*cdf0e10cSrcweir break; 186*cdf0e10cSrcweir case TokPunctuation::CurledBracketClose: 187*cdf0e10cSrcweir if (eState == e_std OR eState == e_std_sib) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir SetResult(done, stay); 190*cdf0e10cSrcweir eState = need_finish; 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir else 193*cdf0e10cSrcweir On_Default(); 194*cdf0e10cSrcweir break; 195*cdf0e10cSrcweir case TokPunctuation::Comma: 196*cdf0e10cSrcweir if (eState == expect_ifc_separator) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir SetResult(done, push_sure, pPE_Type.Ptr()); 199*cdf0e10cSrcweir eState = in_ifc_type; 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir else if (eState == expect_service_separator) 202*cdf0e10cSrcweir { 203*cdf0e10cSrcweir SetResult(done, push_sure, pPE_Type.Ptr()); 204*cdf0e10cSrcweir eState = in_service_type; 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir else if (eState == e_std) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir SetResult(done, stay); 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir else 211*cdf0e10cSrcweir On_Default(); 212*cdf0e10cSrcweir break; 213*cdf0e10cSrcweir case TokPunctuation::Semicolon: 214*cdf0e10cSrcweir switch (eState) 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir case need_curlbr_open: 217*cdf0e10cSrcweir sData_Name.clear(); 218*cdf0e10cSrcweir bIsPreDeclaration = true; 219*cdf0e10cSrcweir SetResult(done, pop_success); 220*cdf0e10cSrcweir eState = e_none; 221*cdf0e10cSrcweir break; 222*cdf0e10cSrcweir case need_curlbr_open_sib: 223*cdf0e10cSrcweir SetResult(done, pop_success); 224*cdf0e10cSrcweir eState = e_none; 225*cdf0e10cSrcweir break; 226*cdf0e10cSrcweir case expect_ifc_separator: 227*cdf0e10cSrcweir case expect_service_separator: 228*cdf0e10cSrcweir SetResult(done, stay); 229*cdf0e10cSrcweir eState = e_std; 230*cdf0e10cSrcweir break; 231*cdf0e10cSrcweir case need_finish: 232*cdf0e10cSrcweir SetResult(done, pop_success); 233*cdf0e10cSrcweir eState = e_none; 234*cdf0e10cSrcweir break; 235*cdf0e10cSrcweir case at_ignore: 236*cdf0e10cSrcweir SetResult(done, stay); 237*cdf0e10cSrcweir eState = e_std; 238*cdf0e10cSrcweir break; 239*cdf0e10cSrcweir default: 240*cdf0e10cSrcweir On_Default(); 241*cdf0e10cSrcweir } // end switch 242*cdf0e10cSrcweir break; 243*cdf0e10cSrcweir default: 244*cdf0e10cSrcweir On_Default(); 245*cdf0e10cSrcweir } // end switch 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir void 249*cdf0e10cSrcweir PE_Service::Process_Stereotype( const TokStereotype & i_rToken ) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir if (i_rToken.Id() == TokStereotype::ste_optional) 252*cdf0e10cSrcweir { 253*cdf0e10cSrcweir bOptionalMember = true; 254*cdf0e10cSrcweir SetResult(done, stay); 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir else if ( eState == e_std ) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir StartProperty(); 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir else 261*cdf0e10cSrcweir On_Default(); 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir void 265*cdf0e10cSrcweir PE_Service::Process_Needs() 266*cdf0e10cSrcweir { 267*cdf0e10cSrcweir SetResult(done,stay); 268*cdf0e10cSrcweir eState = at_ignore; 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir void 272*cdf0e10cSrcweir PE_Service::Process_Observes() 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir SetResult(done,stay); 275*cdf0e10cSrcweir eState = at_ignore; 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir void 279*cdf0e10cSrcweir PE_Service::Process_Default() 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir On_Default(); 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir void 286*cdf0e10cSrcweir PE_Service::On_Default() 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir if (eState == at_ignore) 289*cdf0e10cSrcweir SetResult(done, stay); 290*cdf0e10cSrcweir else 291*cdf0e10cSrcweir SetResult(not_done, pop_failure); 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir void 295*cdf0e10cSrcweir PE_Service::InitData() 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir eState = need_name; 298*cdf0e10cSrcweir sData_Name.clear(); 299*cdf0e10cSrcweir bIsPreDeclaration = false; 300*cdf0e10cSrcweir pCurService = 0; 301*cdf0e10cSrcweir pCurSiService = 0; 302*cdf0e10cSrcweir nCurService = 0; 303*cdf0e10cSrcweir nCurParsed_Property = 0; 304*cdf0e10cSrcweir nCurParsed_Type = 0; 305*cdf0e10cSrcweir bOptionalMember = false; 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir void 309*cdf0e10cSrcweir PE_Service::TransferData() 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir if (NOT bIsPreDeclaration) 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir csv_assert(sData_Name.size() > 0); 314*cdf0e10cSrcweir csv_assert( (pCurService != 0) != (pCurSiService != 0) ); 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir eState = e_none; 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir void 321*cdf0e10cSrcweir PE_Service::ReceiveData() 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir switch (eState) 324*cdf0e10cSrcweir { 325*cdf0e10cSrcweir case in_property: 326*cdf0e10cSrcweir eState = e_std; 327*cdf0e10cSrcweir break; 328*cdf0e10cSrcweir case in_ifc_type: 329*cdf0e10cSrcweir if (bOptionalMember) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir pPE_Type->SetOptional(); 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir pCurService->AddRef_SupportedInterface( 334*cdf0e10cSrcweir nCurParsed_Type, 335*cdf0e10cSrcweir pPE_Type->ReleaseDocu()); 336*cdf0e10cSrcweir nCurParsed_Type = 0; 337*cdf0e10cSrcweir eState = expect_ifc_separator; 338*cdf0e10cSrcweir break; 339*cdf0e10cSrcweir case in_service_type: 340*cdf0e10cSrcweir if (bOptionalMember) 341*cdf0e10cSrcweir { 342*cdf0e10cSrcweir pPE_Type->SetOptional(); 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir pCurService->AddRef_IncludedService( 345*cdf0e10cSrcweir nCurParsed_Type, 346*cdf0e10cSrcweir pPE_Type->ReleaseDocu()); 347*cdf0e10cSrcweir nCurParsed_Type = 0; 348*cdf0e10cSrcweir eState = expect_service_separator; 349*cdf0e10cSrcweir break; 350*cdf0e10cSrcweir case need_base_interface: 351*cdf0e10cSrcweir pCurSiService = &Gate().Ces().Store_SglIfcService( 352*cdf0e10cSrcweir CurNamespace().CeId(), 353*cdf0e10cSrcweir sData_Name, 354*cdf0e10cSrcweir nCurParsed_Type ); 355*cdf0e10cSrcweir nCurService = pCurSiService->CeId(); 356*cdf0e10cSrcweir PassDocuAt(*pCurSiService); 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir nCurParsed_Type = 0; 359*cdf0e10cSrcweir eState = need_curlbr_open_sib; 360*cdf0e10cSrcweir break; 361*cdf0e10cSrcweir case e_std_sib: 362*cdf0e10cSrcweir break; 363*cdf0e10cSrcweir default: 364*cdf0e10cSrcweir csv_assert(false); 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir bOptionalMember = false; 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir UnoIDL_PE & 372*cdf0e10cSrcweir PE_Service::MyPE() 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir return *this; 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir void 378*cdf0e10cSrcweir PE_Service::StartProperty() 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir SetResult(not_done, push_sure, pPE_Property.Ptr()); 381*cdf0e10cSrcweir eState = in_property; 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir if (bOptionalMember) 384*cdf0e10cSrcweir { 385*cdf0e10cSrcweir pPE_Property->PresetOptional(); 386*cdf0e10cSrcweir bOptionalMember = false; 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir } 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir } // namespace uidl 392*cdf0e10cSrcweir } // namespace csi 393*cdf0e10cSrcweir 394