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 <s2_luidl/pe_tydf2.hxx>
24 
25 // NOT FULLY DECLARED SERVICES
26 #include <ary/idl/i_gate.hxx>
27 #include <ary/idl/i_typedef.hxx>
28 #include <ary/idl/ip_ce.hxx>
29 #include <ary/doc/d_oldidldocu.hxx>
30 #include <s2_luidl/pe_type2.hxx>
31 #include <s2_luidl/tk_ident.hxx>
32 #include <s2_luidl/tk_punct.hxx>
33 #include <s2_luidl/tk_const.hxx>
34 
35 
36 namespace csi
37 {
38 namespace uidl
39 {
40 
41 
42 #ifdef DF
43 #undef DF
44 #endif
45 #define DF 	&PE_Typedef::On_Default
46 
47 PE_Typedef::F_TOK
48 PE_Typedef::aDispatcher[PE_Typedef::e_STATES_MAX][PE_Typedef::tt_MAX] =
49 		{ 	{ DF, DF, DF },  // e_none
50 			{ &PE_Typedef::On_expect_description_Any,
51 				  &PE_Typedef::On_expect_description_Any,
52 				      DF },  // expect_description
53 			{ DF, &PE_Typedef::On_expect_name_Identifier,
54 					  DF },  // expect_name
55 			{ DF, DF, &PE_Typedef::On_got_name_Punctuation }  // got_name
56 		};
57 
58 
59 
60 inline void
CallHandler(const char * i_sTokenText,E_TokenType i_eTokenType)61 PE_Typedef::CallHandler( const char *		i_sTokenText,
62 						 E_TokenType		i_eTokenType )
63 	{ (this->*aDispatcher[eState][i_eTokenType])(i_sTokenText); }
64 
65 
66 
67 
68 
PE_Typedef()69 PE_Typedef::PE_Typedef()
70 	:	eState(e_none),
71 		pPE_Type(0),
72 		nType(0),
73 		sName()
74 {
75 	pPE_Type = new PE_Type(nType);
76 }
77 
78 void
EstablishContacts(UnoIDL_PE * io_pParentPE,ary::Repository & io_rRepository,TokenProcessing_Result & o_rResult)79 PE_Typedef::EstablishContacts( UnoIDL_PE *				io_pParentPE,
80 							   ary::Repository &	io_rRepository,
81 							   TokenProcessing_Result & o_rResult )
82 {
83 	UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
84 	pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
85 }
86 
~PE_Typedef()87 PE_Typedef::~PE_Typedef()
88 {
89 }
90 
91 void
ProcessToken(const Token & i_rToken)92 PE_Typedef::ProcessToken( const Token & i_rToken )
93 {
94 	i_rToken.Trigger(*this);
95 }
96 
97 void
Process_Identifier(const TokIdentifier & i_rToken)98 PE_Typedef::Process_Identifier( const TokIdentifier & i_rToken )
99 {
100 	CallHandler(i_rToken.Text(), tt_identifier);
101 }
102 
103 void
Process_Punctuation(const TokPunctuation & i_rToken)104 PE_Typedef::Process_Punctuation( const TokPunctuation & i_rToken )
105 {
106 	CallHandler(i_rToken.Text(), tt_punctuation);
107 }
108 
109 void
Process_Default()110 PE_Typedef::Process_Default()
111 {
112 	CallHandler("", tt_any);
113 }
114 
115 void
On_expect_description_Any(const char *)116 PE_Typedef::On_expect_description_Any(const char *)
117 {
118 	SetResult(not_done,push_sure, pPE_Type.Ptr());
119 }
120 
121 void
On_expect_name_Identifier(const char * i_sText)122 PE_Typedef::On_expect_name_Identifier(const char * i_sText)
123 {
124 	sName = i_sText;
125 	SetResult(done,stay);
126 	eState = got_name;
127 }
128 
129 void
On_got_name_Punctuation(const char * i_sText)130 PE_Typedef::On_got_name_Punctuation(const char * i_sText)
131 {
132 	if ( i_sText[0] == ';' )
133 	{
134 		SetResult(done,pop_success);
135 		eState = e_none;
136 	}
137 	else
138 		On_Default(i_sText);
139 }
140 
141 void
On_Default(const char *)142 PE_Typedef::On_Default(const char * )
143 {
144 	SetResult(not_done,pop_failure);
145 }
146 
147 void
InitData()148 PE_Typedef::InitData()
149 {
150 	eState = expect_description;
151 	nType = 0;
152 	sName = "";
153 }
154 
155 void
ReceiveData()156 PE_Typedef::ReceiveData()
157 {
158 	eState = expect_name;
159 }
160 
161 void
TransferData()162 PE_Typedef::TransferData()
163 {
164     ary::idl::Typedef &
165         rCe = Gate().Ces().Store_Typedef(CurNamespace().CeId(), sName, nType);
166 	PassDocuAt(rCe);
167 	eState = e_none;
168 }
169 
170 UnoIDL_PE &
MyPE()171 PE_Typedef::MyPE()
172 {
173 	return *this;
174 }
175 
176 }   // namespace uidl
177 }   // namespace csi
178 
179