Update ooo320-m1
[ooovba.git] / autodoc / source / parser_i / idl / pe_singl.cxx
blobc77de85d4439745d31369aea66e3c12daec5921e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pe_singl.cxx,v $
10 * $Revision: 1.8 $
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 ************************************************************************/
31 #include <precomp.h>
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>
48 namespace csi
50 namespace uidl
55 #if 0
56 #ifdef DF
57 #undef DF
58 #endif
59 #define DF &PE_Singleton::On_Default
62 PE_Singleton::F_TOK
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,
66 DF }, // need_name
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,
71 }, // e_std
72 { DF, DF, DF }, // in_service
73 { DF, DF, &PE_Interface::On_need_finish_Punctuation,
74 } // need_finish
76 #endif // 0
79 PE_Singleton::PE_Singleton()
80 : eState(e_none),
81 sData_Name(),
82 bIsPreDeclaration(false),
83 pCurSingleton(0),
84 pCurSiSingleton(0),
85 pPE_Type(0),
86 nCurParsed_Type(0)
88 pPE_Type = new PE_Type(nCurParsed_Type);
91 void
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()
104 void
105 PE_Singleton::ProcessToken( const Token & i_rToken )
107 i_rToken.Trigger(*this);
111 void
112 PE_Singleton::Process_MetaType( const TokMetaType & i_rToken )
114 switch ( i_rToken.Id() )
116 case TokMetaType::mt_service:
117 if (eState == e_std)
119 SetResult(done, push_sure, pPE_Type.Ptr());
120 eState = in_service;
122 else
123 On_Default();
124 break;
125 case TokMetaType::mt_singleton:
126 if (eState == need_name)
127 SetResult(done, stay);
128 else
129 On_Default();
130 break;
131 default:
132 // KORR_FUTURE
133 // Should throw syntax error warning
136 } // end switch
139 void
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;
148 else
149 On_Default();
152 void
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(),
162 sData_Name );
163 PassDocuAt(*pCurSingleton);
164 SetResult(done, stay);
165 eState = e_std;
167 else
168 On_Default();
169 break;
170 case TokPunctuation::CurledBracketClose:
171 if (eState == e_std)
173 SetResult(done, stay);
174 eState = need_finish;
176 else
177 On_Default();
178 break;
179 case TokPunctuation::Semicolon:
180 switch (eState)
182 case e_std: SetResult(done, stay);
183 break;
184 case need_finish:
185 SetResult(done, pop_success);
186 eState = e_none;
187 break;
188 default:
189 On_Default();
190 } // end switch
191 break;
192 case TokPunctuation::Colon:
193 switch (eState)
195 case need_curlbr_open:
196 SetResult(done, push_sure, pPE_Type.Ptr());
197 eState = in_base_interface;
198 break;
199 default:
200 On_Default();
201 } // end switch
202 break;
203 default:
204 On_Default();
205 } // end switch
208 void
209 PE_Singleton::Process_Default()
211 On_Default();
215 void
216 PE_Singleton::On_Default()
218 SetResult(not_done, pop_failure);
221 void
222 PE_Singleton::InitData()
224 eState = need_name;
225 sData_Name.clear();
226 bIsPreDeclaration = false;
227 pCurSingleton = 0;
228 pCurSiSingleton = 0;
229 nCurParsed_Type = 0;
232 void
233 PE_Singleton::TransferData()
235 if (NOT bIsPreDeclaration)
237 csv_assert(sData_Name.size() > 0);
238 csv_assert( (pCurSingleton != 0) != (pCurSiSingleton != 0) );
241 eState = e_none;
244 void
245 PE_Singleton::ReceiveData()
247 switch (eState)
249 case in_service:
250 pCurSingleton->Set_Service(nCurParsed_Type);
251 nCurParsed_Type = 0;
252 eState = e_std;
253 break;
254 case in_base_interface:
255 pCurSiSingleton = &Gate().Ces().Store_SglIfcSingleton(
256 CurNamespace().CeId(),
257 sData_Name,
258 nCurParsed_Type );
259 PassDocuAt(*pCurSiSingleton);
260 nCurParsed_Type = 0;
261 eState = need_finish;
262 break;
263 default:
264 csv_assert(false);
265 } // end switch
268 UnoIDL_PE &
269 PE_Singleton::MyPE()
271 return *this;
274 } // namespace uidl
275 } // namespace csi