1*78bc99aaSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*78bc99aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*78bc99aaSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*78bc99aaSAndrew Rist * distributed with this work for additional information
6*78bc99aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*78bc99aaSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*78bc99aaSAndrew Rist * "License"); you may not use this file except in compliance
9*78bc99aaSAndrew Rist * with the License. You may obtain a copy of the License at
10*78bc99aaSAndrew Rist *
11*78bc99aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*78bc99aaSAndrew Rist *
13*78bc99aaSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*78bc99aaSAndrew Rist * software distributed under the License is distributed on an
15*78bc99aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*78bc99aaSAndrew Rist * KIND, either express or implied. See the License for the
17*78bc99aaSAndrew Rist * specific language governing permissions and limitations
18*78bc99aaSAndrew Rist * under the License.
19*78bc99aaSAndrew Rist *
20*78bc99aaSAndrew Rist *************************************************************/
21cdf0e10cSrcweir
22cdf0e10cSrcweir #include <precomp.h>
23cdf0e10cSrcweir #include <s2_luidl/pe_property.hxx>
24cdf0e10cSrcweir
25cdf0e10cSrcweir
26cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
27cdf0e10cSrcweir #include <ary/idl/i_gate.hxx>
28cdf0e10cSrcweir #include <ary/idl/i_property.hxx>
29cdf0e10cSrcweir #include <ary/idl/i_service.hxx>
30cdf0e10cSrcweir #include <ary/idl/ip_ce.hxx>
31cdf0e10cSrcweir #include <ary/doc/d_oldidldocu.hxx>
32cdf0e10cSrcweir #include <s2_luidl/pe_vari2.hxx>
33cdf0e10cSrcweir #include <s2_luidl/tk_keyw.hxx>
34cdf0e10cSrcweir #include <s2_luidl/tk_ident.hxx>
35cdf0e10cSrcweir #include <s2_luidl/tk_punct.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir
38cdf0e10cSrcweir
39cdf0e10cSrcweir namespace csi
40cdf0e10cSrcweir {
41cdf0e10cSrcweir namespace uidl
42cdf0e10cSrcweir {
43cdf0e10cSrcweir
44cdf0e10cSrcweir
45cdf0e10cSrcweir
PE_Property(const Ce_id & i_rCurOwner)46cdf0e10cSrcweir PE_Property::PE_Property( const Ce_id & i_rCurOwner )
47cdf0e10cSrcweir : eState(e_none),
48cdf0e10cSrcweir pCurOwner(&i_rCurOwner),
49cdf0e10cSrcweir pPE_Variable(0),
50cdf0e10cSrcweir nCurParsedType(0),
51cdf0e10cSrcweir sCurParsedName(),
52cdf0e10cSrcweir bIsOptional(false),
53cdf0e10cSrcweir aStereotypes()
54cdf0e10cSrcweir {
55cdf0e10cSrcweir pPE_Variable = new PE_Variable(nCurParsedType, sCurParsedName);
56cdf0e10cSrcweir }
57cdf0e10cSrcweir
58cdf0e10cSrcweir void
EstablishContacts(UnoIDL_PE * io_pParentPE,ary::Repository & io_rRepository,TokenProcessing_Result & o_rResult)59cdf0e10cSrcweir PE_Property::EstablishContacts( UnoIDL_PE * io_pParentPE,
60cdf0e10cSrcweir ary::Repository & io_rRepository,
61cdf0e10cSrcweir TokenProcessing_Result & o_rResult )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
64cdf0e10cSrcweir pPE_Variable->EstablishContacts(this,io_rRepository,o_rResult);
65cdf0e10cSrcweir }
66cdf0e10cSrcweir
~PE_Property()67cdf0e10cSrcweir PE_Property::~PE_Property()
68cdf0e10cSrcweir {
69cdf0e10cSrcweir }
70cdf0e10cSrcweir
71cdf0e10cSrcweir void
ProcessToken(const Token & i_rToken)72cdf0e10cSrcweir PE_Property::ProcessToken( const Token & i_rToken )
73cdf0e10cSrcweir {
74cdf0e10cSrcweir i_rToken.Trigger(*this);
75cdf0e10cSrcweir }
76cdf0e10cSrcweir
77cdf0e10cSrcweir void
Process_Stereotype(const TokStereotype & i_rToken)78cdf0e10cSrcweir PE_Property::Process_Stereotype( const TokStereotype & i_rToken )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir switch (i_rToken.Id())
81cdf0e10cSrcweir {
82cdf0e10cSrcweir case TokStereotype::ste_optional:
83cdf0e10cSrcweir bIsOptional = true;
84cdf0e10cSrcweir break;
85cdf0e10cSrcweir case TokStereotype::ste_readonly:
86cdf0e10cSrcweir aStereotypes.Set_Flag(Stereotypes::readonly);
87cdf0e10cSrcweir break;
88cdf0e10cSrcweir case TokStereotype::ste_bound:
89cdf0e10cSrcweir aStereotypes.Set_Flag(Stereotypes::bound);
90cdf0e10cSrcweir break;
91cdf0e10cSrcweir case TokStereotype::ste_constrained:
92cdf0e10cSrcweir aStereotypes.Set_Flag(Stereotypes::constrained);
93cdf0e10cSrcweir break;
94cdf0e10cSrcweir case TokStereotype::ste_maybeambiguous:
95cdf0e10cSrcweir aStereotypes.Set_Flag(Stereotypes::maybeambiguous);
96cdf0e10cSrcweir break;
97cdf0e10cSrcweir case TokStereotype::ste_maybedefault:
98cdf0e10cSrcweir aStereotypes.Set_Flag(Stereotypes::maybedefault);
99cdf0e10cSrcweir break;
100cdf0e10cSrcweir case TokStereotype::ste_maybevoid:
101cdf0e10cSrcweir aStereotypes.Set_Flag(Stereotypes::maybevoid);
102cdf0e10cSrcweir break;
103cdf0e10cSrcweir case TokStereotype::ste_removable:
104cdf0e10cSrcweir aStereotypes.Set_Flag(Stereotypes::removable);
105cdf0e10cSrcweir break;
106cdf0e10cSrcweir case TokStereotype::ste_transient:
107cdf0e10cSrcweir aStereotypes.Set_Flag(Stereotypes::transient);
108cdf0e10cSrcweir break;
109cdf0e10cSrcweir
110cdf0e10cSrcweir default:
111cdf0e10cSrcweir SetResult(not_done, pop_failure);
112cdf0e10cSrcweir eState = e_none;
113cdf0e10cSrcweir return;
114cdf0e10cSrcweir }
115cdf0e10cSrcweir
116cdf0e10cSrcweir SetResult(done, stay);
117cdf0e10cSrcweir }
118cdf0e10cSrcweir
119cdf0e10cSrcweir void
Process_MetaType(const TokMetaType & i_rToken)120cdf0e10cSrcweir PE_Property::Process_MetaType( const TokMetaType & i_rToken )
121cdf0e10cSrcweir {
122cdf0e10cSrcweir if (eState == e_start)
123cdf0e10cSrcweir {
124cdf0e10cSrcweir if ( i_rToken.Id() == TokMetaType::mt_property )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir SetResult(done, stay);
127cdf0e10cSrcweir eState = expect_variable;
128cdf0e10cSrcweir return;
129cdf0e10cSrcweir }
130cdf0e10cSrcweir } // endif (eState == e_start)
131cdf0e10cSrcweir
132cdf0e10cSrcweir SetResult(not_done, pop_failure);
133cdf0e10cSrcweir eState = e_none;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir
136cdf0e10cSrcweir void
Process_Punctuation(const TokPunctuation & i_rToken)137cdf0e10cSrcweir PE_Property::Process_Punctuation( const TokPunctuation & i_rToken )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir switch (eState)
140cdf0e10cSrcweir {
141cdf0e10cSrcweir case e_start:
142cdf0e10cSrcweir SetResult(done, stay);
143cdf0e10cSrcweir break;
144cdf0e10cSrcweir case expect_variable:
145cdf0e10cSrcweir if (i_rToken.Id() == TokPunctuation::Semicolon)
146cdf0e10cSrcweir {
147cdf0e10cSrcweir SetResult(done, pop_success);
148cdf0e10cSrcweir eState = e_none;
149cdf0e10cSrcweir }
150cdf0e10cSrcweir else if (i_rToken.Id() == TokPunctuation::Comma)
151cdf0e10cSrcweir SetResult(done, stay);
152cdf0e10cSrcweir else
153cdf0e10cSrcweir SetResult(not_done, pop_failure);
154cdf0e10cSrcweir break;
155cdf0e10cSrcweir default:
156cdf0e10cSrcweir csv_assert(false);
157cdf0e10cSrcweir }
158cdf0e10cSrcweir }
159cdf0e10cSrcweir
160cdf0e10cSrcweir void
Process_Default()161cdf0e10cSrcweir PE_Property::Process_Default()
162cdf0e10cSrcweir {
163cdf0e10cSrcweir if (eState == expect_variable)
164cdf0e10cSrcweir {
165cdf0e10cSrcweir SetResult(not_done, push_sure, pPE_Variable.Ptr());
166cdf0e10cSrcweir eState = in_variable;
167cdf0e10cSrcweir }
168cdf0e10cSrcweir else
169cdf0e10cSrcweir SetResult(not_done, pop_failure);
170cdf0e10cSrcweir }
171cdf0e10cSrcweir
172cdf0e10cSrcweir void
InitData()173cdf0e10cSrcweir PE_Property::InitData()
174cdf0e10cSrcweir {
175cdf0e10cSrcweir eState = e_start;
176cdf0e10cSrcweir
177cdf0e10cSrcweir nCurParsedType = 0;
178cdf0e10cSrcweir sCurParsedName = "";
179cdf0e10cSrcweir
180cdf0e10cSrcweir // bIsOptional and
181cdf0e10cSrcweir // aStereotypes
182cdf0e10cSrcweir // may be preset by the PE_Service-(or PE_Interface-)parent
183cdf0e10cSrcweir // with PresetOptional() or
184cdf0e10cSrcweir // PresetStereotype()
185cdf0e10cSrcweir // - therefore it must not be set here!
186cdf0e10cSrcweir }
187cdf0e10cSrcweir
188cdf0e10cSrcweir void
TransferData()189cdf0e10cSrcweir PE_Property::TransferData()
190cdf0e10cSrcweir {
191cdf0e10cSrcweir if (bIsOptional)
192cdf0e10cSrcweir {
193cdf0e10cSrcweir SetOptional();
194cdf0e10cSrcweir bIsOptional = false;
195cdf0e10cSrcweir }
196cdf0e10cSrcweir
197cdf0e10cSrcweir ary::idl::CodeEntity *
198cdf0e10cSrcweir pCe = 0;
199cdf0e10cSrcweir csv_assert(pCurOwner->IsValid());
200cdf0e10cSrcweir
201cdf0e10cSrcweir pCe = &Gate().Ces().Store_Property( *pCurOwner,
202cdf0e10cSrcweir sCurParsedName,
203cdf0e10cSrcweir nCurParsedType,
204cdf0e10cSrcweir aStereotypes );
205cdf0e10cSrcweir
206cdf0e10cSrcweir csv_assert(pCe != 0);
207cdf0e10cSrcweir PassDocuAt(*pCe);
208cdf0e10cSrcweir
209cdf0e10cSrcweir nCurParsedType = 0;
210cdf0e10cSrcweir sCurParsedName.clear();
211cdf0e10cSrcweir aStereotypes = Stereotypes();
212cdf0e10cSrcweir
213cdf0e10cSrcweir eState = e_none;
214cdf0e10cSrcweir }
215cdf0e10cSrcweir
216cdf0e10cSrcweir void
ReceiveData()217cdf0e10cSrcweir PE_Property::ReceiveData()
218cdf0e10cSrcweir {
219cdf0e10cSrcweir eState = expect_variable;
220cdf0e10cSrcweir }
221cdf0e10cSrcweir
222cdf0e10cSrcweir
223cdf0e10cSrcweir UnoIDL_PE &
MyPE()224cdf0e10cSrcweir PE_Property::MyPE()
225cdf0e10cSrcweir {
226cdf0e10cSrcweir return *this;
227cdf0e10cSrcweir }
228cdf0e10cSrcweir
229cdf0e10cSrcweir
230cdf0e10cSrcweir } // namespace uidl
231cdf0e10cSrcweir } // namespace csi
232cdf0e10cSrcweir
233