1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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>
46 PE_Service::PE_Service()
49 bIsPreDeclaration(false),
54 nCurParsed_Property(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
);
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()
81 PE_Service::ProcessToken( const Token
& i_rToken
)
83 i_rToken
.Trigger(*this);
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
;
103 case TokMetaType::mt_interface
:
106 SetResult(done
, push_sure
, pPE_Type
.Ptr());
107 eState
= in_ifc_type
;
112 case TokMetaType::mt_property
:
122 // Should throw syntax error warning.
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());
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
;
159 case TokPunctuation::CurledBracketOpen
:
160 if (eState
== need_curlbr_open
)
162 pCurService
= &Gate().Ces().Store_Service(
163 CurNamespace().CeId(),
165 nCurService
= pCurService
->CeId();
166 PassDocuAt(*pCurService
);
167 SetResult(done
, stay
);
170 else if (eState
== need_curlbr_open_sib
)
172 SetResult(done
, stay
);
178 case TokPunctuation::CurledBracketClose
:
179 if (eState
== e_std OR eState
== e_std_sib
)
181 SetResult(done
, stay
);
182 eState
= need_finish
;
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
);
205 case TokPunctuation::Semicolon
:
208 case need_curlbr_open
:
210 bIsPreDeclaration
= true;
211 SetResult(done
, pop_success
);
214 case need_curlbr_open_sib
:
215 SetResult(done
, pop_success
);
218 case expect_ifc_separator
:
219 case expect_service_separator
:
220 SetResult(done
, stay
);
224 SetResult(done
, pop_success
);
228 SetResult(done
, stay
);
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
)
257 PE_Service::Process_Needs()
259 SetResult(done
,stay
);
264 PE_Service::Process_Observes()
266 SetResult(done
,stay
);
271 PE_Service::Process_Default()
278 PE_Service::On_Default()
280 if (eState
== at_ignore
)
281 SetResult(done
, stay
);
283 SetResult(not_done
, pop_failure
);
287 PE_Service::InitData()
291 bIsPreDeclaration
= false;
295 nCurParsed_Property
= 0;
297 bOptionalMember
= false;
301 PE_Service::TransferData()
303 if (NOT bIsPreDeclaration
)
305 csv_assert(sData_Name
.size() > 0);
306 csv_assert( (pCurService
!= 0) != (pCurSiService
!= 0) );
313 PE_Service::ReceiveData()
323 pPE_Type
->SetOptional();
325 pCurService
->AddRef_SupportedInterface(
327 pPE_Type
->ReleaseDocu());
329 eState
= expect_ifc_separator
;
331 case in_service_type
:
334 pPE_Type
->SetOptional();
336 pCurService
->AddRef_IncludedService(
338 pPE_Type
->ReleaseDocu());
340 eState
= expect_service_separator
;
342 case need_base_interface
:
343 pCurSiService
= &Gate().Ces().Store_SglIfcService(
344 CurNamespace().CeId(),
347 nCurService
= pCurSiService
->CeId();
348 PassDocuAt(*pCurSiService
);
351 eState
= need_curlbr_open_sib
;
359 bOptionalMember
= false;
370 PE_Service::StartProperty()
372 SetResult(not_done
, push_sure
, pPE_Property
.Ptr());
373 eState
= in_property
;
377 pPE_Property
->PresetOptional();
378 bOptionalMember
= false;
386 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */