Updated core
[LibreOffice.git] / autodoc / source / parser_i / idl / pe_servi.cxx
blob2b35c4327dcb56cb2912821c3ce174389b7f5f54
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <precomp.h>
21 #include <s2_luidl/pe_servi.hxx>
24 // NOT FULLY DEFINED SERVICES
25 #include <ary/idl/i_gate.hxx>
26 #include <ary/idl/i_service.hxx>
27 #include <ary/idl/i_siservice.hxx>
28 #include <ary/idl/ip_ce.hxx>
29 #include <ary/doc/d_oldidldocu.hxx>
30 #include <s2_luidl/pe_func2.hxx>
31 #include <s2_luidl/pe_property.hxx>
32 #include <s2_luidl/pe_type2.hxx>
33 #include <s2_luidl/tk_keyw.hxx>
34 #include <s2_luidl/tk_ident.hxx>
35 #include <s2_luidl/tk_punct.hxx>
39 namespace csi
41 namespace uidl
46 PE_Service::PE_Service()
47 : eState(e_none),
48 sData_Name(),
49 bIsPreDeclaration(false),
50 pCurService(0),
51 pCurSiService(0),
52 nCurService(0),
53 pPE_Property(0),
54 nCurParsed_Property(0),
55 pPE_Type(0),
56 nCurParsed_Type(0),
57 pPE_Constructor(0),
58 bOptionalMember(false)
60 pPE_Property = new PE_Property(nCurService);
61 pPE_Type = new PE_Type(nCurParsed_Type);
62 pPE_Constructor = new PE_Function(nCurService, PE_Function::constructor);
65 void
66 PE_Service::EstablishContacts( UnoIDL_PE * io_pParentPE,
67 ary::Repository & io_rRepository,
68 TokenProcessing_Result & o_rResult )
70 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
71 pPE_Property->EstablishContacts(this,io_rRepository,o_rResult);
72 pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
73 pPE_Constructor->EstablishContacts(this,io_rRepository,o_rResult);
76 PE_Service::~PE_Service()
80 void
81 PE_Service::ProcessToken( const Token & i_rToken )
83 i_rToken.Trigger(*this);
87 void
88 PE_Service::Process_MetaType( const TokMetaType & i_rToken )
90 switch ( i_rToken.Id() )
92 case TokMetaType::mt_service:
93 if (eState == need_name)
94 SetResult(done, stay );
95 else if (eState == e_std)
97 SetResult(done, push_sure, pPE_Type.Ptr());
98 eState = in_service_type;
100 else
101 On_Default();
102 break;
103 case TokMetaType::mt_interface:
104 if (eState == e_std)
106 SetResult(done, push_sure, pPE_Type.Ptr());
107 eState = in_ifc_type;
109 else
110 On_Default();
111 break;
112 case TokMetaType::mt_property:
113 if (eState == e_std)
115 StartProperty();
117 else
118 On_Default();
119 break;
120 default:
121 // KORR_FUTURE:
122 // Should throw syntax error warning.
124 } // end switch
127 void
128 PE_Service::Process_Identifier( const TokIdentifier & i_rToken )
130 if (eState == need_name)
132 sData_Name = i_rToken.Text();
133 SetResult(done, stay);
134 eState = need_curlbr_open;
136 else if (eState == e_std_sib)
138 SetResult(not_done, push_sure, pPE_Constructor.Ptr());
140 else
141 On_Default();
144 void
145 PE_Service::Process_Punctuation( const TokPunctuation & i_rToken )
147 switch (i_rToken.Id())
149 case TokPunctuation::Colon:
150 if (eState == need_curlbr_open)
152 SetResult(done, push_sure, pPE_Type.Ptr());
153 eState = need_base_interface;
155 else
156 On_Default();
157 break;
159 case TokPunctuation::CurledBracketOpen:
160 if (eState == need_curlbr_open)
162 pCurService = &Gate().Ces().Store_Service(
163 CurNamespace().CeId(),
164 sData_Name );
165 nCurService = pCurService->CeId();
166 PassDocuAt(*pCurService);
167 SetResult(done, stay);
168 eState = e_std;
170 else if (eState == need_curlbr_open_sib)
172 SetResult(done, stay);
173 eState = e_std_sib;
175 else
176 On_Default();
177 break;
178 case TokPunctuation::CurledBracketClose:
179 if (eState == e_std OR eState == e_std_sib)
181 SetResult(done, stay);
182 eState = need_finish;
184 else
185 On_Default();
186 break;
187 case TokPunctuation::Comma:
188 if (eState == expect_ifc_separator)
190 SetResult(done, push_sure, pPE_Type.Ptr());
191 eState = in_ifc_type;
193 else if (eState == expect_service_separator)
195 SetResult(done, push_sure, pPE_Type.Ptr());
196 eState = in_service_type;
198 else if (eState == e_std)
200 SetResult(done, stay);
202 else
203 On_Default();
204 break;
205 case TokPunctuation::Semicolon:
206 switch (eState)
208 case need_curlbr_open:
209 sData_Name.clear();
210 bIsPreDeclaration = true;
211 SetResult(done, pop_success);
212 eState = e_none;
213 break;
214 case need_curlbr_open_sib:
215 SetResult(done, pop_success);
216 eState = e_none;
217 break;
218 case expect_ifc_separator:
219 case expect_service_separator:
220 SetResult(done, stay);
221 eState = e_std;
222 break;
223 case need_finish:
224 SetResult(done, pop_success);
225 eState = e_none;
226 break;
227 case at_ignore:
228 SetResult(done, stay);
229 eState = e_std;
230 break;
231 default:
232 On_Default();
233 } // end switch
234 break;
235 default:
236 On_Default();
237 } // end switch
240 void
241 PE_Service::Process_Stereotype( const TokStereotype & i_rToken )
243 if (i_rToken.Id() == TokStereotype::ste_optional)
245 bOptionalMember = true;
246 SetResult(done, stay);
248 else if ( eState == e_std )
250 StartProperty();
252 else
253 On_Default();
256 void
257 PE_Service::Process_Needs()
259 SetResult(done,stay);
260 eState = at_ignore;
263 void
264 PE_Service::Process_Observes()
266 SetResult(done,stay);
267 eState = at_ignore;
270 void
271 PE_Service::Process_Default()
273 On_Default();
277 void
278 PE_Service::On_Default()
280 if (eState == at_ignore)
281 SetResult(done, stay);
282 else
283 SetResult(not_done, pop_failure);
286 void
287 PE_Service::InitData()
289 eState = need_name;
290 sData_Name.clear();
291 bIsPreDeclaration = false;
292 pCurService = 0;
293 pCurSiService = 0;
294 nCurService = 0;
295 nCurParsed_Property = 0;
296 nCurParsed_Type = 0;
297 bOptionalMember = false;
300 void
301 PE_Service::TransferData()
303 if (NOT bIsPreDeclaration)
305 csv_assert(sData_Name.size() > 0);
306 csv_assert( (pCurService != 0) != (pCurSiService != 0) );
309 eState = e_none;
312 void
313 PE_Service::ReceiveData()
315 switch (eState)
317 case in_property:
318 eState = e_std;
319 break;
320 case in_ifc_type:
321 if (bOptionalMember)
323 pPE_Type->SetOptional();
325 pCurService->AddRef_SupportedInterface(
326 nCurParsed_Type,
327 pPE_Type->ReleaseDocu());
328 nCurParsed_Type = 0;
329 eState = expect_ifc_separator;
330 break;
331 case in_service_type:
332 if (bOptionalMember)
334 pPE_Type->SetOptional();
336 pCurService->AddRef_IncludedService(
337 nCurParsed_Type,
338 pPE_Type->ReleaseDocu());
339 nCurParsed_Type = 0;
340 eState = expect_service_separator;
341 break;
342 case need_base_interface:
343 pCurSiService = &Gate().Ces().Store_SglIfcService(
344 CurNamespace().CeId(),
345 sData_Name,
346 nCurParsed_Type );
347 nCurService = pCurSiService->CeId();
348 PassDocuAt(*pCurSiService);
350 nCurParsed_Type = 0;
351 eState = need_curlbr_open_sib;
352 break;
353 case e_std_sib:
354 break;
355 default:
356 csv_assert(false);
359 bOptionalMember = false;
363 UnoIDL_PE &
364 PE_Service::MyPE()
366 return *this;
369 void
370 PE_Service::StartProperty()
372 SetResult(not_done, push_sure, pPE_Property.Ptr());
373 eState = in_property;
375 if (bOptionalMember)
377 pPE_Property->PresetOptional();
378 bOptionalMember = false;
383 } // namespace uidl
384 } // namespace csi
386 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */