Update ooo320-m1
[ooovba.git] / autodoc / source / parser / cpp / pe_file.cxx
blob145db1ebbb096d6f60f8013ee8ad186e1c421743
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_file.cxx,v $
10 * $Revision: 1.12 $
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_file.hxx"
34 // NOT FULLY DECLARED SERVICES
35 #include "pe_defs.hxx"
36 #include "pe_enum.hxx"
37 #include "pe_namsp.hxx"
38 #include "pe_tpltp.hxx"
39 #include "pe_tydef.hxx"
40 #include "pe_vafu.hxx"
41 #include "pe_ignor.hxx"
44 // NOT FULLY DECLARED SERVICES
47 namespace cpp
50 PE_File::PE_File( cpp::PeEnvironment & io_rEnv)
51 : Cpp_PE(io_rEnv),
52 pEnv(&io_rEnv),
53 pStati( new PeStatusArray<PE_File> ),
54 // pSpNamespace,
55 // pSpTypedef,
56 // pSpVarFunc,
57 // pSpIgnore,
58 // pSpuNamespace,
59 // pSpuClass,
60 // pSpuTypedef,
61 // pSpuVarFunc,
62 // pSpuTemplate,
63 // pSpuUsing,
64 // pSpuIgnoreFailure,
65 bWithinSingleExternC(false)
67 Setup_StatusFunctions();
69 pSpNamespace = new SP_Namespace(*this);
70 pSpTypedef = new SP_Typedef(*this);
71 pSpVarFunc = new SP_VarFunc(*this);
72 pSpTemplate = new SP_Template(*this);
73 pSpDefs = new SP_Defines(*this);
74 pSpIgnore = new SP_Ignore(*this);
76 pSpuNamespace = new SPU_Namespace(*pSpNamespace, 0, 0);
77 pSpuTypedef = new SPU_Typedef(*pSpTypedef, 0, 0);
78 pSpuVarFunc = new SPU_VarFunc(*pSpVarFunc, 0, &PE_File::SpReturn_VarFunc);
79 pSpuTemplate = new SPU_Template(*pSpTemplate, 0, &PE_File::SpReturn_Template);
80 pSpuDefs = new SPU_Defines(*pSpDefs, 0, 0);
81 pSpuUsing = new SPU_Ignore(*pSpIgnore, 0, 0);
82 pSpuIgnoreFailure
83 = new SPU_Ignore(*pSpIgnore, 0, 0);
86 PE_File::~PE_File()
90 void
91 PE_File::Call_Handler( const cpp::Token & i_rTok )
93 pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text());
96 Cpp_PE *
97 PE_File::Handle_ChildFailure()
99 SetCurSPU(pSpuIgnoreFailure.Ptr());
100 return &pSpuIgnoreFailure->Child();
103 void
104 PE_File::Setup_StatusFunctions()
106 typedef CallFunction<PE_File>::F_Tok F_Tok;
107 static F_Tok stateF_std[] = { &PE_File::On_std_VarFunc,
108 &PE_File::On_std_ClassKey,
109 &PE_File::On_std_ClassKey,
110 &PE_File::On_std_ClassKey,
111 &PE_File::On_std_enum,
113 &PE_File::On_std_typedef,
114 &PE_File::On_std_template,
115 &PE_File::On_std_VarFunc,
116 &PE_File::On_std_VarFunc,
117 &PE_File::On_std_extern,
119 &PE_File::On_std_VarFunc,
120 &PE_File::On_std_VarFunc,
121 &PE_File::On_std_VarFunc,
122 &PE_File::On_std_namespace,
123 &PE_File::On_std_using,
125 &PE_File::On_std_SwBracketRight,
126 &PE_File::On_std_VarFunc,
127 &PE_File::On_std_VarFunc,
128 &PE_File::On_std_DefineName,
129 &PE_File::On_std_MacroName,
131 &PE_File::On_std_VarFunc,
132 &PE_File::On_std_VarFunc };
134 static INT16 stateT_std[] = { Tid_Identifier,
135 Tid_class,
136 Tid_struct,
137 Tid_union,
138 Tid_enum,
140 Tid_typedef,
141 Tid_template,
142 Tid_const,
143 Tid_volatile,
144 Tid_extern,
146 Tid_static,
147 Tid_register,
148 Tid_inline,
149 Tid_namespace,
150 Tid_using,
152 Tid_SwBracket_Right,
153 Tid_DoubleColon,
154 Tid_typename,
155 Tid_DefineName,
156 Tid_MacroName,
158 Tid_BuiltInType,
159 Tid_TypeSpecializer };
161 static F_Tok stateF_in_extern[] = { &PE_File::On_in_extern_Constant };
162 static INT16 stateT_in_extern[] = { Tid_Constant };
164 static F_Tok stateF_in_externC[] = { &PE_File::On_in_externC_SwBracket_Left };
165 static INT16 stateT_in_externC[] = { Tid_SwBracket_Left };
168 SEMPARSE_CREATE_STATUS(PE_File, std, Hdl_SyntaxError);
169 SEMPARSE_CREATE_STATUS(PE_File, in_extern, On_in_extern_Ignore);
170 SEMPARSE_CREATE_STATUS(PE_File, in_externC, On_in_externC_NoBlock);
173 void
174 PE_File::InitData()
176 pStati->SetCur(std);
179 void
180 PE_File::TransferData()
182 pStati->SetCur(size_of_states);
185 void
186 PE_File::Hdl_SyntaxError( const char * i_sText)
188 if ( *i_sText == ';' )
190 Cerr() << Env().CurFileName() << ", line "
191 << Env().LineCount()
192 << ": Sourcecode warning: ';' as a toplevel declaration is deprecated."
193 << Endl();
194 SetTokenResult(done,stay);
195 return;
198 StdHandlingOfSyntaxError(i_sText);
201 void
202 PE_File::SpReturn_VarFunc()
204 if (bWithinSingleExternC)
206 access_Env().CloseBlock();
207 bWithinSingleExternC = false;
211 void
212 PE_File::SpReturn_Template()
214 access_Env().OpenTemplate( pSpuTemplate->Child().Result_Parameters() );
217 void
218 PE_File::On_std_namespace(const char * )
220 pSpuNamespace->Push(done);
223 void
224 PE_File::On_std_ClassKey(const char * )
226 pSpuVarFunc->Push(not_done); // This is correct,
227 // classes are parsed via PE_Type.
230 void
231 PE_File::On_std_typedef(const char * )
233 pSpuTypedef->Push(not_done);
236 void
237 PE_File::On_std_enum(const char * )
239 pSpuVarFunc->Push(not_done); // This is correct,
240 // enums are parsed via PE_Type.
243 void
244 PE_File::On_std_VarFunc(const char * )
246 pSpuVarFunc->Push(not_done);
249 void
250 PE_File::On_std_template(const char * )
252 pSpuTemplate->Push(done);
255 void
256 PE_File::On_std_extern(const char * )
258 SetTokenResult(done, stay);
259 pStati->SetCur(in_extern);
262 void
263 PE_File::On_std_using(const char * )
265 pSpuUsing->Push(done);
268 void
269 PE_File::On_std_SwBracketRight(const char * )
271 SetTokenResult(done,stay);
272 access_Env().CloseBlock();
275 void
276 PE_File::On_std_DefineName(const char * )
278 pSpuDefs->Push(not_done);
281 void
282 PE_File::On_std_MacroName(const char * )
284 pSpuDefs->Push(not_done);
287 void
288 PE_File::On_in_extern_Constant(const char * )
290 SetTokenResult(done,stay);
291 pStati->SetCur(in_externC);
293 access_Env().OpenExternC();
296 void
297 PE_File::On_in_extern_Ignore(const char * )
299 SetTokenResult(not_done, stay);
300 pStati->SetCur(std);
303 void
304 PE_File::On_in_externC_SwBracket_Left(const char * )
306 SetTokenResult(done, stay);
307 pStati->SetCur(std);
310 void
311 PE_File::On_in_externC_NoBlock(const char * )
313 SetTokenResult(not_done, stay);
314 pStati->SetCur(std);
316 bWithinSingleExternC = true;
320 } // namespace cpp