1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pe_const.cxx,v $
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 ************************************************************************/
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>
56 #define DF &PE_Constant::On_Default
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
,
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
,
68 { DF
, DF
, &PE_Constant::On_expect_finish_Punctuation
} // expect_finish
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()
91 pPE_Type
= new PE_Type(nType
);
92 pPE_Value
= new PE_Value(sName
, sAssignment
, true);
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()
110 PE_Constant::ProcessToken( const Token
& i_rToken
)
112 i_rToken
.Trigger(*this);
116 PE_Constant::Process_Identifier( const TokIdentifier
& i_rToken
)
118 CallHandler(i_rToken
.Text(), tt_identifier
);
122 PE_Constant::Process_Punctuation( const TokPunctuation
& i_rToken
)
124 CallHandler(i_rToken
.Text(), tt_punctuation
);
128 PE_Constant::Process_Stereotype( const TokStereotype
& i_rToken
)
130 CallHandler(i_rToken
.Text(), tt_stereotype
);
134 PE_Constant::On_expect_name_Identifier(const char * i_sText
)
138 SetResult(done
,stay
);
139 eState
= expect_curl_bracket_open
;
143 PE_Constant::On_expect_curl_bracket_open_Punctuation(const char * i_sText
)
145 if ( i_sText
[0] == '{')
149 ary::idl::ConstantsGroup
&
151 Store_ConstantsGroup(CurNamespace().CeId(),sData_Name
);
153 nDataId
= rCe
.CeId();
155 SetResult(done
,stay
);
156 eState
= expect_const
;
165 PE_Constant::On_expect_const_Stereotype(const char *)
167 SetResult( done
, push_sure
, pPE_Type
.Ptr() );
171 PE_Constant::On_expect_const_Punctuation(const char * i_sText
)
173 if ( i_sText
[0] == '}')
175 SetResult(done
,stay
);
176 eState
= expect_finish
;
185 PE_Constant::On_expect_value_Identifier(const char *)
187 SetResult( not_done
, push_sure
, pPE_Value
.Ptr() );
191 PE_Constant::On_expect_finish_Punctuation(const char * i_sText
)
193 if ( i_sText
[0] == ';')
195 SetResult(done
,pop_success
);
205 PE_Constant::On_Default(const char * )
207 SetResult(not_done
,pop_failure
);
212 PE_Constant::EmptySingleConstData()
220 PE_Constant::CreateSingleConstant()
223 rCe
= Gate().Ces().Store_Constant( nDataId
,
227 pPE_Type
->PassDocuAt(rCe
);
231 PE_Constant::InitData()
233 eState
= expect_name
;
238 EmptySingleConstData();
242 PE_Constant::ReceiveData()
247 eState
= 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
;
258 CreateSingleConstant();
259 EmptySingleConstData();
260 eState
= expect_const
;
263 SetResult(not_done
, pop_failure
);
269 PE_Constant::TransferData()
271 csv_assert(nDataId
.IsValid());