update dev300-m57
[ooovba.git] / autodoc / source / parser_i / idl / pe_servi.cxx
blobf6dce28f70acc051721455cc89fd911d0f80556c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pe_servi.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <precomp.h>
32 #include <s2_luidl/pe_servi.hxx>
35 // NOT FULLY DEFINED SERVICES
36 #include <ary/idl/i_gate.hxx>
37 #include <ary/idl/i_service.hxx>
38 #include <ary/idl/i_siservice.hxx>
39 #include <ary/idl/ip_ce.hxx>
40 #include <ary/doc/d_oldidldocu.hxx>
41 #include <s2_luidl/pe_func2.hxx>
42 #include <s2_luidl/pe_property.hxx>
43 #include <s2_luidl/pe_type2.hxx>
44 #include <s2_luidl/tk_keyw.hxx>
45 #include <s2_luidl/tk_ident.hxx>
46 #include <s2_luidl/tk_punct.hxx>
50 namespace csi
52 namespace uidl
57 PE_Service::PE_Service()
58 : eState(e_none),
59 sData_Name(),
60 bIsPreDeclaration(false),
61 pCurService(0),
62 pCurSiService(0),
63 nCurService(0),
64 pPE_Property(0),
65 nCurParsed_Property(0),
66 pPE_Type(0),
67 nCurParsed_Type(0),
68 pPE_Constructor(0),
69 bOptionalMember(false)
71 pPE_Property = new PE_Property(nCurService);
72 pPE_Type = new PE_Type(nCurParsed_Type);
73 pPE_Constructor = new PE_Function(nCurService, PE_Function::constructor);
76 void
77 PE_Service::EstablishContacts( UnoIDL_PE * io_pParentPE,
78 ary::Repository & io_rRepository,
79 TokenProcessing_Result & o_rResult )
81 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
82 pPE_Property->EstablishContacts(this,io_rRepository,o_rResult);
83 pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
84 pPE_Constructor->EstablishContacts(this,io_rRepository,o_rResult);
87 PE_Service::~PE_Service()
91 void
92 PE_Service::ProcessToken( const Token & i_rToken )
94 i_rToken.Trigger(*this);
98 void
99 PE_Service::Process_MetaType( const TokMetaType & i_rToken )
101 switch ( i_rToken.Id() )
103 case TokMetaType::mt_service:
104 if (eState == need_name)
105 SetResult(done, stay );
106 else if (eState == e_std)
108 SetResult(done, push_sure, pPE_Type.Ptr());
109 eState = in_service_type;
111 else
112 On_Default();
113 break;
114 case TokMetaType::mt_interface:
115 if (eState == e_std)
117 SetResult(done, push_sure, pPE_Type.Ptr());
118 eState = in_ifc_type;
120 else
121 On_Default();
122 break;
123 case TokMetaType::mt_property:
124 if (eState == e_std)
126 StartProperty();
128 else
129 On_Default();
130 break;
131 default:
132 // KORR_FUTURE:
133 // Should throw syntax error warning.
135 } // end switch
138 void
139 PE_Service::Process_Identifier( const TokIdentifier & i_rToken )
141 if (eState == need_name)
143 sData_Name = i_rToken.Text();
144 SetResult(done, stay);
145 eState = need_curlbr_open;
147 else if (eState == e_std_sib)
149 SetResult(not_done, push_sure, pPE_Constructor.Ptr());
151 else
152 On_Default();
155 void
156 PE_Service::Process_Punctuation( const TokPunctuation & i_rToken )
158 switch (i_rToken.Id())
160 case TokPunctuation::Colon:
161 if (eState == need_curlbr_open)
163 SetResult(done, push_sure, pPE_Type.Ptr());
164 eState = need_base_interface;
166 else
167 On_Default();
168 break;
170 case TokPunctuation::CurledBracketOpen:
171 if (eState == need_curlbr_open)
173 pCurService = &Gate().Ces().Store_Service(
174 CurNamespace().CeId(),
175 sData_Name );
176 nCurService = pCurService->CeId();
177 PassDocuAt(*pCurService);
178 SetResult(done, stay);
179 eState = e_std;
181 else if (eState == need_curlbr_open_sib)
183 SetResult(done, stay);
184 eState = e_std_sib;
186 else
187 On_Default();
188 break;
189 case TokPunctuation::CurledBracketClose:
190 if (eState == e_std OR eState == e_std_sib)
192 SetResult(done, stay);
193 eState = need_finish;
195 else
196 On_Default();
197 break;
198 case TokPunctuation::Comma:
199 if (eState == expect_ifc_separator)
201 SetResult(done, push_sure, pPE_Type.Ptr());
202 eState = in_ifc_type;
204 else if (eState == expect_service_separator)
206 SetResult(done, push_sure, pPE_Type.Ptr());
207 eState = in_service_type;
209 else if (eState == e_std)
211 SetResult(done, stay);
213 else
214 On_Default();
215 break;
216 case TokPunctuation::Semicolon:
217 switch (eState)
219 case need_curlbr_open:
220 sData_Name.clear();
221 bIsPreDeclaration = true;
222 SetResult(done, pop_success);
223 eState = e_none;
224 break;
225 case need_curlbr_open_sib:
226 SetResult(done, pop_success);
227 eState = e_none;
228 break;
229 case expect_ifc_separator:
230 case expect_service_separator:
231 SetResult(done, stay);
232 eState = e_std;
233 break;
234 case need_finish:
235 SetResult(done, pop_success);
236 eState = e_none;
237 break;
238 case at_ignore:
239 SetResult(done, stay);
240 eState = e_std;
241 break;
242 default:
243 On_Default();
244 } // end switch
245 break;
246 default:
247 On_Default();
248 } // end switch
251 void
252 PE_Service::Process_Stereotype( const TokStereotype & i_rToken )
254 if (i_rToken.Id() == TokStereotype::ste_optional)
256 bOptionalMember = true;
257 SetResult(done, stay);
259 else if ( eState == e_std )
261 StartProperty();
263 else
264 On_Default();
267 void
268 PE_Service::Process_Needs()
270 SetResult(done,stay);
271 eState = at_ignore;
274 void
275 PE_Service::Process_Observes()
277 SetResult(done,stay);
278 eState = at_ignore;
281 void
282 PE_Service::Process_Default()
284 On_Default();
288 void
289 PE_Service::On_Default()
291 if (eState == at_ignore)
292 SetResult(done, stay);
293 else
294 SetResult(not_done, pop_failure);
297 void
298 PE_Service::InitData()
300 eState = need_name;
301 sData_Name.clear();
302 bIsPreDeclaration = false;
303 pCurService = 0;
304 pCurSiService = 0;
305 nCurService = 0;
306 nCurParsed_Property = 0;
307 nCurParsed_Type = 0;
308 bOptionalMember = false;
311 void
312 PE_Service::TransferData()
314 if (NOT bIsPreDeclaration)
316 csv_assert(sData_Name.size() > 0);
317 csv_assert( (pCurService != 0) != (pCurSiService != 0) );
320 eState = e_none;
323 void
324 PE_Service::ReceiveData()
326 switch (eState)
328 case in_property:
329 eState = e_std;
330 break;
331 case in_ifc_type:
332 if (bOptionalMember)
334 pPE_Type->SetOptional();
336 pCurService->AddRef_SupportedInterface(
337 nCurParsed_Type,
338 pPE_Type->ReleaseDocu());
339 nCurParsed_Type = 0;
340 eState = expect_ifc_separator;
341 break;
342 case in_service_type:
343 if (bOptionalMember)
345 pPE_Type->SetOptional();
347 pCurService->AddRef_IncludedService(
348 nCurParsed_Type,
349 pPE_Type->ReleaseDocu());
350 nCurParsed_Type = 0;
351 eState = expect_service_separator;
352 break;
353 case need_base_interface:
354 pCurSiService = &Gate().Ces().Store_SglIfcService(
355 CurNamespace().CeId(),
356 sData_Name,
357 nCurParsed_Type );
358 nCurService = pCurSiService->CeId();
359 PassDocuAt(*pCurSiService);
361 nCurParsed_Type = 0;
362 eState = need_curlbr_open_sib;
363 break;
364 case e_std_sib:
365 break;
366 default:
367 csv_assert(false);
370 bOptionalMember = false;
374 UnoIDL_PE &
375 PE_Service::MyPE()
377 return *this;
380 void
381 PE_Service::StartProperty()
383 SetResult(not_done, push_sure, pPE_Property.Ptr());
384 eState = in_property;
386 if (bOptionalMember)
388 pPE_Property->PresetOptional();
389 bOptionalMember = false;
394 } // namespace uidl
395 } // namespace csi