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_vari2.hxx>
24
25
26 // NOT FULLY DECLARED SERVICES
27 #include <ary/idl/i_gate.hxx>
28 #include <ary/idl/i_property.hxx>
29 #include <ary/idl/ip_ce.hxx>
30 #include <ary/doc/d_oldidldocu.hxx>
31 #include <s2_luidl/pe_type2.hxx>
32 #include <s2_luidl/tk_keyw.hxx>
33 #include <s2_luidl/tk_ident.hxx>
34 #include <s2_luidl/tk_punct.hxx>
35
36
37 namespace csi
38 {
39 namespace uidl
40 {
41
42
PE_Variable(ary::idl::Type_id & i_rResult_Type,String & i_rResult_Name)43 PE_Variable::PE_Variable( ary::idl::Type_id & i_rResult_Type,
44 String & i_rResult_Name )
45 : eState(e_none),
46 pResult_Type(&i_rResult_Type),
47 pResult_Name(&i_rResult_Name),
48 pPE_Type(0)
49 {
50 pPE_Type = new PE_Type(i_rResult_Type);
51 }
52
53 void
EstablishContacts(UnoIDL_PE * io_pParentPE,ary::Repository & io_rRepository,TokenProcessing_Result & o_rResult)54 PE_Variable::EstablishContacts( UnoIDL_PE * io_pParentPE,
55 ary::Repository & io_rRepository,
56 TokenProcessing_Result & o_rResult )
57 {
58 UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
59 pPE_Type->EstablishContacts(this,io_rRepository,o_rResult);
60 }
61
~PE_Variable()62 PE_Variable::~PE_Variable()
63 {
64 }
65
66 void
ProcessToken(const Token & i_rToken)67 PE_Variable::ProcessToken( const Token & i_rToken )
68 {
69 i_rToken.Trigger(*this);
70 }
71
72
73 void
Process_Default()74 PE_Variable::Process_Default()
75 {
76 if (eState == expect_type)
77 {
78 SetResult( not_done, push_sure, pPE_Type.Ptr() );
79 }
80 else{
81 csv_assert(false);
82 }
83 }
84
85 void
Process_Identifier(const TokIdentifier & i_rToken)86 PE_Variable::Process_Identifier( const TokIdentifier & i_rToken )
87 {
88 if (eState == expect_type)
89 {
90 SetResult( not_done, push_sure, pPE_Type.Ptr() );
91 }
92 else if (eState == expect_name)
93 {
94 *pResult_Name = i_rToken.Text();
95 SetResult( done, stay );
96 eState = expect_finish;
97 }
98 else {
99 csv_assert(false);
100 }
101 }
102
103 void
Process_Punctuation(const TokPunctuation &)104 PE_Variable::Process_Punctuation( const TokPunctuation & )
105 {
106 if (eState == expect_finish)
107 {
108 SetResult( not_done, pop_success );
109 eState = e_none;
110 }
111 else if (eState == expect_name)
112 {
113 SetResult( not_done, pop_success );
114 eState = e_none;
115 }
116 else {
117 csv_assert(false);
118 }
119 }
120
121 void
Process_BuiltInType(const TokBuiltInType & i_rToken)122 PE_Variable::Process_BuiltInType( const TokBuiltInType & i_rToken )
123 {
124 if (eState == expect_type)
125 {
126 SetResult( not_done, push_sure, pPE_Type.Ptr() );
127 }
128 else if (eState == expect_name AND i_rToken.Id() == TokBuiltInType::bty_ellipse)
129 {
130 SetResult( not_done, pop_success );
131 eState = e_none;
132 }
133 else {
134 csv_assert(false);
135 }
136 }
137
138 void
InitData()139 PE_Variable::InitData()
140 {
141 eState = expect_type;
142
143 *pResult_Type = 0;
144 *pResult_Name = "";
145 }
146
147 void
ReceiveData()148 PE_Variable::ReceiveData()
149 {
150 eState = expect_name;
151 }
152
153 void
TransferData()154 PE_Variable::TransferData()
155 {
156 eState = e_none;
157 }
158
159 UnoIDL_PE &
MyPE()160 PE_Variable::MyPE()
161 {
162 return *this;
163 }
164
165 } // namespace uidl
166 } // namespace csi
167
168