1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pe_servi.cxx,v $
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 ************************************************************************/
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>
57 PE_Service::PE_Service()
60 bIsPreDeclaration(false),
65 nCurParsed_Property(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
);
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()
92 PE_Service::ProcessToken( const Token
& i_rToken
)
94 i_rToken
.Trigger(*this);
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
;
114 case TokMetaType::mt_interface
:
117 SetResult(done
, push_sure
, pPE_Type
.Ptr());
118 eState
= in_ifc_type
;
123 case TokMetaType::mt_property
:
133 // Should throw syntax error warning.
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());
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
;
170 case TokPunctuation::CurledBracketOpen
:
171 if (eState
== need_curlbr_open
)
173 pCurService
= &Gate().Ces().Store_Service(
174 CurNamespace().CeId(),
176 nCurService
= pCurService
->CeId();
177 PassDocuAt(*pCurService
);
178 SetResult(done
, stay
);
181 else if (eState
== need_curlbr_open_sib
)
183 SetResult(done
, stay
);
189 case TokPunctuation::CurledBracketClose
:
190 if (eState
== e_std OR eState
== e_std_sib
)
192 SetResult(done
, stay
);
193 eState
= need_finish
;
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
);
216 case TokPunctuation::Semicolon
:
219 case need_curlbr_open
:
221 bIsPreDeclaration
= true;
222 SetResult(done
, pop_success
);
225 case need_curlbr_open_sib
:
226 SetResult(done
, pop_success
);
229 case expect_ifc_separator
:
230 case expect_service_separator
:
231 SetResult(done
, stay
);
235 SetResult(done
, pop_success
);
239 SetResult(done
, stay
);
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
)
268 PE_Service::Process_Needs()
270 SetResult(done
,stay
);
275 PE_Service::Process_Observes()
277 SetResult(done
,stay
);
282 PE_Service::Process_Default()
289 PE_Service::On_Default()
291 if (eState
== at_ignore
)
292 SetResult(done
, stay
);
294 SetResult(not_done
, pop_failure
);
298 PE_Service::InitData()
302 bIsPreDeclaration
= false;
306 nCurParsed_Property
= 0;
308 bOptionalMember
= false;
312 PE_Service::TransferData()
314 if (NOT bIsPreDeclaration
)
316 csv_assert(sData_Name
.size() > 0);
317 csv_assert( (pCurService
!= 0) != (pCurSiService
!= 0) );
324 PE_Service::ReceiveData()
334 pPE_Type
->SetOptional();
336 pCurService
->AddRef_SupportedInterface(
338 pPE_Type
->ReleaseDocu());
340 eState
= expect_ifc_separator
;
342 case in_service_type
:
345 pPE_Type
->SetOptional();
347 pCurService
->AddRef_IncludedService(
349 pPE_Type
->ReleaseDocu());
351 eState
= expect_service_separator
;
353 case need_base_interface
:
354 pCurSiService
= &Gate().Ces().Store_SglIfcService(
355 CurNamespace().CeId(),
358 nCurService
= pCurSiService
->CeId();
359 PassDocuAt(*pCurSiService
);
362 eState
= need_curlbr_open_sib
;
370 bOptionalMember
= false;
381 PE_Service::StartProperty()
383 SetResult(not_done
, push_sure
, pPE_Property
.Ptr());
384 eState
= in_property
;
388 pPE_Property
->PresetOptional();
389 bOptionalMember
= false;