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 ************************************************************************/
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>
55 PE_Service::PE_Service()
58 bIsPreDeclaration(false),
63 nCurParsed_Property(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
);
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()
90 PE_Service::ProcessToken( const Token
& i_rToken
)
92 i_rToken
.Trigger(*this);
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
;
112 case TokMetaType::mt_interface
:
115 SetResult(done
, push_sure
, pPE_Type
.Ptr());
116 eState
= in_ifc_type
;
121 case TokMetaType::mt_property
:
131 // Should throw syntax error warning.
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());
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
;
168 case TokPunctuation::CurledBracketOpen
:
169 if (eState
== need_curlbr_open
)
171 pCurService
= &Gate().Ces().Store_Service(
172 CurNamespace().CeId(),
174 nCurService
= pCurService
->CeId();
175 PassDocuAt(*pCurService
);
176 SetResult(done
, stay
);
179 else if (eState
== need_curlbr_open_sib
)
181 SetResult(done
, stay
);
187 case TokPunctuation::CurledBracketClose
:
188 if (eState
== e_std OR eState
== e_std_sib
)
190 SetResult(done
, stay
);
191 eState
= need_finish
;
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
);
214 case TokPunctuation::Semicolon
:
217 case need_curlbr_open
:
219 bIsPreDeclaration
= true;
220 SetResult(done
, pop_success
);
223 case need_curlbr_open_sib
:
224 SetResult(done
, pop_success
);
227 case expect_ifc_separator
:
228 case expect_service_separator
:
229 SetResult(done
, stay
);
233 SetResult(done
, pop_success
);
237 SetResult(done
, stay
);
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
)
266 PE_Service::Process_Needs()
268 SetResult(done
,stay
);
273 PE_Service::Process_Observes()
275 SetResult(done
,stay
);
280 PE_Service::Process_Default()
287 PE_Service::On_Default()
289 if (eState
== at_ignore
)
290 SetResult(done
, stay
);
292 SetResult(not_done
, pop_failure
);
296 PE_Service::InitData()
300 bIsPreDeclaration
= false;
304 nCurParsed_Property
= 0;
306 bOptionalMember
= false;
310 PE_Service::TransferData()
312 if (NOT bIsPreDeclaration
)
314 csv_assert(sData_Name
.size() > 0);
315 csv_assert( (pCurService
!= 0) != (pCurSiService
!= 0) );
322 PE_Service::ReceiveData()
332 pPE_Type
->SetOptional();
334 pCurService
->AddRef_SupportedInterface(
336 pPE_Type
->ReleaseDocu());
338 eState
= expect_ifc_separator
;
340 case in_service_type
:
343 pPE_Type
->SetOptional();
345 pCurService
->AddRef_IncludedService(
347 pPE_Type
->ReleaseDocu());
349 eState
= expect_service_separator
;
351 case need_base_interface
:
352 pCurSiService
= &Gate().Ces().Store_SglIfcService(
353 CurNamespace().CeId(),
356 nCurService
= pCurSiService
->CeId();
357 PassDocuAt(*pCurSiService
);
360 eState
= need_curlbr_open_sib
;
368 bOptionalMember
= false;
379 PE_Service::StartProperty()
381 SetResult(not_done
, push_sure
, pPE_Property
.Ptr());
382 eState
= in_property
;
386 pPE_Property
->PresetOptional();
387 bOptionalMember
= false;
395 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */