Bump for 3.6-28
[LibreOffice.git] / autodoc / source / parser_i / idl / pe_servi.cxx
bloba4209c58f7be0122594557eb0ad53ed7f507b6ed
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <precomp.h>
30 #include <s2_luidl/pe_servi.hxx>
33 // NOT FULLY DEFINED SERVICES
34 #include <ary/idl/i_gate.hxx>
35 #include <ary/idl/i_service.hxx>
36 #include <ary/idl/i_siservice.hxx>
37 #include <ary/idl/ip_ce.hxx>
38 #include <ary/doc/d_oldidldocu.hxx>
39 #include <s2_luidl/pe_func2.hxx>
40 #include <s2_luidl/pe_property.hxx>
41 #include <s2_luidl/pe_type2.hxx>
42 #include <s2_luidl/tk_keyw.hxx>
43 #include <s2_luidl/tk_ident.hxx>
44 #include <s2_luidl/tk_punct.hxx>
48 namespace csi
50 namespace uidl
55 PE_Service::PE_Service()
56 : eState(e_none),
57 sData_Name(),
58 bIsPreDeclaration(false),
59 pCurService(0),
60 pCurSiService(0),
61 nCurService(0),
62 pPE_Property(0),
63 nCurParsed_Property(0),
64 pPE_Type(0),
65 nCurParsed_Type(0),
66 pPE_Constructor(0),
67 bOptionalMember(false)
69 pPE_Property = new PE_Property(nCurService);
70 pPE_Type = new PE_Type(nCurParsed_Type);
71 pPE_Constructor = new PE_Function(nCurService, PE_Function::constructor);
74 void
75 PE_Service::EstablishContacts( UnoIDL_PE * io_pParentPE,
76 ary::Repository & io_rRepository,
77 TokenProcessing_Result & o_rResult )
79 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
80 pPE_Property->EstablishContacts(this,io_rRepository,o_rResult);
81 pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
82 pPE_Constructor->EstablishContacts(this,io_rRepository,o_rResult);
85 PE_Service::~PE_Service()
89 void
90 PE_Service::ProcessToken( const Token & i_rToken )
92 i_rToken.Trigger(*this);
96 void
97 PE_Service::Process_MetaType( const TokMetaType & i_rToken )
99 switch ( i_rToken.Id() )
101 case TokMetaType::mt_service:
102 if (eState == need_name)
103 SetResult(done, stay );
104 else if (eState == e_std)
106 SetResult(done, push_sure, pPE_Type.Ptr());
107 eState = in_service_type;
109 else
110 On_Default();
111 break;
112 case TokMetaType::mt_interface:
113 if (eState == e_std)
115 SetResult(done, push_sure, pPE_Type.Ptr());
116 eState = in_ifc_type;
118 else
119 On_Default();
120 break;
121 case TokMetaType::mt_property:
122 if (eState == e_std)
124 StartProperty();
126 else
127 On_Default();
128 break;
129 default:
130 // KORR_FUTURE:
131 // Should throw syntax error warning.
133 } // end switch
136 void
137 PE_Service::Process_Identifier( const TokIdentifier & i_rToken )
139 if (eState == need_name)
141 sData_Name = i_rToken.Text();
142 SetResult(done, stay);
143 eState = need_curlbr_open;
145 else if (eState == e_std_sib)
147 SetResult(not_done, push_sure, pPE_Constructor.Ptr());
149 else
150 On_Default();
153 void
154 PE_Service::Process_Punctuation( const TokPunctuation & i_rToken )
156 switch (i_rToken.Id())
158 case TokPunctuation::Colon:
159 if (eState == need_curlbr_open)
161 SetResult(done, push_sure, pPE_Type.Ptr());
162 eState = need_base_interface;
164 else
165 On_Default();
166 break;
168 case TokPunctuation::CurledBracketOpen:
169 if (eState == need_curlbr_open)
171 pCurService = &Gate().Ces().Store_Service(
172 CurNamespace().CeId(),
173 sData_Name );
174 nCurService = pCurService->CeId();
175 PassDocuAt(*pCurService);
176 SetResult(done, stay);
177 eState = e_std;
179 else if (eState == need_curlbr_open_sib)
181 SetResult(done, stay);
182 eState = e_std_sib;
184 else
185 On_Default();
186 break;
187 case TokPunctuation::CurledBracketClose:
188 if (eState == e_std OR eState == e_std_sib)
190 SetResult(done, stay);
191 eState = need_finish;
193 else
194 On_Default();
195 break;
196 case TokPunctuation::Comma:
197 if (eState == expect_ifc_separator)
199 SetResult(done, push_sure, pPE_Type.Ptr());
200 eState = in_ifc_type;
202 else if (eState == expect_service_separator)
204 SetResult(done, push_sure, pPE_Type.Ptr());
205 eState = in_service_type;
207 else if (eState == e_std)
209 SetResult(done, stay);
211 else
212 On_Default();
213 break;
214 case TokPunctuation::Semicolon:
215 switch (eState)
217 case need_curlbr_open:
218 sData_Name.clear();
219 bIsPreDeclaration = true;
220 SetResult(done, pop_success);
221 eState = e_none;
222 break;
223 case need_curlbr_open_sib:
224 SetResult(done, pop_success);
225 eState = e_none;
226 break;
227 case expect_ifc_separator:
228 case expect_service_separator:
229 SetResult(done, stay);
230 eState = e_std;
231 break;
232 case need_finish:
233 SetResult(done, pop_success);
234 eState = e_none;
235 break;
236 case at_ignore:
237 SetResult(done, stay);
238 eState = e_std;
239 break;
240 default:
241 On_Default();
242 } // end switch
243 break;
244 default:
245 On_Default();
246 } // end switch
249 void
250 PE_Service::Process_Stereotype( const TokStereotype & i_rToken )
252 if (i_rToken.Id() == TokStereotype::ste_optional)
254 bOptionalMember = true;
255 SetResult(done, stay);
257 else if ( eState == e_std )
259 StartProperty();
261 else
262 On_Default();
265 void
266 PE_Service::Process_Needs()
268 SetResult(done,stay);
269 eState = at_ignore;
272 void
273 PE_Service::Process_Observes()
275 SetResult(done,stay);
276 eState = at_ignore;
279 void
280 PE_Service::Process_Default()
282 On_Default();
286 void
287 PE_Service::On_Default()
289 if (eState == at_ignore)
290 SetResult(done, stay);
291 else
292 SetResult(not_done, pop_failure);
295 void
296 PE_Service::InitData()
298 eState = need_name;
299 sData_Name.clear();
300 bIsPreDeclaration = false;
301 pCurService = 0;
302 pCurSiService = 0;
303 nCurService = 0;
304 nCurParsed_Property = 0;
305 nCurParsed_Type = 0;
306 bOptionalMember = false;
309 void
310 PE_Service::TransferData()
312 if (NOT bIsPreDeclaration)
314 csv_assert(sData_Name.size() > 0);
315 csv_assert( (pCurService != 0) != (pCurSiService != 0) );
318 eState = e_none;
321 void
322 PE_Service::ReceiveData()
324 switch (eState)
326 case in_property:
327 eState = e_std;
328 break;
329 case in_ifc_type:
330 if (bOptionalMember)
332 pPE_Type->SetOptional();
334 pCurService->AddRef_SupportedInterface(
335 nCurParsed_Type,
336 pPE_Type->ReleaseDocu());
337 nCurParsed_Type = 0;
338 eState = expect_ifc_separator;
339 break;
340 case in_service_type:
341 if (bOptionalMember)
343 pPE_Type->SetOptional();
345 pCurService->AddRef_IncludedService(
346 nCurParsed_Type,
347 pPE_Type->ReleaseDocu());
348 nCurParsed_Type = 0;
349 eState = expect_service_separator;
350 break;
351 case need_base_interface:
352 pCurSiService = &Gate().Ces().Store_SglIfcService(
353 CurNamespace().CeId(),
354 sData_Name,
355 nCurParsed_Type );
356 nCurService = pCurSiService->CeId();
357 PassDocuAt(*pCurSiService);
359 nCurParsed_Type = 0;
360 eState = need_curlbr_open_sib;
361 break;
362 case e_std_sib:
363 break;
364 default:
365 csv_assert(false);
368 bOptionalMember = false;
372 UnoIDL_PE &
373 PE_Service::MyPE()
375 return *this;
378 void
379 PE_Service::StartProperty()
381 SetResult(not_done, push_sure, pPE_Property.Ptr());
382 eState = in_property;
384 if (bOptionalMember)
386 pPE_Property->PresetOptional();
387 bOptionalMember = false;
392 } // namespace uidl
393 } // namespace csi
395 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */