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 ************************************************************************/
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>
54 PE_Function::PE_Function( const RParent
& i_rCurInterface
)
60 pCurParent(&i_rCurInterface
),
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
,
76 : eState(expect_name
),
81 pCurParent(&i_rCurService
),
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
);
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()
110 PE_Function::ProcessToken( const Token
& i_rToken
)
112 i_rToken
.Trigger(*this);
116 PE_Function::Process_Stereotype( const TokStereotype
& i_rToken
)
118 if (eState
== e_start
)
120 switch (i_rToken
.Id())
122 case TokStereotype::ste_oneway
:
124 SetResult(done
, stay
);
135 PE_Function::Process_Identifier( const TokIdentifier
& i_rToken
)
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(
157 pCurFunction
= &Gate().Ces().Store_ServiceConstructor(
161 PassDocuAt(*pCurFunction
);
163 case expect_parameter_variable
:
164 GoIntoParameterVariable();
166 case expect_exception
:
175 PE_Function::Process_Punctuation( const TokPunctuation
& i_rToken
)
180 SetResult(done
,stay
);
182 case expect_params_list
:
183 if (i_rToken
.Id() != TokPunctuation::BracketOpen
)
188 SetResult(done
,stay
);
189 eState
= expect_parameter
;
191 case expect_parameter
:
192 if (i_rToken
.Id() == TokPunctuation::BracketClose
)
194 SetResult(done
,stay
);
195 eState
= params_finished
;
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
;
220 case params_finished
:
221 case exceptions_finished
:
222 if (i_rToken
.Id() != TokPunctuation::Semicolon
)
227 SetResult(done
,pop_success
);
230 case expect_exceptions_list
:
231 if (i_rToken
.Id() != TokPunctuation::BracketOpen
)
236 SetResult(done
,stay
);
237 eState
= expect_exception
;
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
;
262 PE_Function::Process_BuiltInType( const TokBuiltInType
& i_rToken
)
269 case expect_parameter_variable
:
270 GoIntoParameterVariable();
272 case expect_parameter_separator
:
273 if (i_rToken
.Id() != TokBuiltInType::bty_ellipse
)
279 pCurFunction
->Set_Ellipse();
280 SetResult(done
,stay
);
281 // eState stays the same, because we wait for the closing ")" now.
284 case expect_exception
:
293 PE_Function::Process_ParameterHandling( const TokParameterHandling
& i_rToken
)
295 if (eState
!= expect_parameter
)
301 switch (i_rToken
.Id())
303 case TokParameterHandling::ph_in
:
304 eCurParsedParam_Direction
= ary::idl::param_in
;
306 case TokParameterHandling::ph_out
:
307 eCurParsedParam_Direction
= ary::idl::param_out
;
309 case TokParameterHandling::ph_inout
:
310 eCurParsedParam_Direction
= ary::idl::param_inout
;
315 SetResult(done
,stay
);
316 eState
= expect_parameter_variable
;
320 PE_Function::Process_Raises()
322 if (eState
!= params_finished
)
327 SetResult(done
,stay
);
328 eState
= expect_exceptions_list
;
332 PE_Function::Process_Default()
339 case expect_parameter_variable
:
340 GoIntoParameterVariable();
342 case expect_exception
:
351 PE_Function::GoIntoReturnType()
353 SetResult(not_done
, push_sure
, pPE_Type
.Ptr());
354 eState
= in_return_type
;
358 PE_Function::GoIntoParameterVariable()
360 SetResult(not_done
, push_sure
, pPE_Variable
.Ptr());
361 eState
= in_parameter_variable
;
365 PE_Function::GoIntoException()
367 SetResult(not_done
, push_sure
, pPE_Type
.Ptr());
368 eState
= in_exception
;
372 PE_Function::OnDefault()
374 throw X_AutodocParser(X_AutodocParser::x_Any
);
378 PE_Function::InitData()
383 nData_ReturnType
= 0;
384 bData_Oneway
= false;
388 eCurParsedParam_Direction
= ary::idl::param_in
;
389 nCurParsedParam_Type
= 0;
390 sCurParsedParam_Name
.clear();
392 if (bIsForConstructors
)
394 eState
= expect_name
;
399 PE_Function::ReceiveData()
404 nData_ReturnType
= nCurParsedType
;
406 eState
= expect_name
;
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
;
420 csv_assert(pCurFunction
!= 0);
421 pCurFunction
->Add_Exception(nCurParsedType
);
422 eState
= expect_exception_separator
;
430 PE_Function::TransferData()
447 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */