xref: /trunk/main/autodoc/source/parser/cpp/pe_base.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_base.hxx"
30 
31 
32 // NOT FULLY DECLARED SERVICES
33 #include <cosv/tpl/tpltools.hxx>
34 #include <ary/cpp/c_gate.hxx>
35 #include <ary/cpp/c_type.hxx>
36 #include "pe_type.hxx"
37 
38 
39 
40 
41 namespace cpp
42 {
43 
44 
45 static const PE_Base::Base aNullBase_;
46 
47 
48 PE_Base::PE_Base( Cpp_PE * i_pParent )
49     :   Cpp_PE(i_pParent),
50         pStati(new PeStatusArray<PE_Base>)
51         // aBaseIds,
52         // pSpType,
53         // pSpuBaseName
54 {
55     Setup_StatusFunctions();
56     aBaseIds.reserve(4);
57 
58     pSpType         = new SP_Type(*this);
59     pSpuBaseName    = new SPU_BaseName(*pSpType, 0, &PE_Base::SpReturn_BaseName);
60 }
61 
62 
63 PE_Base::~PE_Base()
64 {
65 }
66 
67 void
68 PE_Base::Call_Handler( const cpp::Token & i_rTok )
69 {
70     pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text());
71 }
72 
73 void
74 PE_Base::Setup_StatusFunctions()
75 {
76     typedef CallFunction<PE_Base>::F_Tok    F_Tok;
77     static F_Tok stateF_startOfNext[] =     { &PE_Base::On_startOfNext_Identifier,
78                                               &PE_Base::On_startOfNext_public,
79                                               &PE_Base::On_startOfNext_protected,
80                                               &PE_Base::On_startOfNext_private,
81                                               &PE_Base::On_startOfNext_virtual,
82                                               &PE_Base::On_startOfNext_DoubleColon };
83     static INT16 stateT_startOfNext[] =     { Tid_Identifier,
84                                               Tid_public,
85                                               Tid_protected,
86                                               Tid_private,
87                                               Tid_virtual,
88                                               Tid_DoubleColon };
89     static F_Tok stateF_inName[] =          { &PE_Base::On_inName_Identifier,
90                                               &PE_Base::On_inName_virtual,
91                                               &PE_Base::On_inName_SwBracket_Left,
92                                               &PE_Base::On_inName_DoubleColon,
93                                               &PE_Base::On_inName_Comma };
94     static INT16 stateT_inName[] =          { Tid_Identifier,
95                                               Tid_virtual,
96                                               Tid_SwBracket_Left,
97                                               Tid_DoubleColon,
98                                               Tid_Comma };
99 
100     SEMPARSE_CREATE_STATUS(PE_Base, startOfNext, Hdl_SyntaxError);
101     SEMPARSE_CREATE_STATUS(PE_Base, inName, Hdl_SyntaxError);
102 }
103 
104 void
105 PE_Base::Hdl_SyntaxError( const char * i_sText)
106 {
107     StdHandlingOfSyntaxError(i_sText);
108 }
109 
110 void
111 PE_Base::InitData()
112 {
113     pStati->SetCur(startOfNext);
114     csv::erase_container(aBaseIds);
115     aBaseIds.push_back(aNullBase_);
116 }
117 
118 void
119 PE_Base::TransferData()
120 {
121     // Does nothing.
122 }
123 
124 void
125 PE_Base::SpReturn_BaseName()
126 {
127     CurObject().nId = pSpuBaseName->Child().Result_Type().Id();
128 
129     static StreamStr aBaseName(100);
130     aBaseName.seekp(0);
131     pSpuBaseName->Child().Result_Type().Get_Text( aBaseName, Env().AryGate() );
132 
133     Env().Event_Class_FinishedBase(aBaseName.c_str());
134 }
135 
136 void
137 PE_Base::On_startOfNext_public(const char *)
138 {
139     SetTokenResult(done, stay);
140     pStati->SetCur(inName);
141 
142     CurObject().eProtection = ary::cpp::PROTECT_public;
143 }
144 
145 void
146 PE_Base::On_startOfNext_protected(const char *)
147 {
148     SetTokenResult(done, stay);
149     pStati->SetCur(inName);
150 
151     CurObject().eProtection = ary::cpp::PROTECT_protected;
152 }
153 
154 void
155 PE_Base::On_startOfNext_private(const char *)
156 {
157     SetTokenResult(done, stay);
158     pStati->SetCur(inName);
159 
160     CurObject().eProtection = ary::cpp::PROTECT_private;
161 }
162 
163 void
164 PE_Base::On_startOfNext_virtual(const char *)
165 {
166     SetTokenResult(done, stay);
167 
168     CurObject().eVirtuality = ary::cpp::VIRTUAL_virtual;
169 }
170 
171 void
172 PE_Base::On_startOfNext_Identifier(const char * )
173 {
174     pSpuBaseName->Push(not_done);
175 }
176 
177 void
178 PE_Base::On_startOfNext_DoubleColon(const char *)
179 {
180     pSpuBaseName->Push(not_done);
181 }
182 
183 void
184 PE_Base::On_inName_Identifier(const char * )
185 {
186     pSpuBaseName->Push(not_done);
187 }
188 
189 void
190 PE_Base::On_inName_virtual(const char *)
191 {
192     SetTokenResult(done, stay);
193 
194     CurObject().eVirtuality = ary::cpp::VIRTUAL_virtual;
195 }
196 
197 void
198 PE_Base::On_inName_DoubleColon(const char *)
199 {
200     pSpuBaseName->Push(not_done);
201 }
202 
203 void
204 PE_Base::On_inName_Comma(const char *)
205 {
206     SetTokenResult(done, stay);
207     pStati->SetCur(startOfNext);
208 
209     aBaseIds.push_back( aNullBase_ );
210 }
211 
212 void
213 PE_Base::On_inName_SwBracket_Left(const char *)
214 {
215     SetTokenResult(not_done, pop_success);
216 }
217 
218 
219 }   // namespace cpp
220 
221 
222 
223 
224 
225