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_excp.hxx>
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES
33*cdf0e10cSrcweir #include <ary/idl/i_exception.hxx>
34*cdf0e10cSrcweir #include <ary/idl/i_gate.hxx>
35*cdf0e10cSrcweir #include <ary/idl/i_structelem.hxx>
36*cdf0e10cSrcweir #include <ary/idl/ip_ce.hxx>
37*cdf0e10cSrcweir #include <ary/doc/d_oldidldocu.hxx>
38*cdf0e10cSrcweir #include <s2_luidl/tk_ident.hxx>
39*cdf0e10cSrcweir #include <s2_luidl/tk_punct.hxx>
40*cdf0e10cSrcweir #include <s2_luidl/tk_keyw.hxx>
41*cdf0e10cSrcweir #include <s2_luidl/pe_type2.hxx>
42*cdf0e10cSrcweir #include <s2_luidl/pe_selem.hxx>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir namespace csi
47*cdf0e10cSrcweir {
48*cdf0e10cSrcweir namespace uidl
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir PE_Exception::PE_Exception()
53*cdf0e10cSrcweir 	// :	aWork,
54*cdf0e10cSrcweir 	//      pStati
55*cdf0e10cSrcweir {
56*cdf0e10cSrcweir 	pStati = new S_Stati(*this);
57*cdf0e10cSrcweir }
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir void
60*cdf0e10cSrcweir PE_Exception::EstablishContacts( UnoIDL_PE *				io_pParentPE,
61*cdf0e10cSrcweir 							  ary::Repository &			io_rRepository,
62*cdf0e10cSrcweir 							  TokenProcessing_Result & 	o_rResult )
63*cdf0e10cSrcweir {
64*cdf0e10cSrcweir 	UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
65*cdf0e10cSrcweir 	Work().pPE_Element->EstablishContacts(this,io_rRepository,o_rResult);
66*cdf0e10cSrcweir 	Work().pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
67*cdf0e10cSrcweir }
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir PE_Exception::~PE_Exception()
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir }
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir void
74*cdf0e10cSrcweir PE_Exception::ProcessToken( const Token & i_rToken )
75*cdf0e10cSrcweir {
76*cdf0e10cSrcweir 	i_rToken.Trigger(*Stati().pCurStatus);
77*cdf0e10cSrcweir }
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir void
81*cdf0e10cSrcweir PE_Exception::InitData()
82*cdf0e10cSrcweir {
83*cdf0e10cSrcweir 	Work().InitData();
84*cdf0e10cSrcweir 	Stati().pCurStatus = &Stati().aWaitForName;
85*cdf0e10cSrcweir }
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir void
88*cdf0e10cSrcweir PE_Exception::TransferData()
89*cdf0e10cSrcweir {
90*cdf0e10cSrcweir 	if (NOT Work().bIsPreDeclaration)
91*cdf0e10cSrcweir 	{
92*cdf0e10cSrcweir 		csv_assert(Work().sData_Name.size() > 0);
93*cdf0e10cSrcweir 		csv_assert(Work().nCurStruct.IsValid());
94*cdf0e10cSrcweir 	}
95*cdf0e10cSrcweir 	Stati().pCurStatus = &Stati().aNone;
96*cdf0e10cSrcweir }
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir void
99*cdf0e10cSrcweir PE_Exception::ReceiveData()
100*cdf0e10cSrcweir {
101*cdf0e10cSrcweir 	Stati().pCurStatus->On_SubPE_Left();
102*cdf0e10cSrcweir }
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir PE_Exception::S_Work::S_Work()
105*cdf0e10cSrcweir 	:	sData_Name(),
106*cdf0e10cSrcweir 		bIsPreDeclaration(false),
107*cdf0e10cSrcweir 		nCurStruct(0),
108*cdf0e10cSrcweir 		pPE_Element(0),
109*cdf0e10cSrcweir 		nCurParsed_ElementRef(0),
110*cdf0e10cSrcweir 		pPE_Type(0),
111*cdf0e10cSrcweir 		nCurParsed_Base(0)
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir 	pPE_Element = new PE_StructElement(nCurParsed_ElementRef,nCurStruct);
115*cdf0e10cSrcweir 	pPE_Type = new PE_Type(nCurParsed_Base);
116*cdf0e10cSrcweir }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir void
119*cdf0e10cSrcweir PE_Exception::S_Work::InitData()
120*cdf0e10cSrcweir {
121*cdf0e10cSrcweir 	sData_Name.clear();
122*cdf0e10cSrcweir 	bIsPreDeclaration = false;
123*cdf0e10cSrcweir 	nCurStruct = 0;
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir     nCurParsed_ElementRef = 0;
126*cdf0e10cSrcweir     nCurParsed_Base = 0;
127*cdf0e10cSrcweir }
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir void
130*cdf0e10cSrcweir PE_Exception::S_Work::Prepare_PE_QualifiedName()
131*cdf0e10cSrcweir {
132*cdf0e10cSrcweir 	nCurParsed_ElementRef = 0;
133*cdf0e10cSrcweir }
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir void
136*cdf0e10cSrcweir PE_Exception::S_Work::Prepare_PE_Element()
137*cdf0e10cSrcweir {
138*cdf0e10cSrcweir 	nCurParsed_Base = 0;
139*cdf0e10cSrcweir }
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir void
142*cdf0e10cSrcweir PE_Exception::S_Work::Data_Set_Name( const char * i_sName )
143*cdf0e10cSrcweir {
144*cdf0e10cSrcweir 	sData_Name = i_sName;
145*cdf0e10cSrcweir }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir PE_Exception::S_Stati::S_Stati(PE_Exception & io_rStruct)
148*cdf0e10cSrcweir 	:	aNone(io_rStruct),
149*cdf0e10cSrcweir 		aWaitForName(io_rStruct),
150*cdf0e10cSrcweir 		aGotName(io_rStruct),
151*cdf0e10cSrcweir 		aWaitForBase(io_rStruct),
152*cdf0e10cSrcweir 		aGotBase(io_rStruct),
153*cdf0e10cSrcweir 		aWaitForElement(io_rStruct),
154*cdf0e10cSrcweir 		aWaitForFinish(io_rStruct),
155*cdf0e10cSrcweir 		pCurStatus(0)
156*cdf0e10cSrcweir {
157*cdf0e10cSrcweir 	pCurStatus = &aNone;
158*cdf0e10cSrcweir }
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir //***********************		Stati		***************************//
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir UnoIDL_PE &
165*cdf0e10cSrcweir PE_Exception::PE_StructState::MyPE()
166*cdf0e10cSrcweir {
167*cdf0e10cSrcweir 	return rStruct;
168*cdf0e10cSrcweir }
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir void
172*cdf0e10cSrcweir PE_Exception::State_WaitForName::Process_Identifier( const TokIdentifier & i_rToken )
173*cdf0e10cSrcweir {
174*cdf0e10cSrcweir 	Work().Data_Set_Name(i_rToken.Text());
175*cdf0e10cSrcweir 	MoveState( Stati().aGotName );
176*cdf0e10cSrcweir 	SetResult(done,stay);
177*cdf0e10cSrcweir }
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir void
180*cdf0e10cSrcweir PE_Exception::State_GotName::Process_Punctuation( const TokPunctuation & i_rToken )
181*cdf0e10cSrcweir {
182*cdf0e10cSrcweir 	if ( i_rToken.Id() != TokPunctuation::Semicolon )
183*cdf0e10cSrcweir     {
184*cdf0e10cSrcweir 		switch (i_rToken.Id())
185*cdf0e10cSrcweir 		{
186*cdf0e10cSrcweir 			case TokPunctuation::Colon:
187*cdf0e10cSrcweir 				MoveState( Stati().aWaitForBase );
188*cdf0e10cSrcweir 				SetResult(done,push_sure,Work().pPE_Type.Ptr());
189*cdf0e10cSrcweir 				Work().Prepare_PE_QualifiedName();
190*cdf0e10cSrcweir 				break;
191*cdf0e10cSrcweir 			case TokPunctuation::CurledBracketOpen:
192*cdf0e10cSrcweir 			    PE().store_Exception();
193*cdf0e10cSrcweir 				MoveState( Stati().aWaitForElement );
194*cdf0e10cSrcweir 				SetResult(done,stay);
195*cdf0e10cSrcweir 				break;
196*cdf0e10cSrcweir 			default:
197*cdf0e10cSrcweir 				SetResult(not_done,pop_failure);
198*cdf0e10cSrcweir 		}	// end switch
199*cdf0e10cSrcweir 	}
200*cdf0e10cSrcweir 	else
201*cdf0e10cSrcweir 	{
202*cdf0e10cSrcweir 		Work().sData_Name.clear();
203*cdf0e10cSrcweir 		SetResult(done,pop_success);
204*cdf0e10cSrcweir 	}
205*cdf0e10cSrcweir }
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir void
208*cdf0e10cSrcweir PE_Exception::State_WaitForBase::On_SubPE_Left()
209*cdf0e10cSrcweir {
210*cdf0e10cSrcweir 	MoveState(Stati().aGotBase);
211*cdf0e10cSrcweir }
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir void
214*cdf0e10cSrcweir PE_Exception::State_GotBase::Process_Punctuation( const TokPunctuation & i_rToken )
215*cdf0e10cSrcweir {
216*cdf0e10cSrcweir 	if ( i_rToken.Id() == TokPunctuation::CurledBracketOpen )
217*cdf0e10cSrcweir 	{
218*cdf0e10cSrcweir 	    PE().store_Exception();
219*cdf0e10cSrcweir 		MoveState( Stati().aWaitForElement );
220*cdf0e10cSrcweir 		SetResult(done,stay);
221*cdf0e10cSrcweir 	}
222*cdf0e10cSrcweir 	else
223*cdf0e10cSrcweir 	{
224*cdf0e10cSrcweir 		SetResult(not_done,pop_failure);
225*cdf0e10cSrcweir 	}
226*cdf0e10cSrcweir }
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir void
229*cdf0e10cSrcweir PE_Exception::State_WaitForElement::Process_Identifier( const TokIdentifier & )
230*cdf0e10cSrcweir {
231*cdf0e10cSrcweir 	SetResult( not_done, push_sure, Work().pPE_Element.Ptr() );
232*cdf0e10cSrcweir 	Work().Prepare_PE_Element();
233*cdf0e10cSrcweir }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir void
236*cdf0e10cSrcweir PE_Exception::State_WaitForElement::Process_NameSeparator()
237*cdf0e10cSrcweir {
238*cdf0e10cSrcweir 	SetResult( not_done, push_sure, Work().pPE_Element.Ptr());
239*cdf0e10cSrcweir 	Work().Prepare_PE_Element();
240*cdf0e10cSrcweir }
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir void
243*cdf0e10cSrcweir PE_Exception::State_WaitForElement::Process_BuiltInType( const TokBuiltInType & )
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir 	SetResult( not_done, push_sure, Work().pPE_Element.Ptr());
246*cdf0e10cSrcweir 	Work().Prepare_PE_Element();
247*cdf0e10cSrcweir }
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir void
250*cdf0e10cSrcweir PE_Exception::State_WaitForElement::Process_TypeModifier(const TokTypeModifier & )
251*cdf0e10cSrcweir {
252*cdf0e10cSrcweir 	SetResult( not_done, push_sure, Work().pPE_Element.Ptr());
253*cdf0e10cSrcweir 	Work().Prepare_PE_Element();
254*cdf0e10cSrcweir }
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir void
257*cdf0e10cSrcweir PE_Exception::State_WaitForElement::Process_Punctuation( const TokPunctuation & i_rToken )
258*cdf0e10cSrcweir {
259*cdf0e10cSrcweir 	if ( i_rToken.Id() == TokPunctuation::CurledBracketClose )
260*cdf0e10cSrcweir 	{
261*cdf0e10cSrcweir 		MoveState( Stati().aWaitForFinish );
262*cdf0e10cSrcweir 		SetResult( done, stay );
263*cdf0e10cSrcweir 	}
264*cdf0e10cSrcweir 	else
265*cdf0e10cSrcweir 	{
266*cdf0e10cSrcweir 		SetResult( not_done, pop_failure );
267*cdf0e10cSrcweir 	}
268*cdf0e10cSrcweir }
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir void
271*cdf0e10cSrcweir PE_Exception::State_WaitForFinish::Process_Punctuation( const TokPunctuation & i_rToken )
272*cdf0e10cSrcweir {
273*cdf0e10cSrcweir 	if (i_rToken.Id() == TokPunctuation::Semicolon)
274*cdf0e10cSrcweir 	{
275*cdf0e10cSrcweir 		MoveState( Stati().aNone );
276*cdf0e10cSrcweir 		SetResult( done, pop_success );
277*cdf0e10cSrcweir 	}
278*cdf0e10cSrcweir 	else
279*cdf0e10cSrcweir 	{
280*cdf0e10cSrcweir 		SetResult( not_done, pop_failure );
281*cdf0e10cSrcweir 	}
282*cdf0e10cSrcweir }
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir void
285*cdf0e10cSrcweir PE_Exception::store_Exception()
286*cdf0e10cSrcweir {
287*cdf0e10cSrcweir     ary::idl::Exception &
288*cdf0e10cSrcweir         rCe = Gate().Ces().Store_Exception(
289*cdf0e10cSrcweir 						    CurNamespace().CeId(),
290*cdf0e10cSrcweir 						    Work().sData_Name,
291*cdf0e10cSrcweir                             Work().nCurParsed_Base );
292*cdf0e10cSrcweir     PassDocuAt(rCe);
293*cdf0e10cSrcweir     Work().nCurStruct = rCe.Id();
294*cdf0e10cSrcweir }
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir }   // namespace uidl
298*cdf0e10cSrcweir }   // namespace csi
299