Bump for 3.6-28
[LibreOffice.git] / autodoc / source / parser_i / idl / pe_const.cxx
blob817060e6e0cede48bf62319967352b6c810017e1
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 "sal/config.h"
31 #include "sal/types.h"
33 #include <precomp.h>
34 #include <s2_luidl/pe_const.hxx>
36 // NOT FULLY DECLARED SERVICES
37 #include <ary/idl/i_gate.hxx>
38 #include <ary/idl/i_constant.hxx>
39 #include <ary/idl/i_constgroup.hxx>
40 #include <ary/idl/ip_ce.hxx>
41 #include <ary/doc/d_oldidldocu.hxx>
42 #include <s2_luidl/pe_type2.hxx>
43 #include <s2_luidl/pe_evalu.hxx>
44 #include <s2_luidl/tk_punct.hxx>
45 #include <s2_luidl/tk_ident.hxx>
46 #include <s2_luidl/tk_keyw.hxx>
49 namespace csi
51 namespace uidl
55 #ifdef DF
56 #undef DF
57 #endif
58 #define DF &PE_Constant::On_Default
60 PE_Constant::F_TOK
61 PE_Constant::aDispatcher[PE_Constant::e_STATES_MAX][PE_Constant::tt_MAX] =
62 { { DF, DF, DF }, // e_none
63 { DF, &PE_Constant::On_expect_name_Identifier,
64 DF }, // expect_name
65 { DF, DF, &PE_Constant::On_expect_curl_bracket_open_Punctuation }, // expect_curl_bracket_open
66 { &PE_Constant::On_expect_const_Stereotype,
67 DF, &PE_Constant::On_expect_const_Punctuation }, // expect_const
68 { DF, &PE_Constant::On_expect_value_Identifier,
69 DF }, // expect_value
70 { DF, DF, &PE_Constant::On_expect_finish_Punctuation } // expect_finish
75 inline void
76 PE_Constant::CallHandler( const char * i_sTokenText,
77 E_TokenType i_eTokenType )
78 { (this->*aDispatcher[eState][i_eTokenType])(i_sTokenText); }
83 PE_Constant::PE_Constant()
84 : eState(e_none),
85 sData_Name(),
86 nDataId(0),
87 pPE_Type(0),
88 nType(0),
89 pPE_Value(0),
90 sName(),
91 sAssignment()
93 pPE_Type = new PE_Type(nType);
94 pPE_Value = new PE_Value(sName, sAssignment, true);
97 void
98 PE_Constant::EstablishContacts( UnoIDL_PE * io_pParentPE,
99 ary::Repository & io_rRepository,
100 TokenProcessing_Result & o_rResult )
102 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
103 pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
104 pPE_Value->EstablishContacts(this,io_rRepository,o_rResult);
107 PE_Constant::~PE_Constant()
111 void
112 PE_Constant::ProcessToken( const Token & i_rToken )
114 i_rToken.Trigger(*this);
117 void
118 PE_Constant::Process_Identifier( const TokIdentifier & i_rToken )
120 CallHandler(i_rToken.Text(), tt_identifier);
123 void
124 PE_Constant::Process_Punctuation( const TokPunctuation & i_rToken )
126 CallHandler(i_rToken.Text(), tt_punctuation);
129 void
130 PE_Constant::Process_Stereotype( const TokStereotype & i_rToken )
132 CallHandler(i_rToken.Text(), tt_stereotype);
135 void
136 PE_Constant::On_expect_name_Identifier(const char * i_sText)
138 sName = i_sText;
140 SetResult(done,stay);
141 eState = expect_curl_bracket_open;
144 void
145 PE_Constant::On_expect_curl_bracket_open_Punctuation(const char * i_sText)
147 if ( i_sText[0] == '{')
149 sData_Name = sName;
151 ary::idl::ConstantsGroup &
152 rCe = Gate().Ces().
153 Store_ConstantsGroup(CurNamespace().CeId(),sData_Name);
154 PassDocuAt(rCe);
155 nDataId = rCe.CeId();
157 SetResult(done,stay);
158 eState = expect_const;
160 else
162 On_Default(i_sText);
166 void
167 PE_Constant::On_expect_const_Stereotype(SAL_UNUSED_PARAMETER const char *)
169 SetResult( done, push_sure, pPE_Type.Ptr() );
172 void
173 PE_Constant::On_expect_const_Punctuation(const char * i_sText)
175 if ( i_sText[0] == '}')
177 SetResult(done,stay);
178 eState = expect_finish;
180 else
182 On_Default(i_sText);
186 void
187 PE_Constant::On_expect_value_Identifier(SAL_UNUSED_PARAMETER const char *)
189 SetResult( not_done, push_sure, pPE_Value.Ptr() );
192 void
193 PE_Constant::On_expect_finish_Punctuation(const char * i_sText)
195 if ( i_sText[0] == ';')
197 SetResult(done,pop_success);
198 eState = e_none;
200 else
202 On_Default(i_sText);
206 void
207 PE_Constant::On_Default(SAL_UNUSED_PARAMETER const char * )
209 SetResult(not_done,pop_failure);
210 eState = e_none;
213 void
214 PE_Constant::EmptySingleConstData()
216 nType = 0;
217 sName = "";
218 sAssignment = "";
221 void
222 PE_Constant::CreateSingleConstant()
224 ary::idl::Constant &
225 rCe = Gate().Ces().Store_Constant( nDataId,
226 sName,
227 nType,
228 sAssignment );
229 pPE_Type->PassDocuAt(rCe);
232 void
233 PE_Constant::InitData()
235 eState = expect_name;
237 sData_Name.clear();
238 nDataId = 0;
240 EmptySingleConstData();
243 void
244 PE_Constant::ReceiveData()
246 switch (eState)
248 case expect_const:
249 eState = expect_value;
250 break;
251 case expect_value:
253 if (sName.length() == 0 OR sAssignment.length() == 0 OR NOT nType.IsValid())
255 Cerr() << "Constant without value found." << Endl();
256 eState = expect_const;
257 break;
260 CreateSingleConstant();
261 EmptySingleConstData();
262 eState = expect_const;
263 } break;
264 default:
265 SetResult(not_done, pop_failure);
266 eState = e_none;
267 } // end switch
270 void
271 PE_Constant::TransferData()
273 csv_assert(nDataId.IsValid());
274 eState = e_none;
277 UnoIDL_PE &
278 PE_Constant::MyPE()
280 return *this;
283 } // namespace uidl
284 } // namespace csi
286 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */