178bc99aaSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
378bc99aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
478bc99aaSAndrew Rist * or more contributor license agreements. See the NOTICE file
578bc99aaSAndrew Rist * distributed with this work for additional information
678bc99aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file
778bc99aaSAndrew Rist * to you under the Apache License, Version 2.0 (the
878bc99aaSAndrew Rist * "License"); you may not use this file except in compliance
978bc99aaSAndrew Rist * with the License. You may obtain a copy of the License at
1078bc99aaSAndrew Rist *
1178bc99aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
1278bc99aaSAndrew Rist *
1378bc99aaSAndrew Rist * Unless required by applicable law or agreed to in writing,
1478bc99aaSAndrew Rist * software distributed under the License is distributed on an
1578bc99aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1678bc99aaSAndrew Rist * KIND, either express or implied. See the License for the
1778bc99aaSAndrew Rist * specific language governing permissions and limitations
1878bc99aaSAndrew Rist * under the License.
1978bc99aaSAndrew Rist *
2078bc99aaSAndrew Rist *************************************************************/
21cdf0e10cSrcweir
22cdf0e10cSrcweir #include <precomp.h>
23cdf0e10cSrcweir #include <s2_luidl/pe_singl.hxx>
24cdf0e10cSrcweir
25cdf0e10cSrcweir
26cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
27cdf0e10cSrcweir #include <ary/idl/i_gate.hxx>
28cdf0e10cSrcweir #include <ary/idl/i_singleton.hxx>
29cdf0e10cSrcweir #include <ary/idl/i_sisingleton.hxx>
30cdf0e10cSrcweir #include <ary/idl/ip_ce.hxx>
31cdf0e10cSrcweir #include <ary/doc/d_oldidldocu.hxx>
32cdf0e10cSrcweir #include <s2_luidl/pe_type2.hxx>
33cdf0e10cSrcweir #include <s2_luidl/tk_keyw.hxx>
34cdf0e10cSrcweir #include <s2_luidl/tk_ident.hxx>
35cdf0e10cSrcweir #include <s2_luidl/tk_punct.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir
38cdf0e10cSrcweir
39cdf0e10cSrcweir namespace csi
40cdf0e10cSrcweir {
41cdf0e10cSrcweir namespace uidl
42cdf0e10cSrcweir {
43cdf0e10cSrcweir
44cdf0e10cSrcweir
45cdf0e10cSrcweir
46cdf0e10cSrcweir #if 0
47cdf0e10cSrcweir #ifdef DF
48cdf0e10cSrcweir #undef DF
49cdf0e10cSrcweir #endif
50cdf0e10cSrcweir #define DF &PE_Singleton::On_Default
51cdf0e10cSrcweir
52cdf0e10cSrcweir
53cdf0e10cSrcweir PE_Singleton::F_TOK
54cdf0e10cSrcweir PE_Singleton::aDispatcher[PE_Singleton::e_STATES_MAX][PE_Singleton::tt_MAX] =
55cdf0e10cSrcweir { { DF, DF, DF }, // e_none
56cdf0e10cSrcweir { DF, &PE_Singleton::On_need_name_Identifer,
57cdf0e10cSrcweir DF }, // need_name
58cdf0e10cSrcweir { DF, DF, &PE_Singleton::On_need_curlbr_open_Punctuation,
59cdf0e10cSrcweir }, // need_curlbr_open
60cdf0e10cSrcweir { &PE_Singleton::On_std_GotoService,
61cdf0e10cSrcweir DF, &PE_Singleton::On_std_Punctuation,
62cdf0e10cSrcweir }, // e_std
63cdf0e10cSrcweir { DF, DF, DF }, // in_service
64cdf0e10cSrcweir { DF, DF, &PE_Interface::On_need_finish_Punctuation,
65cdf0e10cSrcweir } // need_finish
66cdf0e10cSrcweir };
67cdf0e10cSrcweir #endif // 0
68cdf0e10cSrcweir
69cdf0e10cSrcweir
PE_Singleton()70cdf0e10cSrcweir PE_Singleton::PE_Singleton()
71cdf0e10cSrcweir : eState(e_none),
72cdf0e10cSrcweir sData_Name(),
73cdf0e10cSrcweir bIsPreDeclaration(false),
74cdf0e10cSrcweir pCurSingleton(0),
75cdf0e10cSrcweir pCurSiSingleton(0),
76cdf0e10cSrcweir pPE_Type(0),
77cdf0e10cSrcweir nCurParsed_Type(0)
78cdf0e10cSrcweir {
79cdf0e10cSrcweir pPE_Type = new PE_Type(nCurParsed_Type);
80cdf0e10cSrcweir }
81cdf0e10cSrcweir
82cdf0e10cSrcweir void
EstablishContacts(UnoIDL_PE * io_pParentPE,ary::Repository & io_rRepository,TokenProcessing_Result & o_rResult)83cdf0e10cSrcweir PE_Singleton::EstablishContacts( UnoIDL_PE * io_pParentPE,
84cdf0e10cSrcweir ary::Repository & io_rRepository,
85cdf0e10cSrcweir TokenProcessing_Result & o_rResult )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
88cdf0e10cSrcweir pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
89cdf0e10cSrcweir }
90cdf0e10cSrcweir
~PE_Singleton()91cdf0e10cSrcweir PE_Singleton::~PE_Singleton()
92cdf0e10cSrcweir {
93cdf0e10cSrcweir }
94cdf0e10cSrcweir
95cdf0e10cSrcweir void
ProcessToken(const Token & i_rToken)96cdf0e10cSrcweir PE_Singleton::ProcessToken( const Token & i_rToken )
97cdf0e10cSrcweir {
98cdf0e10cSrcweir i_rToken.Trigger(*this);
99cdf0e10cSrcweir }
100cdf0e10cSrcweir
101cdf0e10cSrcweir
102cdf0e10cSrcweir void
Process_MetaType(const TokMetaType & i_rToken)103cdf0e10cSrcweir PE_Singleton::Process_MetaType( const TokMetaType & i_rToken )
104cdf0e10cSrcweir {
105cdf0e10cSrcweir switch ( i_rToken.Id() )
106cdf0e10cSrcweir {
107cdf0e10cSrcweir case TokMetaType::mt_service:
108cdf0e10cSrcweir if (eState == e_std)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir SetResult(done, push_sure, pPE_Type.Ptr());
111cdf0e10cSrcweir eState = in_service;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir else
114cdf0e10cSrcweir On_Default();
115cdf0e10cSrcweir break;
116cdf0e10cSrcweir case TokMetaType::mt_singleton:
117cdf0e10cSrcweir if (eState == need_name)
118cdf0e10cSrcweir SetResult(done, stay);
119cdf0e10cSrcweir else
120cdf0e10cSrcweir On_Default();
121cdf0e10cSrcweir break;
122cdf0e10cSrcweir default:
123cdf0e10cSrcweir // KORR_FUTURE
124cdf0e10cSrcweir // Should throw syntax error warning
125cdf0e10cSrcweir ;
126cdf0e10cSrcweir
127cdf0e10cSrcweir } // end switch
128cdf0e10cSrcweir }
129cdf0e10cSrcweir
130cdf0e10cSrcweir void
Process_Identifier(const TokIdentifier & i_rToken)131cdf0e10cSrcweir PE_Singleton::Process_Identifier( const TokIdentifier & i_rToken )
132cdf0e10cSrcweir {
133cdf0e10cSrcweir if (eState == need_name)
134cdf0e10cSrcweir {
135cdf0e10cSrcweir sData_Name = i_rToken.Text();
136cdf0e10cSrcweir SetResult(done, stay);
137cdf0e10cSrcweir eState = need_curlbr_open;
138cdf0e10cSrcweir }
139cdf0e10cSrcweir else
140cdf0e10cSrcweir On_Default();
141cdf0e10cSrcweir }
142cdf0e10cSrcweir
143cdf0e10cSrcweir void
Process_Punctuation(const TokPunctuation & i_rToken)144cdf0e10cSrcweir PE_Singleton::Process_Punctuation( const TokPunctuation & i_rToken )
145cdf0e10cSrcweir {
146cdf0e10cSrcweir switch (i_rToken.Id())
147cdf0e10cSrcweir {
148cdf0e10cSrcweir case TokPunctuation::CurledBracketOpen:
149cdf0e10cSrcweir if (eState == need_curlbr_open)
150cdf0e10cSrcweir {
151cdf0e10cSrcweir pCurSingleton = &Gate().Ces().Store_Singleton(
152cdf0e10cSrcweir CurNamespace().CeId(),
153cdf0e10cSrcweir sData_Name );
154cdf0e10cSrcweir PassDocuAt(*pCurSingleton);
155cdf0e10cSrcweir SetResult(done, stay);
156cdf0e10cSrcweir eState = e_std;
157cdf0e10cSrcweir }
158cdf0e10cSrcweir else
159cdf0e10cSrcweir On_Default();
160cdf0e10cSrcweir break;
161cdf0e10cSrcweir case TokPunctuation::CurledBracketClose:
162cdf0e10cSrcweir if (eState == e_std)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir SetResult(done, stay);
165cdf0e10cSrcweir eState = need_finish;
166cdf0e10cSrcweir }
167cdf0e10cSrcweir else
168cdf0e10cSrcweir On_Default();
169cdf0e10cSrcweir break;
170cdf0e10cSrcweir case TokPunctuation::Semicolon:
171cdf0e10cSrcweir switch (eState)
172cdf0e10cSrcweir {
173cdf0e10cSrcweir case e_std: SetResult(done, stay);
174cdf0e10cSrcweir break;
175cdf0e10cSrcweir case need_finish:
176cdf0e10cSrcweir SetResult(done, pop_success);
177cdf0e10cSrcweir eState = e_none;
178cdf0e10cSrcweir break;
179cdf0e10cSrcweir default:
180cdf0e10cSrcweir On_Default();
181cdf0e10cSrcweir } // end switch
182cdf0e10cSrcweir break;
183cdf0e10cSrcweir case TokPunctuation::Colon:
184cdf0e10cSrcweir switch (eState)
185cdf0e10cSrcweir {
186cdf0e10cSrcweir case need_curlbr_open:
187cdf0e10cSrcweir SetResult(done, push_sure, pPE_Type.Ptr());
188cdf0e10cSrcweir eState = in_base_interface;
189cdf0e10cSrcweir break;
190cdf0e10cSrcweir default:
191cdf0e10cSrcweir On_Default();
192cdf0e10cSrcweir } // end switch
193cdf0e10cSrcweir break;
194cdf0e10cSrcweir default:
195cdf0e10cSrcweir On_Default();
196cdf0e10cSrcweir } // end switch
197cdf0e10cSrcweir }
198cdf0e10cSrcweir
199cdf0e10cSrcweir void
Process_Default()200cdf0e10cSrcweir PE_Singleton::Process_Default()
201cdf0e10cSrcweir {
202cdf0e10cSrcweir On_Default();
203cdf0e10cSrcweir }
204cdf0e10cSrcweir
205cdf0e10cSrcweir
206cdf0e10cSrcweir void
On_Default()207cdf0e10cSrcweir PE_Singleton::On_Default()
208cdf0e10cSrcweir {
209cdf0e10cSrcweir SetResult(not_done, pop_failure);
210cdf0e10cSrcweir }
211cdf0e10cSrcweir
212cdf0e10cSrcweir void
InitData()213cdf0e10cSrcweir PE_Singleton::InitData()
214cdf0e10cSrcweir {
215cdf0e10cSrcweir eState = need_name;
216cdf0e10cSrcweir sData_Name.clear();
217cdf0e10cSrcweir bIsPreDeclaration = false;
218cdf0e10cSrcweir pCurSingleton = 0;
219cdf0e10cSrcweir pCurSiSingleton = 0;
220cdf0e10cSrcweir nCurParsed_Type = 0;
221cdf0e10cSrcweir }
222cdf0e10cSrcweir
223cdf0e10cSrcweir void
TransferData()224cdf0e10cSrcweir PE_Singleton::TransferData()
225cdf0e10cSrcweir {
226cdf0e10cSrcweir if (NOT bIsPreDeclaration)
227cdf0e10cSrcweir {
228*a0d53b35SJürgen Schmidt csv_assert(! sData_Name.empty());
229cdf0e10cSrcweir csv_assert( (pCurSingleton != 0) != (pCurSiSingleton != 0) );
230cdf0e10cSrcweir }
231cdf0e10cSrcweir
232cdf0e10cSrcweir eState = e_none;
233cdf0e10cSrcweir }
234cdf0e10cSrcweir
235cdf0e10cSrcweir void
ReceiveData()236cdf0e10cSrcweir PE_Singleton::ReceiveData()
237cdf0e10cSrcweir {
238cdf0e10cSrcweir switch (eState)
239cdf0e10cSrcweir {
240cdf0e10cSrcweir case in_service:
241cdf0e10cSrcweir pCurSingleton->Set_Service(nCurParsed_Type);
242cdf0e10cSrcweir nCurParsed_Type = 0;
243cdf0e10cSrcweir eState = e_std;
244cdf0e10cSrcweir break;
245cdf0e10cSrcweir case in_base_interface:
246cdf0e10cSrcweir pCurSiSingleton = &Gate().Ces().Store_SglIfcSingleton(
247cdf0e10cSrcweir CurNamespace().CeId(),
248cdf0e10cSrcweir sData_Name,
249cdf0e10cSrcweir nCurParsed_Type );
250cdf0e10cSrcweir PassDocuAt(*pCurSiSingleton);
251cdf0e10cSrcweir nCurParsed_Type = 0;
252cdf0e10cSrcweir eState = need_finish;
253cdf0e10cSrcweir break;
254cdf0e10cSrcweir default:
255cdf0e10cSrcweir csv_assert(false);
256cdf0e10cSrcweir } // end switch
257cdf0e10cSrcweir }
258cdf0e10cSrcweir
259cdf0e10cSrcweir UnoIDL_PE &
MyPE()260cdf0e10cSrcweir PE_Singleton::MyPE()
261cdf0e10cSrcweir {
262cdf0e10cSrcweir return *this;
263cdf0e10cSrcweir }
264cdf0e10cSrcweir
265cdf0e10cSrcweir } // namespace uidl
266cdf0e10cSrcweir } // namespace csi
267