merge the formfield patch from ooo-build
[ooovba.git] / autodoc / source / parser_i / idl / pe_file2.cxx
blobf5f3242ca57c85592b46530e33aea77a2cf16fb6
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_file2.cxx,v $
10 * $Revision: 1.10 $
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_file2.hxx>
35 // NOT FULLY DECLARED SERVICES
36 #include <ary/idl/i_gate.hxx>
37 #include <ary/idl/i_module.hxx>
38 #include <ary/idl/ip_ce.hxx>
39 #include <ary/doc/d_oldidldocu.hxx>
40 #include <s2_luidl/distrib.hxx>
41 #include <s2_luidl/pe_servi.hxx>
42 #include <s2_luidl/pe_iface.hxx>
43 #include <s2_luidl/pe_singl.hxx>
44 #include <s2_luidl/pe_struc.hxx>
45 #include <s2_luidl/pe_excp.hxx>
46 #include <s2_luidl/pe_const.hxx>
47 #include <s2_luidl/pe_enum2.hxx>
48 #include <s2_luidl/pe_tydf2.hxx>
49 #include <s2_luidl/tk_keyw.hxx>
50 #include <s2_luidl/tk_ident.hxx>
51 #include <s2_luidl/tk_punct.hxx>
56 namespace csi
58 namespace uidl
62 PE_File::PE_File( TokenDistributor & i_rTokenAdmin,
63 const ParserInfo & i_parseInfo )
64 : pTokenAdmin(&i_rTokenAdmin),
65 pPE_Service(new PE_Service),
66 pPE_Singleton(new PE_Singleton),
67 pPE_Interface(new PE_Interface),
68 pPE_Struct(new PE_Struct),
69 pPE_Exception(new PE_Exception),
70 pPE_Constant(new PE_Constant),
71 pPE_Enum(new PE_Enum),
72 pPE_Typedef(new PE_Typedef),
73 pCurNamespace(0),
74 pParseInfo(&i_parseInfo),
75 eState(e_none),
76 nBracketCount_inDefMode(0)
80 void
81 PE_File::EstablishContacts( UnoIDL_PE * io_pParentPE,
82 ary::Repository & io_rRepository,
83 TokenProcessing_Result & o_rResult )
85 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
86 pPE_Service->EstablishContacts(this,io_rRepository,o_rResult);
87 pPE_Singleton->EstablishContacts(this,io_rRepository,o_rResult);
88 pPE_Interface->EstablishContacts(this,io_rRepository,o_rResult);
89 pPE_Struct->EstablishContacts(this,io_rRepository,o_rResult);
90 pPE_Exception->EstablishContacts(this,io_rRepository,o_rResult);
91 pPE_Constant->EstablishContacts(this,io_rRepository,o_rResult);
92 pPE_Enum->EstablishContacts(this,io_rRepository,o_rResult);
93 pPE_Typedef->EstablishContacts(this,io_rRepository,o_rResult);
95 pCurNamespace = &Gate().Ces().GlobalNamespace();
98 PE_File::~PE_File()
102 void
103 PE_File::ProcessToken( const Token & i_rToken )
105 i_rToken.Trigger(*this);
108 void
109 PE_File::Process_Identifier( const TokIdentifier & i_rToken )
111 switch (eState)
113 case wait_for_module:
115 csv_assert(pCurNamespace != 0);
117 ary::idl::Module & rCe = Gate().Ces().CheckIn_Module(pCurNamespace->CeId(), i_rToken.Text());
118 pCurNamespace = &rCe;
120 // Get docu out of normal:
121 SetDocu(pTokenAdmin->ReleaseLastParsedDocu());
122 PassDocuAt(rCe);
124 csv_assert(pCurNamespace != 0);
126 SetResult(done, stay);
127 eState = wait_for_module_bracket;
128 } break;
129 case on_default:
130 SetResult(done, stay);
131 break;
132 default:
133 csv_assert(false);
137 void
138 PE_File::Process_Punctuation( const TokPunctuation & i_rToken )
140 switch (eState)
142 case e_std:
143 if (i_rToken.Id() == TokPunctuation::CurledBracketClose)
145 csv_assert(pCurNamespace != 0);
147 pCurNamespace = &Gate().Ces().Find_Module(pCurNamespace->Owner());
149 SetResult(done, stay);
150 eState = wait_for_module_semicolon;
152 else
154 csv_assert(false);
156 break;
157 case wait_for_module_bracket:
158 if (i_rToken.Id() == TokPunctuation::CurledBracketOpen)
160 SetResult(done, stay);
161 eState = e_std;
163 else
165 csv_assert(false);
167 break;
168 case wait_for_module_semicolon:
169 if (i_rToken.Id() == TokPunctuation::Semicolon)
171 SetResult(done, stay);
172 eState = e_std;
174 else
176 csv_assert(false);
178 break;
179 case on_default:
180 if (i_rToken.Id() == TokPunctuation::CurledBracketClose)
182 nBracketCount_inDefMode--;
184 else if (i_rToken.Id() == TokPunctuation::CurledBracketOpen)
186 nBracketCount_inDefMode++;
188 else if (i_rToken.Id() == TokPunctuation::Semicolon)
190 if (nBracketCount_inDefMode <= 0)
192 eState = e_std;
195 SetResult(done, stay);
196 break;
197 default:
198 csv_assert(false);
202 void
203 PE_File::Process_MetaType( const TokMetaType & i_rToken )
205 switch (i_rToken.Id())
207 case TokMetaType::mt_service:
208 eState = in_sub_pe;
209 SetResult( not_done, push_sure, pPE_Service.Ptr());
210 break;
211 case TokMetaType::mt_singleton:
212 eState = in_sub_pe;
213 SetResult( not_done, push_sure, pPE_Singleton.Ptr());
214 break;
215 case TokMetaType::mt_uik:
216 Cerr() << "Syntax error: [uik ....] is obsolete now." << Endl();
217 SetResult( not_done, pop_failure);
218 break;
219 case TokMetaType::mt_interface:
220 eState = in_sub_pe;
221 SetResult( not_done, push_sure, pPE_Interface.Ptr());
222 break;
223 case TokMetaType::mt_module:
224 eState = wait_for_module;
225 SetResult( done, stay );
226 break;
227 case TokMetaType::mt_struct:
228 eState = in_sub_pe;
229 SetResult( done, push_sure, pPE_Struct.Ptr());
230 break;
231 case TokMetaType::mt_exception:
232 eState = in_sub_pe;
233 SetResult( done, push_sure, pPE_Exception.Ptr());
234 break;
235 case TokMetaType::mt_constants:
236 eState = in_sub_pe;
237 SetResult( done, push_sure, pPE_Constant.Ptr());
238 break;
239 case TokMetaType::mt_enum:
240 eState = in_sub_pe;
241 SetResult( done, push_sure, pPE_Enum.Ptr());
242 break;
243 case TokMetaType::mt_typedef:
244 eState = in_sub_pe;
245 SetResult( done, push_sure, pPE_Typedef.Ptr());
246 break;
248 default:
249 Process_Default();
250 } // end switch
253 void
254 PE_File::Process_Stereotype( const TokStereotype & i_rToken )
256 if (i_rToken.Id() == TokStereotype::ste_published)
258 pTokenAdmin->Set_PublishedOn();
260 SetResult(done, stay);
262 else
264 Process_Default();
268 void
269 PE_File::Process_Default()
271 if (eState != on_default)
273 eState = on_default;
274 nBracketCount_inDefMode = 0;
276 SetResult(done, stay);
279 const ary::idl::Module &
280 PE_File::CurNamespace() const
282 csv_assert(pCurNamespace);
283 return *pCurNamespace;
286 const ParserInfo &
287 PE_File::ParseInfo() const
289 csv_assert(pParseInfo);
290 return *pParseInfo;
293 void
294 PE_File::InitData()
296 eState = e_std;
299 void
300 PE_File::TransferData()
302 eState = e_none;
305 void
306 PE_File::ReceiveData()
308 eState = e_std;
312 UnoIDL_PE &
313 PE_File::MyPE()
315 return *this;
318 } // namespace uidl
319 } // namespace csi