xref: /trunk/main/autodoc/source/parser_i/idl/pe_servi.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
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
10cdf0e10cSrcweir  *
1178bc99aaSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
2078bc99aaSAndrew Rist  *************************************************************/
21cdf0e10cSrcweir 
22cdf0e10cSrcweir #include <precomp.h>
23cdf0e10cSrcweir #include <s2_luidl/pe_servi.hxx>
24cdf0e10cSrcweir 
25cdf0e10cSrcweir 
26cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
27cdf0e10cSrcweir #include <ary/idl/i_gate.hxx>
28cdf0e10cSrcweir #include <ary/idl/i_service.hxx>
29cdf0e10cSrcweir #include <ary/idl/i_siservice.hxx>
30cdf0e10cSrcweir #include <ary/idl/ip_ce.hxx>
31cdf0e10cSrcweir #include <ary/doc/d_oldidldocu.hxx>
32cdf0e10cSrcweir #include <s2_luidl/pe_func2.hxx>
33cdf0e10cSrcweir #include <s2_luidl/pe_property.hxx>
34cdf0e10cSrcweir #include <s2_luidl/pe_type2.hxx>
35cdf0e10cSrcweir #include <s2_luidl/tk_keyw.hxx>
36cdf0e10cSrcweir #include <s2_luidl/tk_ident.hxx>
37cdf0e10cSrcweir #include <s2_luidl/tk_punct.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir 
40cdf0e10cSrcweir 
41cdf0e10cSrcweir namespace csi
42cdf0e10cSrcweir {
43cdf0e10cSrcweir namespace uidl
44cdf0e10cSrcweir {
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 
PE_Service()48cdf0e10cSrcweir PE_Service::PE_Service()
49cdf0e10cSrcweir     :   eState(e_none),
50cdf0e10cSrcweir         sData_Name(),
51cdf0e10cSrcweir         bIsPreDeclaration(false),
52cdf0e10cSrcweir         pCurService(0),
53cdf0e10cSrcweir         pCurSiService(0),
54cdf0e10cSrcweir         nCurService(0),
55cdf0e10cSrcweir         pPE_Property(0),
56cdf0e10cSrcweir         nCurParsed_Property(0),
57cdf0e10cSrcweir         pPE_Type(0),
58cdf0e10cSrcweir         nCurParsed_Type(0),
59cdf0e10cSrcweir         pPE_Constructor(0),
60cdf0e10cSrcweir         bOptionalMember(false)
61cdf0e10cSrcweir {
62cdf0e10cSrcweir     pPE_Property    = new PE_Property(nCurService);
63cdf0e10cSrcweir     pPE_Type        = new PE_Type(nCurParsed_Type);
64cdf0e10cSrcweir     pPE_Constructor = new PE_Function(nCurService, PE_Function::constructor);
65cdf0e10cSrcweir }
66cdf0e10cSrcweir 
67cdf0e10cSrcweir void
EstablishContacts(UnoIDL_PE * io_pParentPE,ary::Repository & io_rRepository,TokenProcessing_Result & o_rResult)68cdf0e10cSrcweir PE_Service::EstablishContacts( UnoIDL_PE *              io_pParentPE,
69cdf0e10cSrcweir                                ary::Repository &        io_rRepository,
70cdf0e10cSrcweir                                TokenProcessing_Result & o_rResult )
71cdf0e10cSrcweir {
72cdf0e10cSrcweir     UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
73cdf0e10cSrcweir     pPE_Property->EstablishContacts(this,io_rRepository,o_rResult);
74cdf0e10cSrcweir     pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
75cdf0e10cSrcweir     pPE_Constructor->EstablishContacts(this,io_rRepository,o_rResult);
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
~PE_Service()78cdf0e10cSrcweir PE_Service::~PE_Service()
79cdf0e10cSrcweir {
80cdf0e10cSrcweir }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir void
ProcessToken(const Token & i_rToken)83cdf0e10cSrcweir PE_Service::ProcessToken( const Token & i_rToken )
84cdf0e10cSrcweir {
85cdf0e10cSrcweir     i_rToken.Trigger(*this);
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 
89cdf0e10cSrcweir void
Process_MetaType(const TokMetaType & i_rToken)90cdf0e10cSrcweir PE_Service::Process_MetaType( const TokMetaType &   i_rToken )
91cdf0e10cSrcweir {
92cdf0e10cSrcweir     switch ( i_rToken.Id() )
93cdf0e10cSrcweir     {
94cdf0e10cSrcweir         case TokMetaType::mt_service:
95cdf0e10cSrcweir                     if (eState == need_name)
96cdf0e10cSrcweir                         SetResult(done, stay );
97cdf0e10cSrcweir                     else if (eState == e_std)
98cdf0e10cSrcweir                     {
99cdf0e10cSrcweir                         SetResult(done, push_sure, pPE_Type.Ptr());
100cdf0e10cSrcweir                         eState = in_service_type;
101cdf0e10cSrcweir                     }
102cdf0e10cSrcweir                     else
103cdf0e10cSrcweir                         On_Default();
104cdf0e10cSrcweir                     break;
105cdf0e10cSrcweir         case TokMetaType::mt_interface:
106cdf0e10cSrcweir                     if (eState == e_std)
107cdf0e10cSrcweir                     {
108cdf0e10cSrcweir                         SetResult(done, push_sure, pPE_Type.Ptr());
109cdf0e10cSrcweir                         eState = in_ifc_type;
110cdf0e10cSrcweir                     }
111cdf0e10cSrcweir                     else
112cdf0e10cSrcweir                         On_Default();
113cdf0e10cSrcweir                     break;
114cdf0e10cSrcweir         case TokMetaType::mt_property:
115cdf0e10cSrcweir                     if (eState == e_std)
116cdf0e10cSrcweir                     {
117cdf0e10cSrcweir                         StartProperty();
118cdf0e10cSrcweir                     }
119cdf0e10cSrcweir                     else
120cdf0e10cSrcweir                         On_Default();
121cdf0e10cSrcweir                     break;
122cdf0e10cSrcweir         default:
123cdf0e10cSrcweir             // KORR_FUTURE:
124cdf0e10cSrcweir             // Should throw syntax error warning.
125cdf0e10cSrcweir                     ;
126cdf0e10cSrcweir     }   // end switch
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir void
Process_Identifier(const TokIdentifier & i_rToken)130cdf0e10cSrcweir PE_Service::Process_Identifier( const TokIdentifier & i_rToken )
131cdf0e10cSrcweir {
132cdf0e10cSrcweir     if (eState == need_name)
133cdf0e10cSrcweir     {
134cdf0e10cSrcweir         sData_Name = i_rToken.Text();
135cdf0e10cSrcweir         SetResult(done, stay);
136cdf0e10cSrcweir         eState = need_curlbr_open;
137cdf0e10cSrcweir     }
138cdf0e10cSrcweir     else if (eState == e_std_sib)
139cdf0e10cSrcweir     {
140cdf0e10cSrcweir         SetResult(not_done, push_sure, pPE_Constructor.Ptr());
141cdf0e10cSrcweir     }
142cdf0e10cSrcweir     else
143cdf0e10cSrcweir         On_Default();
144cdf0e10cSrcweir }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir void
Process_Punctuation(const TokPunctuation & i_rToken)147cdf0e10cSrcweir PE_Service::Process_Punctuation( const TokPunctuation & i_rToken )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir     switch (i_rToken.Id())
150cdf0e10cSrcweir     {
151cdf0e10cSrcweir         case TokPunctuation::Colon:
152cdf0e10cSrcweir                     if (eState == need_curlbr_open)
153cdf0e10cSrcweir                     {
154cdf0e10cSrcweir                         SetResult(done, push_sure, pPE_Type.Ptr());
155cdf0e10cSrcweir                         eState = need_base_interface;
156cdf0e10cSrcweir                     }
157cdf0e10cSrcweir                     else
158cdf0e10cSrcweir                         On_Default();
159cdf0e10cSrcweir                     break;
160cdf0e10cSrcweir 
161cdf0e10cSrcweir         case TokPunctuation::CurledBracketOpen:
162cdf0e10cSrcweir                     if (eState == need_curlbr_open)
163cdf0e10cSrcweir                     {
164cdf0e10cSrcweir                         pCurService = &Gate().Ces().Store_Service(
165cdf0e10cSrcweir                                                         CurNamespace().CeId(),
166cdf0e10cSrcweir                                                         sData_Name );
167cdf0e10cSrcweir                         nCurService = pCurService->CeId();
168cdf0e10cSrcweir                         PassDocuAt(*pCurService);
169cdf0e10cSrcweir                         SetResult(done, stay);
170cdf0e10cSrcweir                         eState = e_std;
171cdf0e10cSrcweir                     }
172cdf0e10cSrcweir                     else if (eState == need_curlbr_open_sib)
173cdf0e10cSrcweir                     {
174cdf0e10cSrcweir                         SetResult(done, stay);
175cdf0e10cSrcweir                         eState = e_std_sib;
176cdf0e10cSrcweir                     }
177cdf0e10cSrcweir                     else
178cdf0e10cSrcweir                         On_Default();
179cdf0e10cSrcweir                     break;
180cdf0e10cSrcweir         case TokPunctuation::CurledBracketClose:
181cdf0e10cSrcweir                     if (eState == e_std OR eState == e_std_sib)
182cdf0e10cSrcweir                     {
183cdf0e10cSrcweir                         SetResult(done, stay);
184cdf0e10cSrcweir                         eState = need_finish;
185cdf0e10cSrcweir                     }
186cdf0e10cSrcweir                     else
187cdf0e10cSrcweir                         On_Default();
188cdf0e10cSrcweir                     break;
189cdf0e10cSrcweir         case TokPunctuation::Comma:
190cdf0e10cSrcweir                     if (eState == expect_ifc_separator)
191cdf0e10cSrcweir                     {
192cdf0e10cSrcweir                         SetResult(done, push_sure, pPE_Type.Ptr());
193cdf0e10cSrcweir                         eState = in_ifc_type;
194cdf0e10cSrcweir                     }
195cdf0e10cSrcweir                     else if (eState == expect_service_separator)
196cdf0e10cSrcweir                     {
197cdf0e10cSrcweir                         SetResult(done, push_sure, pPE_Type.Ptr());
198cdf0e10cSrcweir                         eState = in_service_type;
199cdf0e10cSrcweir                     }
200cdf0e10cSrcweir                     else if (eState == e_std)
201cdf0e10cSrcweir                     {
202cdf0e10cSrcweir                         SetResult(done, stay);
203cdf0e10cSrcweir                     }
204cdf0e10cSrcweir                     else
205cdf0e10cSrcweir                         On_Default();
206cdf0e10cSrcweir                     break;
207cdf0e10cSrcweir         case TokPunctuation::Semicolon:
208cdf0e10cSrcweir                     switch (eState)
209cdf0e10cSrcweir                     {
210cdf0e10cSrcweir                        case need_curlbr_open:
211cdf0e10cSrcweir                                     sData_Name.clear();
212cdf0e10cSrcweir                                     bIsPreDeclaration = true;
213cdf0e10cSrcweir                                     SetResult(done, pop_success);
214cdf0e10cSrcweir                                     eState = e_none;
215cdf0e10cSrcweir                                     break;
216cdf0e10cSrcweir                        case need_curlbr_open_sib:
217cdf0e10cSrcweir                                     SetResult(done, pop_success);
218cdf0e10cSrcweir                                     eState = e_none;
219cdf0e10cSrcweir                                     break;
220cdf0e10cSrcweir                        case expect_ifc_separator:
221cdf0e10cSrcweir                        case expect_service_separator:
222cdf0e10cSrcweir                                     SetResult(done, stay);
223cdf0e10cSrcweir                                     eState = e_std;
224cdf0e10cSrcweir                                     break;
225cdf0e10cSrcweir                        case need_finish:
226cdf0e10cSrcweir                                     SetResult(done, pop_success);
227cdf0e10cSrcweir                                     eState = e_none;
228cdf0e10cSrcweir                                     break;
229cdf0e10cSrcweir                        case at_ignore:
230cdf0e10cSrcweir                                     SetResult(done, stay);
231cdf0e10cSrcweir                                     eState = e_std;
232cdf0e10cSrcweir                                     break;
233cdf0e10cSrcweir                        default:
234cdf0e10cSrcweir                                     On_Default();
235cdf0e10cSrcweir                     }   // end switch
236cdf0e10cSrcweir                     break;
237cdf0e10cSrcweir         default:
238cdf0e10cSrcweir                     On_Default();
239cdf0e10cSrcweir     }   // end switch
240cdf0e10cSrcweir }
241cdf0e10cSrcweir 
242cdf0e10cSrcweir void
Process_Stereotype(const TokStereotype & i_rToken)243cdf0e10cSrcweir PE_Service::Process_Stereotype( const TokStereotype & i_rToken )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir     if (i_rToken.Id() == TokStereotype::ste_optional)
246cdf0e10cSrcweir     {
247cdf0e10cSrcweir         bOptionalMember = true;
248cdf0e10cSrcweir         SetResult(done, stay);
249cdf0e10cSrcweir     }
250cdf0e10cSrcweir     else if ( eState == e_std )
251cdf0e10cSrcweir     {
252cdf0e10cSrcweir         StartProperty();
253cdf0e10cSrcweir     }
254cdf0e10cSrcweir     else
255cdf0e10cSrcweir         On_Default();
256cdf0e10cSrcweir }
257cdf0e10cSrcweir 
258cdf0e10cSrcweir void
Process_Needs()259cdf0e10cSrcweir PE_Service::Process_Needs()
260cdf0e10cSrcweir {
261cdf0e10cSrcweir     SetResult(done,stay);
262cdf0e10cSrcweir     eState = at_ignore;
263cdf0e10cSrcweir }
264cdf0e10cSrcweir 
265cdf0e10cSrcweir void
Process_Observes()266cdf0e10cSrcweir PE_Service::Process_Observes()
267cdf0e10cSrcweir {
268cdf0e10cSrcweir     SetResult(done,stay);
269cdf0e10cSrcweir     eState = at_ignore;
270cdf0e10cSrcweir }
271cdf0e10cSrcweir 
272cdf0e10cSrcweir void
Process_Default()273cdf0e10cSrcweir PE_Service::Process_Default()
274cdf0e10cSrcweir {
275cdf0e10cSrcweir     On_Default();
276cdf0e10cSrcweir }
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 
279cdf0e10cSrcweir void
On_Default()280cdf0e10cSrcweir PE_Service::On_Default()
281cdf0e10cSrcweir {
282cdf0e10cSrcweir     if (eState == at_ignore)
283cdf0e10cSrcweir         SetResult(done, stay);
284cdf0e10cSrcweir     else
285cdf0e10cSrcweir         SetResult(not_done, pop_failure);
286cdf0e10cSrcweir }
287cdf0e10cSrcweir 
288cdf0e10cSrcweir void
InitData()289cdf0e10cSrcweir PE_Service::InitData()
290cdf0e10cSrcweir {
291cdf0e10cSrcweir     eState = need_name;
292cdf0e10cSrcweir     sData_Name.clear();
293cdf0e10cSrcweir     bIsPreDeclaration = false;
294cdf0e10cSrcweir     pCurService = 0;
295cdf0e10cSrcweir     pCurSiService = 0;
296cdf0e10cSrcweir     nCurService = 0;
297cdf0e10cSrcweir     nCurParsed_Property = 0;
298cdf0e10cSrcweir     nCurParsed_Type = 0;
299cdf0e10cSrcweir     bOptionalMember = false;
300cdf0e10cSrcweir }
301cdf0e10cSrcweir 
302cdf0e10cSrcweir void
TransferData()303cdf0e10cSrcweir PE_Service::TransferData()
304cdf0e10cSrcweir {
305cdf0e10cSrcweir     if (NOT bIsPreDeclaration)
306cdf0e10cSrcweir     {
307*a0d53b35SJürgen Schmidt         csv_assert(! sData_Name.empty());
308cdf0e10cSrcweir         csv_assert( (pCurService != 0) != (pCurSiService != 0) );
309cdf0e10cSrcweir     }
310cdf0e10cSrcweir 
311cdf0e10cSrcweir     eState = e_none;
312cdf0e10cSrcweir }
313cdf0e10cSrcweir 
314cdf0e10cSrcweir void
ReceiveData()315cdf0e10cSrcweir PE_Service::ReceiveData()
316cdf0e10cSrcweir {
317cdf0e10cSrcweir     switch (eState)
318cdf0e10cSrcweir     {
319cdf0e10cSrcweir         case in_property:
320cdf0e10cSrcweir                 eState = e_std;
321cdf0e10cSrcweir                 break;
322cdf0e10cSrcweir         case in_ifc_type:
323cdf0e10cSrcweir                 if (bOptionalMember)
324cdf0e10cSrcweir                 {
325cdf0e10cSrcweir                     pPE_Type->SetOptional();
326cdf0e10cSrcweir                 }
327cdf0e10cSrcweir                 pCurService->AddRef_SupportedInterface(
328cdf0e10cSrcweir                                     nCurParsed_Type,
329cdf0e10cSrcweir                                     pPE_Type->ReleaseDocu());
330cdf0e10cSrcweir                 nCurParsed_Type = 0;
331cdf0e10cSrcweir                 eState = expect_ifc_separator;
332cdf0e10cSrcweir                 break;
333cdf0e10cSrcweir         case in_service_type:
334cdf0e10cSrcweir                 if (bOptionalMember)
335cdf0e10cSrcweir                 {
336cdf0e10cSrcweir                     pPE_Type->SetOptional();
337cdf0e10cSrcweir                 }
338cdf0e10cSrcweir                 pCurService->AddRef_IncludedService(
339cdf0e10cSrcweir                                     nCurParsed_Type,
340cdf0e10cSrcweir                                     pPE_Type->ReleaseDocu());
341cdf0e10cSrcweir                 nCurParsed_Type = 0;
342cdf0e10cSrcweir                 eState = expect_service_separator;
343cdf0e10cSrcweir                 break;
344cdf0e10cSrcweir         case need_base_interface:
345cdf0e10cSrcweir                 pCurSiService = &Gate().Ces().Store_SglIfcService(
346cdf0e10cSrcweir                                                 CurNamespace().CeId(),
347cdf0e10cSrcweir                                                 sData_Name,
348cdf0e10cSrcweir                                                 nCurParsed_Type );
349cdf0e10cSrcweir                 nCurService = pCurSiService->CeId();
350cdf0e10cSrcweir                 PassDocuAt(*pCurSiService);
351cdf0e10cSrcweir 
352cdf0e10cSrcweir                 nCurParsed_Type = 0;
353cdf0e10cSrcweir                 eState = need_curlbr_open_sib;
354cdf0e10cSrcweir                 break;
355cdf0e10cSrcweir         case e_std_sib:
356cdf0e10cSrcweir                 break;
357cdf0e10cSrcweir         default:
358cdf0e10cSrcweir             csv_assert(false);
359cdf0e10cSrcweir     }
360cdf0e10cSrcweir 
361cdf0e10cSrcweir     bOptionalMember = false;
362cdf0e10cSrcweir }
363cdf0e10cSrcweir 
364cdf0e10cSrcweir 
365cdf0e10cSrcweir UnoIDL_PE &
MyPE()366cdf0e10cSrcweir PE_Service::MyPE()
367cdf0e10cSrcweir {
368cdf0e10cSrcweir     return *this;
369cdf0e10cSrcweir }
370cdf0e10cSrcweir 
371cdf0e10cSrcweir void
StartProperty()372cdf0e10cSrcweir PE_Service::StartProperty()
373cdf0e10cSrcweir {
374cdf0e10cSrcweir     SetResult(not_done, push_sure, pPE_Property.Ptr());
375cdf0e10cSrcweir     eState = in_property;
376cdf0e10cSrcweir 
377cdf0e10cSrcweir     if (bOptionalMember)
378cdf0e10cSrcweir     {
379cdf0e10cSrcweir         pPE_Property->PresetOptional();
380cdf0e10cSrcweir         bOptionalMember = false;
381cdf0e10cSrcweir     }
382cdf0e10cSrcweir }
383cdf0e10cSrcweir 
384cdf0e10cSrcweir 
385cdf0e10cSrcweir }   // namespace uidl
386cdf0e10cSrcweir }   // namespace csi
387