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_singl.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_singleton.hxx>
35*cdf0e10cSrcweir #include <ary/idl/i_sisingleton.hxx>
36*cdf0e10cSrcweir #include <ary/idl/ip_ce.hxx>
37*cdf0e10cSrcweir #include <ary/doc/d_oldidldocu.hxx>
38*cdf0e10cSrcweir #include <s2_luidl/pe_type2.hxx>
39*cdf0e10cSrcweir #include <s2_luidl/tk_keyw.hxx>
40*cdf0e10cSrcweir #include <s2_luidl/tk_ident.hxx>
41*cdf0e10cSrcweir #include <s2_luidl/tk_punct.hxx>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir namespace csi
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir namespace uidl
48*cdf0e10cSrcweir {
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir #if 0
53*cdf0e10cSrcweir #ifdef DF
54*cdf0e10cSrcweir #undef DF
55*cdf0e10cSrcweir #endif
56*cdf0e10cSrcweir #define DF 	&PE_Singleton::On_Default
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir PE_Singleton::F_TOK
60*cdf0e10cSrcweir PE_Singleton::aDispatcher[PE_Singleton::e_STATES_MAX][PE_Singleton::tt_MAX] =
61*cdf0e10cSrcweir 		{ 	{ DF, DF, DF },  // e_none
62*cdf0e10cSrcweir 			{ DF, &PE_Singleton::On_need_name_Identifer,
63*cdf0e10cSrcweir 					  DF },  // need_name
64*cdf0e10cSrcweir 			{ DF, DF, &PE_Singleton::On_need_curlbr_open_Punctuation,
65*cdf0e10cSrcweir 						 },  // need_curlbr_open
66*cdf0e10cSrcweir 			{ &PE_Singleton::On_std_GotoService,
67*cdf0e10cSrcweir 				  DF, &PE_Singleton::On_std_Punctuation,
68*cdf0e10cSrcweir 						 },  // e_std
69*cdf0e10cSrcweir 			{ DF, DF, DF },  // in_service
70*cdf0e10cSrcweir 			{ DF, DF, &PE_Interface::On_need_finish_Punctuation,
71*cdf0e10cSrcweir 						 }   // need_finish
72*cdf0e10cSrcweir 		};
73*cdf0e10cSrcweir #endif // 0
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir PE_Singleton::PE_Singleton()
77*cdf0e10cSrcweir 	:	eState(e_none),
78*cdf0e10cSrcweir 		sData_Name(),
79*cdf0e10cSrcweir 		bIsPreDeclaration(false),
80*cdf0e10cSrcweir 		pCurSingleton(0),
81*cdf0e10cSrcweir         pCurSiSingleton(0),
82*cdf0e10cSrcweir 		pPE_Type(0),
83*cdf0e10cSrcweir 		nCurParsed_Type(0)
84*cdf0e10cSrcweir {
85*cdf0e10cSrcweir 	pPE_Type 		= new PE_Type(nCurParsed_Type);
86*cdf0e10cSrcweir }
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir void
89*cdf0e10cSrcweir PE_Singleton::EstablishContacts( UnoIDL_PE *				io_pParentPE,
90*cdf0e10cSrcweir 							   ary::Repository &		io_rRepository,
91*cdf0e10cSrcweir 							   TokenProcessing_Result & o_rResult )
92*cdf0e10cSrcweir {
93*cdf0e10cSrcweir 	UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
94*cdf0e10cSrcweir 	pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
95*cdf0e10cSrcweir }
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir PE_Singleton::~PE_Singleton()
98*cdf0e10cSrcweir {
99*cdf0e10cSrcweir }
100*cdf0e10cSrcweir 
101*cdf0e10cSrcweir void
102*cdf0e10cSrcweir PE_Singleton::ProcessToken( const Token & i_rToken )
103*cdf0e10cSrcweir {
104*cdf0e10cSrcweir 	i_rToken.Trigger(*this);
105*cdf0e10cSrcweir }
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir void
109*cdf0e10cSrcweir PE_Singleton::Process_MetaType( const TokMetaType &	i_rToken )
110*cdf0e10cSrcweir {
111*cdf0e10cSrcweir 	switch ( i_rToken.Id() )
112*cdf0e10cSrcweir 	{
113*cdf0e10cSrcweir 		case TokMetaType::mt_service:
114*cdf0e10cSrcweir 					if (eState == e_std)
115*cdf0e10cSrcweir 					{
116*cdf0e10cSrcweir 						SetResult(done, push_sure, pPE_Type.Ptr());
117*cdf0e10cSrcweir 						eState = in_service;
118*cdf0e10cSrcweir 					}
119*cdf0e10cSrcweir 					else
120*cdf0e10cSrcweir 						On_Default();
121*cdf0e10cSrcweir 					break;
122*cdf0e10cSrcweir 		case TokMetaType::mt_singleton:
123*cdf0e10cSrcweir 					if (eState == need_name)
124*cdf0e10cSrcweir 						SetResult(done, stay);
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 
133*cdf0e10cSrcweir 	}	// end switch
134*cdf0e10cSrcweir }
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir void
137*cdf0e10cSrcweir PE_Singleton::Process_Identifier( const TokIdentifier & i_rToken )
138*cdf0e10cSrcweir {
139*cdf0e10cSrcweir 	if (eState == need_name)
140*cdf0e10cSrcweir 	{
141*cdf0e10cSrcweir 		sData_Name = i_rToken.Text();
142*cdf0e10cSrcweir 		SetResult(done, stay);
143*cdf0e10cSrcweir 		eState = need_curlbr_open;
144*cdf0e10cSrcweir 	}
145*cdf0e10cSrcweir 	else
146*cdf0e10cSrcweir 		On_Default();
147*cdf0e10cSrcweir }
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir void
150*cdf0e10cSrcweir PE_Singleton::Process_Punctuation( const TokPunctuation & i_rToken )
151*cdf0e10cSrcweir {
152*cdf0e10cSrcweir 	switch (i_rToken.Id())
153*cdf0e10cSrcweir 	{
154*cdf0e10cSrcweir 		case TokPunctuation::CurledBracketOpen:
155*cdf0e10cSrcweir 					if (eState == need_curlbr_open)
156*cdf0e10cSrcweir 					{
157*cdf0e10cSrcweir                         pCurSingleton = &Gate().Ces().Store_Singleton(
158*cdf0e10cSrcweir                                                         CurNamespace().CeId(),
159*cdf0e10cSrcweir                                                         sData_Name );
160*cdf0e10cSrcweir 						PassDocuAt(*pCurSingleton);
161*cdf0e10cSrcweir 						SetResult(done, stay);
162*cdf0e10cSrcweir 						eState = e_std;
163*cdf0e10cSrcweir 					}
164*cdf0e10cSrcweir 					else
165*cdf0e10cSrcweir 						On_Default();
166*cdf0e10cSrcweir 					break;
167*cdf0e10cSrcweir 		case TokPunctuation::CurledBracketClose:
168*cdf0e10cSrcweir 					if (eState == e_std)
169*cdf0e10cSrcweir 					{
170*cdf0e10cSrcweir 						SetResult(done, stay);
171*cdf0e10cSrcweir 						eState = need_finish;
172*cdf0e10cSrcweir 					}
173*cdf0e10cSrcweir 					else
174*cdf0e10cSrcweir 						On_Default();
175*cdf0e10cSrcweir 					break;
176*cdf0e10cSrcweir 		case TokPunctuation::Semicolon:
177*cdf0e10cSrcweir 					switch (eState)
178*cdf0e10cSrcweir 					{
179*cdf0e10cSrcweir 					   case e_std:  SetResult(done, stay);
180*cdf0e10cSrcweir 									break;
181*cdf0e10cSrcweir 					   case need_finish:
182*cdf0e10cSrcweir 									SetResult(done, pop_success);
183*cdf0e10cSrcweir 									eState = e_none;
184*cdf0e10cSrcweir 									break;
185*cdf0e10cSrcweir 					   default:
186*cdf0e10cSrcweir 									On_Default();
187*cdf0e10cSrcweir 					}	// end switch
188*cdf0e10cSrcweir 					break;
189*cdf0e10cSrcweir 		case TokPunctuation::Colon:
190*cdf0e10cSrcweir 					switch (eState)
191*cdf0e10cSrcweir 					{
192*cdf0e10cSrcweir 					   case need_curlbr_open:
193*cdf0e10cSrcweir 					                SetResult(done, push_sure, pPE_Type.Ptr());
194*cdf0e10cSrcweir                                     eState = in_base_interface;
195*cdf0e10cSrcweir 									break;
196*cdf0e10cSrcweir 					   default:
197*cdf0e10cSrcweir 									On_Default();
198*cdf0e10cSrcweir 					}	// end switch
199*cdf0e10cSrcweir 		            break;
200*cdf0e10cSrcweir 		default:
201*cdf0e10cSrcweir 					On_Default();
202*cdf0e10cSrcweir 	}	// end switch
203*cdf0e10cSrcweir }
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir void
206*cdf0e10cSrcweir PE_Singleton::Process_Default()
207*cdf0e10cSrcweir {
208*cdf0e10cSrcweir 	On_Default();
209*cdf0e10cSrcweir }
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir void
213*cdf0e10cSrcweir PE_Singleton::On_Default()
214*cdf0e10cSrcweir {
215*cdf0e10cSrcweir     SetResult(not_done, pop_failure);
216*cdf0e10cSrcweir }
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir void
219*cdf0e10cSrcweir PE_Singleton::InitData()
220*cdf0e10cSrcweir {
221*cdf0e10cSrcweir 	eState = need_name;
222*cdf0e10cSrcweir 	sData_Name.clear();
223*cdf0e10cSrcweir 	bIsPreDeclaration = false;
224*cdf0e10cSrcweir 	pCurSingleton = 0;
225*cdf0e10cSrcweir     pCurSiSingleton = 0;
226*cdf0e10cSrcweir 	nCurParsed_Type = 0;
227*cdf0e10cSrcweir }
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir void
230*cdf0e10cSrcweir PE_Singleton::TransferData()
231*cdf0e10cSrcweir {
232*cdf0e10cSrcweir 	if (NOT bIsPreDeclaration)
233*cdf0e10cSrcweir 	{
234*cdf0e10cSrcweir 		csv_assert(sData_Name.size() > 0);
235*cdf0e10cSrcweir 		csv_assert( (pCurSingleton != 0) != (pCurSiSingleton != 0) );
236*cdf0e10cSrcweir 	}
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir 	eState = e_none;
239*cdf0e10cSrcweir }
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir void
242*cdf0e10cSrcweir PE_Singleton::ReceiveData()
243*cdf0e10cSrcweir {
244*cdf0e10cSrcweir     switch (eState)
245*cdf0e10cSrcweir     {
246*cdf0e10cSrcweir         case in_service:
247*cdf0e10cSrcweir                     pCurSingleton->Set_Service(nCurParsed_Type);
248*cdf0e10cSrcweir 					nCurParsed_Type = 0;
249*cdf0e10cSrcweir 					eState = e_std;
250*cdf0e10cSrcweir                     break;
251*cdf0e10cSrcweir         case in_base_interface:
252*cdf0e10cSrcweir                     pCurSiSingleton = &Gate().Ces().Store_SglIfcSingleton(
253*cdf0e10cSrcweir                                                     CurNamespace().CeId(),
254*cdf0e10cSrcweir                                                     sData_Name,
255*cdf0e10cSrcweir                                                     nCurParsed_Type );
256*cdf0e10cSrcweir 					PassDocuAt(*pCurSiSingleton);
257*cdf0e10cSrcweir 					nCurParsed_Type = 0;
258*cdf0e10cSrcweir 					eState = need_finish;
259*cdf0e10cSrcweir                     break;
260*cdf0e10cSrcweir         default:
261*cdf0e10cSrcweir             csv_assert(false);
262*cdf0e10cSrcweir     }   // end switch
263*cdf0e10cSrcweir }
264*cdf0e10cSrcweir 
265*cdf0e10cSrcweir UnoIDL_PE &
266*cdf0e10cSrcweir PE_Singleton::MyPE()
267*cdf0e10cSrcweir {
268*cdf0e10cSrcweir 	return *this;
269*cdf0e10cSrcweir }
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir }   // namespace uidl
272*cdf0e10cSrcweir }   // namespace csi
273