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_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>
52 PE_Struct::PE_Struct()
56 pStati
= new S_Stati(*this);
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()
74 PE_Struct::ProcessToken( const Token
& i_rToken
)
76 i_rToken
.Trigger(*Stati().pCurStatus
);
84 Stati().pCurStatus
= &Stati().aWaitForName
;
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
;
99 PE_Struct::ReceiveData()
101 Stati().pCurStatus
->On_SubPE_Left();
104 PE_Struct::S_Work::S_Work()
106 sData_TemplateParam(),
107 bIsPreDeclaration(false),
110 nCurParsed_ElementRef(0),
115 pPE_Element
= new PE_StructElement(nCurParsed_ElementRef
,nCurStruct
,sData_TemplateParam
);
116 pPE_Type
= new PE_Type(nCurParsed_Base
);
120 PE_Struct::S_Work::InitData()
123 sData_TemplateParam
.clear();
124 bIsPreDeclaration
= false;
126 nCurParsed_ElementRef
= 0;
131 PE_Struct::S_Work::Prepare_PE_QualifiedName()
133 nCurParsed_ElementRef
= 0;
137 PE_Struct::S_Work::Prepare_PE_Element()
143 PE_Struct::S_Work::Data_Set_Name( const char * i_sName
)
145 sData_Name
= i_sName
;
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
)
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
),
170 //*********************** Stati ***************************//
174 PE_Struct::PE_StructState::MyPE()
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
);
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();
200 case TokPunctuation::CurledBracketOpen
:
202 MoveState( Stati().aWaitForElement
);
203 SetResult(done
,stay
);
205 case TokPunctuation::Lesser
:
206 MoveState( Stati().aWaitForTemplateParam
);
207 SetResult(done
,stay
);
210 SetResult(not_done
,pop_failure
);
215 Work().sData_Name
.clear();
216 SetResult(done
,pop_success
);
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
);
229 PE_Struct::State_WaitForTemplateEnd::Process_Punctuation( const TokPunctuation
& )
231 // Assume: TokPunctuation::Greater
232 MoveState( Stati().aGotName
);
233 SetResult(done
,stay
);
237 PE_Struct::State_WaitForBase::On_SubPE_Left()
239 MoveState(Stati().aGotBase
);
243 PE_Struct::State_GotBase::Process_Punctuation( const TokPunctuation
& i_rToken
)
245 if ( i_rToken
.Id() == TokPunctuation::CurledBracketOpen
)
248 MoveState( Stati().aWaitForElement
);
249 SetResult(done
,stay
);
253 SetResult(not_done
,pop_failure
);
258 PE_Struct::State_WaitForElement::Process_Identifier( const TokIdentifier
& )
260 SetResult( not_done
, push_sure
, Work().pPE_Element
.Ptr() );
261 Work().Prepare_PE_Element();
265 PE_Struct::State_WaitForElement::Process_NameSeparator()
267 SetResult( not_done
, push_sure
, Work().pPE_Element
.Ptr());
268 Work().Prepare_PE_Element();
272 PE_Struct::State_WaitForElement::Process_BuiltInType( const TokBuiltInType
& )
274 SetResult( not_done
, push_sure
, Work().pPE_Element
.Ptr());
275 Work().Prepare_PE_Element();
279 PE_Struct::State_WaitForElement::Process_TypeModifier(const TokTypeModifier
& )
281 SetResult( not_done
, push_sure
, Work().pPE_Element
.Ptr());
282 Work().Prepare_PE_Element();
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
);
295 SetResult( not_done
, pop_failure
);
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
);
309 SetResult( not_done
, pop_failure
);
314 PE_Struct::store_Struct()
317 rCe
= Gate().Ces().Store_Struct(
318 CurNamespace().CeId(),
320 Work().nCurParsed_Base
,
321 Work().sData_TemplateParam
);
323 Work().nCurStruct
= rCe
.CeId();
330 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */