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_singl.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_singl.hxx>
35 // NOT FULLY DEFINED SERVICES
36 #include <ary/idl/i_gate.hxx>
37 #include <ary/idl/i_singleton.hxx>
38 #include <ary/idl/i_sisingleton.hxx>
39 #include <ary/idl/ip_ce.hxx>
40 #include <ary/doc/d_oldidldocu.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>
59 #define DF &PE_Singleton::On_Default
63 PE_Singleton::aDispatcher
[PE_Singleton::e_STATES_MAX
][PE_Singleton::tt_MAX
] =
64 { { DF
, DF
, DF
}, // e_none
65 { DF
, &PE_Singleton::On_need_name_Identifer
,
67 { DF
, DF
, &PE_Singleton::On_need_curlbr_open_Punctuation
,
68 }, // need_curlbr_open
69 { &PE_Singleton::On_std_GotoService
,
70 DF
, &PE_Singleton::On_std_Punctuation
,
72 { DF
, DF
, DF
}, // in_service
73 { DF
, DF
, &PE_Interface::On_need_finish_Punctuation
,
79 PE_Singleton::PE_Singleton()
82 bIsPreDeclaration(false),
88 pPE_Type
= new PE_Type(nCurParsed_Type
);
92 PE_Singleton::EstablishContacts( UnoIDL_PE
* io_pParentPE
,
93 ary::Repository
& io_rRepository
,
94 TokenProcessing_Result
& o_rResult
)
96 UnoIDL_PE::EstablishContacts(io_pParentPE
,io_rRepository
,o_rResult
);
97 pPE_Type
->EstablishContacts(this,io_rRepository
,o_rResult
);
100 PE_Singleton::~PE_Singleton()
105 PE_Singleton::ProcessToken( const Token
& i_rToken
)
107 i_rToken
.Trigger(*this);
112 PE_Singleton::Process_MetaType( const TokMetaType
& i_rToken
)
114 switch ( i_rToken
.Id() )
116 case TokMetaType::mt_service
:
119 SetResult(done
, push_sure
, pPE_Type
.Ptr());
125 case TokMetaType::mt_singleton
:
126 if (eState
== need_name
)
127 SetResult(done
, stay
);
133 // Should throw syntax error warning
140 PE_Singleton::Process_Identifier( const TokIdentifier
& i_rToken
)
142 if (eState
== need_name
)
144 sData_Name
= i_rToken
.Text();
145 SetResult(done
, stay
);
146 eState
= need_curlbr_open
;
153 PE_Singleton::Process_Punctuation( const TokPunctuation
& i_rToken
)
155 switch (i_rToken
.Id())
157 case TokPunctuation::CurledBracketOpen
:
158 if (eState
== need_curlbr_open
)
160 pCurSingleton
= &Gate().Ces().Store_Singleton(
161 CurNamespace().CeId(),
163 PassDocuAt(*pCurSingleton
);
164 SetResult(done
, stay
);
170 case TokPunctuation::CurledBracketClose
:
173 SetResult(done
, stay
);
174 eState
= need_finish
;
179 case TokPunctuation::Semicolon
:
182 case e_std
: SetResult(done
, stay
);
185 SetResult(done
, pop_success
);
192 case TokPunctuation::Colon
:
195 case need_curlbr_open
:
196 SetResult(done
, push_sure
, pPE_Type
.Ptr());
197 eState
= in_base_interface
;
209 PE_Singleton::Process_Default()
216 PE_Singleton::On_Default()
218 SetResult(not_done
, pop_failure
);
222 PE_Singleton::InitData()
226 bIsPreDeclaration
= false;
233 PE_Singleton::TransferData()
235 if (NOT bIsPreDeclaration
)
237 csv_assert(sData_Name
.size() > 0);
238 csv_assert( (pCurSingleton
!= 0) != (pCurSiSingleton
!= 0) );
245 PE_Singleton::ReceiveData()
250 pCurSingleton
->Set_Service(nCurParsed_Type
);
254 case in_base_interface
:
255 pCurSiSingleton
= &Gate().Ces().Store_SglIfcSingleton(
256 CurNamespace().CeId(),
259 PassDocuAt(*pCurSiSingleton
);
261 eState
= need_finish
;