Bump for 3.6-28
[LibreOffice.git] / autodoc / source / parser_i / idl / pe_func2.cxx
bloba091fa72811afdd0f2eeb491ad83535a6ca96713
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_func2.hxx>
33 // NOT FULLY DEFINED SERVICES
34 #include <ary/idl/i_function.hxx>
35 #include <ary/idl/i_type.hxx>
36 #include <ary/idl/i_gate.hxx>
37 #include <ary/idl/ip_ce.hxx>
38 #include <ary/idl/ip_type.hxx>
39 #include <ary/doc/d_oldidldocu.hxx>
40 #include <s2_luidl/pe_type2.hxx>
41 #include <s2_luidl/pe_vari2.hxx>
42 #include <s2_luidl/tk_keyw.hxx>
43 #include <s2_luidl/tk_ident.hxx>
44 #include <s2_luidl/tk_punct.hxx>
45 #include <x_parse2.hxx>
48 namespace csi
50 namespace uidl
54 PE_Function::PE_Function( const RParent & i_rCurInterface )
55 : eState(e_none),
56 sData_Name(),
57 nData_ReturnType(0),
58 bData_Oneway(false),
59 pCurFunction(0),
60 pCurParent(&i_rCurInterface),
61 pPE_Type(0),
62 nCurParsedType(0),
63 sName(),
64 pPE_Variable(0),
65 eCurParsedParam_Direction(ary::idl::param_in),
66 nCurParsedParam_Type(0),
67 sCurParsedParam_Name(),
68 bIsForConstructors(false)
70 pPE_Type = new PE_Type(nCurParsedType);
71 pPE_Variable = new PE_Variable(nCurParsedParam_Type, sCurParsedParam_Name);
74 PE_Function::PE_Function( const RParent & i_rCurService,
75 E_Constructor )
76 : eState(expect_name),
77 sData_Name(),
78 nData_ReturnType(0),
79 bData_Oneway(false),
80 pCurFunction(0),
81 pCurParent(&i_rCurService),
82 pPE_Type(0),
83 nCurParsedType(0),
84 sName(),
85 pPE_Variable(0),
86 eCurParsedParam_Direction(ary::idl::param_in),
87 nCurParsedParam_Type(0),
88 sCurParsedParam_Name(),
89 bIsForConstructors(true)
91 pPE_Type = new PE_Type(nCurParsedType);
92 pPE_Variable = new PE_Variable(nCurParsedParam_Type, sCurParsedParam_Name);
95 void
96 PE_Function::EstablishContacts( UnoIDL_PE * io_pParentPE,
97 ary::Repository & io_rRepository,
98 TokenProcessing_Result & o_rResult )
100 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
101 pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
102 pPE_Variable->EstablishContacts(this,io_rRepository,o_rResult);
105 PE_Function::~PE_Function()
109 void
110 PE_Function::ProcessToken( const Token & i_rToken )
112 i_rToken.Trigger(*this);
115 void
116 PE_Function::Process_Stereotype( const TokStereotype & i_rToken )
118 if (eState == e_start)
120 switch (i_rToken.Id())
122 case TokStereotype::ste_oneway:
123 bData_Oneway = true;
124 SetResult(done, stay);
125 break;
126 default:
127 OnDefault();
128 } // end switch
130 else
131 OnDefault();
134 void
135 PE_Function::Process_Identifier( const TokIdentifier & i_rToken )
137 switch (eState)
139 case e_start:
140 GoIntoReturnType();
141 break;
142 case expect_name:
143 sData_Name = i_rToken.Text();
144 SetResult(done,stay);
145 eState = expect_params_list;
147 if (NOT bIsForConstructors)
149 pCurFunction = &Gate().Ces().Store_Function(
150 *pCurParent,
151 sData_Name,
152 nData_ReturnType,
153 bData_Oneway );
155 else
157 pCurFunction = &Gate().Ces().Store_ServiceConstructor(
158 *pCurParent,
159 sData_Name );
161 PassDocuAt(*pCurFunction);
162 break;
163 case expect_parameter_variable:
164 GoIntoParameterVariable();
165 break;
166 case expect_exception:
167 GoIntoException();
168 break;
169 default:
170 OnDefault();
174 void
175 PE_Function::Process_Punctuation( const TokPunctuation & i_rToken )
177 switch (eState)
179 case e_start:
180 SetResult(done,stay);
181 break;
182 case expect_params_list:
183 if (i_rToken.Id() != TokPunctuation::BracketOpen)
185 OnDefault();
186 return;
188 SetResult(done,stay);
189 eState = expect_parameter;
190 break;
191 case expect_parameter:
192 if (i_rToken.Id() == TokPunctuation::BracketClose)
194 SetResult(done,stay);
195 eState = params_finished;
197 else
199 OnDefault();
200 return;
202 break;
203 case expect_parameter_separator:
204 if (i_rToken.Id() == TokPunctuation::Comma)
206 SetResult(done,stay);
207 eState = expect_parameter;
209 else if (i_rToken.Id() == TokPunctuation::BracketClose)
211 SetResult(done,stay);
212 eState = params_finished;
214 else
216 OnDefault();
217 return;
219 break;
220 case params_finished:
221 case exceptions_finished:
222 if (i_rToken.Id() != TokPunctuation::Semicolon)
224 OnDefault();
225 return;
227 SetResult(done,pop_success);
228 eState = e_none;
229 break;
230 case expect_exceptions_list:
231 if (i_rToken.Id() != TokPunctuation::BracketOpen)
233 OnDefault();
234 return;
236 SetResult(done,stay);
237 eState = expect_exception;
238 break;
239 case expect_exception_separator:
240 if (i_rToken.Id() == TokPunctuation::Comma)
242 SetResult(done,stay);
243 eState = expect_exception;
245 else if (i_rToken.Id() == TokPunctuation::BracketClose)
247 SetResult(done,stay);
248 eState = exceptions_finished;
250 else
252 OnDefault();
253 return;
255 break;
256 default:
257 OnDefault();
261 void
262 PE_Function::Process_BuiltInType( const TokBuiltInType & i_rToken )
264 switch (eState)
266 case e_start:
267 GoIntoReturnType();
268 break;
269 case expect_parameter_variable:
270 GoIntoParameterVariable();
271 break;
272 case expect_parameter_separator:
273 if (i_rToken.Id() != TokBuiltInType::bty_ellipse)
275 OnDefault();
277 else
279 pCurFunction->Set_Ellipse();
280 SetResult(done,stay);
281 // eState stays the same, because we wait for the closing ")" now.
283 break;
284 case expect_exception:
285 GoIntoException();
286 break;
287 default:
288 OnDefault();
289 } // end switch
292 void
293 PE_Function::Process_ParameterHandling( const TokParameterHandling & i_rToken )
295 if (eState != expect_parameter)
297 OnDefault();
298 return;
301 switch (i_rToken.Id())
303 case TokParameterHandling::ph_in:
304 eCurParsedParam_Direction = ary::idl::param_in;
305 break;
306 case TokParameterHandling::ph_out:
307 eCurParsedParam_Direction = ary::idl::param_out;
308 break;
309 case TokParameterHandling::ph_inout:
310 eCurParsedParam_Direction = ary::idl::param_inout;
311 break;
312 default:
313 csv_assert(false);
315 SetResult(done,stay);
316 eState = expect_parameter_variable;
319 void
320 PE_Function::Process_Raises()
322 if (eState != params_finished)
324 OnDefault();
325 return;
327 SetResult(done,stay);
328 eState = expect_exceptions_list;
331 void
332 PE_Function::Process_Default()
334 switch (eState)
336 case e_start:
337 GoIntoReturnType();
338 break;
339 case expect_parameter_variable:
340 GoIntoParameterVariable();
341 break;
342 case expect_exception:
343 GoIntoException();
344 break;
345 default:
346 OnDefault();
347 } // end switch
350 void
351 PE_Function::GoIntoReturnType()
353 SetResult(not_done, push_sure, pPE_Type.Ptr());
354 eState = in_return_type;
357 void
358 PE_Function::GoIntoParameterVariable()
360 SetResult(not_done, push_sure, pPE_Variable.Ptr());
361 eState = in_parameter_variable;
364 void
365 PE_Function::GoIntoException()
367 SetResult(not_done, push_sure, pPE_Type.Ptr());
368 eState = in_exception;
371 void
372 PE_Function::OnDefault()
374 throw X_AutodocParser(X_AutodocParser::x_Any);
377 void
378 PE_Function::InitData()
380 eState = e_start;
382 sData_Name.clear();
383 nData_ReturnType = 0;
384 bData_Oneway = false;
385 pCurFunction = 0;
387 nCurParsedType = 0;
388 eCurParsedParam_Direction = ary::idl::param_in;
389 nCurParsedParam_Type = 0;
390 sCurParsedParam_Name.clear();
392 if (bIsForConstructors)
394 eState = expect_name;
398 void
399 PE_Function::ReceiveData()
401 switch (eState)
403 case in_return_type:
404 nData_ReturnType = nCurParsedType;
405 nCurParsedType = 0;
406 eState = expect_name;
407 break;
408 case in_parameter_variable:
409 csv_assert(pCurFunction != 0);
410 pCurFunction->Add_Parameter(
411 sCurParsedParam_Name,
412 nCurParsedParam_Type,
413 eCurParsedParam_Direction );
414 sCurParsedParam_Name = "";
415 nCurParsedParam_Type = 0;
416 eCurParsedParam_Direction = ary::idl::param_in;
417 eState = expect_parameter_separator;
418 break;
419 case in_exception:
420 csv_assert(pCurFunction != 0);
421 pCurFunction->Add_Exception(nCurParsedType);
422 eState = expect_exception_separator;
423 break;
424 default:
425 csv_assert(false);
426 } // end switch
429 void
430 PE_Function::TransferData()
432 pCurFunction = 0;
433 eState = e_none;
436 UnoIDL_PE &
437 PE_Function::MyPE()
439 return *this;
444 } // namespace uidl
445 } // namespace csi
447 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */