Bump for 3.6-28
[LibreOffice.git] / autodoc / source / parser_i / idl / pe_attri.cxx
blob31fe8063ea6cf70fba62aa59f7824b24dbce9ebf
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 <precomp.h>
30 #include <s2_luidl/pe_attri.hxx>
33 // NOT FULLY DEFINED SERVICES
34 #include <ary/idl/i_gate.hxx>
35 #include <ary/idl/i_attribute.hxx>
36 #include <ary/idl/i_service.hxx>
37 #include <ary/idl/ip_ce.hxx>
38 #include <ary/doc/d_oldidldocu.hxx>
39 #include <s2_luidl/pe_type2.hxx>
40 #include <s2_luidl/pe_vari2.hxx>
41 #include <s2_luidl/tk_keyw.hxx>
42 #include <s2_luidl/tk_ident.hxx>
43 #include <s2_luidl/tk_punct.hxx>
47 namespace csi
49 namespace uidl
54 PE_Attribute::PE_Attribute( const Ce_id & i_rCurOwner )
55 : eState(e_none),
56 pCurOwner(&i_rCurOwner),
57 pPE_Variable(0),
58 pPE_Exception(0),
59 pCurAttribute(0),
60 nCurParsedType(0),
61 sCurParsedName(),
62 bReadOnly(false),
63 bBound(false)
65 pPE_Variable = new PE_Variable(nCurParsedType, sCurParsedName);
66 pPE_Exception = new PE_Type(nCurParsedType);
69 void
70 PE_Attribute::EstablishContacts( UnoIDL_PE * io_pParentPE,
71 ary::Repository & io_rRepository,
72 TokenProcessing_Result & o_rResult )
74 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
75 pPE_Variable->EstablishContacts(this,io_rRepository,o_rResult);
76 pPE_Exception->EstablishContacts(this,io_rRepository,o_rResult);
79 PE_Attribute::~PE_Attribute()
83 void
84 PE_Attribute::ProcessToken( const Token & i_rToken )
86 i_rToken.Trigger(*this);
89 void
90 PE_Attribute::Process_Identifier( const TokIdentifier & i_rToken )
92 switch (eState)
94 case e_start:
95 SetResult(not_done, push_sure, pPE_Variable.Ptr());
96 eState = in_variable;
97 break;
98 case in_raise_std:
99 if (strcmp(i_rToken.Text(),"get") == 0)
101 SetResult(done, stay);
102 eState = in_get;
104 else if (strcmp(i_rToken.Text(),"set") == 0)
106 SetResult(done, stay);
107 eState = in_set;
109 else
111 SetResult(not_done, pop_failure);
112 eState = e_none;
114 break;
115 case in_get:
116 case in_set:
117 SetResult(not_done, push_sure, pPE_Exception.Ptr());
118 break;
119 default:
120 SetResult(not_done, pop_failure);
121 } // end switch
124 void
125 PE_Attribute::Process_Stereotype( const TokStereotype & i_rToken )
127 if (eState != e_start)
129 SetResult(not_done, pop_failure);
130 eState = e_none;
131 return;
134 switch (i_rToken.Id())
136 case TokStereotype::ste_readonly:
137 bReadOnly = true;
138 break;
139 case TokStereotype::ste_bound:
140 bBound = true;
141 break;
142 default:
143 SetResult(not_done, pop_failure);
144 eState = e_none;
145 return;
146 } // end switch
148 SetResult(done, stay);
151 void
152 PE_Attribute::Process_MetaType( const TokMetaType & i_rToken )
154 if (eState != e_start OR i_rToken.Id() != TokMetaType::mt_attribute)
156 SetResult(not_done, pop_failure);
157 eState = e_none;
158 return;
161 SetResult(done, stay);
164 void
165 PE_Attribute::Process_Punctuation( const TokPunctuation & i_rToken )
167 switch (eState)
169 case e_start:
170 SetResult(done, stay);
171 break;
172 case expect_end:
173 switch(i_rToken.Id())
175 case TokPunctuation::Semicolon:
176 SetResult(done, pop_success);
177 eState = e_none;
178 break;
179 case TokPunctuation::Comma:
180 SetResult(not_done, pop_failure);
181 Cerr() << "Autodoc does not support comma separated attributes, because those are discouraged by IDL policies." << Endl();
182 break;
183 case TokPunctuation::CurledBracketOpen:
184 SetResult(done, stay);
185 eState = in_raise_std;
186 break;
187 default:
188 SetResult(not_done, pop_failure);
189 } // end switch
190 break;
191 case in_raise_std:
192 SetResult(done, stay);
193 if (i_rToken.Id() == TokPunctuation::CurledBracketClose)
195 eState = expect_end;
197 break;
198 case in_get:
199 case in_set:
200 SetResult(done, stay);
201 if (i_rToken.Id() == TokPunctuation::Semicolon)
203 eState = in_raise_std;
205 break;
206 default:
207 csv_assert(false);
211 void
212 PE_Attribute::Process_Raises()
214 if (eState == in_get OR eState == in_set)
216 SetResult(done, stay);
218 else
219 SetResult(not_done, pop_failure);
222 void
223 PE_Attribute::Process_Default()
225 if (eState == e_start)
227 SetResult(not_done, push_sure, pPE_Variable.Ptr());
228 eState = in_variable;
230 else if (eState == in_get OR eState == in_set)
231 SetResult(not_done, push_sure, pPE_Exception.Ptr());
232 else
233 SetResult(not_done, pop_failure);
236 void
237 PE_Attribute::InitData()
239 eState = e_start;
241 pCurAttribute = 0;
242 nCurParsedType = 0;
243 sCurParsedName = "";
244 bReadOnly = false;
245 bBound = false;
248 void
249 PE_Attribute::TransferData()
251 eState = e_none;
254 void
255 PE_Attribute::ReceiveData()
257 switch (eState)
259 case in_variable:
260 csv_assert(pCurOwner->IsValid());
261 pCurAttribute = &Gate().Ces().Store_Attribute(
262 *pCurOwner,
263 sCurParsedName,
264 nCurParsedType,
265 bReadOnly,
266 bBound );
267 PassDocuAt(*pCurAttribute);
268 nCurParsedType = 0;
269 eState = expect_end;
270 break;
271 case in_get:
272 csv_assert(pCurAttribute != 0);
273 pCurAttribute->Add_GetException(nCurParsedType);
274 nCurParsedType = 0;
275 break;
276 case in_set:
277 csv_assert(pCurAttribute != 0);
278 pCurAttribute->Add_SetException(nCurParsedType);
279 nCurParsedType = 0;
280 break;
281 default:
282 csv_assert(false);
283 } // end switch
287 UnoIDL_PE &
288 PE_Attribute::MyPE()
290 return *this;
294 } // namespace uidl
295 } // namespace csi
297 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */