xref: /trunk/main/autodoc/source/parser/cpp/pe_param.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include <precomp.h>
29 #include "pe_param.hxx"
30 
31 
32 // NOT FULLY DEFINED SERVICES
33 #include <cosv/tpl/tpltools.hxx>
34 #include <ary/cpp/c_gate.hxx>
35 #include <ary/cpp/cp_type.hxx>
36 #include "pe_type.hxx"
37 #include "pe_vari.hxx"
38 
39 
40 namespace cpp {
41 
42 
43 
44 //***********************       PE_Parameter        ***********************//
45 
46 
47 PE_Parameter::PE_Parameter( Cpp_PE * i_pParent )
48     :   Cpp_PE(i_pParent),
49         pStati( new PeStatusArray<PE_Parameter> )
50         // pSpType,
51         // pSpuType,
52         // pSpVariable,
53         // pSpuVariable,
54         // aResultParamInfo
55 {
56     Setup_StatusFunctions();
57 
58     pSpType         = new SP_Type(*this);
59     pSpuType        = new SPU_Type(*pSpType, &PE_Parameter::SpInit_Type, &PE_Parameter::SpReturn_Type);
60     pSpVariable     = new SP_Variable(*this);
61     pSpuVariable    = new SPU_Variable(*pSpVariable, &PE_Parameter::SpInit_Variable, &PE_Parameter::SpReturn_Variable);
62 }
63 
64 PE_Parameter::~PE_Parameter()
65 {
66 }
67 
68 void
69 PE_Parameter::Call_Handler( const cpp::Token & i_rTok )
70 {
71     pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text());
72 }
73 
74 void
75 PE_Parameter::Setup_StatusFunctions()
76 {
77     typedef CallFunction<PE_Parameter>::F_Tok   F_Tok;
78     static F_Tok stateF_start[] =           { &PE_Parameter::On_start_Type,
79                                               &PE_Parameter::On_start_Type,
80                                               &PE_Parameter::On_start_Type,
81                                               &PE_Parameter::On_start_Type,
82                                               &PE_Parameter::On_start_Type,
83 
84                                               &PE_Parameter::On_start_Type,
85                                               &PE_Parameter::On_start_Type,
86                                               &PE_Parameter::On_start_Bracket_Right,
87                                               &PE_Parameter::On_start_Type,
88                                               &PE_Parameter::On_start_Ellipse,
89 
90                                               &PE_Parameter::On_start_Type,
91                                               &PE_Parameter::On_start_Type,
92                                               &PE_Parameter::On_start_Type };
93     static INT16 stateT_start[] =           { Tid_Identifier,
94                                               Tid_class,
95                                               Tid_struct,
96                                               Tid_union,
97                                               Tid_enum,
98 
99                                               Tid_const,
100                                               Tid_volatile,
101                                               Tid_Bracket_Right,
102                                               Tid_DoubleColon,
103                                               Tid_Ellipse,
104 
105                                               Tid_typename,
106                                               Tid_BuiltInType,
107                                               Tid_TypeSpecializer };
108 
109     static F_Tok stateF_expectName[] =      { &PE_Parameter::On_expectName_Identifier,
110                                               &PE_Parameter::On_expectName_ArrayBracket_Left,
111                                               &PE_Parameter::On_expectName_Bracket_Right,
112                                               &PE_Parameter::On_expectName_Comma,
113                                               &PE_Parameter::On_afterName_Assign  };
114     static INT16 stateT_expectName[] =      { Tid_Identifier,
115                                               Tid_ArrayBracket_Left,
116                                               Tid_Bracket_Right,
117                                               Tid_Comma,
118                                               Tid_Assign };
119     static F_Tok stateF_afterName[] =       { &PE_Parameter::On_afterName_ArrayBracket_Left,
120                                               &PE_Parameter::On_afterName_Bracket_Right,
121                                               &PE_Parameter::On_afterName_Comma,
122                                               &PE_Parameter::On_afterName_Assign };
123     static INT16 stateT_afterName[] =       { Tid_ArrayBracket_Left,
124                                               Tid_Bracket_Right,
125                                               Tid_Comma,
126                                               Tid_Assign };
127     static F_Tok stateF_finished[] =        { &PE_Parameter::On_finished_Comma,
128                                               &PE_Parameter::On_finished_Bracket_Right };
129     static INT16 stateT_finished[] =        { Tid_Bracket_Right,
130                                               Tid_Comma };
131 
132     SEMPARSE_CREATE_STATUS(PE_Parameter, start, Hdl_SyntaxError);
133     SEMPARSE_CREATE_STATUS(PE_Parameter, expectName, Hdl_SyntaxError);
134     SEMPARSE_CREATE_STATUS(PE_Parameter, afterName, Hdl_SyntaxError);
135     SEMPARSE_CREATE_STATUS(PE_Parameter, finished, Hdl_SyntaxError);
136 }
137 
138 
139 void
140 PE_Parameter::InitData()
141 {
142     pStati->SetCur(start);
143     aResultParamInfo.Empty();
144 }
145 
146 void
147 PE_Parameter::TransferData()
148 {
149     pStati->SetCur(size_of_states);
150 }
151 
152 void
153 PE_Parameter::Hdl_SyntaxError( const char * i_sText)
154 {
155     StdHandlingOfSyntaxError(i_sText);
156 }
157 
158 void
159 PE_Parameter::SpInit_Type()
160 {
161     // Does nothing.
162 }
163 
164 void
165 PE_Parameter::SpInit_Variable()
166 {
167     // Does nothing.
168 }
169 
170 void
171 PE_Parameter::SpReturn_Type()
172 {
173     aResultParamInfo.nType = pSpuType->Child().Result_Type().Id();
174     pStati->SetCur(expectName);
175 }
176 
177 void
178 PE_Parameter::SpReturn_Variable()
179 {
180     if (pSpuVariable->Child().Result_Pattern() > 0)
181     {
182         aResultParamInfo.sSizeExpression = pSpuVariable->Child().Result_SizeExpression();
183         aResultParamInfo.sInitExpression = pSpuVariable->Child().Result_InitExpression();
184     }
185 }
186 
187 void
188 PE_Parameter::On_start_Type(const char *)
189 {
190     pSpuType->Push(not_done);
191 }
192 
193 void
194 PE_Parameter::On_start_Bracket_Right(const char *)
195 {
196     SetTokenResult(not_done, pop_success);
197 }
198 
199 void
200 PE_Parameter::On_start_Ellipse(const char *)
201 {
202     SetTokenResult(done, pop_success);
203 
204     aResultParamInfo.nType = Env().AryGate().Types().Tid_Ellipse();
205 }
206 
207 void
208 PE_Parameter::On_expectName_Identifier(const char * i_sText)
209 {
210     SetTokenResult(done, stay);
211     pStati->SetCur(afterName);
212 
213     aResultParamInfo.sName = i_sText;
214 }
215 
216 void
217 PE_Parameter::On_expectName_ArrayBracket_Left(const char * i_sText)
218 {
219     On_afterName_ArrayBracket_Left(i_sText);
220 }
221 
222 void
223 PE_Parameter::On_expectName_Bracket_Right(const char * i_sText)
224 {
225     On_afterName_Bracket_Right(i_sText);
226 }
227 
228 void
229 PE_Parameter::On_expectName_Comma(const char * i_sText)
230 {
231     On_afterName_Comma(i_sText);
232 }
233 
234 void
235 PE_Parameter::On_afterName_ArrayBracket_Left(const char *)
236 {
237     pSpuVariable->Push(not_done);
238 }
239 
240 void
241 PE_Parameter::On_afterName_Bracket_Right(const char *)
242 {
243     SetTokenResult(not_done, pop_success);
244 }
245 
246 void
247 PE_Parameter::On_afterName_Comma(const char *)
248 {
249     SetTokenResult(not_done, pop_success);
250 }
251 
252 void
253 PE_Parameter::On_afterName_Assign(const char *)
254 {
255     pSpuVariable->Push(not_done);
256 }
257 
258 void
259 PE_Parameter::On_finished_Bracket_Right(const char *)
260 {
261     SetTokenResult(not_done, pop_success);
262 }
263 
264 void
265 PE_Parameter::On_finished_Comma(const char *)
266 {
267     SetTokenResult(not_done, pop_success);
268 }
269 
270 
271 }   // namespace cpp
272 
273 
274 
275 
276 
277 
278 
279 
280 
281