Bump for 3.6-28
[LibreOffice.git] / autodoc / source / parser_i / idl / pe_struc.cxx
bloba9dc68448ee3485021aa0af46886ff6e01ade491
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 ************************************************************************/
29 #include <precomp.h>
30 #include <s2_luidl/pe_struc.hxx>
33 // NOT FULLY DECLARED SERVICES
34 #include <ary/idl/i_gate.hxx>
35 #include <ary/idl/i_struct.hxx>
36 #include <ary/idl/ip_ce.hxx>
37 #include <ary/doc/d_oldidldocu.hxx>
38 #include <s2_luidl/tk_ident.hxx>
39 #include <s2_luidl/tk_punct.hxx>
40 #include <s2_luidl/tk_keyw.hxx>
41 #include <s2_luidl/pe_type2.hxx>
42 #include <s2_luidl/pe_selem.hxx>
46 namespace csi
48 namespace uidl
52 PE_Struct::PE_Struct()
53 // : aWork,
54 // pStati
56 pStati = new S_Stati(*this);
59 void
60 PE_Struct::EstablishContacts( UnoIDL_PE * io_pParentPE,
61 ary::Repository & io_rRepository,
62 TokenProcessing_Result & o_rResult )
64 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
65 Work().pPE_Element->EstablishContacts(this,io_rRepository,o_rResult);
66 Work().pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
69 PE_Struct::~PE_Struct()
73 void
74 PE_Struct::ProcessToken( const Token & i_rToken )
76 i_rToken.Trigger(*Stati().pCurStatus);
80 void
81 PE_Struct::InitData()
83 Work().InitData();
84 Stati().pCurStatus = &Stati().aWaitForName;
87 void
88 PE_Struct::TransferData()
90 if (NOT Work().bIsPreDeclaration)
92 csv_assert(Work().sData_Name.size() > 0);
93 csv_assert(Work().nCurStruct.IsValid());
95 Stati().pCurStatus = &Stati().aNone;
98 void
99 PE_Struct::ReceiveData()
101 Stati().pCurStatus->On_SubPE_Left();
104 PE_Struct::S_Work::S_Work()
105 : sData_Name(),
106 sData_TemplateParam(),
107 bIsPreDeclaration(false),
108 nCurStruct(0),
109 pPE_Element(0),
110 nCurParsed_ElementRef(0),
111 pPE_Type(0),
112 nCurParsed_Base(0)
115 pPE_Element = new PE_StructElement(nCurParsed_ElementRef,nCurStruct,sData_TemplateParam);
116 pPE_Type = new PE_Type(nCurParsed_Base);
119 void
120 PE_Struct::S_Work::InitData()
122 sData_Name.clear();
123 sData_TemplateParam.clear();
124 bIsPreDeclaration = false;
125 nCurStruct = 0;
126 nCurParsed_ElementRef = 0;
127 nCurParsed_Base = 0;
130 void
131 PE_Struct::S_Work::Prepare_PE_QualifiedName()
133 nCurParsed_ElementRef = 0;
136 void
137 PE_Struct::S_Work::Prepare_PE_Element()
139 nCurParsed_Base = 0;
142 void
143 PE_Struct::S_Work::Data_Set_Name( const char * i_sName )
145 sData_Name = i_sName;
148 void
149 PE_Struct::S_Work::Data_Set_TemplateParam( const char * i_sTemplateParam )
151 sData_TemplateParam = i_sTemplateParam;
154 PE_Struct::S_Stati::S_Stati(PE_Struct & io_rStruct)
155 : aNone(io_rStruct),
156 aWaitForName(io_rStruct),
157 aGotName(io_rStruct),
158 aWaitForTemplateParam(io_rStruct),
159 aWaitForTemplateEnd(io_rStruct),
160 aWaitForBase(io_rStruct),
161 aGotBase(io_rStruct),
162 aWaitForElement(io_rStruct),
163 aWaitForFinish(io_rStruct),
164 pCurStatus(0)
166 pCurStatus = &aNone;
170 //*********************** Stati ***************************//
173 UnoIDL_PE &
174 PE_Struct::PE_StructState::MyPE()
176 return rStruct;
180 void
181 PE_Struct::State_WaitForName::Process_Identifier( const TokIdentifier & i_rToken )
183 Work().Data_Set_Name(i_rToken.Text());
184 MoveState( Stati().aGotName );
185 SetResult(done,stay);
188 void
189 PE_Struct::State_GotName::Process_Punctuation( const TokPunctuation & i_rToken )
191 if ( i_rToken.Id() != TokPunctuation::Semicolon )
193 switch (i_rToken.Id())
195 case TokPunctuation::Colon:
196 MoveState( Stati().aWaitForBase );
197 SetResult(done,push_sure,Work().pPE_Type.Ptr());
198 Work().Prepare_PE_QualifiedName();
199 break;
200 case TokPunctuation::CurledBracketOpen:
201 PE().store_Struct();
202 MoveState( Stati().aWaitForElement );
203 SetResult(done,stay);
204 break;
205 case TokPunctuation::Lesser:
206 MoveState( Stati().aWaitForTemplateParam );
207 SetResult(done,stay);
208 break;
209 default:
210 SetResult(not_done,pop_failure);
211 } // end switch
213 else
215 Work().sData_Name.clear();
216 SetResult(done,pop_success);
220 void
221 PE_Struct::State_WaitForTemplateParam::Process_Identifier( const TokIdentifier & i_rToken )
223 Work().Data_Set_TemplateParam(i_rToken.Text());
224 MoveState( Stati().aWaitForTemplateEnd );
225 SetResult(done,stay);
228 void
229 PE_Struct::State_WaitForTemplateEnd::Process_Punctuation( const TokPunctuation & )
231 // Assume: TokPunctuation::Greater
232 MoveState( Stati().aGotName );
233 SetResult(done,stay);
236 void
237 PE_Struct::State_WaitForBase::On_SubPE_Left()
239 MoveState(Stati().aGotBase);
242 void
243 PE_Struct::State_GotBase::Process_Punctuation( const TokPunctuation & i_rToken )
245 if ( i_rToken.Id() == TokPunctuation::CurledBracketOpen )
247 PE().store_Struct();
248 MoveState( Stati().aWaitForElement );
249 SetResult(done,stay);
251 else
253 SetResult(not_done,pop_failure);
257 void
258 PE_Struct::State_WaitForElement::Process_Identifier( const TokIdentifier & )
260 SetResult( not_done, push_sure, Work().pPE_Element.Ptr() );
261 Work().Prepare_PE_Element();
264 void
265 PE_Struct::State_WaitForElement::Process_NameSeparator()
267 SetResult( not_done, push_sure, Work().pPE_Element.Ptr());
268 Work().Prepare_PE_Element();
271 void
272 PE_Struct::State_WaitForElement::Process_BuiltInType( const TokBuiltInType & )
274 SetResult( not_done, push_sure, Work().pPE_Element.Ptr());
275 Work().Prepare_PE_Element();
278 void
279 PE_Struct::State_WaitForElement::Process_TypeModifier(const TokTypeModifier & )
281 SetResult( not_done, push_sure, Work().pPE_Element.Ptr());
282 Work().Prepare_PE_Element();
285 void
286 PE_Struct::State_WaitForElement::Process_Punctuation( const TokPunctuation & i_rToken )
288 if ( i_rToken.Id() == TokPunctuation::CurledBracketClose )
290 MoveState( Stati().aWaitForFinish );
291 SetResult( done, stay );
293 else
295 SetResult( not_done, pop_failure );
299 void
300 PE_Struct::State_WaitForFinish::Process_Punctuation( const TokPunctuation & i_rToken )
302 if (i_rToken.Id() == TokPunctuation::Semicolon)
304 MoveState( Stati().aNone );
305 SetResult( done, pop_success );
307 else
309 SetResult( not_done, pop_failure );
313 void
314 PE_Struct::store_Struct()
316 ary::idl::Struct &
317 rCe = Gate().Ces().Store_Struct(
318 CurNamespace().CeId(),
319 Work().sData_Name,
320 Work().nCurParsed_Base,
321 Work().sData_TemplateParam );
322 PassDocuAt(rCe);
323 Work().nCurStruct = rCe.CeId();
327 } // namespace uidl
328 } // namespace csi
330 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */