merge the formfield patch from ooo-build
[ooovba.git] / autodoc / source / parser / cpp / pe_param.cxx
blob97d28777b434b72fa41c051a0ca6c2fd4672cad8
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_param.cxx,v $
10 * $Revision: 1.11 $
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 "pe_param.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <cosv/tpl/tpltools.hxx>
37 #include <ary/cpp/c_gate.hxx>
38 #include <ary/cpp/cp_type.hxx>
39 #include "pe_type.hxx"
40 #include "pe_vari.hxx"
43 namespace cpp {
47 //*********************** PE_Parameter ***********************//
50 PE_Parameter::PE_Parameter( Cpp_PE * i_pParent )
51 : Cpp_PE(i_pParent),
52 pStati( new PeStatusArray<PE_Parameter> )
53 // pSpType,
54 // pSpuType,
55 // pSpVariable,
56 // pSpuVariable,
57 // aResultParamInfo
59 Setup_StatusFunctions();
61 pSpType = new SP_Type(*this);
62 pSpuType = new SPU_Type(*pSpType, &PE_Parameter::SpInit_Type, &PE_Parameter::SpReturn_Type);
63 pSpVariable = new SP_Variable(*this);
64 pSpuVariable = new SPU_Variable(*pSpVariable, &PE_Parameter::SpInit_Variable, &PE_Parameter::SpReturn_Variable);
67 PE_Parameter::~PE_Parameter()
71 void
72 PE_Parameter::Call_Handler( const cpp::Token & i_rTok )
74 pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text());
77 void
78 PE_Parameter::Setup_StatusFunctions()
80 typedef CallFunction<PE_Parameter>::F_Tok F_Tok;
81 static F_Tok stateF_start[] = { &PE_Parameter::On_start_Type,
82 &PE_Parameter::On_start_Type,
83 &PE_Parameter::On_start_Type,
84 &PE_Parameter::On_start_Type,
85 &PE_Parameter::On_start_Type,
87 &PE_Parameter::On_start_Type,
88 &PE_Parameter::On_start_Type,
89 &PE_Parameter::On_start_Bracket_Right,
90 &PE_Parameter::On_start_Type,
91 &PE_Parameter::On_start_Ellipse,
93 &PE_Parameter::On_start_Type,
94 &PE_Parameter::On_start_Type,
95 &PE_Parameter::On_start_Type };
96 static INT16 stateT_start[] = { Tid_Identifier,
97 Tid_class,
98 Tid_struct,
99 Tid_union,
100 Tid_enum,
102 Tid_const,
103 Tid_volatile,
104 Tid_Bracket_Right,
105 Tid_DoubleColon,
106 Tid_Ellipse,
108 Tid_typename,
109 Tid_BuiltInType,
110 Tid_TypeSpecializer };
112 static F_Tok stateF_expectName[] = { &PE_Parameter::On_expectName_Identifier,
113 &PE_Parameter::On_expectName_ArrayBracket_Left,
114 &PE_Parameter::On_expectName_Bracket_Right,
115 &PE_Parameter::On_expectName_Comma,
116 &PE_Parameter::On_afterName_Assign };
117 static INT16 stateT_expectName[] = { Tid_Identifier,
118 Tid_ArrayBracket_Left,
119 Tid_Bracket_Right,
120 Tid_Comma,
121 Tid_Assign };
122 static F_Tok stateF_afterName[] = { &PE_Parameter::On_afterName_ArrayBracket_Left,
123 &PE_Parameter::On_afterName_Bracket_Right,
124 &PE_Parameter::On_afterName_Comma,
125 &PE_Parameter::On_afterName_Assign };
126 static INT16 stateT_afterName[] = { Tid_ArrayBracket_Left,
127 Tid_Bracket_Right,
128 Tid_Comma,
129 Tid_Assign };
130 static F_Tok stateF_finished[] = { &PE_Parameter::On_finished_Comma,
131 &PE_Parameter::On_finished_Bracket_Right };
132 static INT16 stateT_finished[] = { Tid_Bracket_Right,
133 Tid_Comma };
135 SEMPARSE_CREATE_STATUS(PE_Parameter, start, Hdl_SyntaxError);
136 SEMPARSE_CREATE_STATUS(PE_Parameter, expectName, Hdl_SyntaxError);
137 SEMPARSE_CREATE_STATUS(PE_Parameter, afterName, Hdl_SyntaxError);
138 SEMPARSE_CREATE_STATUS(PE_Parameter, finished, Hdl_SyntaxError);
142 void
143 PE_Parameter::InitData()
145 pStati->SetCur(start);
146 aResultParamInfo.Empty();
149 void
150 PE_Parameter::TransferData()
152 pStati->SetCur(size_of_states);
155 void
156 PE_Parameter::Hdl_SyntaxError( const char * i_sText)
158 StdHandlingOfSyntaxError(i_sText);
161 void
162 PE_Parameter::SpInit_Type()
164 // Does nothing.
167 void
168 PE_Parameter::SpInit_Variable()
170 // Does nothing.
173 void
174 PE_Parameter::SpReturn_Type()
176 aResultParamInfo.nType = pSpuType->Child().Result_Type().Id();
177 pStati->SetCur(expectName);
180 void
181 PE_Parameter::SpReturn_Variable()
183 if (pSpuVariable->Child().Result_Pattern() > 0)
185 aResultParamInfo.sSizeExpression = pSpuVariable->Child().Result_SizeExpression();
186 aResultParamInfo.sInitExpression = pSpuVariable->Child().Result_InitExpression();
190 void
191 PE_Parameter::On_start_Type(const char *)
193 pSpuType->Push(not_done);
196 void
197 PE_Parameter::On_start_Bracket_Right(const char *)
199 SetTokenResult(not_done, pop_success);
202 void
203 PE_Parameter::On_start_Ellipse(const char *)
205 SetTokenResult(done, pop_success);
207 aResultParamInfo.nType = Env().AryGate().Types().Tid_Ellipse();
210 void
211 PE_Parameter::On_expectName_Identifier(const char * i_sText)
213 SetTokenResult(done, stay);
214 pStati->SetCur(afterName);
216 aResultParamInfo.sName = i_sText;
219 void
220 PE_Parameter::On_expectName_ArrayBracket_Left(const char * i_sText)
222 On_afterName_ArrayBracket_Left(i_sText);
225 void
226 PE_Parameter::On_expectName_Bracket_Right(const char * i_sText)
228 On_afterName_Bracket_Right(i_sText);
231 void
232 PE_Parameter::On_expectName_Comma(const char * i_sText)
234 On_afterName_Comma(i_sText);
237 void
238 PE_Parameter::On_afterName_ArrayBracket_Left(const char *)
240 pSpuVariable->Push(not_done);
243 void
244 PE_Parameter::On_afterName_Bracket_Right(const char *)
246 SetTokenResult(not_done, pop_success);
249 void
250 PE_Parameter::On_afterName_Comma(const char *)
252 SetTokenResult(not_done, pop_success);
255 void
256 PE_Parameter::On_afterName_Assign(const char *)
258 pSpuVariable->Push(not_done);
261 void
262 PE_Parameter::On_finished_Bracket_Right(const char *)
264 SetTokenResult(not_done, pop_success);
267 void
268 PE_Parameter::On_finished_Comma(const char *)
270 SetTokenResult(not_done, pop_success);
274 } // namespace cpp