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"
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>
58 #define DF &PE_Constant::On_Default
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
,
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
,
70 { DF
, DF
, &PE_Constant::On_expect_finish_Punctuation
} // expect_finish
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()
93 pPE_Type
= new PE_Type(nType
);
94 pPE_Value
= new PE_Value(sName
, sAssignment
, true);
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()
112 PE_Constant::ProcessToken( const Token
& i_rToken
)
114 i_rToken
.Trigger(*this);
118 PE_Constant::Process_Identifier( const TokIdentifier
& i_rToken
)
120 CallHandler(i_rToken
.Text(), tt_identifier
);
124 PE_Constant::Process_Punctuation( const TokPunctuation
& i_rToken
)
126 CallHandler(i_rToken
.Text(), tt_punctuation
);
130 PE_Constant::Process_Stereotype( const TokStereotype
& i_rToken
)
132 CallHandler(i_rToken
.Text(), tt_stereotype
);
136 PE_Constant::On_expect_name_Identifier(const char * i_sText
)
140 SetResult(done
,stay
);
141 eState
= expect_curl_bracket_open
;
145 PE_Constant::On_expect_curl_bracket_open_Punctuation(const char * i_sText
)
147 if ( i_sText
[0] == '{')
151 ary::idl::ConstantsGroup
&
153 Store_ConstantsGroup(CurNamespace().CeId(),sData_Name
);
155 nDataId
= rCe
.CeId();
157 SetResult(done
,stay
);
158 eState
= expect_const
;
167 PE_Constant::On_expect_const_Stereotype(SAL_UNUSED_PARAMETER
const char *)
169 SetResult( done
, push_sure
, pPE_Type
.Ptr() );
173 PE_Constant::On_expect_const_Punctuation(const char * i_sText
)
175 if ( i_sText
[0] == '}')
177 SetResult(done
,stay
);
178 eState
= expect_finish
;
187 PE_Constant::On_expect_value_Identifier(SAL_UNUSED_PARAMETER
const char *)
189 SetResult( not_done
, push_sure
, pPE_Value
.Ptr() );
193 PE_Constant::On_expect_finish_Punctuation(const char * i_sText
)
195 if ( i_sText
[0] == ';')
197 SetResult(done
,pop_success
);
207 PE_Constant::On_Default(SAL_UNUSED_PARAMETER
const char * )
209 SetResult(not_done
,pop_failure
);
214 PE_Constant::EmptySingleConstData()
222 PE_Constant::CreateSingleConstant()
225 rCe
= Gate().Ces().Store_Constant( nDataId
,
229 pPE_Type
->PassDocuAt(rCe
);
233 PE_Constant::InitData()
235 eState
= expect_name
;
240 EmptySingleConstData();
244 PE_Constant::ReceiveData()
249 eState
= 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
;
260 CreateSingleConstant();
261 EmptySingleConstData();
262 eState
= expect_const
;
265 SetResult(not_done
, pop_failure
);
271 PE_Constant::TransferData()
273 csv_assert(nDataId
.IsValid());
286 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */