Update ooo320-m1
[ooovba.git] / autodoc / source / parser_i / idl / pe_attri.cxx
blob65f2cd419e9377f6731a3a59c16be9ce116944dc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pe_attri.cxx,v $
10 * $Revision: 1.8 $
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 ************************************************************************/
31 #include <precomp.h>
32 #include <s2_luidl/pe_attri.hxx>
35 // NOT FULLY DEFINED SERVICES
36 #include <ary/idl/i_gate.hxx>
37 #include <ary/idl/i_attribute.hxx>
38 #include <ary/idl/i_service.hxx>
39 #include <ary/idl/ip_ce.hxx>
40 #include <ary/doc/d_oldidldocu.hxx>
41 #include <s2_luidl/pe_type2.hxx>
42 #include <s2_luidl/pe_vari2.hxx>
43 #include <s2_luidl/tk_keyw.hxx>
44 #include <s2_luidl/tk_ident.hxx>
45 #include <s2_luidl/tk_punct.hxx>
49 namespace csi
51 namespace uidl
56 PE_Attribute::PE_Attribute( const Ce_id & i_rCurOwner )
57 : eState(e_none),
58 pCurOwner(&i_rCurOwner),
59 pPE_Variable(0),
60 pPE_Exception(0),
61 pCurAttribute(0),
62 nCurParsedType(0),
63 sCurParsedName(),
64 bReadOnly(false),
65 bBound(false)
67 pPE_Variable = new PE_Variable(nCurParsedType, sCurParsedName);
68 pPE_Exception = new PE_Type(nCurParsedType);
71 void
72 PE_Attribute::EstablishContacts( UnoIDL_PE * io_pParentPE,
73 ary::Repository & io_rRepository,
74 TokenProcessing_Result & o_rResult )
76 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
77 pPE_Variable->EstablishContacts(this,io_rRepository,o_rResult);
78 pPE_Exception->EstablishContacts(this,io_rRepository,o_rResult);
81 PE_Attribute::~PE_Attribute()
85 void
86 PE_Attribute::ProcessToken( const Token & i_rToken )
88 i_rToken.Trigger(*this);
91 void
92 PE_Attribute::Process_Identifier( const TokIdentifier & i_rToken )
94 switch (eState)
96 case e_start:
97 SetResult(not_done, push_sure, pPE_Variable.Ptr());
98 eState = in_variable;
99 break;
100 case in_raise_std:
101 if (strcmp(i_rToken.Text(),"get") == 0)
103 SetResult(done, stay);
104 eState = in_get;
106 else if (strcmp(i_rToken.Text(),"set") == 0)
108 SetResult(done, stay);
109 eState = in_set;
111 else
113 SetResult(not_done, pop_failure);
114 eState = e_none;
116 break;
117 case in_get:
118 case in_set:
119 SetResult(not_done, push_sure, pPE_Exception.Ptr());
120 break;
121 default:
122 SetResult(not_done, pop_failure);
123 } // end switch
126 void
127 PE_Attribute::Process_Stereotype( const TokStereotype & i_rToken )
129 if (eState != e_start)
131 SetResult(not_done, pop_failure);
132 eState = e_none;
133 return;
136 switch (i_rToken.Id())
138 case TokStereotype::ste_readonly:
139 bReadOnly = true;
140 break;
141 case TokStereotype::ste_bound:
142 bBound = true;
143 break;
144 default:
145 SetResult(not_done, pop_failure);
146 eState = e_none;
147 return;
148 } // end switch
150 SetResult(done, stay);
153 void
154 PE_Attribute::Process_MetaType( const TokMetaType & i_rToken )
156 if (eState != e_start OR i_rToken.Id() != TokMetaType::mt_attribute)
158 SetResult(not_done, pop_failure);
159 eState = e_none;
160 return;
163 SetResult(done, stay);
166 void
167 PE_Attribute::Process_Punctuation( const TokPunctuation & i_rToken )
169 switch (eState)
171 case e_start:
172 SetResult(done, stay);
173 break;
174 case expect_end:
175 switch(i_rToken.Id())
177 case TokPunctuation::Semicolon:
178 SetResult(done, pop_success);
179 eState = e_none;
180 break;
181 case TokPunctuation::Comma:
182 SetResult(not_done, pop_failure);
183 Cerr() << "Autodoc does not support comma separated attributes, because those are discouraged by IDL policies." << Endl();
184 break;
185 case TokPunctuation::CurledBracketOpen:
186 SetResult(done, stay);
187 eState = in_raise_std;
188 break;
189 default:
190 SetResult(not_done, pop_failure);
191 } // end switch
192 break;
193 case in_raise_std:
194 SetResult(done, stay);
195 if (i_rToken.Id() == TokPunctuation::CurledBracketClose)
197 eState = expect_end;
199 break;
200 case in_get:
201 case in_set:
202 SetResult(done, stay);
203 if (i_rToken.Id() == TokPunctuation::Semicolon)
205 eState = in_raise_std;
207 break;
208 default:
209 csv_assert(false);
213 void
214 PE_Attribute::Process_Raises()
216 if (eState == in_get OR eState == in_set)
218 SetResult(done, stay);
220 else
221 SetResult(not_done, pop_failure);
224 void
225 PE_Attribute::Process_Default()
227 if (eState == e_start)
229 SetResult(not_done, push_sure, pPE_Variable.Ptr());
230 eState = in_variable;
232 else if (eState == in_get OR eState == in_set)
233 SetResult(not_done, push_sure, pPE_Exception.Ptr());
234 else
235 SetResult(not_done, pop_failure);
238 void
239 PE_Attribute::InitData()
241 eState = e_start;
243 pCurAttribute = 0;
244 nCurParsedType = 0;
245 sCurParsedName = "";
246 bReadOnly = false;
247 bBound = false;
250 void
251 PE_Attribute::TransferData()
253 eState = e_none;
256 void
257 PE_Attribute::ReceiveData()
259 switch (eState)
261 case in_variable:
262 csv_assert(pCurOwner->IsValid());
263 pCurAttribute = &Gate().Ces().Store_Attribute(
264 *pCurOwner,
265 sCurParsedName,
266 nCurParsedType,
267 bReadOnly,
268 bBound );
269 PassDocuAt(*pCurAttribute);
270 nCurParsedType = 0;
271 eState = expect_end;
272 break;
273 case in_get:
274 csv_assert(pCurAttribute != 0);
275 pCurAttribute->Add_GetException(nCurParsedType);
276 nCurParsedType = 0;
277 break;
278 case in_set:
279 csv_assert(pCurAttribute != 0);
280 pCurAttribute->Add_SetException(nCurParsedType);
281 nCurParsedType = 0;
282 break;
283 default:
284 csv_assert(false);
285 } // end switch
289 UnoIDL_PE &
290 PE_Attribute::MyPE()
292 return *this;
296 } // namespace uidl
297 } // namespace csi