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_attri.hxx>
24
25
26 // NOT FULLY DEFINED SERVICES
27 #include <ary/idl/i_gate.hxx>
28 #include <ary/idl/i_attribute.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_type2.hxx>
33 #include <s2_luidl/pe_vari2.hxx>
34 #include <s2_luidl/tk_keyw.hxx>
35 #include <s2_luidl/tk_ident.hxx>
36 #include <s2_luidl/tk_punct.hxx>
37
38
39
40 namespace csi
41 {
42 namespace uidl
43 {
44
45
46
PE_Attribute(const Ce_id & i_rCurOwner)47 PE_Attribute::PE_Attribute( const Ce_id & i_rCurOwner )
48 : eState(e_none),
49 pCurOwner(&i_rCurOwner),
50 pPE_Variable(0),
51 pPE_Exception(0),
52 pCurAttribute(0),
53 nCurParsedType(0),
54 sCurParsedName(),
55 bReadOnly(false),
56 bBound(false)
57 {
58 pPE_Variable = new PE_Variable(nCurParsedType, sCurParsedName);
59 pPE_Exception = new PE_Type(nCurParsedType);
60 }
61
62 void
EstablishContacts(UnoIDL_PE * io_pParentPE,ary::Repository & io_rRepository,TokenProcessing_Result & o_rResult)63 PE_Attribute::EstablishContacts( UnoIDL_PE * io_pParentPE,
64 ary::Repository & io_rRepository,
65 TokenProcessing_Result & o_rResult )
66 {
67 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
68 pPE_Variable->EstablishContacts(this,io_rRepository,o_rResult);
69 pPE_Exception->EstablishContacts(this,io_rRepository,o_rResult);
70 }
71
~PE_Attribute()72 PE_Attribute::~PE_Attribute()
73 {
74 }
75
76 void
ProcessToken(const Token & i_rToken)77 PE_Attribute::ProcessToken( const Token & i_rToken )
78 {
79 i_rToken.Trigger(*this);
80 }
81
82 void
Process_Identifier(const TokIdentifier & i_rToken)83 PE_Attribute::Process_Identifier( const TokIdentifier & i_rToken )
84 {
85 switch (eState)
86 {
87 case e_start:
88 SetResult(not_done, push_sure, pPE_Variable.Ptr());
89 eState = in_variable;
90 break;
91 case in_raise_std:
92 if (strcmp(i_rToken.Text(),"get") == 0)
93 {
94 SetResult(done, stay);
95 eState = in_get;
96 }
97 else if (strcmp(i_rToken.Text(),"set") == 0)
98 {
99 SetResult(done, stay);
100 eState = in_set;
101 }
102 else
103 {
104 SetResult(not_done, pop_failure);
105 eState = e_none;
106 }
107 break;
108 case in_get:
109 case in_set:
110 SetResult(not_done, push_sure, pPE_Exception.Ptr());
111 break;
112 default:
113 SetResult(not_done, pop_failure);
114 } // end switch
115 }
116
117 void
Process_Stereotype(const TokStereotype & i_rToken)118 PE_Attribute::Process_Stereotype( const TokStereotype & i_rToken )
119 {
120 if (eState != e_start)
121 {
122 SetResult(not_done, pop_failure);
123 eState = e_none;
124 return;
125 }
126
127 switch (i_rToken.Id())
128 {
129 case TokStereotype::ste_readonly:
130 bReadOnly = true;
131 break;
132 case TokStereotype::ste_bound:
133 bBound = true;
134 break;
135 default:
136 SetResult(not_done, pop_failure);
137 eState = e_none;
138 return;
139 } // end switch
140
141 SetResult(done, stay);
142 }
143
144 void
Process_MetaType(const TokMetaType & i_rToken)145 PE_Attribute::Process_MetaType( const TokMetaType & i_rToken )
146 {
147 if (eState != e_start OR i_rToken.Id() != TokMetaType::mt_attribute)
148 {
149 SetResult(not_done, pop_failure);
150 eState = e_none;
151 return;
152 }
153
154 SetResult(done, stay);
155 }
156
157 void
Process_Punctuation(const TokPunctuation & i_rToken)158 PE_Attribute::Process_Punctuation( const TokPunctuation & i_rToken )
159 {
160 switch (eState)
161 {
162 case e_start:
163 SetResult(done, stay);
164 break;
165 case expect_end:
166 switch(i_rToken.Id())
167 {
168 case TokPunctuation::Semicolon:
169 SetResult(done, pop_success);
170 eState = e_none;
171 break;
172 case TokPunctuation::Comma:
173 SetResult(not_done, pop_failure);
174 Cerr() << "Autodoc does not support comma separated attributes, because those are discouraged by IDL policies." << Endl();
175 break;
176 case TokPunctuation::CurledBracketOpen:
177 SetResult(done, stay);
178 eState = in_raise_std;
179 break;
180 default:
181 SetResult(not_done, pop_failure);
182 } // end switch
183 break;
184 case in_raise_std:
185 SetResult(done, stay);
186 if (i_rToken.Id() == TokPunctuation::CurledBracketClose)
187 {
188 eState = expect_end;
189 }
190 break;
191 case in_get:
192 case in_set:
193 SetResult(done, stay);
194 if (i_rToken.Id() == TokPunctuation::Semicolon)
195 {
196 eState = in_raise_std;
197 }
198 break;
199 default:
200 csv_assert(false);
201 }
202 }
203
204 void
Process_Raises()205 PE_Attribute::Process_Raises()
206 {
207 if (eState == in_get OR eState == in_set)
208 {
209 SetResult(done, stay);
210 }
211 else
212 SetResult(not_done, pop_failure);
213 }
214
215 void
Process_Default()216 PE_Attribute::Process_Default()
217 {
218 if (eState == e_start)
219 {
220 SetResult(not_done, push_sure, pPE_Variable.Ptr());
221 eState = in_variable;
222 }
223 else if (eState == in_get OR eState == in_set)
224 SetResult(not_done, push_sure, pPE_Exception.Ptr());
225 else
226 SetResult(not_done, pop_failure);
227 }
228
229 void
InitData()230 PE_Attribute::InitData()
231 {
232 eState = e_start;
233
234 pCurAttribute = 0;
235 nCurParsedType = 0;
236 sCurParsedName = "";
237 bReadOnly = false;
238 bBound = false;
239 }
240
241 void
TransferData()242 PE_Attribute::TransferData()
243 {
244 eState = e_none;
245 }
246
247 void
ReceiveData()248 PE_Attribute::ReceiveData()
249 {
250 switch (eState)
251 {
252 case in_variable:
253 csv_assert(pCurOwner->IsValid());
254 pCurAttribute = &Gate().Ces().Store_Attribute(
255 *pCurOwner,
256 sCurParsedName,
257 nCurParsedType,
258 bReadOnly,
259 bBound );
260 PassDocuAt(*pCurAttribute);
261 nCurParsedType = 0;
262 eState = expect_end;
263 break;
264 case in_get:
265 csv_assert(pCurAttribute != 0);
266 pCurAttribute->Add_GetException(nCurParsedType);
267 nCurParsedType = 0;
268 break;
269 case in_set:
270 csv_assert(pCurAttribute != 0);
271 pCurAttribute->Add_SetException(nCurParsedType);
272 nCurParsedType = 0;
273 break;
274 default:
275 csv_assert(false);
276 } // end switch
277 }
278
279
280 UnoIDL_PE &
MyPE()281 PE_Attribute::MyPE()
282 {
283 return *this;
284 }
285
286
287 } // namespace uidl
288 } // namespace csi
289