1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pe_func2.cxx,v $
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 ************************************************************************/
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>
56 PE_Function::PE_Function( const RParent
& i_rCurInterface
)
62 pCurParent(&i_rCurInterface
),
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
,
78 : eState(expect_name
),
83 pCurParent(&i_rCurService
),
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
);
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()
112 PE_Function::ProcessToken( const Token
& i_rToken
)
114 i_rToken
.Trigger(*this);
118 PE_Function::Process_Stereotype( const TokStereotype
& i_rToken
)
120 if (eState
== e_start
)
122 switch (i_rToken
.Id())
124 case TokStereotype::ste_oneway
:
126 SetResult(done
, stay
);
137 PE_Function::Process_Identifier( const TokIdentifier
& i_rToken
)
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(
159 pCurFunction
= &Gate().Ces().Store_ServiceConstructor(
163 PassDocuAt(*pCurFunction
);
165 case expect_parameter_variable
:
166 GoIntoParameterVariable();
168 case expect_exception
:
177 PE_Function::Process_Punctuation( const TokPunctuation
& i_rToken
)
182 SetResult(done
,stay
);
184 case expect_params_list
:
185 if (i_rToken
.Id() != TokPunctuation::BracketOpen
)
190 SetResult(done
,stay
);
191 eState
= expect_parameter
;
193 case expect_parameter
:
194 if (i_rToken
.Id() == TokPunctuation::BracketClose
)
196 SetResult(done
,stay
);
197 eState
= params_finished
;
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
;
222 case params_finished
:
223 case exceptions_finished
:
224 if (i_rToken
.Id() != TokPunctuation::Semicolon
)
229 SetResult(done
,pop_success
);
232 case expect_exceptions_list
:
233 if (i_rToken
.Id() != TokPunctuation::BracketOpen
)
238 SetResult(done
,stay
);
239 eState
= expect_exception
;
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
;
264 PE_Function::Process_BuiltInType( const TokBuiltInType
& i_rToken
)
271 case expect_parameter_variable
:
272 GoIntoParameterVariable();
274 case expect_parameter_separator
:
275 if (i_rToken
.Id() != TokBuiltInType::bty_ellipse
)
281 pCurFunction
->Set_Ellipse();
282 SetResult(done
,stay
);
283 // eState stays the same, because we wait for the closing ")" now.
286 case expect_exception
:
295 PE_Function::Process_ParameterHandling( const TokParameterHandling
& i_rToken
)
297 if (eState
!= expect_parameter
)
303 switch (i_rToken
.Id())
305 case TokParameterHandling::ph_in
:
306 eCurParsedParam_Direction
= ary::idl::param_in
;
308 case TokParameterHandling::ph_out
:
309 eCurParsedParam_Direction
= ary::idl::param_out
;
311 case TokParameterHandling::ph_inout
:
312 eCurParsedParam_Direction
= ary::idl::param_inout
;
317 SetResult(done
,stay
);
318 eState
= expect_parameter_variable
;
322 PE_Function::Process_Raises()
324 if (eState
!= params_finished
)
329 SetResult(done
,stay
);
330 eState
= expect_exceptions_list
;
334 PE_Function::Process_Default()
341 case expect_parameter_variable
:
342 GoIntoParameterVariable();
344 case expect_exception
:
353 PE_Function::GoIntoReturnType()
355 SetResult(not_done
, push_sure
, pPE_Type
.Ptr());
356 eState
= in_return_type
;
360 PE_Function::GoIntoParameterVariable()
362 SetResult(not_done
, push_sure
, pPE_Variable
.Ptr());
363 eState
= in_parameter_variable
;
367 PE_Function::GoIntoException()
369 SetResult(not_done
, push_sure
, pPE_Type
.Ptr());
370 eState
= in_exception
;
374 PE_Function::OnDefault()
376 throw X_AutodocParser(X_AutodocParser::x_Any
);
380 PE_Function::InitData()
385 nData_ReturnType
= 0;
386 bData_Oneway
= false;
390 eCurParsedParam_Direction
= ary::idl::param_in
;
391 nCurParsedParam_Type
= 0;
392 sCurParsedParam_Name
.clear();
394 if (bIsForConstructors
)
396 eState
= expect_name
;
401 PE_Function::ReceiveData()
406 nData_ReturnType
= nCurParsedType
;
408 eState
= expect_name
;
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
;
422 csv_assert(pCurFunction
!= 0);
423 pCurFunction
->Add_Exception(nCurParsedType
);
424 eState
= expect_exception_separator
;
432 PE_Function::TransferData()