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