merge the formfield patch from ooo-build
[ooovba.git] / autodoc / source / parser_i / idl / pe_func2.cxx
blob990d6d073a0ac75a2144c0be8da771366212ff72
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_func2.cxx,v $
10 * $Revision: 1.10 $
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_func2.hxx>
35 // NOT FULLY DEFINED SERVICES
36 #include <ary/idl/i_function.hxx>
37 #include <ary/idl/i_type.hxx>
38 #include <ary/idl/i_gate.hxx>
39 #include <ary/idl/ip_ce.hxx>
40 #include <ary/idl/ip_type.hxx>
41 #include <ary/doc/d_oldidldocu.hxx>
42 #include <s2_luidl/pe_type2.hxx>
43 #include <s2_luidl/pe_vari2.hxx>
44 #include <s2_luidl/tk_keyw.hxx>
45 #include <s2_luidl/tk_ident.hxx>
46 #include <s2_luidl/tk_punct.hxx>
47 #include <x_parse2.hxx>
50 namespace csi
52 namespace uidl
56 PE_Function::PE_Function( const RParent & i_rCurInterface )
57 : eState(e_none),
58 sData_Name(),
59 nData_ReturnType(0),
60 bData_Oneway(false),
61 pCurFunction(0),
62 pCurParent(&i_rCurInterface),
63 pPE_Type(0),
64 nCurParsedType(0),
65 sName(),
66 pPE_Variable(0),
67 eCurParsedParam_Direction(ary::idl::param_in),
68 nCurParsedParam_Type(0),
69 sCurParsedParam_Name(),
70 bIsForConstructors(false)
72 pPE_Type = new PE_Type(nCurParsedType);
73 pPE_Variable = new PE_Variable(nCurParsedParam_Type, sCurParsedParam_Name);
76 PE_Function::PE_Function( const RParent & i_rCurService,
77 E_Constructor )
78 : eState(expect_name),
79 sData_Name(),
80 nData_ReturnType(0),
81 bData_Oneway(false),
82 pCurFunction(0),
83 pCurParent(&i_rCurService),
84 pPE_Type(0),
85 nCurParsedType(0),
86 sName(),
87 pPE_Variable(0),
88 eCurParsedParam_Direction(ary::idl::param_in),
89 nCurParsedParam_Type(0),
90 sCurParsedParam_Name(),
91 bIsForConstructors(true)
93 pPE_Type = new PE_Type(nCurParsedType);
94 pPE_Variable = new PE_Variable(nCurParsedParam_Type, sCurParsedParam_Name);
97 void
98 PE_Function::EstablishContacts( UnoIDL_PE * io_pParentPE,
99 ary::Repository & io_rRepository,
100 TokenProcessing_Result & o_rResult )
102 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
103 pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
104 pPE_Variable->EstablishContacts(this,io_rRepository,o_rResult);
107 PE_Function::~PE_Function()
111 void
112 PE_Function::ProcessToken( const Token & i_rToken )
114 i_rToken.Trigger(*this);
117 void
118 PE_Function::Process_Stereotype( const TokStereotype & i_rToken )
120 if (eState == e_start)
122 switch (i_rToken.Id())
124 case TokStereotype::ste_oneway:
125 bData_Oneway = true;
126 SetResult(done, stay);
127 break;
128 default:
129 OnDefault();
130 } // end switch
132 else
133 OnDefault();
136 void
137 PE_Function::Process_Identifier( const TokIdentifier & i_rToken )
139 switch (eState)
141 case e_start:
142 GoIntoReturnType();
143 break;
144 case expect_name:
145 sData_Name = i_rToken.Text();
146 SetResult(done,stay);
147 eState = expect_params_list;
149 if (NOT bIsForConstructors)
151 pCurFunction = &Gate().Ces().Store_Function(
152 *pCurParent,
153 sData_Name,
154 nData_ReturnType,
155 bData_Oneway );
157 else
159 pCurFunction = &Gate().Ces().Store_ServiceConstructor(
160 *pCurParent,
161 sData_Name );
163 PassDocuAt(*pCurFunction);
164 break;
165 case expect_parameter_variable:
166 GoIntoParameterVariable();
167 break;
168 case expect_exception:
169 GoIntoException();
170 break;
171 default:
172 OnDefault();
176 void
177 PE_Function::Process_Punctuation( const TokPunctuation & i_rToken )
179 switch (eState)
181 case e_start:
182 SetResult(done,stay);
183 break;
184 case expect_params_list:
185 if (i_rToken.Id() != TokPunctuation::BracketOpen)
187 OnDefault();
188 return;
190 SetResult(done,stay);
191 eState = expect_parameter;
192 break;
193 case expect_parameter:
194 if (i_rToken.Id() == TokPunctuation::BracketClose)
196 SetResult(done,stay);
197 eState = params_finished;
199 else
201 OnDefault();
202 return;
204 break;
205 case expect_parameter_separator:
206 if (i_rToken.Id() == TokPunctuation::Comma)
208 SetResult(done,stay);
209 eState = expect_parameter;
211 else if (i_rToken.Id() == TokPunctuation::BracketClose)
213 SetResult(done,stay);
214 eState = params_finished;
216 else
218 OnDefault();
219 return;
221 break;
222 case params_finished:
223 case exceptions_finished:
224 if (i_rToken.Id() != TokPunctuation::Semicolon)
226 OnDefault();
227 return;
229 SetResult(done,pop_success);
230 eState = e_none;
231 break;
232 case expect_exceptions_list:
233 if (i_rToken.Id() != TokPunctuation::BracketOpen)
235 OnDefault();
236 return;
238 SetResult(done,stay);
239 eState = expect_exception;
240 break;
241 case expect_exception_separator:
242 if (i_rToken.Id() == TokPunctuation::Comma)
244 SetResult(done,stay);
245 eState = expect_exception;
247 else if (i_rToken.Id() == TokPunctuation::BracketClose)
249 SetResult(done,stay);
250 eState = exceptions_finished;
252 else
254 OnDefault();
255 return;
257 break;
258 default:
259 OnDefault();
263 void
264 PE_Function::Process_BuiltInType( const TokBuiltInType & i_rToken )
266 switch (eState)
268 case e_start:
269 GoIntoReturnType();
270 break;
271 case expect_parameter_variable:
272 GoIntoParameterVariable();
273 break;
274 case expect_parameter_separator:
275 if (i_rToken.Id() != TokBuiltInType::bty_ellipse)
277 OnDefault();
279 else
281 pCurFunction->Set_Ellipse();
282 SetResult(done,stay);
283 // eState stays the same, because we wait for the closing ")" now.
285 break;
286 case expect_exception:
287 GoIntoException();
288 break;
289 default:
290 OnDefault();
291 } // end switch
294 void
295 PE_Function::Process_ParameterHandling( const TokParameterHandling & i_rToken )
297 if (eState != expect_parameter)
299 OnDefault();
300 return;
303 switch (i_rToken.Id())
305 case TokParameterHandling::ph_in:
306 eCurParsedParam_Direction = ary::idl::param_in;
307 break;
308 case TokParameterHandling::ph_out:
309 eCurParsedParam_Direction = ary::idl::param_out;
310 break;
311 case TokParameterHandling::ph_inout:
312 eCurParsedParam_Direction = ary::idl::param_inout;
313 break;
314 default:
315 csv_assert(false);
317 SetResult(done,stay);
318 eState = expect_parameter_variable;
321 void
322 PE_Function::Process_Raises()
324 if (eState != params_finished)
326 OnDefault();
327 return;
329 SetResult(done,stay);
330 eState = expect_exceptions_list;
333 void
334 PE_Function::Process_Default()
336 switch (eState)
338 case e_start:
339 GoIntoReturnType();
340 break;
341 case expect_parameter_variable:
342 GoIntoParameterVariable();
343 break;
344 case expect_exception:
345 GoIntoException();
346 break;
347 default:
348 OnDefault();
349 } // end switch
352 void
353 PE_Function::GoIntoReturnType()
355 SetResult(not_done, push_sure, pPE_Type.Ptr());
356 eState = in_return_type;
359 void
360 PE_Function::GoIntoParameterVariable()
362 SetResult(not_done, push_sure, pPE_Variable.Ptr());
363 eState = in_parameter_variable;
366 void
367 PE_Function::GoIntoException()
369 SetResult(not_done, push_sure, pPE_Type.Ptr());
370 eState = in_exception;
373 void
374 PE_Function::OnDefault()
376 throw X_AutodocParser(X_AutodocParser::x_Any);
379 void
380 PE_Function::InitData()
382 eState = e_start;
384 sData_Name.clear();
385 nData_ReturnType = 0;
386 bData_Oneway = false;
387 pCurFunction = 0;
389 nCurParsedType = 0;
390 eCurParsedParam_Direction = ary::idl::param_in;
391 nCurParsedParam_Type = 0;
392 sCurParsedParam_Name.clear();
394 if (bIsForConstructors)
396 eState = expect_name;
400 void
401 PE_Function::ReceiveData()
403 switch (eState)
405 case in_return_type:
406 nData_ReturnType = nCurParsedType;
407 nCurParsedType = 0;
408 eState = expect_name;
409 break;
410 case in_parameter_variable:
411 csv_assert(pCurFunction != 0);
412 pCurFunction->Add_Parameter(
413 sCurParsedParam_Name,
414 nCurParsedParam_Type,
415 eCurParsedParam_Direction );
416 sCurParsedParam_Name = "";
417 nCurParsedParam_Type = 0;
418 eCurParsedParam_Direction = ary::idl::param_in;
419 eState = expect_parameter_separator;
420 break;
421 case in_exception:
422 csv_assert(pCurFunction != 0);
423 pCurFunction->Add_Exception(nCurParsedType);
424 eState = expect_exception_separator;
425 break;
426 default:
427 csv_assert(false);
428 } // end switch
431 void
432 PE_Function::TransferData()
434 pCurFunction = 0;
435 eState = e_none;
438 UnoIDL_PE &
439 PE_Function::MyPE()
441 return *this;
446 } // namespace uidl
447 } // namespace csi