1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22 #include <precomp.h>
23 #include "pe_base.hxx"
24
25
26 // NOT FULLY DECLARED SERVICES
27 #include <cosv/tpl/tpltools.hxx>
28 #include <ary/cpp/c_gate.hxx>
29 #include <ary/cpp/c_type.hxx>
30 #include "pe_type.hxx"
31
32
33
34
35 namespace cpp
36 {
37
38
39 static const PE_Base::Base aNullBase_;
40
41
PE_Base(Cpp_PE * i_pParent)42 PE_Base::PE_Base( Cpp_PE * i_pParent )
43 : Cpp_PE(i_pParent),
44 pStati(new PeStatusArray<PE_Base>)
45 // aBaseIds,
46 // pSpType,
47 // pSpuBaseName
48 {
49 Setup_StatusFunctions();
50 aBaseIds.reserve(4);
51
52 pSpType = new SP_Type(*this);
53 pSpuBaseName = new SPU_BaseName(*pSpType, 0, &PE_Base::SpReturn_BaseName);
54 }
55
56
~PE_Base()57 PE_Base::~PE_Base()
58 {
59 }
60
61 void
Call_Handler(const cpp::Token & i_rTok)62 PE_Base::Call_Handler( const cpp::Token & i_rTok )
63 {
64 pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text());
65 }
66
67 void
Setup_StatusFunctions()68 PE_Base::Setup_StatusFunctions()
69 {
70 typedef CallFunction<PE_Base>::F_Tok F_Tok;
71 static F_Tok stateF_startOfNext[] = { &PE_Base::On_startOfNext_Identifier,
72 &PE_Base::On_startOfNext_public,
73 &PE_Base::On_startOfNext_protected,
74 &PE_Base::On_startOfNext_private,
75 &PE_Base::On_startOfNext_virtual,
76 &PE_Base::On_startOfNext_DoubleColon };
77 static INT16 stateT_startOfNext[] = { Tid_Identifier,
78 Tid_public,
79 Tid_protected,
80 Tid_private,
81 Tid_virtual,
82 Tid_DoubleColon };
83 static F_Tok stateF_inName[] = { &PE_Base::On_inName_Identifier,
84 &PE_Base::On_inName_virtual,
85 &PE_Base::On_inName_SwBracket_Left,
86 &PE_Base::On_inName_DoubleColon,
87 &PE_Base::On_inName_Comma };
88 static INT16 stateT_inName[] = { Tid_Identifier,
89 Tid_virtual,
90 Tid_SwBracket_Left,
91 Tid_DoubleColon,
92 Tid_Comma };
93
94 SEMPARSE_CREATE_STATUS(PE_Base, startOfNext, Hdl_SyntaxError);
95 SEMPARSE_CREATE_STATUS(PE_Base, inName, Hdl_SyntaxError);
96 }
97
98 void
Hdl_SyntaxError(const char * i_sText)99 PE_Base::Hdl_SyntaxError( const char * i_sText)
100 {
101 StdHandlingOfSyntaxError(i_sText);
102 }
103
104 void
InitData()105 PE_Base::InitData()
106 {
107 pStati->SetCur(startOfNext);
108 csv::erase_container(aBaseIds);
109 aBaseIds.push_back(aNullBase_);
110 }
111
112 void
TransferData()113 PE_Base::TransferData()
114 {
115 // Does nothing.
116 }
117
118 void
SpReturn_BaseName()119 PE_Base::SpReturn_BaseName()
120 {
121 CurObject().nId = pSpuBaseName->Child().Result_Type().Id();
122
123 static StreamStr aBaseName(100);
124 aBaseName.seekp(0);
125 pSpuBaseName->Child().Result_Type().Get_Text( aBaseName, Env().AryGate() );
126
127 Env().Event_Class_FinishedBase(aBaseName.c_str());
128 }
129
130 void
On_startOfNext_public(const char *)131 PE_Base::On_startOfNext_public(const char *)
132 {
133 SetTokenResult(done, stay);
134 pStati->SetCur(inName);
135
136 CurObject().eProtection = ary::cpp::PROTECT_public;
137 }
138
139 void
On_startOfNext_protected(const char *)140 PE_Base::On_startOfNext_protected(const char *)
141 {
142 SetTokenResult(done, stay);
143 pStati->SetCur(inName);
144
145 CurObject().eProtection = ary::cpp::PROTECT_protected;
146 }
147
148 void
On_startOfNext_private(const char *)149 PE_Base::On_startOfNext_private(const char *)
150 {
151 SetTokenResult(done, stay);
152 pStati->SetCur(inName);
153
154 CurObject().eProtection = ary::cpp::PROTECT_private;
155 }
156
157 void
On_startOfNext_virtual(const char *)158 PE_Base::On_startOfNext_virtual(const char *)
159 {
160 SetTokenResult(done, stay);
161
162 CurObject().eVirtuality = ary::cpp::VIRTUAL_virtual;
163 }
164
165 void
On_startOfNext_Identifier(const char *)166 PE_Base::On_startOfNext_Identifier(const char * )
167 {
168 pSpuBaseName->Push(not_done);
169 }
170
171 void
On_startOfNext_DoubleColon(const char *)172 PE_Base::On_startOfNext_DoubleColon(const char *)
173 {
174 pSpuBaseName->Push(not_done);
175 }
176
177 void
On_inName_Identifier(const char *)178 PE_Base::On_inName_Identifier(const char * )
179 {
180 pSpuBaseName->Push(not_done);
181 }
182
183 void
On_inName_virtual(const char *)184 PE_Base::On_inName_virtual(const char *)
185 {
186 SetTokenResult(done, stay);
187
188 CurObject().eVirtuality = ary::cpp::VIRTUAL_virtual;
189 }
190
191 void
On_inName_DoubleColon(const char *)192 PE_Base::On_inName_DoubleColon(const char *)
193 {
194 pSpuBaseName->Push(not_done);
195 }
196
197 void
On_inName_Comma(const char *)198 PE_Base::On_inName_Comma(const char *)
199 {
200 SetTokenResult(done, stay);
201 pStati->SetCur(startOfNext);
202
203 aBaseIds.push_back( aNullBase_ );
204 }
205
206 void
On_inName_SwBracket_Left(const char *)207 PE_Base::On_inName_SwBracket_Left(const char *)
208 {
209 SetTokenResult(not_done, pop_success);
210 }
211
212
213 } // namespace cpp
214
215
216
217
218
219