Update ooo320-m1
[ooovba.git] / autodoc / source / parser_i / idl / pe_const.cxx
blob98bde788d297c8efb6070a86633b931da56e0106
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_const.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_const.hxx>
34 // NOT FULLY DECLARED SERVICES
35 #include <ary/idl/i_gate.hxx>
36 #include <ary/idl/i_constant.hxx>
37 #include <ary/idl/i_constgroup.hxx>
38 #include <ary/idl/ip_ce.hxx>
39 #include <ary/doc/d_oldidldocu.hxx>
40 #include <s2_luidl/pe_type2.hxx>
41 #include <s2_luidl/pe_evalu.hxx>
42 #include <s2_luidl/tk_punct.hxx>
43 #include <s2_luidl/tk_ident.hxx>
44 #include <s2_luidl/tk_keyw.hxx>
47 namespace csi
49 namespace uidl
53 #ifdef DF
54 #undef DF
55 #endif
56 #define DF &PE_Constant::On_Default
58 PE_Constant::F_TOK
59 PE_Constant::aDispatcher[PE_Constant::e_STATES_MAX][PE_Constant::tt_MAX] =
60 { { DF, DF, DF }, // e_none
61 { DF, &PE_Constant::On_expect_name_Identifier,
62 DF }, // expect_name
63 { DF, DF, &PE_Constant::On_expect_curl_bracket_open_Punctuation }, // expect_curl_bracket_open
64 { &PE_Constant::On_expect_const_Stereotype,
65 DF, &PE_Constant::On_expect_const_Punctuation }, // expect_const
66 { DF, &PE_Constant::On_expect_value_Identifier,
67 DF }, // expect_value
68 { DF, DF, &PE_Constant::On_expect_finish_Punctuation } // expect_finish
73 inline void
74 PE_Constant::CallHandler( const char * i_sTokenText,
75 E_TokenType i_eTokenType )
76 { (this->*aDispatcher[eState][i_eTokenType])(i_sTokenText); }
81 PE_Constant::PE_Constant()
82 : eState(e_none),
83 sData_Name(),
84 nDataId(0),
85 pPE_Type(0),
86 nType(0),
87 pPE_Value(0),
88 sName(),
89 sAssignment()
91 pPE_Type = new PE_Type(nType);
92 pPE_Value = new PE_Value(sName, sAssignment, true);
95 void
96 PE_Constant::EstablishContacts( UnoIDL_PE * io_pParentPE,
97 ary::Repository & io_rRepository,
98 TokenProcessing_Result & o_rResult )
100 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
101 pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
102 pPE_Value->EstablishContacts(this,io_rRepository,o_rResult);
105 PE_Constant::~PE_Constant()
109 void
110 PE_Constant::ProcessToken( const Token & i_rToken )
112 i_rToken.Trigger(*this);
115 void
116 PE_Constant::Process_Identifier( const TokIdentifier & i_rToken )
118 CallHandler(i_rToken.Text(), tt_identifier);
121 void
122 PE_Constant::Process_Punctuation( const TokPunctuation & i_rToken )
124 CallHandler(i_rToken.Text(), tt_punctuation);
127 void
128 PE_Constant::Process_Stereotype( const TokStereotype & i_rToken )
130 CallHandler(i_rToken.Text(), tt_stereotype);
133 void
134 PE_Constant::On_expect_name_Identifier(const char * i_sText)
136 sName = i_sText;
138 SetResult(done,stay);
139 eState = expect_curl_bracket_open;
142 void
143 PE_Constant::On_expect_curl_bracket_open_Punctuation(const char * i_sText)
145 if ( i_sText[0] == '{')
147 sData_Name = sName;
149 ary::idl::ConstantsGroup &
150 rCe = Gate().Ces().
151 Store_ConstantsGroup(CurNamespace().CeId(),sData_Name);
152 PassDocuAt(rCe);
153 nDataId = rCe.CeId();
155 SetResult(done,stay);
156 eState = expect_const;
158 else
160 On_Default(i_sText);
164 void
165 PE_Constant::On_expect_const_Stereotype(const char *)
167 SetResult( done, push_sure, pPE_Type.Ptr() );
170 void
171 PE_Constant::On_expect_const_Punctuation(const char * i_sText)
173 if ( i_sText[0] == '}')
175 SetResult(done,stay);
176 eState = expect_finish;
178 else
180 On_Default(i_sText);
184 void
185 PE_Constant::On_expect_value_Identifier(const char *)
187 SetResult( not_done, push_sure, pPE_Value.Ptr() );
190 void
191 PE_Constant::On_expect_finish_Punctuation(const char * i_sText)
193 if ( i_sText[0] == ';')
195 SetResult(done,pop_success);
196 eState = e_none;
198 else
200 On_Default(i_sText);
204 void
205 PE_Constant::On_Default(const char * )
207 SetResult(not_done,pop_failure);
208 eState = e_none;
211 void
212 PE_Constant::EmptySingleConstData()
214 nType = 0;
215 sName = "";
216 sAssignment = "";
219 void
220 PE_Constant::CreateSingleConstant()
222 ary::idl::Constant &
223 rCe = Gate().Ces().Store_Constant( nDataId,
224 sName,
225 nType,
226 sAssignment );
227 pPE_Type->PassDocuAt(rCe);
230 void
231 PE_Constant::InitData()
233 eState = expect_name;
235 sData_Name.clear();
236 nDataId = 0;
238 EmptySingleConstData();
241 void
242 PE_Constant::ReceiveData()
244 switch (eState)
246 case expect_const:
247 eState = expect_value;
248 break;
249 case expect_value:
251 if (sName.length() == 0 OR sAssignment.length() == 0 OR NOT nType.IsValid())
253 Cerr() << "Constant without value found." << Endl();
254 eState = expect_const;
255 break;
258 CreateSingleConstant();
259 EmptySingleConstData();
260 eState = expect_const;
261 } break;
262 default:
263 SetResult(not_done, pop_failure);
264 eState = e_none;
265 } // end switch
268 void
269 PE_Constant::TransferData()
271 csv_assert(nDataId.IsValid());
272 eState = e_none;
275 UnoIDL_PE &
276 PE_Constant::MyPE()
278 return *this;
281 } // namespace uidl
282 } // namespace csi