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